Skip to content

Commit

Permalink
POLISHING WHEEL
Browse files Browse the repository at this point in the history
  • Loading branch information
ghasto69 committed Aug 26, 2023
1 parent 8b4856c commit f36d334
Show file tree
Hide file tree
Showing 16 changed files with 768 additions and 74 deletions.
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ version = "${mod_version}+${minecraft_version}" + (buildNumber != null ? "-${bui

repositories {
maven { url = "https://maven.shedaniel.me/" } // Cloth Config, REI
maven { url = "https://dvs1.progwml6.com/files/maven/" } // JEI
maven { url = "https://maven.parchmentmc.org" } // Parchment mappings
maven { url = "https://maven.quiltmc.org/repository/release" } // Quilt Mappings
maven { url = "https://api.modrinth.com/maven" } // LazyDFU
Expand Down
26 changes: 13 additions & 13 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
org.gradle.jvmargs=-Xmx2G

# Mod Info
maven_group = com.example
archives_base_name = modid
mod_version = 0.0.1
maven_group = com.ghasto
archives_base_name = create_so
mod_version = 1.6

minecraft_version = 1.18.2
minecraft_version = 1.20.1

# Dependencies
# https://fabricmc.net/develop
fabric_loader_version = 0.14.11
fabric_api_version = 0.67.0+1.18.2
fabric_loader_version = 0.14.22
fabric_api_version = 0.87.0+1.20.1

# Mappings
# https://lambdaurora.dev/tools/import_quilt.html
qm_version = 26
qm_version = 23
# https://parchmentmc.org/docs/getting-started
parchment_version = 2022.11.06
parchment_version = 2023.08.20

# Create
# https://modrinth.com/mod/create-fabric/versions
create_version = 0.5.0.i-944+1.18.2
create_version = 0.5.1-d-build.1161+mc1.20.1

# Development QOL
# Create supports all 3 recipe viewers: JEI, REI, and EMI. This decides which is enabled at runtime.
Expand All @@ -29,11 +29,11 @@ recipe_viewer = unspecified
# JEI - https://www.curseforge.com/minecraft/mc-mods/jei/files/all
jei_version = 10.2.1.283
# REI - https://modrinth.com/mod/roughly-enough-items/versions
rei_version = 8.3.583
rei_version = 12.0.645
# EMI - https://modrinth.com/mod/emi/versions
emi_version = 0.5.3+1.18.2
emi_version = 1.0.19+1.20.1+fabric

# Mod Menu - https://modrinth.com/mod/modmenu/versions
modmenu_version = 3.2.5
modmenu_version = 7.2.1
# LazyDFU - https://modrinth.com/mod/lazydfu/versions
lazydfu_version = 0.1.2
lazydfu_version = 0.1.3
30 changes: 0 additions & 30 deletions src/main/java/com/example/modid/ExampleMod.java

This file was deleted.

20 changes: 0 additions & 20 deletions src/main/java/com/example/modid/mixin/MinecraftMixin.java

This file was deleted.

46 changes: 46 additions & 0 deletions src/main/java/com/ghasto/create_so/CreateSandpaperOverhaul.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.ghasto.create_so;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.simibubi.create.AllItems;
import com.simibubi.create.Create;
import com.simibubi.create.foundation.data.CreateRegistrate;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.CreativeModeTab;

public class CreateSandpaperOverhaul implements ModInitializer{
public static final String ID = "create_so";
public static final String NAME = "Create: Sandpaper Overhaul";
public static final Logger LOGGER = LoggerFactory.getLogger(NAME);
public static final CreateRegistrate REGISTRATE = CreateRegistrate.create(ID);
public static final CreativeModeTab TAB = FabricItemGroup.builder()
.title(Component.literal(NAME))
.icon(AllItems.RED_SAND_PAPER::asStack)
.displayItems((c,p) -> {
REGISTRATE.getAll(Registries.ITEM).forEach(e -> {
p.accept(e.get());
});
})
.build();

@Override
public void onInitialize() {
ModItems.register();
ModBlocks.register();
ModBlockEntities.register();
ModRecipeTypes.register();
REGISTRATE.simple("tab", Registries.CREATIVE_MODE_TAB, () -> TAB);
REGISTRATE.register();
LOGGER.info("{} is loading alongside Create {}!", NAME, Create.VERSION);
}

public static ResourceLocation id(String path) {
return new ResourceLocation(ID, path);
}
}
26 changes: 26 additions & 0 deletions src/main/java/com/ghasto/create_so/ModBlockEntities.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.ghasto.create_so;

import static com.ghasto.create_so.CreateSandpaperOverhaul.REGISTRATE;

import com.ghasto.create_so.content.polishing_wheel.PolishingWheelBlockEntity;
import com.ghasto.create_so.content.polishing_wheel.PolishingWheelControllerBlockEntity;
import com.simibubi.create.content.kinetics.base.CutoutRotatingInstance;
import com.simibubi.create.content.kinetics.base.KineticBlockEntityRenderer;
import com.tterrag.registrate.util.entry.BlockEntityEntry;

public class ModBlockEntities {
public static final BlockEntityEntry<PolishingWheelBlockEntity> POLISHING_WHEEL = REGISTRATE
.blockEntity("polishing_wheel", PolishingWheelBlockEntity::new)
.instance(() -> CutoutRotatingInstance::new, false)
.validBlocks(ModBlocks.POLISHING_WHEEL)
.renderer(() -> KineticBlockEntityRenderer::new)
.register();

public static final BlockEntityEntry<PolishingWheelControllerBlockEntity> POLISHING_WHEEL_CONTROLLER =
REGISTRATE
.blockEntity("crushing_wheel_controller", PolishingWheelControllerBlockEntity::new)
.validBlocks(ModBlocks.POLISHING_WHEEL_CONTROLLER)
// .renderer(() -> renderer)
.register();
public static void register() {}
}
46 changes: 46 additions & 0 deletions src/main/java/com/ghasto/create_so/ModBlocks.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.ghasto.create_so;

import static com.ghasto.create_so.CreateSandpaperOverhaul.REGISTRATE;
import static com.simibubi.create.foundation.data.ModelGen.customItemModel;
import static com.simibubi.create.foundation.data.TagGen.pickaxeOnly;

import com.ghasto.create_so.content.polishing_wheel.PolishingWheelBlock;
import com.ghasto.create_so.content.polishing_wheel.PolishingWheelControllerBlock;
import com.simibubi.create.content.kinetics.BlockStressDefaults;
import com.simibubi.create.foundation.data.AssetLookup;
import com.simibubi.create.foundation.data.BlockStateGen;
import com.simibubi.create.foundation.data.SharedProperties;
import com.tterrag.registrate.util.entry.BlockEntry;

import net.minecraft.client.renderer.RenderType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.material.MapColor;
import net.minecraft.world.level.material.PushReaction;

public class ModBlocks {
public static final BlockEntry<PolishingWheelBlock> POLISHING_WHEEL =
REGISTRATE.block("crushing_wheel", PolishingWheelBlock::new)
.properties(p -> p.mapColor(MapColor.METAL))
.initialProperties(SharedProperties::stone)
.properties(BlockBehaviour.Properties::noOcclusion)
.transform(pickaxeOnly())
.blockstate((c, p) -> BlockStateGen.axisBlock(c, p, s -> AssetLookup.partialBaseModel(c, p)))
.addLayer(() -> RenderType::cutoutMipped)
.transform(BlockStressDefaults.setImpact(12.0))
.item()
.transform(customItemModel())
.register();

public static final BlockEntry<PolishingWheelControllerBlock> POLISHING_WHEEL_CONTROLLER =
REGISTRATE.block("crushing_wheel_controller", PolishingWheelControllerBlock::new)
.properties(p -> p.mapColor(MapColor.STONE)
.noOcclusion()
.noLootTable()
.air()
.noCollission()
.pushReaction(PushReaction.BLOCK))
.blockstate((c, p) -> p.getVariantBuilder(c.get())
.forAllStatesExcept(BlockStateGen.mapToAir(p), PolishingWheelControllerBlock.FACING))
.register();
public static void register() {}
}
5 changes: 5 additions & 0 deletions src/main/java/com/ghasto/create_so/ModItems.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.ghasto.create_so;

public class ModItems {
public static void register() {}
}
109 changes: 109 additions & 0 deletions src/main/java/com/ghasto/create_so/ModRecipeTypes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
package com.ghasto.create_so;

import java.util.Optional;
import java.util.Set;
import java.util.function.Supplier;

import org.jetbrains.annotations.Nullable;

import com.ghasto.create_so.content.polishing_wheel.PolishingRecipe;
import com.google.common.collect.ImmutableSet;
import com.simibubi.create.content.processing.recipe.ProcessingRecipeBuilder;
import com.simibubi.create.content.processing.recipe.ProcessingRecipeSerializer;
import com.simibubi.create.foundation.recipe.IRecipeTypeInfo;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.RegisteredObjects;

import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.Container;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.Level;

public enum ModRecipeTypes implements IRecipeTypeInfo {

POLISHING(PolishingRecipe::new);

private final ResourceLocation id;
private final RecipeSerializer<?> serializerObject;
@Nullable
private final RecipeType<?> typeObject;
private final Supplier<RecipeType<?>> type;

ModRecipeTypes(Supplier<RecipeSerializer<?>> serializerSupplier, Supplier<RecipeType<?>> typeSupplier, boolean registerType) {
String name = Lang.asId(name());
id = CreateSandpaperOverhaul.id(name);
serializerObject = Registry.register(BuiltInRegistries.RECIPE_SERIALIZER, id, serializerSupplier.get());
if (registerType) {
typeObject = typeSupplier.get();
Registry.register(BuiltInRegistries.RECIPE_TYPE, id, typeObject);
type = typeSupplier;
} else {
typeObject = null;
type = typeSupplier;
}
}

ModRecipeTypes(Supplier<RecipeSerializer<?>> serializerSupplier) {
String name = Lang.asId(name());
id = CreateSandpaperOverhaul.id(name);
serializerObject = Registry.register(BuiltInRegistries.RECIPE_SERIALIZER, id, serializerSupplier.get());
typeObject = simpleType(id);
Registry.register(BuiltInRegistries.RECIPE_TYPE, id, typeObject);
type = () -> typeObject;
}

ModRecipeTypes(ProcessingRecipeBuilder.ProcessingRecipeFactory<?> processingFactory) {
this(() -> new ProcessingRecipeSerializer<>(processingFactory));
}

public static <T extends Recipe<?>> RecipeType<T> simpleType(ResourceLocation id) {
String stringId = id.toString();
return new RecipeType<T>() {
@Override
public String toString() {
return stringId;
}
};
}

public static void register() {
}

@Override
public ResourceLocation getId() {
return id;
}

@SuppressWarnings("unchecked")
@Override
public <T extends RecipeSerializer<?>> T getSerializer() {
return (T) serializerObject;
}

@SuppressWarnings("unchecked")
@Override
public <T extends RecipeType<?>> T getType() {
return (T) type.get();
}

public <C extends Container, T extends Recipe<C>> Optional<T> find(C inv, Level world) {
return world.getRecipeManager()
.getRecipeFor(getType(), inv, world);
}

public static final Set<ResourceLocation> RECIPE_DENY_SET =
ImmutableSet.of(new ResourceLocation("occultism", "spirit_trade"), new ResourceLocation("occultism", "ritual"));

public static boolean shouldIgnoreInAutomation(Recipe<?> recipe) {
RecipeSerializer<?> serializer = recipe.getSerializer();
if (serializer != null && RECIPE_DENY_SET.contains(RegisteredObjects.getKeyOrThrow(serializer)))
return true;
return recipe.getId()
.getPath()
.endsWith("_manual_only");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.ghasto.create_so.content.polishing_wheel;

import com.ghasto.create_so.ModRecipeTypes;
import com.simibubi.create.content.kinetics.crusher.AbstractCrushingRecipe;
import com.simibubi.create.content.processing.recipe.ProcessingRecipeBuilder;

import net.minecraft.world.Container;
import net.minecraft.world.level.Level;

public class PolishingRecipe extends AbstractCrushingRecipe {
public PolishingRecipe(ProcessingRecipeBuilder.ProcessingRecipeParams params) {
super(ModRecipeTypes.POLISHING, params);
}
@Override
public boolean matches(Container inv, Level worldIn) {
if (inv.isEmpty())
return false;
return ingredients.get(0)
.test(inv.getItem(0));
}

@Override
protected int getMaxOutputCount() {
return 64;
}
}
Loading

0 comments on commit f36d334

Please sign in to comment.