From f5cb606ee5bdcc7b97d6c2a6328f5203601aaf70 Mon Sep 17 00:00:00 2001 From: Frank Date: Sat, 22 Jul 2023 12:31:19 +0200 Subject: [PATCH] [Feature] Tool template for Spawners --- .../betterx/bclib/items/DebugDataItem.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/betterx/bclib/items/DebugDataItem.java b/src/main/java/org/betterx/bclib/items/DebugDataItem.java index bffc654f..a5c13cbf 100644 --- a/src/main/java/org/betterx/bclib/items/DebugDataItem.java +++ b/src/main/java/org/betterx/bclib/items/DebugDataItem.java @@ -31,10 +31,7 @@ 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.JigsawBlock; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.entity.JigsawBlockEntity; -import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity; -import net.minecraft.world.level.block.entity.StructureBlockEntity; +import net.minecraft.world.level.block.entity.*; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool; @@ -241,6 +238,22 @@ public class DebugDataItem extends Item implements ItemModelProvider, AirSelecti ); } + public static DebugDataItem forSpawner(CompoundTag tag, Item icon) { + ResourceLocation iconId = BuiltInRegistries.ITEM.getKey(icon); + return new DebugDataItem( + (player, entity, ctx) -> { + if (entity instanceof SpawnerBlockEntity) { + entity.load(tag); + message(player, "Did set Data to " + tag.toString()); + return InteractionResult.SUCCESS; + } + return InteractionResult.FAIL; + }, + false, + iconId + ); + } + public static DebugDataItem forSteetJigSaw( String modID, ResourceKey pool,