Switch to using a singleton

The reason for this is that the object needs to stay accessible
because adding a block into the world is done by the object
that was used to register it in the game registry, not by the type.
master
BodgeMaster 2022-12-15 12:50:16 +01:00
parent 643cef87a7
commit e52c9b6011
2 changed files with 12 additions and 4 deletions

View File

@ -46,7 +46,9 @@ public class DeathChests {
@EventHandler @EventHandler
public void init(FMLInitializationEvent event) { public void init(FMLInitializationEvent event) {
Debug.out("Received FMLInitializationEvent"); Debug.out("Received FMLInitializationEvent");
GameRegistry.registerBlock(new BlockDeathChest(), "death_chest");
GameRegistry.registerBlock(BlockDeathChest.getInstance(), "death_chest");
// TODO (probably here): Add death event handler // TODO (probably here): Add death event handler
} }

View File

@ -2,9 +2,15 @@ package lostcave.deathchests.block;
import net.minecraft.block.BlockChest; import net.minecraft.block.BlockChest;
public class BlockDeathChest extends BlockChest{ public class BlockDeathChest extends BlockChest {
public BlockDeathChest() { private static final BlockDeathChest instance = new BlockDeathChest();
public static BlockDeathChest getInstance() {
return instance;
}
private BlockDeathChest() {
super(0); super(0);
this.setBlockName("death_chest"); this.setBlockName("death_chest");
} }