diff --git a/changelog.md b/changelog.md index de905f2b..5310f051 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,6 @@ ## Ex Deorum 4.0 - Added Pale Oak Crucible, Sieve, Compressed Sieve, and Barrel +- Added Creaking Core to turn Pale Oak Log into Creaking Heart ## Ex Deorum 3.10 - Now requires KubeJS 7.2 to fix incompatibility (#158) diff --git a/src/generated/resources/.cache/93943142017732f21fbc4fa325d116c728b69767 b/src/generated/resources/.cache/93943142017732f21fbc4fa325d116c728b69767 index 34f0498c..55e3a33f 100644 --- a/src/generated/resources/.cache/93943142017732f21fbc4fa325d116c728b69767 +++ b/src/generated/resources/.cache/93943142017732f21fbc4fa325d116c728b69767 @@ -1,2 +1,2 @@ -// 26.1.1 2026-05-14T19:37:53.699684597 ModKit Language: en_us for mod 'exdeorum' -7710223f1e3d7313116cdec689ac157a248fe3af assets/exdeorum/lang/en_us.json +// 26.1.1 2026-05-15T11:59:32.026904984 ModKit Language: en_us for mod 'exdeorum' +994c3e75819f30f5398e9ddf6b3ace1e04caccfc assets/exdeorum/lang/en_us.json diff --git a/src/generated/resources/.cache/dd659b25f3b63c39e7c4bd9f09cb7a21361864b4 b/src/generated/resources/.cache/dd659b25f3b63c39e7c4bd9f09cb7a21361864b4 index f2f6656d..0a09a337 100644 --- a/src/generated/resources/.cache/dd659b25f3b63c39e7c4bd9f09cb7a21361864b4 +++ b/src/generated/resources/.cache/dd659b25f3b63c39e7c4bd9f09cb7a21361864b4 @@ -1,4 +1,4 @@ -// 26.1.1 2026-05-14T21:40:52.187136309 ModKit Recipes for mod 'exdeorum' +// 26.1.1 2026-05-15T11:59:32.033519479 ModKit Recipes for mod 'exdeorum' 0060d0e16dba2df44cc115f8ed68ef5dc52c74f1 data/exdeorum/advancement/recipes/building_blocks/andesite.json b9c5d12771d724cd646e637641da7a4d6b0a6bbf data/exdeorum/advancement/recipes/building_blocks/basalt.json d87a237248c140367dbfb748d45f532534e5b45c data/exdeorum/advancement/recipes/building_blocks/blackstone.json @@ -65,6 +65,7 @@ fbc3177ba6245faa8910f589be2bbe089985950a data/exdeorum/advancement/recipes/misc/ 936078196fa7564a0c9aa131061d2679745068c3 data/exdeorum/advancement/recipes/misc/cooked_silkworm.json f0984681c912fcad8769e5dcffacb60befc0687b data/exdeorum/advancement/recipes/misc/cooked_silkworm_from_campfire_cooking.json 1f94ea7eba0d7f40a7de0317035a9345f18dc72b data/exdeorum/advancement/recipes/misc/cooked_silkworm_from_smoking.json +3f69e677b6224c2e166cf2e483b09283d81d27be data/exdeorum/advancement/recipes/misc/creaking_core.json 4a374da9a6c7356bcd48fe4cd982444b65f1a935 data/exdeorum/advancement/recipes/misc/crimson_barrel.json 7b80139f137891960bc0a35edb205ccfd58989de data/exdeorum/advancement/recipes/misc/crimson_compressed_sieve.json 2f9e0122d86df790a363819123dc4b1c64a2ded4 data/exdeorum/advancement/recipes/misc/crimson_crucible.json diff --git a/src/generated/resources/.cache/fc2b6ffd874afaa6f2f20b450921dbfbbc8b86bd b/src/generated/resources/.cache/fc2b6ffd874afaa6f2f20b450921dbfbbc8b86bd index 7b63a963..ba98e1cb 100644 --- a/src/generated/resources/.cache/fc2b6ffd874afaa6f2f20b450921dbfbbc8b86bd +++ b/src/generated/resources/.cache/fc2b6ffd874afaa6f2f20b450921dbfbbc8b86bd @@ -1,4 +1,4 @@ -// 26.1.1 2026-05-14T19:37:53.700441026 ModKit Item Models for mod 'exdeorum' +// 26.1.1 2026-05-15T11:59:32.028019255 ModKit Item Models for mod 'exdeorum' 8cfb1fdb327d53288205eb62b8b7857eafa2a091 assets/exdeorum/items/acacia_barrel.json 8c5b35194de98a2325ed84334623e72596e50b0f assets/exdeorum/items/acacia_compressed_sieve.json 930e698609436fdf71a3ab0b738f7566adfe15c7 assets/exdeorum/items/acacia_crucible.json @@ -63,6 +63,7 @@ e6d96fa05cd3c8ebaa5f2e0d3e67ba04f203b741 assets/exdeorum/items/compressed_stone_ f1cd9e3ce836021d8e435bc206fc8e62c242a615 assets/exdeorum/items/compressed_wooden_hammer.json 52de2263e21e688edae120e80bac0f15a95397c9 assets/exdeorum/items/cooked_silkworm.json 1d5add85d17aa829a184d469690e654f9fdbf5ef assets/exdeorum/items/copper_ore_chunk.json +e109bde87167aec1b6cf7d5d6c1ca50824f974c2 assets/exdeorum/items/creaking_core.json 535f3bf29763fe534df092396589e75f41ff25bd assets/exdeorum/items/crimson_barrel.json 2ea9c91eacc0413d3ba0794bef229f502d076eb0 assets/exdeorum/items/crimson_compressed_sieve.json 4572720da57b1f2571dbc0ecae12e1a013dcb810 assets/exdeorum/items/crimson_crucible.json @@ -302,6 +303,7 @@ fa43f2736b5d430be09a4040699d50f4716422d0 assets/exdeorum/models/item/compressed_ 8ee0cde55fd9244eff5b9ed65e8027ba89362c03 assets/exdeorum/models/item/compressed_wooden_hammer.json 2738250c8aaede17c32c2df28612bfd70145a158 assets/exdeorum/models/item/cooked_silkworm.json f611abadb3d337ab6a40255116e974e6f5b6edf2 assets/exdeorum/models/item/copper_ore_chunk.json +9303141f016767327bc7e8de59fa58bc26529a05 assets/exdeorum/models/item/creaking_core.json d6109df4904776aca591e7dfc8ee8da50664e1df assets/exdeorum/models/item/crimson_barrel.json b240f3070b3c93e54ddbf02bf2c3f6876a28a4bc assets/exdeorum/models/item/crimson_compressed_sieve.json de4c8c3d97810a3da75d7c0e27622af66c12fb61 assets/exdeorum/models/item/crimson_crucible.json diff --git a/src/generated/resources/assets/exdeorum/items/creaking_core.json b/src/generated/resources/assets/exdeorum/items/creaking_core.json new file mode 100644 index 00000000..f9b81e94 --- /dev/null +++ b/src/generated/resources/assets/exdeorum/items/creaking_core.json @@ -0,0 +1,6 @@ +{ + "model": { + "type": "minecraft:model", + "model": "exdeorum:item/creaking_core" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/exdeorum/lang/en_us.json b/src/generated/resources/assets/exdeorum/lang/en_us.json index b43079ad..5e77138d 100644 --- a/src/generated/resources/assets/exdeorum/lang/en_us.json +++ b/src/generated/resources/assets/exdeorum/lang/en_us.json @@ -224,6 +224,7 @@ "gui.exdeorum.redstone_control.mode": "Mode: ", "gui.exdeorum.redstone_control.powered": "Powered", "gui.exdeorum.redstone_control.unpowered": "Unpowered", + "info.exdeorum.creaking_core": "Use a creaking core on a Pale Oak Log to turn it into a Creaking Heart. Creaking Hearts created this way do not drop experience orbs when broken.", "info.exdeorum.crimson_nylium_spores": "Use on netherrack to turn it into a crimson nylium block.", "info.exdeorum.grass_seeds": "Use on dirt to turn it into a grass block.", "info.exdeorum.mechanical_hammer": "The Mechanical Hammer is a machine that, when supplied with Forge Energy (FE), will hammer blocks without a player having to do it themselves. It can operate without a hammer, but adding any hammer will double the speed, and efficiency enchantments on the hammer will further increase speed. It also supports three different modes of redstone control. Since Ex Deorum does not provide a way to generate FE, you will need another mod to provide power.", @@ -300,6 +301,7 @@ "item.exdeorum.compressed_wooden_hammer": "Compressed Wooden Hammer", "item.exdeorum.cooked_silkworm": "Cooked Silkworm", "item.exdeorum.copper_ore_chunk": "Copper Ore Chunk", + "item.exdeorum.creaking_core": "Creaking Core", "item.exdeorum.crimson_barrel": "Crimson Barrel", "item.exdeorum.crimson_compressed_sieve": "Crimson Compressed Sieve", "item.exdeorum.crimson_crucible": "Crimson Crucible", diff --git a/src/generated/resources/assets/exdeorum/models/item/creaking_core.json b/src/generated/resources/assets/exdeorum/models/item/creaking_core.json new file mode 100644 index 00000000..9936399e --- /dev/null +++ b/src/generated/resources/assets/exdeorum/models/item/creaking_core.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "exdeorum:item/creaking_core" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/exdeorum/advancement/recipes/misc/creaking_core.json b/src/generated/resources/data/exdeorum/advancement/recipes/misc/creaking_core.json new file mode 100644 index 00000000..df6d6b8a --- /dev/null +++ b/src/generated/resources/data/exdeorum/advancement/recipes/misc/creaking_core.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_item": { + "conditions": { + "items": [ + { + "items": "minecraft:resin_clump" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "exdeorum:creaking_core" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_item" + ] + ], + "rewards": { + "recipes": [ + "exdeorum:creaking_core" + ] + } +} \ No newline at end of file diff --git a/src/generated/resources/data/exdeorum/recipe/creaking_core.json b/src/generated/resources/data/exdeorum/recipe/creaking_core.json new file mode 100644 index 00000000..58b450bd --- /dev/null +++ b/src/generated/resources/data/exdeorum/recipe/creaking_core.json @@ -0,0 +1,16 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "key": { + "#": "minecraft:resin_clump", + "O": "minecraft:ender_pearl" + }, + "pattern": [ + " # ", + "#O#", + " # " + ], + "result": { + "id": "exdeorum:creaking_core" + } +} \ No newline at end of file diff --git a/src/main/java/thedarkcolour/exdeorum/compat/jei/ExDeorumJeiPlugin.java b/src/main/java/thedarkcolour/exdeorum/compat/jei/ExDeorumJeiPlugin.java index b4b68d27..a5e0540c 100644 --- a/src/main/java/thedarkcolour/exdeorum/compat/jei/ExDeorumJeiPlugin.java +++ b/src/main/java/thedarkcolour/exdeorum/compat/jei/ExDeorumJeiPlugin.java @@ -179,6 +179,7 @@ public class ExDeorumJeiPlugin implements IModPlugin { registration.addItemStackInfo(new ItemStack(EItems.WARPED_NYLIUM_SPORES.get()), Component.translatable(TranslationKeys.WARPED_NYLIUM_SPORES_JEI_INFO)); registration.addItemStackInfo(new ItemStack(EItems.CRIMSON_NYLIUM_SPORES.get()), Component.translatable(TranslationKeys.CRIMSON_NYLIUM_SPORES_JEI_INFO)); registration.addItemStackInfo(new ItemStack(EItems.SCULK_CORE.get()), Component.translatable(TranslationKeys.SCULK_CORE_JEI_INFO)); + registration.addItemStackInfo(new ItemStack(EItems.CREAKING_CORE.get()), Component.translatable(TranslationKeys.CREAKING_CORE_JEI_INFO)); registration.addItemStackInfo(new ItemStack(EItems.MECHANICAL_SIEVE.get()), Component.translatable(TranslationKeys.MECHANICAL_SIEVE_JEI_INFO)); registration.addItemStackInfo(new ItemStack(EItems.MECHANICAL_HAMMER.get()), Component.translatable(TranslationKeys.MECHANICAL_HAMMER_JEI_INFO)); diff --git a/src/main/java/thedarkcolour/exdeorum/data/English.java b/src/main/java/thedarkcolour/exdeorum/data/English.java index 44652e1f..2923a3b2 100644 --- a/src/main/java/thedarkcolour/exdeorum/data/English.java +++ b/src/main/java/thedarkcolour/exdeorum/data/English.java @@ -84,6 +84,7 @@ class English { english.add(TranslationKeys.WARPED_NYLIUM_SPORES_JEI_INFO, "Use on netherrack to turn it into a warped nylium block."); english.add(TranslationKeys.CRIMSON_NYLIUM_SPORES_JEI_INFO, "Use on netherrack to turn it into a crimson nylium block."); english.add(TranslationKeys.SCULK_CORE_JEI_INFO, "Use a sculk core on a Sculk Shrieker to enable it to spawn Wardens. Normally, Sculk Shriekers placed by players cannot spawn Wardens, so this item is useful for obtaining Sculk items in a SkyBlock world."); + english.add(TranslationKeys.CREAKING_CORE_JEI_INFO, "Use a creaking core on a Pale Oak Log to turn it into a Creaking Heart. Creaking Hearts created this way do not drop experience orbs when broken."); english.add(TranslationKeys.MECHANICAL_SIEVE_JEI_INFO, "The Mechanical Sieve is a machine that, when supplied with a mesh and Forge Energy (FE), will sift blocks without a player having to do it themselves. It also supports three different modes of redstone control. Since Ex Deorum does not provide a way to generate FE, you will need another mod to provide power."); english.add(TranslationKeys.MECHANICAL_HAMMER_JEI_INFO, "The Mechanical Hammer is a machine that, when supplied with Forge Energy (FE), will hammer blocks without a player having to do it themselves. It can operate without a hammer, but adding any hammer will double the speed, and efficiency enchantments on the hammer will further increase speed. It also supports three different modes of redstone control. Since Ex Deorum does not provide a way to generate FE, you will need another mod to provide power."); diff --git a/src/main/java/thedarkcolour/exdeorum/data/TranslationKeys.java b/src/main/java/thedarkcolour/exdeorum/data/TranslationKeys.java index c9148db3..3a9c92d5 100644 --- a/src/main/java/thedarkcolour/exdeorum/data/TranslationKeys.java +++ b/src/main/java/thedarkcolour/exdeorum/data/TranslationKeys.java @@ -60,6 +60,7 @@ public class TranslationKeys { public static final String WARPED_NYLIUM_SPORES_JEI_INFO = "info." + ExDeorum.ID + ".warped_nylium_spores"; public static final String CRIMSON_NYLIUM_SPORES_JEI_INFO = "info." + ExDeorum.ID + ".crimson_nylium_spores"; public static final String SCULK_CORE_JEI_INFO = "info." + ExDeorum.ID + ".sculk_core"; + public static final String CREAKING_CORE_JEI_INFO = "info." + ExDeorum.ID + ".creaking_core"; public static final String MECHANICAL_SIEVE_JEI_INFO = "info." + ExDeorum.ID + ".mechanical_sieve"; public static final String MECHANICAL_HAMMER_JEI_INFO = "info." + ExDeorum.ID + ".mechanical_hammer"; diff --git a/src/main/java/thedarkcolour/exdeorum/data/recipe/Recipes.java b/src/main/java/thedarkcolour/exdeorum/data/recipe/Recipes.java index 4aa67770..b14fc298 100644 --- a/src/main/java/thedarkcolour/exdeorum/data/recipe/Recipes.java +++ b/src/main/java/thedarkcolour/exdeorum/data/recipe/Recipes.java @@ -365,6 +365,13 @@ public class Recipes { recipe.pattern("#O#"); recipe.pattern(" # "); }); + recipes.shapedCrafting(RecipeCategory.MISC, EItems.CREAKING_CORE.get(), recipe -> { + recipe.define('#', Items.RESIN_CLUMP); + recipe.define('O', Items.ENDER_PEARL); + recipe.pattern(" # "); + recipe.pattern("#O#"); + recipe.pattern(" # "); + }); recipes.shapedCrafting(RecipeCategory.FOOD, EItems.END_CAKE.get(), recipe -> { recipe.define('P', Items.ENDER_EYE); recipe.define('S', Items.SUGAR); diff --git a/src/main/java/thedarkcolour/exdeorum/item/BlockTransformingItem.java b/src/main/java/thedarkcolour/exdeorum/item/BlockTransformingItem.java new file mode 100644 index 00000000..30f83886 --- /dev/null +++ b/src/main/java/thedarkcolour/exdeorum/item/BlockTransformingItem.java @@ -0,0 +1,38 @@ +package thedarkcolour.exdeorum.item; + +import net.minecraft.core.BlockPos; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; + +// reused logic between Silkworm, Sculk Core, and Creaking Core, which transform blocks they're used on +public abstract class BlockTransformingItem extends Item { + public BlockTransformingItem(Properties properties) { + super(properties); + } + + @Override + public InteractionResult useOn(UseOnContext context) { + var level = context.getLevel(); + var pos = context.getClickedPos(); + var state = level.getBlockState(pos); + + if (canTransformState(state)) { + doTransformState(level, pos, state); + + if (!level.isClientSide()) { + context.getItemInHand().shrink(1); + } + + return level.isClientSide() ? InteractionResult.SUCCESS : InteractionResult.SUCCESS_SERVER; + } + + return InteractionResult.PASS; + } + + protected abstract boolean canTransformState(BlockState state); + + protected abstract void doTransformState(Level level, BlockPos pos, BlockState state); +} diff --git a/src/main/java/thedarkcolour/exdeorum/item/CreakingCoreItem.java b/src/main/java/thedarkcolour/exdeorum/item/CreakingCoreItem.java new file mode 100644 index 00000000..2b22e468 --- /dev/null +++ b/src/main/java/thedarkcolour/exdeorum/item/CreakingCoreItem.java @@ -0,0 +1,32 @@ +package thedarkcolour.exdeorum.item; + +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.CreakingHeartBlock; +import net.minecraft.world.level.block.LevelEvent; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; + +public class CreakingCoreItem extends BlockTransformingItem { + public CreakingCoreItem(Properties properties) { + super(properties); + } + + @Override + protected boolean canTransformState(BlockState state) { + return state.is(Blocks.PALE_OAK_LOG); + } + + @Override + protected void doTransformState(Level level, BlockPos pos, BlockState state) { + if (level.isClientSide()) return; + + var newState = Blocks.CREAKING_HEART.defaultBlockState() + .setValue(CreakingHeartBlock.AXIS, state.getValue(BlockStateProperties.AXIS)) + .setValue(CreakingHeartBlock.NATURAL, false); + level.setBlock(pos, newState, 3); + level.levelEvent(LevelEvent.PARTICLES_DESTROY_BLOCK, pos, Block.getId(Blocks.CREAKING_HEART.defaultBlockState())); + } +} diff --git a/src/main/java/thedarkcolour/exdeorum/item/SculkCoreItem.java b/src/main/java/thedarkcolour/exdeorum/item/SculkCoreItem.java index 35d0a571..3a9fe307 100644 --- a/src/main/java/thedarkcolour/exdeorum/item/SculkCoreItem.java +++ b/src/main/java/thedarkcolour/exdeorum/item/SculkCoreItem.java @@ -18,52 +18,41 @@ package thedarkcolour.exdeorum.item; +import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.sounds.SoundSource; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.SculkShriekerBlock; +import net.minecraft.world.level.block.state.BlockState; import org.joml.Math; import thedarkcolour.exdeorum.registry.ESounds; -public class SculkCoreItem extends Item { +public class SculkCoreItem extends BlockTransformingItem { public SculkCoreItem(Properties properties) { super(properties); } @Override - public InteractionResult useOn(UseOnContext context) { - var level = context.getLevel(); - var pos = context.getClickedPos(); - var state = level.getBlockState(pos); + protected boolean canTransformState(BlockState state) { + return state.getBlock() == Blocks.SCULK_SHRIEKER && !state.getValue(SculkShriekerBlock.CAN_SUMMON); + } - if (state.getBlock() == Blocks.SCULK_SHRIEKER && !state.getValue(SculkShriekerBlock.CAN_SUMMON)) { - var stack = context.getItemInHand(); - var player = context.getPlayer(); - - if (!level.isClientSide()) { - if (!player.getAbilities().instabuild) { - stack.shrink(1); - } - level.setBlock(pos, state.setValue(SculkShriekerBlock.CAN_SUMMON, true), 3); - } else { - var rand = level.getRandom(); - for (int i = 0; i < 10; i++) { - int j = i * 36; - double radians = Math.toRadians(j); - for (int k = 0; k < 3; k++) { - level.addParticle(ParticleTypes.PORTAL, pos.getX() + 0.5 + 0.3 * (-0.5 + rand.nextFloat()), pos.getY() + 0.5625, pos.getZ() + 0.5 + 0.3 * (-0.5 + rand.nextFloat()), - Math.cos(radians) * 0.15, 0.15, Math.sin(radians) * 0.15); - } + @Override + protected void doTransformState(Level level, BlockPos pos, BlockState state) { + if (!level.isClientSide()) { + level.setBlock(pos, state.setValue(SculkShriekerBlock.CAN_SUMMON, true), 3); + } else { + var rand = level.getRandom(); + for (int i = 0; i < 10; i++) { + int j = i * 36; + double radians = Math.toRadians(j); + for (int k = 0; k < 3; k++) { + level.addParticle(ParticleTypes.PORTAL, pos.getX() + 0.5 + 0.3 * (-0.5 + rand.nextFloat()), pos.getY() + 0.5625, pos.getZ() + 0.5 + 0.3 * (-0.5 + rand.nextFloat()), + Math.cos(radians) * 0.15, 0.15, Math.sin(radians) * 0.15); } } - level.playSound(null, pos, ESounds.SCULK_CORE_ACTIVATE.get(), SoundSource.BLOCKS, 1.0f, 1.0f); - - return level.isClientSide() ? InteractionResult.SUCCESS : InteractionResult.SUCCESS_SERVER; } - - return InteractionResult.PASS; + level.playSound(null, pos, ESounds.SCULK_CORE_ACTIVATE.get(), SoundSource.BLOCKS, 1.0f, 1.0f); } } diff --git a/src/main/java/thedarkcolour/exdeorum/item/SilkwormItem.java b/src/main/java/thedarkcolour/exdeorum/item/SilkwormItem.java index bb531e1e..d1d515e3 100644 --- a/src/main/java/thedarkcolour/exdeorum/item/SilkwormItem.java +++ b/src/main/java/thedarkcolour/exdeorum/item/SilkwormItem.java @@ -18,49 +18,41 @@ package thedarkcolour.exdeorum.item; +import net.minecraft.core.BlockPos; import net.minecraft.sounds.SoundSource; import net.minecraft.tags.BlockTags; -import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; import thedarkcolour.exdeorum.block.InfestedLeavesBlock; import thedarkcolour.exdeorum.blockentity.InfestedLeavesBlockEntity; import thedarkcolour.exdeorum.registry.EBlocks; import thedarkcolour.exdeorum.registry.ESounds; -public class SilkwormItem extends Item { - public SilkwormItem(Item.Properties properties) { +public class SilkwormItem extends BlockTransformingItem { + public SilkwormItem(Properties properties) { super(properties); } @Override - public InteractionResult useOn(UseOnContext context) { - var pos = context.getClickedPos(); - var level = context.getLevel(); - var state = level.getBlockState(pos); + protected boolean canTransformState(BlockState state) { + return !state.isAir() && state.is(BlockTags.LEAVES) && state.getBlock() != EBlocks.INFESTED_LEAVES.get(); + } - if (!state.isAir()) { - if (state.is(BlockTags.LEAVES) && state.getBlock() != EBlocks.INFESTED_LEAVES.get()) { - if (!level.isClientSide()) { - // Replace with infested block - InfestedLeavesBlock.setBlock(level, pos, state); + @Override + protected void doTransformState(Level level, BlockPos pos, BlockState state) { + if (!level.isClientSide()) { + // Replace with infested block + InfestedLeavesBlock.setBlock(level, pos, state); - level.playSound(null, pos, ESounds.SILK_WORM_INFEST.get(), SoundSource.BLOCKS); + level.playSound(null, pos, ESounds.SILK_WORM_INFEST.get(), SoundSource.BLOCKS); - // Set mimic - if (level.getBlockEntity(pos) instanceof InfestedLeavesBlockEntity leaves) { - leaves.setMimic(state); - } - context.getItemInHand().shrink(1); - } - - return level.isClientSide() ? InteractionResult.SUCCESS : InteractionResult.SUCCESS_SERVER; + // Set mimic + if (level.getBlockEntity(pos) instanceof InfestedLeavesBlockEntity leaves) { + leaves.setMimic(state); } } - - return InteractionResult.PASS; } @Override diff --git a/src/main/java/thedarkcolour/exdeorum/registry/EItems.java b/src/main/java/thedarkcolour/exdeorum/registry/EItems.java index 7054db9d..50562e8f 100644 --- a/src/main/java/thedarkcolour/exdeorum/registry/EItems.java +++ b/src/main/java/thedarkcolour/exdeorum/registry/EItems.java @@ -120,6 +120,7 @@ public class EItems { 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 CREAKING_CORE = register("creaking_core", CreakingCoreItem::new); 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"); @@ -276,6 +277,7 @@ public class EItems { output.accept(WARPED_NYLIUM_SPORES.get()); output.accept(CRIMSON_NYLIUM_SPORES.get()); output.accept(SCULK_CORE.get()); + output.accept(CREAKING_CORE.get()); output.accept(WOOD_CHIPPINGS.get()); output.accept(PORCELAIN_CLAY_BALL.get()); output.accept(UNFIRED_PORCELAIN_BUCKET.get());