[Feature] Tool template for Spawners

This commit is contained in:
Frank 2023-07-22 12:31:19 +02:00
parent f3ca586f8b
commit f5cb606ee5

View file

@ -31,10 +31,7 @@ import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.JigsawBlock; import net.minecraft.world.level.block.JigsawBlock;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.*;
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.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool; 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( public static DebugDataItem forSteetJigSaw(
String modID, String modID,
ResourceKey<StructureTemplatePool> pool, ResourceKey<StructureTemplatePool> pool,