diff --git a/build.gradle b/build.gradle index a2ff5880..a6b7e184 100644 --- a/build.gradle +++ b/build.gradle @@ -40,9 +40,7 @@ neoForge { } data { - data() - // instead of using --all, skip file check validation - programArguments.addAll('--server', '--client', '--dev', '--reports') + clientData() programArguments.addAll('--mod', 'exdeorum', '--output', file('src/generated/resources/').absolutePath, '--existing', file('src/main/resources/').absolutePath) } } diff --git a/gradle.properties b/gradle.properties index 71439e09..9d2efefb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.daemon=true org.gradle.parallel=true org.gradle.caching=true -mc_version=1.26.1 +mc_version=26.1.1 neo_version=26.1.1.1-beta neo_version_range=[26.1,) loader_version_range=[4,) @@ -19,5 +19,5 @@ loader_version_range=[4,) #rhino_version=2101.2.7-build.81 #architectury_version=13.0.8 -#parchment_minecraft_version=1.26.1 -#parchment_mappings_version=2024.11.17 \ No newline at end of file +#parchment_minecraft_version=26.1.1 +#parchment_mappings_version=2024.11.17 diff --git a/src/main/java/thedarkcolour/exdeorum/block/CompressedBlockType.java b/src/main/java/thedarkcolour/exdeorum/block/CompressedBlockType.java index 1dceeb4a..29a8a62d 100644 --- a/src/main/java/thedarkcolour/exdeorum/block/CompressedBlockType.java +++ b/src/main/java/thedarkcolour/exdeorum/block/CompressedBlockType.java @@ -1,7 +1,9 @@ package thedarkcolour.exdeorum.block; import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.Identifier; +import net.minecraft.resources.ResourceKey; import net.minecraft.tags.TagKey; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; @@ -32,8 +34,8 @@ public class CompressedBlockType implements ItemLike { this.base = base; } - private Block createBlock() { - return new Block(BlockBehaviour.Properties.ofFullCopy(this.base.get())); + private Block createBlock(Identifier id) { + return new Block(BlockBehaviour.Properties.ofFullCopy(this.base.get()).setId(ResourceKey.create(Registries.BLOCK, id))); } public Block getBlock() { diff --git a/src/main/java/thedarkcolour/exdeorum/blockentity/AbstractCrucibleBlockEntity.java b/src/main/java/thedarkcolour/exdeorum/blockentity/AbstractCrucibleBlockEntity.java index 49b110da..5be5eb27 100644 --- a/src/main/java/thedarkcolour/exdeorum/blockentity/AbstractCrucibleBlockEntity.java +++ b/src/main/java/thedarkcolour/exdeorum/blockentity/AbstractCrucibleBlockEntity.java @@ -216,10 +216,10 @@ public abstract class AbstractCrucibleBlockEntity extends ETankBlockEntity { var result = recipe.getResult(); var contained = this.tank.getFluid(); shrinkAction.accept(item); - this.solids = (short) Math.min(this.solids + result.getAmount(), MAX_SOLIDS); + this.solids = (short) Math.min(this.solids + result.amount(), MAX_SOLIDS); if (contained.isEmpty()) { - this.fluid = result.getFluid(); + this.fluid = result.fluid().value(); updateLight(this.level, this.worldPosition, this.fluid); } @@ -249,8 +249,8 @@ public abstract class AbstractCrucibleBlockEntity extends ETankBlockEntity { var result = recipe.getResult(); var contained = this.tank.getFluid(); - if (FluidStack.isSameFluidSameComponents(result, contained) || contained.isEmpty()) { - return result.getAmount() + this.solids <= MAX_SOLIDS ? InsertionResult.YES : InsertionResult.FULL; + if (FluidStack.isSameFluidSameComponents(contained, result) || contained.isEmpty()) { + return result.amount() + this.solids <= MAX_SOLIDS ? InsertionResult.YES : InsertionResult.FULL; } } diff --git a/src/main/java/thedarkcolour/exdeorum/blockentity/BarrelBlockEntity.java b/src/main/java/thedarkcolour/exdeorum/blockentity/BarrelBlockEntity.java index 6a1cd584..d6ce4aa6 100644 --- a/src/main/java/thedarkcolour/exdeorum/blockentity/BarrelBlockEntity.java +++ b/src/main/java/thedarkcolour/exdeorum/blockentity/BarrelBlockEntity.java @@ -272,7 +272,7 @@ public class BarrelBlockEntity extends ETankBlockEntity { if (recipe != null && this.tank.getFluidAmount() >= recipe.baseFluid().amount() && itemFluid.getAmount() == 1000) { if (!level.isClientSide()) { this.tank.drain(recipe.baseFluid().amount(), IFluidHandler.FluidAction.EXECUTE); - setItem(recipe.result().copy()); + setItem(recipe.result().create()); if (recipe.consumesAdditive()) { itemFluidCap.drain(1000, IFluidHandler.FluidAction.EXECUTE); @@ -376,7 +376,7 @@ public class BarrelBlockEntity extends ETankBlockEntity { // Empty barrel this.tank.drain(recipe.fluid.amount(), IFluidHandler.FluidAction.EXECUTE); // Replace fluid with result - setItem(recipe.result.copy()); + setItem(recipe.result.create()); this.level.playSound(null, this.worldPosition, ESounds.BARREL_MIXING.get(), SoundSource.BLOCKS, 0.8f, 1.0f); } // Mixing was successful, so return true @@ -443,12 +443,12 @@ public class BarrelBlockEntity extends ETankBlockEntity { // If additive is consumed, check that the additive can be consumed before crafting if (!recipe.consumesAdditive()) { this.tank.drain(recipe.baseFluid().amount(), IFluidHandler.FluidAction.EXECUTE); - setItem(recipe.result().copy()); + setItem(recipe.result().create()); } else if (aboveBlockState.getBlock() instanceof BucketPickup pickup) { // If something was picked up, we can craft if (!pickup.pickupBlock(null, this.level, abovePos, aboveBlockState).isEmpty()) { this.tank.drain(recipe.baseFluid().amount(), IFluidHandler.FluidAction.EXECUTE); - setItem(recipe.result().copy()); + setItem(recipe.result().create()); } } } diff --git a/src/main/java/thedarkcolour/exdeorum/blockentity/MechanicalHammerBlockEntity.java b/src/main/java/thedarkcolour/exdeorum/blockentity/MechanicalHammerBlockEntity.java index ef0434e0..6e4c52e6 100644 --- a/src/main/java/thedarkcolour/exdeorum/blockentity/MechanicalHammerBlockEntity.java +++ b/src/main/java/thedarkcolour/exdeorum/blockentity/MechanicalHammerBlockEntity.java @@ -131,7 +131,7 @@ public class MechanicalHammerBlockEntity extends AbstractMachineBlockEntity 0) { hasDrops = true; // make a single item copy of recipe result - var result = recipe.result.copyWithCount(1); + var result = recipe.result.withCount(1).create(); // the size of the stack respecting stack limits (ex. ender pearl limits to 16) - var stackAmount = Math.min(amount, recipe.result.getMaxStackSize()); + var stackAmount = Math.min(amount, result.getMaxStackSize()); result.setCount(stackAmount); amount -= stackAmount; var handleDrop = this.owner.handleResultItem(result, level, rand); diff --git a/src/main/java/thedarkcolour/exdeorum/compat/XeiSieveRecipe.java b/src/main/java/thedarkcolour/exdeorum/compat/XeiSieveRecipe.java index a8805c45..aa353aa3 100644 --- a/src/main/java/thedarkcolour/exdeorum/compat/XeiSieveRecipe.java +++ b/src/main/java/thedarkcolour/exdeorum/compat/XeiSieveRecipe.java @@ -94,7 +94,7 @@ public record XeiSieveRecipe(Ingredient ingredient, ItemStack mesh, List for (var recipe : meshRecipes) { int resultCount = recipe.resultAmount instanceof ConstantValue constant ? Math.round(constant.value()) : 1; - results.add(new Result(recipe.result.copyWithCount(resultCount), recipe.resultAmount, recipe.byHandOnly)); + results.add(new Result(recipe.result.withCount(resultCount).create(), recipe.resultAmount, recipe.byHandOnly)); } results.sort(resultSorter); diff --git a/src/main/java/thedarkcolour/exdeorum/compat/emi/CrucibleEmiRecipe.java b/src/main/java/thedarkcolour/exdeorum/compat/emi/CrucibleEmiRecipe.java index f7f3d21d..90be389c 100644 --- a/src/main/java/thedarkcolour/exdeorum/compat/emi/CrucibleEmiRecipe.java +++ b/src/main/java/thedarkcolour/exdeorum/compat/emi/CrucibleEmiRecipe.java @@ -31,7 +31,7 @@ abstract class CrucibleEmiRecipe extends EmiOneToOneRecipe { CrucibleEmiRecipe(CrucibleRecipe recipe, Identifier id) { super(recipe, id); - this.outputs = EmiUtil.outputs(recipe.getResult()); + this.outputs = EmiUtil.outputs(recipe.createResult()); } @Override diff --git a/src/main/java/thedarkcolour/exdeorum/compat/jei/BarrelMixingCategory.java b/src/main/java/thedarkcolour/exdeorum/compat/jei/BarrelMixingCategory.java index 1016942a..6ae786ae 100644 --- a/src/main/java/thedarkcolour/exdeorum/compat/jei/BarrelMixingCategory.java +++ b/src/main/java/thedarkcolour/exdeorum/compat/jei/BarrelMixingCategory.java @@ -90,7 +90,7 @@ public abstract class BarrelMixingCategory implements IRecipeCategory { public void setRecipe(IRecipeLayoutBuilder builder, BarrelMixingRecipe recipe, IFocusGroup focuses) { JeiUtil.addFluidIngredient(builder.addSlot(RecipeIngredientRole.INPUT, 1, 1), recipe.fluid).setFluidRenderer(1000, false, 16, 16); builder.addSlot(RecipeIngredientRole.INPUT, 33, 1).addIngredients(recipe.ingredient()); - builder.addSlot(RecipeIngredientRole.OUTPUT, 79, 1).addItemStack(recipe.result); + builder.addSlot(RecipeIngredientRole.OUTPUT, 79, 1).addItemStack(recipe.result.create()); } @Override @@ -115,7 +115,7 @@ public abstract class BarrelMixingCategory implements IRecipeCategory { if (recipe.consumesAdditive()) { additiveSlot.addTooltipCallback((view, tooltip) -> tooltip.add(CONTENTS_ARE_CONSUMED_TOOLTIP)); } - builder.addSlot(RecipeIngredientRole.OUTPUT, 79, 1).addItemStack(recipe.result().copy()); + builder.addSlot(RecipeIngredientRole.OUTPUT, 79, 1).addItemStack(recipe.result().create()); } @Override diff --git a/src/main/java/thedarkcolour/exdeorum/compat/jei/CrucibleCategory.java b/src/main/java/thedarkcolour/exdeorum/compat/jei/CrucibleCategory.java index 1ffa1f5a..003ab2cb 100644 --- a/src/main/java/thedarkcolour/exdeorum/compat/jei/CrucibleCategory.java +++ b/src/main/java/thedarkcolour/exdeorum/compat/jei/CrucibleCategory.java @@ -41,8 +41,8 @@ abstract class CrucibleCategory extends OneToOneCategory { @Override protected void addOutput(IRecipeSlotBuilder slot, CrucibleRecipe recipe) { - slot.addFluidStack(recipe.getResult().getFluid(), recipe.getResult().getAmount()) - .setFluidRenderer(Math.max(1000, recipe.getResult().getAmount()), false, 16, 16); + slot.addFluidStack(recipe.getResult().fluid().value(), recipe.getResult().amount()) + .setFluidRenderer(Math.max(1000, recipe.getResult().amount()), false, 16, 16); } static class LavaCrucible extends CrucibleCategory { diff --git a/src/main/java/thedarkcolour/exdeorum/compat/jei/HammerCategory.java b/src/main/java/thedarkcolour/exdeorum/compat/jei/HammerCategory.java index 0a4d237d..9a44aab1 100644 --- a/src/main/java/thedarkcolour/exdeorum/compat/jei/HammerCategory.java +++ b/src/main/java/thedarkcolour/exdeorum/compat/jei/HammerCategory.java @@ -52,9 +52,9 @@ class HammerCategory extends OneToOneCategory { @Override protected void addOutput(IRecipeSlotBuilder slot, HammerRecipe recipe) { if (recipe.resultAmount instanceof ConstantValue constant) { - slot.addItemStack(recipe.result.getCount() == 1 ? recipe.result : recipe.result.copyWithCount((int) constant.value())); + slot.addItemStack(recipe.result.count() == 1 ? recipe.result.create() : recipe.result.withCount((int) constant.value()).create()); } else { - slot.addItemStack(recipe.result); + slot.addItemStack(recipe.result.create()); SieveCategory.addTooltips(slot, false, recipe.resultAmount); } } diff --git a/src/main/java/thedarkcolour/exdeorum/data/Data.java b/src/main/java/thedarkcolour/exdeorum/data/Data.java index 93b455e3..7503fc76 100644 --- a/src/main/java/thedarkcolour/exdeorum/data/Data.java +++ b/src/main/java/thedarkcolour/exdeorum/data/Data.java @@ -25,7 +25,7 @@ import thedarkcolour.exdeorum.data.recipe.Recipes; import thedarkcolour.modkit.data.DataHelper; public class Data { - public static void generateData(GatherDataEvent event) { + public static void generateData(GatherDataEvent.Client event) { // Two things used by data generators var gen = event.getGenerator(); // writes to json var output = gen.getPackOutput(); diff --git a/src/main/java/thedarkcolour/exdeorum/data/ModCompatData.java b/src/main/java/thedarkcolour/exdeorum/data/ModCompatData.java index c65b3785..6450aa3c 100644 --- a/src/main/java/thedarkcolour/exdeorum/data/ModCompatData.java +++ b/src/main/java/thedarkcolour/exdeorum/data/ModCompatData.java @@ -18,7 +18,9 @@ package thedarkcolour.exdeorum.data; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.Identifier; +import net.minecraft.resources.ResourceKey; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockBehaviour; @@ -42,7 +44,7 @@ public class ModCompatData { private static DeferredItem item(String modid, String name) { if (DatagenModLoader.isRunningDataGen()) { DeferredRegister.Items registry = itemRegistries.computeIfAbsent(modid, DeferredRegister::createItems); - return registry.register(name, () -> new Item(new Item.Properties())); + return registry.register(name, id -> new Item(new Item.Properties().setId(ResourceKey.create(Registries.ITEM, id)))); } else { return null; } @@ -52,7 +54,7 @@ public class ModCompatData { private static DeferredBlock block(String modid, String name) { if (DatagenModLoader.isRunningDataGen()) { DeferredRegister.Blocks registry = blockRegistries.computeIfAbsent(modid, DeferredRegister::createBlocks); - return registry.register(name, () -> new Block(BlockBehaviour.Properties.of())); + return registry.register(name, id -> new Block(BlockBehaviour.Properties.of().setId(ResourceKey.create(Registries.BLOCK, id)))); } else { return null; } diff --git a/src/main/java/thedarkcolour/exdeorum/data/ModTags.java b/src/main/java/thedarkcolour/exdeorum/data/ModTags.java index 35a3df5c..9b84fd17 100644 --- a/src/main/java/thedarkcolour/exdeorum/data/ModTags.java +++ b/src/main/java/thedarkcolour/exdeorum/data/ModTags.java @@ -39,6 +39,7 @@ import thedarkcolour.exdeorum.registry.EBlocks; import thedarkcolour.exdeorum.registry.ECompressedBlocks; import thedarkcolour.exdeorum.registry.EFluids; import thedarkcolour.exdeorum.registry.EItems; +import thedarkcolour.exdeorum.registry.EWorldPresets; import thedarkcolour.exdeorum.tag.EBlockTags; import thedarkcolour.exdeorum.tag.EItemTags; import thedarkcolour.exdeorum.tag.EStructureSetTags; @@ -150,7 +151,7 @@ class ModTags { } public static void createWorldPresetTags(MKTagsProvider tags) { - tags.tag(net.minecraft.tags.WorldPresetTags.NORMAL).add(ResourceKey.create(Registries.WORLD_PRESET, Identifier.fromNamespaceAndPath(ExDeorum.ID, "void_world"))); + tags.tag(net.minecraft.tags.WorldPresetTags.NORMAL).addOptional(EWorldPresets.VOID_WORLD.identifier()); } public static void createFluidTags(MKTagsProvider tags) { diff --git a/src/main/java/thedarkcolour/exdeorum/data/recipe/Recipes.java b/src/main/java/thedarkcolour/exdeorum/data/recipe/Recipes.java index 3ab9c12c..97f4b308 100644 --- a/src/main/java/thedarkcolour/exdeorum/data/recipe/Recipes.java +++ b/src/main/java/thedarkcolour/exdeorum/data/recipe/Recipes.java @@ -31,7 +31,7 @@ import net.minecraft.tags.BlockTags; import net.minecraft.tags.ItemTags; import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.ItemStackTemplate; import net.minecraft.world.item.Items; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.level.ItemLike; @@ -52,6 +52,7 @@ import net.neoforged.neoforge.common.conditions.ModLoadedCondition; import net.neoforged.neoforge.common.conditions.NotCondition; import net.neoforged.neoforge.common.conditions.TagEmptyCondition; import net.neoforged.neoforge.fluids.FluidStack; +import net.neoforged.neoforge.fluids.FluidStackTemplate; import net.neoforged.neoforge.fluids.crafting.FluidIngredient; import net.neoforged.neoforge.fluids.crafting.SizedFluidIngredient; import thedarkcolour.exdeorum.ExDeorum; @@ -348,7 +349,7 @@ public class Recipes { recipes.netheriteUpgrade(RecipeCategory.TOOLS, ingredient(EItems.DIAMOND_WATERING_CAN), EItems.NETHERITE_WATERING_CAN.get()); // misc - recipes.shapelessCrafting(RecipeCategory.MISC, new ItemStack(EItems.PORCELAIN_CLAY_BALL.get()), ingredient(Items.CLAY_BALL), ingredient(Items.BONE_MEAL)); + recipes.shapelessCrafting(RecipeCategory.MISC, EItems.PORCELAIN_CLAY_BALL.get(), 1, ingredient(Items.CLAY_BALL), ingredient(Items.BONE_MEAL)); recipes.shapedCrafting(RecipeCategory.MISC, EItems.UNFIRED_PORCELAIN_BUCKET.get(), recipe -> { recipe.define('#', EItems.PORCELAIN_CLAY_BALL); recipe.pattern("# #"); @@ -539,11 +540,11 @@ public class Recipes { } private static void lavaCrucible(RecipeOutput writer, String id, Ingredient ingredient, int volume) { - writer.accept(ResourceKey.create(Registries.RECIPE, modLoc("lava_crucible/" + id)), new CrucibleRecipe.Lava(ingredient, new FluidStack(Fluids.LAVA, volume)), null); + writer.accept(ResourceKey.create(Registries.RECIPE, modLoc("lava_crucible/" + id)), new CrucibleRecipe.Lava(ingredient, new FluidStackTemplate(Fluids.LAVA, volume)), null); } private static void waterCrucible(RecipeOutput writer, String id, Ingredient ingredient, int volume) { - writer.accept(ResourceKey.create(Registries.RECIPE, modLoc("water_crucible/" + id)), new CrucibleRecipe.Water(ingredient, new FluidStack(Fluids.WATER, volume)), null); + writer.accept(ResourceKey.create(Registries.RECIPE, modLoc("water_crucible/" + id)), new CrucibleRecipe.Water(ingredient, new FluidStackTemplate(Fluids.WATER, volume)), null); } private static void hammerRecipes(RecipeOutput writer, MKRecipeProvider recipes) { @@ -594,7 +595,7 @@ public class Recipes { } private static void compressedHammerRecipe(RecipeOutput writer, ItemLike result, Ingredient block) { - writer.accept(ResourceKey.create(Registries.RECIPE, modLoc("compressed_hammer/" + path(result))), new CompressedHammerRecipe(block, new ItemStack(result.asItem()), exactly(9)), null); + writer.accept(ResourceKey.create(Registries.RECIPE, modLoc("compressed_hammer/" + path(result))), new CompressedHammerRecipe(block, new ItemStackTemplate(result.asItem()), exactly(9)), null); } private static void hammerRecipe(RecipeOutput writer, String name, Ingredient block, ItemLike result) { @@ -602,7 +603,7 @@ public class Recipes { } private static void hammerRecipe(RecipeOutput writer, String name, Ingredient block, ItemLike result, NumberProvider resultAmount) { - writer.accept(ResourceKey.create(Registries.RECIPE, modLoc("hammer/" + name)), new HammerRecipe(block, new ItemStack(result.asItem()), resultAmount), null); + writer.accept(ResourceKey.create(Registries.RECIPE, modLoc("hammer/" + name)), new HammerRecipe(block, new ItemStackTemplate(result.asItem()), resultAmount), null); } private static void crookRecipes(RecipeOutput writer) { @@ -615,7 +616,7 @@ public class Recipes { } private static void crookRecipe(RecipeOutput writer, String name, BlockPredicate blockPredicate, ItemLike result, float chance) { - writer.accept(ResourceKey.create(Registries.RECIPE, modLoc("crook/" + name)), new CrookRecipe(blockPredicate, new ItemStack(result), chance), null); + writer.accept(ResourceKey.create(Registries.RECIPE, modLoc("crook/" + name)), new CrookRecipe(blockPredicate, new ItemStackTemplate(result.asItem()), chance), null); } @SuppressWarnings("OptionalGetWithoutIsPresent") @@ -742,11 +743,11 @@ public class Recipes { } private static void barrelMixing(RecipeOutput writer, String suffix, Ingredient ingredient, Fluid fluidType, Item result) { - writer.accept(ResourceKey.create(Registries.RECIPE, modLoc("barrel_mixing/" + path(result) + suffix)), new BarrelMixingRecipe(ingredient, SizedFluidIngredient.of(fluidType, 1000), new ItemStack(result)), null); + writer.accept(ResourceKey.create(Registries.RECIPE, modLoc("barrel_mixing/" + path(result) + suffix)), new BarrelMixingRecipe(ingredient, SizedFluidIngredient.of(fluidType, 1000), new ItemStackTemplate(result)), null); } private static void barrelFluidMixing(RecipeOutput writer, Fluid base, Fluid additive, Item result, boolean consumesAdditive) { - writer.accept(ResourceKey.create(Registries.RECIPE, modLoc("barrel_fluid_mixing/" + path(result))), new BarrelFluidMixingRecipe(SizedFluidIngredient.of(base, 1000), FluidIngredient.of(additive), new ItemStack(result), consumesAdditive), null); + writer.accept(ResourceKey.create(Registries.RECIPE, modLoc("barrel_fluid_mixing/" + path(result))), new BarrelFluidMixingRecipe(SizedFluidIngredient.of(base, 1000), FluidIngredient.of(additive), new ItemStackTemplate(result), consumesAdditive), null); } private static void fluidTransformationRecipes(RecipeOutput writer) { diff --git a/src/main/java/thedarkcolour/exdeorum/data/recipe/SieveRecipes.java b/src/main/java/thedarkcolour/exdeorum/data/recipe/SieveRecipes.java index 3f005736..ec5c1f36 100644 --- a/src/main/java/thedarkcolour/exdeorum/data/recipe/SieveRecipes.java +++ b/src/main/java/thedarkcolour/exdeorum/data/recipe/SieveRecipes.java @@ -24,7 +24,7 @@ import net.minecraft.data.recipes.RecipeOutput; import net.minecraft.resources.ResourceKey; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.ItemStackTemplate; import net.minecraft.world.item.Items; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.level.ItemLike; @@ -963,25 +963,27 @@ class SieveRecipes { private record MeshDrops(RecipeOutput output, String basePath, String baseCompressedPath, Ingredient block, Ingredient mesh, Map compressedVariants) { private void add(Item result, NumberProvider resultAmount) { - this.output.accept(ResourceKey.create(Registries.RECIPE, modLoc(this.basePath + path(result))), new SieveRecipe(this.block, new ItemStack(result), resultAmount, this.mesh, false), null); + var resultStack = new ItemStackTemplate(result); + this.output.accept(ResourceKey.create(Registries.RECIPE, modLoc(this.basePath + path(result))), new SieveRecipe(this.block, resultStack, resultAmount, this.mesh, false), null); if (this.compressedVariants.containsKey(this.block)) { var compressedLoc = ResourceKey.create(Registries.RECIPE, modLoc(this.baseCompressedPath + path(result))); var multiplied = Recipes.compressedMultiplier(resultAmount); - this.output.accept(compressedLoc, new CompressedSieveRecipe(this.compressedVariants.get(this.block), new ItemStack(result), multiplied, this.mesh, false), null); + this.output.accept(compressedLoc, new CompressedSieveRecipe(this.compressedVariants.get(this.block), resultStack, multiplied, this.mesh, false), null); } } private void addConditional(ItemLike result, NumberProvider resultAmount, ICondition condition) { var path = ResourceKey.create(Registries.RECIPE, modLoc(this.basePath + path(result))); - this.output.withConditions(condition).accept(path, new SieveRecipe(this.block, new ItemStack(result), resultAmount, this.mesh, false), null); + var resultStack = new ItemStackTemplate(result.asItem()); + this.output.withConditions(condition).accept(path, new SieveRecipe(this.block, resultStack, resultAmount, this.mesh, false), null); if (this.compressedVariants.containsKey(this.block)) { var compressedLoc = ResourceKey.create(Registries.RECIPE, modLoc(this.baseCompressedPath + path(result))); var multiplied = Recipes.compressedMultiplier(resultAmount); - this.output.withConditions(condition).accept(compressedLoc, new CompressedSieveRecipe(this.compressedVariants.get(this.block), new ItemStack(result), multiplied, this.mesh, false), null); + this.output.withConditions(condition).accept(compressedLoc, new CompressedSieveRecipe(this.compressedVariants.get(this.block), resultStack, multiplied, this.mesh, false), null); } } } diff --git a/src/main/java/thedarkcolour/exdeorum/loot/CrookLootModifier.java b/src/main/java/thedarkcolour/exdeorum/loot/CrookLootModifier.java index ccf75a66..594a519c 100644 --- a/src/main/java/thedarkcolour/exdeorum/loot/CrookLootModifier.java +++ b/src/main/java/thedarkcolour/exdeorum/loot/CrookLootModifier.java @@ -62,7 +62,7 @@ public class CrookLootModifier extends LootModifier { for (CrookRecipe recipe : RecipeUtil.getCrookRecipes(state)) { for (int i = 0; i < rolls; i++) { if (rand.nextFloat() < recipe.chance()) { - generatedLoot.add(recipe.result().copy()); + generatedLoot.add(recipe.result().create()); } } } diff --git a/src/main/java/thedarkcolour/exdeorum/loot/HammerLootModifier.java b/src/main/java/thedarkcolour/exdeorum/loot/HammerLootModifier.java index b35d5a3e..5e22bab3 100644 --- a/src/main/java/thedarkcolour/exdeorum/loot/HammerLootModifier.java +++ b/src/main/java/thedarkcolour/exdeorum/loot/HammerLootModifier.java @@ -86,7 +86,7 @@ public class HammerLootModifier extends LootModifier { } if (resultAmount > 0) { - newLoot.add(recipe.result.copyWithCount(resultAmount)); + newLoot.add(recipe.result.withCount(resultAmount).create()); } return newLoot; diff --git a/src/main/java/thedarkcolour/exdeorum/material/AbstractMaterial.java b/src/main/java/thedarkcolour/exdeorum/material/AbstractMaterial.java index 869c19b9..7609c2b7 100644 --- a/src/main/java/thedarkcolour/exdeorum/material/AbstractMaterial.java +++ b/src/main/java/thedarkcolour/exdeorum/material/AbstractMaterial.java @@ -18,6 +18,9 @@ package thedarkcolour.exdeorum.material; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.Identifier; +import net.minecraft.resources.ResourceKey; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; import net.minecraft.world.level.ItemLike; @@ -50,12 +53,12 @@ public abstract class AbstractMaterial implements ItemLike { this.requiredModId = requiredModId; } - protected abstract Block createBlock(); + protected abstract Block createBlock(Identifier id); - protected BlockBehaviour.Properties props() { + protected BlockBehaviour.Properties props(Identifier id) { var properties = BlockBehaviour.Properties.of().strength(this.strength).sound(this.soundType); if (this.needsCorrectTool) properties.requiresCorrectToolForDrops(); - return properties; + return properties.setId(ResourceKey.create(Registries.BLOCK, id)); } public Item getItem() { diff --git a/src/main/java/thedarkcolour/exdeorum/material/BarrelMaterial.java b/src/main/java/thedarkcolour/exdeorum/material/BarrelMaterial.java index 2df47081..f3239c01 100644 --- a/src/main/java/thedarkcolour/exdeorum/material/BarrelMaterial.java +++ b/src/main/java/thedarkcolour/exdeorum/material/BarrelMaterial.java @@ -18,6 +18,7 @@ package thedarkcolour.exdeorum.material; +import net.minecraft.resources.Identifier; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.SoundType; import org.jetbrains.annotations.Nullable; @@ -42,8 +43,8 @@ public class BarrelMaterial extends AbstractMaterial { } @Override - protected Block createBlock() { - var props = props().noOcclusion(); + protected Block createBlock(Identifier id) { + var props = props(id).noOcclusion(); if (!this.fireproof) props.ignitedByLava(); return new BarrelBlock(props); } diff --git a/src/main/java/thedarkcolour/exdeorum/material/CompressedSieveMaterial.java b/src/main/java/thedarkcolour/exdeorum/material/CompressedSieveMaterial.java index 0fc9c973..3c8d2adc 100644 --- a/src/main/java/thedarkcolour/exdeorum/material/CompressedSieveMaterial.java +++ b/src/main/java/thedarkcolour/exdeorum/material/CompressedSieveMaterial.java @@ -18,6 +18,7 @@ package thedarkcolour.exdeorum.material; +import net.minecraft.resources.Identifier; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.SoundType; import org.jetbrains.annotations.Nullable; @@ -29,8 +30,8 @@ public class CompressedSieveMaterial extends SieveMaterial { } @Override - protected Block createBlock() { - return new CompressedSieveBlock(props().noOcclusion()); + protected Block createBlock(Identifier id) { + return new CompressedSieveBlock(props(id).noOcclusion()); } @Nullable diff --git a/src/main/java/thedarkcolour/exdeorum/material/LavaCrucibleMaterial.java b/src/main/java/thedarkcolour/exdeorum/material/LavaCrucibleMaterial.java index a6d6a117..53e1d44c 100644 --- a/src/main/java/thedarkcolour/exdeorum/material/LavaCrucibleMaterial.java +++ b/src/main/java/thedarkcolour/exdeorum/material/LavaCrucibleMaterial.java @@ -18,6 +18,7 @@ package thedarkcolour.exdeorum.material; +import net.minecraft.resources.Identifier; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.SoundType; import thedarkcolour.exdeorum.block.LavaCrucibleBlock; @@ -28,7 +29,7 @@ public class LavaCrucibleMaterial extends AbstractCrucibleMaterial { } @Override - protected Block createBlock() { - return new LavaCrucibleBlock(props().noOcclusion()); + protected Block createBlock(Identifier id) { + return new LavaCrucibleBlock(props(id).noOcclusion()); } } diff --git a/src/main/java/thedarkcolour/exdeorum/material/SieveMaterial.java b/src/main/java/thedarkcolour/exdeorum/material/SieveMaterial.java index d7424fad..765fac25 100644 --- a/src/main/java/thedarkcolour/exdeorum/material/SieveMaterial.java +++ b/src/main/java/thedarkcolour/exdeorum/material/SieveMaterial.java @@ -18,6 +18,7 @@ package thedarkcolour.exdeorum.material; +import net.minecraft.resources.Identifier; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.SoundType; import org.jetbrains.annotations.Nullable; @@ -29,8 +30,8 @@ public class SieveMaterial extends AbstractMaterial { } @Override - protected Block createBlock() { - return new SieveBlock(props().noOcclusion()); + protected Block createBlock(Identifier id) { + return new SieveBlock(props(id).noOcclusion()); } @Nullable diff --git a/src/main/java/thedarkcolour/exdeorum/material/WaterCrucibleMaterial.java b/src/main/java/thedarkcolour/exdeorum/material/WaterCrucibleMaterial.java index 9261d5e3..2d55377c 100644 --- a/src/main/java/thedarkcolour/exdeorum/material/WaterCrucibleMaterial.java +++ b/src/main/java/thedarkcolour/exdeorum/material/WaterCrucibleMaterial.java @@ -18,6 +18,7 @@ package thedarkcolour.exdeorum.material; +import net.minecraft.resources.Identifier; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.SoundType; import thedarkcolour.exdeorum.block.WaterCrucibleBlock; @@ -28,7 +29,7 @@ public class WaterCrucibleMaterial extends AbstractCrucibleMaterial { } @Override - protected Block createBlock() { - return new WaterCrucibleBlock(props().noOcclusion()); + protected Block createBlock(Identifier id) { + return new WaterCrucibleBlock(props(id).noOcclusion()); } } diff --git a/src/main/java/thedarkcolour/exdeorum/recipe/ProbabilityRecipe.java b/src/main/java/thedarkcolour/exdeorum/recipe/ProbabilityRecipe.java index 1ca09dc5..ca46777f 100644 --- a/src/main/java/thedarkcolour/exdeorum/recipe/ProbabilityRecipe.java +++ b/src/main/java/thedarkcolour/exdeorum/recipe/ProbabilityRecipe.java @@ -21,29 +21,30 @@ package thedarkcolour.exdeorum.recipe; import com.mojang.datafixers.Products; import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.ItemStackTemplate; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.level.storage.loot.providers.number.NumberProvider; import net.minecraft.world.level.storage.loot.providers.number.NumberProviders; public abstract class ProbabilityRecipe extends SingleIngredientRecipe { - public final ItemStack result; + public final ItemStackTemplate result; public final NumberProvider resultAmount; - public ProbabilityRecipe(Ingredient ingredient, ItemStack result, NumberProvider resultAmount) { + public ProbabilityRecipe(Ingredient ingredient, ItemStackTemplate result, NumberProvider resultAmount) { super(ingredient); this.result = result; this.resultAmount = resultAmount; } - protected static Products.P3, Ingredient, ItemStack, NumberProvider> commonFields(RecordCodecBuilder.Instance instance) { + protected static Products.P3, Ingredient, ItemStackTemplate, NumberProvider> commonFields(RecordCodecBuilder.Instance instance) { return instance.group( CodecUtil.ingredientField(), - ItemStack.CODEC.fieldOf("result").forGetter(ProbabilityRecipe::result), + ItemStackTemplate.CODEC.fieldOf("result").forGetter(ProbabilityRecipe::result), NumberProviders.CODEC.fieldOf("result_amount").forGetter(ProbabilityRecipe::resultAmount) ); } - public ItemStack result() { + public ItemStackTemplate result() { return this.result; } diff --git a/src/main/java/thedarkcolour/exdeorum/recipe/barrel/BarrelFluidMixingRecipe.java b/src/main/java/thedarkcolour/exdeorum/recipe/barrel/BarrelFluidMixingRecipe.java index 14a5a2a4..e8090154 100644 --- a/src/main/java/thedarkcolour/exdeorum/recipe/barrel/BarrelFluidMixingRecipe.java +++ b/src/main/java/thedarkcolour/exdeorum/recipe/barrel/BarrelFluidMixingRecipe.java @@ -24,6 +24,7 @@ import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.ItemStackTemplate; import net.minecraft.world.item.crafting.PlacementInfo; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.RecipeBookCategories; @@ -44,13 +45,13 @@ import thedarkcolour.exdeorum.registry.ERecipeTypes; public record BarrelFluidMixingRecipe( SizedFluidIngredient baseFluid, FluidIngredient additiveFluid, - ItemStack result, + ItemStackTemplate result, boolean consumesAdditive ) implements Recipe { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( SizedFluidIngredient.CODEC.fieldOf("base_fluid").forGetter(BarrelFluidMixingRecipe::baseFluid), FluidIngredient.CODEC.fieldOf("additive_fluid").forGetter(BarrelFluidMixingRecipe::additiveFluid), - ItemStack.CODEC.fieldOf("result").forGetter(BarrelFluidMixingRecipe::result), + ItemStackTemplate.CODEC.fieldOf("result").forGetter(BarrelFluidMixingRecipe::result), Codec.BOOL.optionalFieldOf("consumes_additive", false).forGetter(BarrelFluidMixingRecipe::consumesAdditive) ).apply(instance, BarrelFluidMixingRecipe::new)); public static final StreamCodec STREAM_CODEC = StreamCodec.of(BarrelFluidMixingRecipe::toNetwork, BarrelFluidMixingRecipe::fromNetwork); @@ -98,14 +99,14 @@ public record BarrelFluidMixingRecipe( public static void toNetwork(RegistryFriendlyByteBuf buffer, BarrelFluidMixingRecipe recipe) { SizedFluidIngredient.STREAM_CODEC.encode(buffer, recipe.baseFluid); FluidIngredient.STREAM_CODEC.encode(buffer, recipe.additiveFluid); - ItemStack.STREAM_CODEC.encode(buffer, recipe.result); + ItemStackTemplate.STREAM_CODEC.encode(buffer, recipe.result); buffer.writeBoolean(recipe.consumesAdditive); } public static BarrelFluidMixingRecipe fromNetwork(RegistryFriendlyByteBuf buffer) { SizedFluidIngredient baseFluid = SizedFluidIngredient.STREAM_CODEC.decode(buffer); FluidIngredient additiveFluid = FluidIngredient.STREAM_CODEC.decode(buffer); - ItemStack result = ItemStack.STREAM_CODEC.decode(buffer); + ItemStackTemplate result = ItemStackTemplate.STREAM_CODEC.decode(buffer); boolean consumesAdditive = buffer.readBoolean(); return new BarrelFluidMixingRecipe(baseFluid, additiveFluid, result, consumesAdditive); diff --git a/src/main/java/thedarkcolour/exdeorum/recipe/barrel/BarrelMixingRecipe.java b/src/main/java/thedarkcolour/exdeorum/recipe/barrel/BarrelMixingRecipe.java index 2ff9b8f2..e2b0c93f 100644 --- a/src/main/java/thedarkcolour/exdeorum/recipe/barrel/BarrelMixingRecipe.java +++ b/src/main/java/thedarkcolour/exdeorum/recipe/barrel/BarrelMixingRecipe.java @@ -23,6 +23,7 @@ import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.ItemStackTemplate; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.RecipeInput; import net.minecraft.world.item.crafting.RecipeSerializer; @@ -39,14 +40,14 @@ public class BarrelMixingRecipe extends SingleIngredientRecipe { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( CodecUtil.ingredientField(), SizedFluidIngredient.CODEC.fieldOf("fluid").forGetter(BarrelMixingRecipe::getFluid), - ItemStack.CODEC.fieldOf("result").forGetter(BarrelMixingRecipe::getResult) + ItemStackTemplate.CODEC.fieldOf("result").forGetter(BarrelMixingRecipe::getResult) ).apply(instance, BarrelMixingRecipe::new)); public static final StreamCodec STREAM_CODEC = StreamCodec.of(BarrelMixingRecipe::toNetwork, BarrelMixingRecipe::fromNetwork); public final SizedFluidIngredient fluid; - public final ItemStack result; + public final ItemStackTemplate result; - public BarrelMixingRecipe(Ingredient ingredient, SizedFluidIngredient fluid, ItemStack result) { + public BarrelMixingRecipe(Ingredient ingredient, SizedFluidIngredient fluid, ItemStackTemplate result) { super(ingredient); this.fluid = fluid; this.result = result; @@ -56,7 +57,7 @@ public class BarrelMixingRecipe extends SingleIngredientRecipe { return this.fluid; } - public ItemStack getResult() { + public ItemStackTemplate getResult() { return this.result; } @@ -84,13 +85,13 @@ public class BarrelMixingRecipe extends SingleIngredientRecipe { public static void toNetwork(RegistryFriendlyByteBuf buffer, BarrelMixingRecipe recipe) { Ingredient.CONTENTS_STREAM_CODEC.encode(buffer, recipe.ingredient); SizedFluidIngredient.STREAM_CODEC.encode(buffer, recipe.fluid); - ItemStack.STREAM_CODEC.encode(buffer, recipe.result); + ItemStackTemplate.STREAM_CODEC.encode(buffer, recipe.result); } public static BarrelMixingRecipe fromNetwork(RegistryFriendlyByteBuf buffer) { Ingredient ingredient = Ingredient.CONTENTS_STREAM_CODEC.decode(buffer); SizedFluidIngredient fluid = SizedFluidIngredient.STREAM_CODEC.decode(buffer); - ItemStack result = ItemStack.STREAM_CODEC.decode(buffer); + ItemStackTemplate result = ItemStackTemplate.STREAM_CODEC.decode(buffer); return new BarrelMixingRecipe(ingredient, fluid, result); } diff --git a/src/main/java/thedarkcolour/exdeorum/recipe/crook/CrookRecipe.java b/src/main/java/thedarkcolour/exdeorum/recipe/crook/CrookRecipe.java index 0b0ff6a0..765c9fbe 100644 --- a/src/main/java/thedarkcolour/exdeorum/recipe/crook/CrookRecipe.java +++ b/src/main/java/thedarkcolour/exdeorum/recipe/crook/CrookRecipe.java @@ -24,6 +24,7 @@ import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.ItemStackTemplate; import net.minecraft.world.item.crafting.PlacementInfo; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.RecipeBookCategories; @@ -36,10 +37,10 @@ import thedarkcolour.exdeorum.recipe.BlockPredicate; import thedarkcolour.exdeorum.registry.ERecipeSerializers; import thedarkcolour.exdeorum.registry.ERecipeTypes; -public record CrookRecipe(BlockPredicate blockPredicate, ItemStack result, float chance) implements Recipe { +public record CrookRecipe(BlockPredicate blockPredicate, ItemStackTemplate result, float chance) implements Recipe { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( BlockPredicate.CODEC.fieldOf("block_predicate").forGetter(CrookRecipe::blockPredicate), - ItemStack.CODEC.fieldOf("result").forGetter(CrookRecipe::result), + ItemStackTemplate.CODEC.fieldOf("result").forGetter(CrookRecipe::result), Codec.FLOAT.fieldOf("chance").forGetter(CrookRecipe::chance) ).apply(instance, CrookRecipe::new)); public static final StreamCodec STREAM_CODEC = StreamCodec.of(CrookRecipe::toNetwork, CrookRecipe::fromNetwork); @@ -86,13 +87,13 @@ public record CrookRecipe(BlockPredicate blockPredicate, ItemStack result, float public static void toNetwork(RegistryFriendlyByteBuf buffer, CrookRecipe recipe) { recipe.blockPredicate.toNetwork(buffer); - ItemStack.STREAM_CODEC.encode(buffer, recipe.result); + ItemStackTemplate.STREAM_CODEC.encode(buffer, recipe.result); buffer.writeFloat(recipe.chance); } public static CrookRecipe fromNetwork(RegistryFriendlyByteBuf buffer) { BlockPredicate blockPredicate = BlockPredicate.STREAM_CODEC.decode(buffer); - ItemStack result = ItemStack.STREAM_CODEC.decode(buffer); + ItemStackTemplate result = ItemStackTemplate.STREAM_CODEC.decode(buffer); float chance = buffer.readFloat(); return new CrookRecipe(blockPredicate, result, chance); diff --git a/src/main/java/thedarkcolour/exdeorum/recipe/crucible/CrucibleRecipe.java b/src/main/java/thedarkcolour/exdeorum/recipe/crucible/CrucibleRecipe.java index 8da65003..99100ded 100644 --- a/src/main/java/thedarkcolour/exdeorum/recipe/crucible/CrucibleRecipe.java +++ b/src/main/java/thedarkcolour/exdeorum/recipe/crucible/CrucibleRecipe.java @@ -26,6 +26,7 @@ import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; import net.neoforged.neoforge.fluids.FluidStack; +import net.neoforged.neoforge.fluids.FluidStackTemplate; import thedarkcolour.exdeorum.recipe.CodecUtil; import thedarkcolour.exdeorum.recipe.SingleIngredientRecipe; import thedarkcolour.exdeorum.registry.ERecipeSerializers; @@ -34,9 +35,9 @@ import thedarkcolour.exdeorum.registry.ERecipeTypes; import java.util.function.BiFunction; public abstract class CrucibleRecipe extends SingleIngredientRecipe { - private final FluidStack result; + private final FluidStackTemplate result; - protected CrucibleRecipe(Ingredient ingredient, FluidStack result) { + protected CrucibleRecipe(Ingredient ingredient, FluidStackTemplate result) { super(ingredient); this.result = result; @@ -45,34 +46,38 @@ public abstract class CrucibleRecipe extends SingleIngredientRecipe { } } - public FluidStack getResult() { + public FluidStackTemplate getResult() { return this.result; } - private static MapCodec mapCodec(BiFunction factory) { + public FluidStack createResult() { + return this.result.create(); + } + + private static MapCodec mapCodec(BiFunction factory) { return RecordCodecBuilder.mapCodec(instance -> instance.group( CodecUtil.ingredientField(), - CodecUtil.FLUIDSTACK_CODEC.fieldOf("fluid").forGetter(CrucibleRecipe::getResult) + FluidStackTemplate.CODEC.fieldOf("fluid").forGetter(CrucibleRecipe::getResult) ).apply(instance, factory)); } - private static StreamCodec streamCodec(BiFunction factory) { + private static StreamCodec streamCodec(BiFunction factory) { return StreamCodec.of( CrucibleRecipe::toNetwork, - buffer -> factory.apply(Ingredient.CONTENTS_STREAM_CODEC.decode(buffer), FluidStack.STREAM_CODEC.decode(buffer)) + buffer -> factory.apply(Ingredient.CONTENTS_STREAM_CODEC.decode(buffer), FluidStackTemplate.STREAM_CODEC.decode(buffer)) ); } public static void toNetwork(RegistryFriendlyByteBuf buffer, CrucibleRecipe recipe) { Ingredient.CONTENTS_STREAM_CODEC.encode(buffer, recipe.ingredient); - FluidStack.STREAM_CODEC.encode(buffer, recipe.result); + FluidStackTemplate.STREAM_CODEC.encode(buffer, recipe.result); } public static class Lava extends CrucibleRecipe { public static final MapCodec CODEC = mapCodec(Lava::new); public static final StreamCodec STREAM_CODEC = streamCodec(Lava::new); - public Lava(Ingredient ingredient, FluidStack result) { + public Lava(Ingredient ingredient, FluidStackTemplate result) { super(ingredient, result); } @@ -91,7 +96,7 @@ public abstract class CrucibleRecipe extends SingleIngredientRecipe { public static final MapCodec CODEC = mapCodec(Water::new); public static final StreamCodec STREAM_CODEC = streamCodec(Water::new); - public Water(Ingredient ingredient, FluidStack result) { + public Water(Ingredient ingredient, FluidStackTemplate result) { super(ingredient, result); } diff --git a/src/main/java/thedarkcolour/exdeorum/recipe/hammer/CompressedHammerRecipe.java b/src/main/java/thedarkcolour/exdeorum/recipe/hammer/CompressedHammerRecipe.java index fc176bfe..2bcf5467 100644 --- a/src/main/java/thedarkcolour/exdeorum/recipe/hammer/CompressedHammerRecipe.java +++ b/src/main/java/thedarkcolour/exdeorum/recipe/hammer/CompressedHammerRecipe.java @@ -22,7 +22,7 @@ import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.ItemStackTemplate; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; @@ -36,11 +36,11 @@ public class CompressedHammerRecipe extends HammerRecipe { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> ProbabilityRecipe.commonFields(instance).apply(instance, CompressedHammerRecipe::new)); public static final StreamCodec STREAM_CODEC = StreamCodec.composite( Ingredient.CONTENTS_STREAM_CODEC, CompressedHammerRecipe::ingredient, - ItemStack.STREAM_CODEC, CompressedHammerRecipe::result, + ItemStackTemplate.STREAM_CODEC, CompressedHammerRecipe::result, CodecUtil.NUMBER_PROVIDER_CODEC, CompressedHammerRecipe::resultAmount, CompressedHammerRecipe::new); - public CompressedHammerRecipe(Ingredient ingredient, ItemStack result, NumberProvider resultAmount) { + public CompressedHammerRecipe(Ingredient ingredient, ItemStackTemplate result, NumberProvider resultAmount) { super(ingredient, result, resultAmount); } diff --git a/src/main/java/thedarkcolour/exdeorum/recipe/hammer/HammerRecipe.java b/src/main/java/thedarkcolour/exdeorum/recipe/hammer/HammerRecipe.java index ba051791..ab1b1ee4 100644 --- a/src/main/java/thedarkcolour/exdeorum/recipe/hammer/HammerRecipe.java +++ b/src/main/java/thedarkcolour/exdeorum/recipe/hammer/HammerRecipe.java @@ -22,7 +22,7 @@ import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.ItemStackTemplate; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; @@ -36,11 +36,11 @@ public class HammerRecipe extends ProbabilityRecipe { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> ProbabilityRecipe.commonFields(instance).apply(instance, HammerRecipe::new)); public static final StreamCodec STREAM_CODEC = StreamCodec.composite( Ingredient.CONTENTS_STREAM_CODEC, HammerRecipe::ingredient, - ItemStack.STREAM_CODEC, HammerRecipe::result, + ItemStackTemplate.STREAM_CODEC, HammerRecipe::result, CodecUtil.NUMBER_PROVIDER_CODEC, HammerRecipe::resultAmount, HammerRecipe::new); - public HammerRecipe(Ingredient ingredient, ItemStack result, NumberProvider resultAmount) { + public HammerRecipe(Ingredient ingredient, ItemStackTemplate result, NumberProvider resultAmount) { super(ingredient, result, resultAmount); } diff --git a/src/main/java/thedarkcolour/exdeorum/recipe/sieve/CompressedSieveRecipe.java b/src/main/java/thedarkcolour/exdeorum/recipe/sieve/CompressedSieveRecipe.java index 9151d522..8d3cace9 100644 --- a/src/main/java/thedarkcolour/exdeorum/recipe/sieve/CompressedSieveRecipe.java +++ b/src/main/java/thedarkcolour/exdeorum/recipe/sieve/CompressedSieveRecipe.java @@ -22,7 +22,7 @@ import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.ItemStackTemplate; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; @@ -34,7 +34,7 @@ public class CompressedSieveRecipe extends SieveRecipe { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> commonSieveFields(instance).apply(instance, CompressedSieveRecipe::new)); public static final StreamCodec STREAM_CODEC = sieveStreamCodec(CompressedSieveRecipe::new); - public CompressedSieveRecipe(Ingredient ingredient, ItemStack result, NumberProvider resultAmount, Ingredient mesh, boolean byHandOnly) { + public CompressedSieveRecipe(Ingredient ingredient, ItemStackTemplate result, NumberProvider resultAmount, Ingredient mesh, boolean byHandOnly) { super(ingredient, result, resultAmount, mesh, byHandOnly); } diff --git a/src/main/java/thedarkcolour/exdeorum/recipe/sieve/SieveRecipe.java b/src/main/java/thedarkcolour/exdeorum/recipe/sieve/SieveRecipe.java index 69911207..ad833b83 100644 --- a/src/main/java/thedarkcolour/exdeorum/recipe/sieve/SieveRecipe.java +++ b/src/main/java/thedarkcolour/exdeorum/recipe/sieve/SieveRecipe.java @@ -26,7 +26,7 @@ import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.ItemStackTemplate; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; @@ -40,10 +40,10 @@ public class SieveRecipe extends ProbabilityRecipe { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> commonSieveFields(instance).apply(instance, SieveRecipe::new)); public static final StreamCodec STREAM_CODEC = sieveStreamCodec(SieveRecipe::new); - static StreamCodec sieveStreamCodec(Function5 factory) { + static StreamCodec sieveStreamCodec(Function5 factory) { return StreamCodec.composite( Ingredient.CONTENTS_STREAM_CODEC, T::ingredient, - ItemStack.STREAM_CODEC, T::result, + ItemStackTemplate.STREAM_CODEC, T::result, CodecUtil.NUMBER_PROVIDER_CODEC, T::resultAmount, Ingredient.CONTENTS_STREAM_CODEC, T::mesh, ByteBufCodecs.BOOL, T::byHandOnly, @@ -51,7 +51,7 @@ public class SieveRecipe extends ProbabilityRecipe { ); } - protected static Products.P5, Ingredient, ItemStack, NumberProvider, Ingredient, Boolean> commonSieveFields(RecordCodecBuilder.Instance instance) { + protected static Products.P5, Ingredient, ItemStackTemplate, NumberProvider, Ingredient, Boolean> commonSieveFields(RecordCodecBuilder.Instance instance) { return commonFields(instance).and( instance.group( Ingredient.CODEC.fieldOf("mesh").forGetter(SieveRecipe::mesh), @@ -62,7 +62,7 @@ public class SieveRecipe extends ProbabilityRecipe { public final Ingredient mesh; public final boolean byHandOnly; - public SieveRecipe(Ingredient ingredient, ItemStack result, NumberProvider resultAmount, Ingredient mesh, boolean byHandOnly) { + public SieveRecipe(Ingredient ingredient, ItemStackTemplate result, NumberProvider resultAmount, Ingredient mesh, boolean byHandOnly) { super(ingredient, result, resultAmount); this.mesh = mesh; diff --git a/src/main/java/thedarkcolour/exdeorum/registry/EBlocks.java b/src/main/java/thedarkcolour/exdeorum/registry/EBlocks.java index 22c4ad81..8351b8df 100644 --- a/src/main/java/thedarkcolour/exdeorum/registry/EBlocks.java +++ b/src/main/java/thedarkcolour/exdeorum/registry/EBlocks.java @@ -18,9 +18,13 @@ package thedarkcolour.exdeorum.registry; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.Identifier; +import net.minecraft.resources.ResourceKey; import net.minecraft.util.ColorRGBA; import net.minecraft.world.item.DyeColor; import net.minecraft.world.level.block.*; +import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.material.MapColor; import net.minecraft.world.level.material.PushReaction; import net.neoforged.neoforge.registries.DeferredBlock; @@ -35,20 +39,24 @@ public class EBlocks { public static final DeferredRegister.Blocks BLOCKS = DeferredRegister.createBlocks(ExDeorum.ID); // Materials - public static final DeferredBlock DUST = BLOCKS.register("dust", () -> new ColoredFallingBlock(new ColorRGBA(0xC8C6AB), of().sound(SoundType.SAND).strength(0.4f))); - public static final DeferredBlock CRUSHED_NETHERRACK = BLOCKS.register("crushed_netherrack", () -> new ColoredFallingBlock(new ColorRGBA(0x501B1B), of().mapColor(MapColor.NETHER).sound(SoundType.SAND).strength(0.6f))); - public static final DeferredBlock CRUSHED_END_STONE = BLOCKS.register("crushed_end_stone", () -> new ColoredFallingBlock(new ColorRGBA(0xEEF6B4), of().mapColor(MapColor.SAND).sound(SoundType.SAND).strength(0.6f))); - public static final DeferredBlock CRUSHED_DEEPSLATE = BLOCKS.register("crushed_deepslate", () -> new ColoredFallingBlock(new ColorRGBA(0x4A4A4F), of().mapColor(DyeColor.GRAY).sound(SoundType.SAND).strength(0.8f))); - public static final DeferredBlock CRUSHED_BLACKSTONE = BLOCKS.register("crushed_blackstone", () -> new ColoredFallingBlock(new ColorRGBA(0x20131C), of().mapColor(DyeColor.BLACK).sound(SoundType.SAND).strength(0.6f))); + public static final DeferredBlock DUST = BLOCKS.register("dust", id -> new ColoredFallingBlock(new ColorRGBA(0xC8C6AB), props(id, of().sound(SoundType.SAND).strength(0.4f)))); + public static final DeferredBlock CRUSHED_NETHERRACK = BLOCKS.register("crushed_netherrack", id -> new ColoredFallingBlock(new ColorRGBA(0x501B1B), props(id, of().mapColor(MapColor.NETHER).sound(SoundType.SAND).strength(0.6f)))); + public static final DeferredBlock CRUSHED_END_STONE = BLOCKS.register("crushed_end_stone", id -> new ColoredFallingBlock(new ColorRGBA(0xEEF6B4), props(id, of().mapColor(MapColor.SAND).sound(SoundType.SAND).strength(0.6f)))); + public static final DeferredBlock CRUSHED_DEEPSLATE = BLOCKS.register("crushed_deepslate", id -> new ColoredFallingBlock(new ColorRGBA(0x4A4A4F), props(id, of().mapColor(DyeColor.GRAY).sound(SoundType.SAND).strength(0.8f)))); + public static final DeferredBlock CRUSHED_BLACKSTONE = BLOCKS.register("crushed_blackstone", id -> new ColoredFallingBlock(new ColorRGBA(0x20131C), props(id, of().mapColor(DyeColor.BLACK).sound(SoundType.SAND).strength(0.6f)))); // Mechanical Sieve - public static final DeferredBlock MECHANICAL_SIEVE = BLOCKS.register("mechanical_sieve", () -> new MechanicalSieveBlock(of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().strength(5f, 1200f))); + public static final DeferredBlock MECHANICAL_SIEVE = BLOCKS.register("mechanical_sieve", id -> new MechanicalSieveBlock(props(id, of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().strength(5f, 1200f)))); // Mechanical Hammer - public static final DeferredBlock MECHANICAL_HAMMER = BLOCKS.register("mechanical_hammer", () -> new MechanicalHammerBlock(of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().strength(5f, 1200f))); + public static final DeferredBlock MECHANICAL_HAMMER = BLOCKS.register("mechanical_hammer", id -> new MechanicalHammerBlock(props(id, of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().strength(5f, 1200f)))); // Misc - public static final DeferredBlock UNFIRED_PORCELAIN_CRUCIBLE = BLOCKS.register("unfired_porcelain_crucible", () -> new UnfiredCrucibleBlock(of().strength(2.0f))); - public static final DeferredBlock INFESTED_LEAVES = BLOCKS.register("infested_leaves", () -> new InfestedLeavesBlock(ofFullCopy(Blocks.OAK_LEAVES))); - public static final DeferredBlock WITCH_WATER = BLOCKS.register("witch_water", () -> new WitchWaterBlock(EFluids.WITCH_WATER, ofFullCopy(Blocks.WATER).mapColor(MapColor.COLOR_PURPLE))); - public static final DeferredBlock END_CAKE = BLOCKS.register("end_cake", () -> new EndCakeBlock(of().noLootTable().mapColor(MapColor.COLOR_BLACK).forceSolidOn().strength(0.5F).sound(SoundType.WOOL).pushReaction(PushReaction.BLOCK))); + public static final DeferredBlock UNFIRED_PORCELAIN_CRUCIBLE = BLOCKS.register("unfired_porcelain_crucible", id -> new UnfiredCrucibleBlock(props(id, of().strength(2.0f)))); + public static final DeferredBlock INFESTED_LEAVES = BLOCKS.register("infested_leaves", id -> new InfestedLeavesBlock(props(id, ofFullCopy(Blocks.OAK_LEAVES)))); + public static final DeferredBlock WITCH_WATER = BLOCKS.register("witch_water", id -> new WitchWaterBlock(EFluids.WITCH_WATER, props(id, ofFullCopy(Blocks.WATER).mapColor(MapColor.COLOR_PURPLE)))); + public static final DeferredBlock END_CAKE = BLOCKS.register("end_cake", id -> new EndCakeBlock(props(id, of().noLootTable().mapColor(MapColor.COLOR_BLACK).forceSolidOn().strength(0.5F).sound(SoundType.WOOL).pushReaction(PushReaction.BLOCK)))); + + private static BlockBehaviour.Properties props(Identifier id, BlockBehaviour.Properties properties) { + return properties.setId(ResourceKey.create(Registries.BLOCK, id)); + } } diff --git a/src/main/java/thedarkcolour/exdeorum/registry/EItems.java b/src/main/java/thedarkcolour/exdeorum/registry/EItems.java index 4b7d9f5d..7054db9d 100644 --- a/src/main/java/thedarkcolour/exdeorum/registry/EItems.java +++ b/src/main/java/thedarkcolour/exdeorum/registry/EItems.java @@ -19,6 +19,9 @@ package thedarkcolour.exdeorum.registry; import com.google.common.collect.Iterables; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.Identifier; +import net.minecraft.resources.ResourceKey; import net.minecraft.world.food.FoodProperties; import net.minecraft.world.item.*; import net.minecraft.world.level.block.Block; @@ -39,44 +42,44 @@ public class EItems { public static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(ExDeorum.ID); // Silk Worm - public static final DeferredItem SILKWORM = ITEMS.register("silkworm", () -> new SilkwormItem(props())); - public static final DeferredItem COOKED_SILKWORM = ITEMS.register("cooked_silkworm", () -> new CookedSilkwormItem(props().food(new FoodProperties.Builder().nutrition(2).saturationModifier(0.6f).build()))); + public static final DeferredItem SILKWORM = register("silkworm", SilkwormItem::new); + public static final DeferredItem COOKED_SILKWORM = register("cooked_silkworm", properties -> new CookedSilkwormItem(properties.food(new FoodProperties.Builder().nutrition(2).saturationModifier(0.6f).build()))); // Crooks - public static final DeferredItem CROOK = ITEMS.register("crook", () -> new CrookItem(props().durability(128), 2.0f)); - public static final DeferredItem BONE_CROOK = ITEMS.register("bone_crook", () -> new CrookItem(props().durability(312), 4.0f)); + public static final DeferredItem CROOK = register("crook", properties -> new CrookItem(properties.durability(128), 2.0f)); + public static final DeferredItem BONE_CROOK = register("bone_crook", properties -> new CrookItem(properties.durability(312), 4.0f)); // Watering cans - public static final DeferredItem WOODEN_WATERING_CAN = ITEMS.register("wooden_watering_can", () -> new WateringCanItem(300, props().stacksTo(1))); - public static final DeferredItem STONE_WATERING_CAN = ITEMS.register("stone_watering_can", () -> new WateringCanItem(1000, props().stacksTo(1))); - public static final DeferredItem IRON_WATERING_CAN = ITEMS.register("iron_watering_can", () -> new WateringCanItem(2000, props().stacksTo(1))); - public static final DeferredItem GOLDEN_WATERING_CAN = ITEMS.register("golden_watering_can", () -> new WateringCanItem(4000, props().stacksTo(1))); - public static final DeferredItem DIAMOND_WATERING_CAN = ITEMS.register("diamond_watering_can", () -> new WideWateringCanItem(false, props().stacksTo(1))); - public static final DeferredItem NETHERITE_WATERING_CAN = ITEMS.register("netherite_watering_can", () -> new WideWateringCanItem(true, props().stacksTo(1))); + public static final DeferredItem WOODEN_WATERING_CAN = register("wooden_watering_can", properties -> new WateringCanItem(300, properties.stacksTo(1))); + public static final DeferredItem STONE_WATERING_CAN = register("stone_watering_can", properties -> new WateringCanItem(1000, properties.stacksTo(1))); + public static final DeferredItem IRON_WATERING_CAN = register("iron_watering_can", properties -> new WateringCanItem(2000, properties.stacksTo(1))); + public static final DeferredItem GOLDEN_WATERING_CAN = register("golden_watering_can", properties -> new WateringCanItem(4000, properties.stacksTo(1))); + public static final DeferredItem DIAMOND_WATERING_CAN = register("diamond_watering_can", properties -> new WideWateringCanItem(false, properties.stacksTo(1))); + public static final DeferredItem NETHERITE_WATERING_CAN = register("netherite_watering_can", properties -> new WideWateringCanItem(true, properties.stacksTo(1))); // Sieve Meshes - public static final DeferredItem STRING_MESH = ITEMS.register("string_mesh", () -> new MeshItem(props().stacksTo(16))); - public static final DeferredItem FLINT_MESH = ITEMS.register("flint_mesh", () -> new MeshItem(props().stacksTo(16))); - public static final DeferredItem IRON_MESH = ITEMS.register("iron_mesh", () -> new MeshItem(props().stacksTo(16))); - public static final DeferredItem GOLDEN_MESH = ITEMS.register("golden_mesh", () -> new MeshItem(props().stacksTo(16))); - public static final DeferredItem DIAMOND_MESH = ITEMS.register("diamond_mesh", () -> new MeshItem(props().stacksTo(16))); - public static final DeferredItem NETHERITE_MESH = ITEMS.register("netherite_mesh", () -> new MeshItem(props().stacksTo(16))); + public static final DeferredItem STRING_MESH = register("string_mesh", properties -> new MeshItem(properties.stacksTo(16))); + public static final DeferredItem FLINT_MESH = register("flint_mesh", properties -> new MeshItem(properties.stacksTo(16))); + public static final DeferredItem IRON_MESH = register("iron_mesh", properties -> new MeshItem(properties.stacksTo(16))); + public static final DeferredItem GOLDEN_MESH = register("golden_mesh", properties -> new MeshItem(properties.stacksTo(16))); + public static final DeferredItem DIAMOND_MESH = register("diamond_mesh", properties -> new MeshItem(properties.stacksTo(16))); + public static final DeferredItem NETHERITE_MESH = register("netherite_mesh", properties -> new MeshItem(properties.stacksTo(16))); // Hammers - public static final DeferredItem WOODEN_HAMMER = ITEMS.register("wooden_hammer", () -> new HammerItem(ToolMaterial.WOOD, props())); - public static final DeferredItem STONE_HAMMER = ITEMS.register("stone_hammer", () -> new HammerItem(ToolMaterial.STONE, props())); - public static final DeferredItem GOLDEN_HAMMER = ITEMS.register("golden_hammer", () -> new HammerItem(ToolMaterial.GOLD, props())); - public static final DeferredItem IRON_HAMMER = ITEMS.register("iron_hammer", () -> new HammerItem(ToolMaterial.IRON, props())); - public static final DeferredItem DIAMOND_HAMMER = ITEMS.register("diamond_hammer", () -> new HammerItem(ToolMaterial.DIAMOND, props())); - public static final DeferredItem NETHERITE_HAMMER = ITEMS.register("netherite_hammer", () -> new HammerItem(ToolMaterial.NETHERITE, props())); + public static final DeferredItem WOODEN_HAMMER = register("wooden_hammer", properties -> new HammerItem(ToolMaterial.WOOD, properties)); + public static final DeferredItem STONE_HAMMER = register("stone_hammer", properties -> new HammerItem(ToolMaterial.STONE, properties)); + public static final DeferredItem GOLDEN_HAMMER = register("golden_hammer", properties -> new HammerItem(ToolMaterial.GOLD, properties)); + public static final DeferredItem IRON_HAMMER = register("iron_hammer", properties -> new HammerItem(ToolMaterial.IRON, properties)); + public static final DeferredItem DIAMOND_HAMMER = register("diamond_hammer", properties -> new HammerItem(ToolMaterial.DIAMOND, properties)); + public static final DeferredItem NETHERITE_HAMMER = register("netherite_hammer", properties -> new HammerItem(ToolMaterial.NETHERITE, properties)); // Compressed Hammers - public static final DeferredItem COMPRESSED_WOODEN_HAMMER = ITEMS.register("compressed_wooden_hammer", () -> new HammerItem(ToolMaterial.WOOD, props())); - public static final DeferredItem COMPRESSED_STONE_HAMMER = ITEMS.register("compressed_stone_hammer", () -> new HammerItem(ToolMaterial.STONE, props())); - public static final DeferredItem COMPRESSED_GOLDEN_HAMMER = ITEMS.register("compressed_golden_hammer", () -> new HammerItem(ToolMaterial.GOLD, props())); - public static final DeferredItem COMPRESSED_IRON_HAMMER = ITEMS.register("compressed_iron_hammer", () -> new HammerItem(ToolMaterial.IRON, props())); - public static final DeferredItem COMPRESSED_DIAMOND_HAMMER = ITEMS.register("compressed_diamond_hammer", () -> new HammerItem(ToolMaterial.DIAMOND, props())); - public static final DeferredItem COMPRESSED_NETHERITE_HAMMER = ITEMS.register("compressed_netherite_hammer", () -> new HammerItem(ToolMaterial.NETHERITE, props())); + public static final DeferredItem COMPRESSED_WOODEN_HAMMER = register("compressed_wooden_hammer", properties -> new HammerItem(ToolMaterial.WOOD, properties)); + public static final DeferredItem COMPRESSED_STONE_HAMMER = register("compressed_stone_hammer", properties -> new HammerItem(ToolMaterial.STONE, properties)); + public static final DeferredItem COMPRESSED_GOLDEN_HAMMER = register("compressed_golden_hammer", properties -> new HammerItem(ToolMaterial.GOLD, properties)); + public static final DeferredItem COMPRESSED_IRON_HAMMER = register("compressed_iron_hammer", properties -> new HammerItem(ToolMaterial.IRON, properties)); + public static final DeferredItem COMPRESSED_DIAMOND_HAMMER = register("compressed_diamond_hammer", properties -> new HammerItem(ToolMaterial.DIAMOND, properties)); + public static final DeferredItem COMPRESSED_NETHERITE_HAMMER = register("compressed_netherite_hammer", properties -> new HammerItem(ToolMaterial.NETHERITE, properties)); // Ore Chunks public static final DeferredItem IRON_ORE_CHUNK = registerSimpleItem("iron_ore_chunk"); @@ -112,38 +115,42 @@ public class EItems { // Misc public static final DeferredItem PORCELAIN_CLAY_BALL = registerSimpleItem("porcelain_clay_ball"); - public static final DeferredItem GRASS_SEEDS = ITEMS.register("grass_seeds", () -> new GrassSpreaderItem(props(), Blocks.GRASS_BLOCK::defaultBlockState)); - public static final DeferredItem MYCELIUM_SPORES = ITEMS.register("mycelium_spores", () -> new GrassSpreaderItem(props(), Blocks.MYCELIUM::defaultBlockState)); - public static final DeferredItem WARPED_NYLIUM_SPORES = ITEMS.register("warped_nylium_spores", () -> new NyliumSpreaderItem(props(), Blocks.WARPED_NYLIUM::defaultBlockState)); - public static final DeferredItem CRIMSON_NYLIUM_SPORES = ITEMS.register("crimson_nylium_spores", () -> new NyliumSpreaderItem(props(), Blocks.CRIMSON_NYLIUM::defaultBlockState)); - public static final DeferredItem SCULK_CORE = ITEMS.register("sculk_core", () -> new SculkCoreItem(props().stacksTo(1))); - public static final DeferredItem RANDOM_POTTERY_SHERD = ITEMS.register("random_pottery_sherd", () -> new RandomResultItem(props(), EItemTags.RANDOM_SHERD_DROPS)); - public static final DeferredItem RANDOM_ARMOR_TRIM = ITEMS.register("random_armor_trim", () -> new RandomResultItem(props(), EItemTags.RANDOM_TRIM_DROPS)); + public static final DeferredItem GRASS_SEEDS = register("grass_seeds", properties -> new GrassSpreaderItem(properties, Blocks.GRASS_BLOCK::defaultBlockState)); + public static final DeferredItem MYCELIUM_SPORES = register("mycelium_spores", properties -> new GrassSpreaderItem(properties, Blocks.MYCELIUM::defaultBlockState)); + public static final DeferredItem WARPED_NYLIUM_SPORES = register("warped_nylium_spores", properties -> new NyliumSpreaderItem(properties, Blocks.WARPED_NYLIUM::defaultBlockState)); + public static final DeferredItem CRIMSON_NYLIUM_SPORES = register("crimson_nylium_spores", properties -> new NyliumSpreaderItem(properties, Blocks.CRIMSON_NYLIUM::defaultBlockState)); + public static final DeferredItem SCULK_CORE = register("sculk_core", properties -> new SculkCoreItem(properties.stacksTo(1))); + public static final DeferredItem RANDOM_POTTERY_SHERD = register("random_pottery_sherd", properties -> new RandomResultItem(properties, EItemTags.RANDOM_SHERD_DROPS)); + public static final DeferredItem RANDOM_ARMOR_TRIM = register("random_armor_trim", properties -> new RandomResultItem(properties, EItemTags.RANDOM_TRIM_DROPS)); public static final DeferredItem WOOD_CHIPPINGS = registerSimpleItem("wood_chippings"); // Buckets public static final DeferredItem UNFIRED_PORCELAIN_BUCKET = registerSimpleItem("unfired_porcelain_bucket"); - public static final DeferredItem PORCELAIN_BUCKET = ITEMS.register("porcelain_bucket", () -> new PorcelainBucket(() -> Fluids.EMPTY, props().stacksTo(16))); - public static final DeferredItem PORCELAIN_WATER_BUCKET = ITEMS.register("porcelain_water_bucket", () -> new PorcelainBucket(() -> Fluids.WATER, props().craftRemainder(PORCELAIN_BUCKET.get()).stacksTo(1))); - public static final DeferredItem PORCELAIN_LAVA_BUCKET = ITEMS.register("porcelain_lava_bucket", () -> new PorcelainBucket(() -> Fluids.LAVA, props().stacksTo(1))); - public static final DeferredItem PORCELAIN_MILK_BUCKET = ITEMS.register("porcelain_milk_bucket", () -> new PorcelainMilkBucket(props().craftRemainder(PORCELAIN_BUCKET.get()).stacksTo(1))); - public static final DeferredItem PORCELAIN_WITCH_WATER_BUCKET = ITEMS.register("porcelain_witch_water_bucket", () -> new PorcelainBucket(EFluids.WITCH_WATER, props().craftRemainder(PORCELAIN_BUCKET.get()).stacksTo(1))); + public static final DeferredItem PORCELAIN_BUCKET = register("porcelain_bucket", properties -> new PorcelainBucket(() -> Fluids.EMPTY, properties.stacksTo(16))); + public static final DeferredItem PORCELAIN_WATER_BUCKET = register("porcelain_water_bucket", properties -> new PorcelainBucket(() -> Fluids.WATER, properties.craftRemainder(PORCELAIN_BUCKET.get()).stacksTo(1))); + public static final DeferredItem PORCELAIN_LAVA_BUCKET = register("porcelain_lava_bucket", properties -> new PorcelainBucket(() -> Fluids.LAVA, properties.stacksTo(1))); + public static final DeferredItem PORCELAIN_MILK_BUCKET = register("porcelain_milk_bucket", properties -> new PorcelainMilkBucket(properties.craftRemainder(PORCELAIN_BUCKET.get()).stacksTo(1))); + public static final DeferredItem PORCELAIN_WITCH_WATER_BUCKET = register("porcelain_witch_water_bucket", properties -> new PorcelainBucket(EFluids.WITCH_WATER, properties.craftRemainder(PORCELAIN_BUCKET.get()).stacksTo(1))); // Fluids - public static final DeferredItem WITCH_WATER_BUCKET = ITEMS.register("witch_water_bucket", () -> new BucketItem(EFluids.WITCH_WATER.get(), props().craftRemainder(Items.BUCKET).stacksTo(1))); + public static final DeferredItem WITCH_WATER_BUCKET = register("witch_water_bucket", properties -> new BucketItem(EFluids.WITCH_WATER.get(), properties.craftRemainder(Items.BUCKET).stacksTo(1))); public static DeferredItem registerSimpleItem(String name) { - return ITEMS.register(name, () -> new Item(props())); + return register(name, Item::new); } // Returns new properties with creative tab set - public static Item.Properties props() { - return new Item.Properties(); + public static Item.Properties props(Identifier id) { + return new Item.Properties().setId(ResourceKey.create(Registries.ITEM, id)); + } + + public static DeferredItem register(String name, java.util.function.Function factory) { + return ITEMS.register(name, id -> factory.apply(props(id))); } // Register a block item public static DeferredItem registerItemBlock(DeferredBlock block) { - return ITEMS.register(block.getId().getPath(), () -> new BlockItem(block.get(), props())); + return ITEMS.register(block.getId().getPath(), id -> new BlockItem(block.get(), props(id))); } // BlockItems