Update Iron Chests to Forge 14.21.0.2359.

This commit is contained in:
alexbegt 2017-06-23 21:13:20 -04:00
parent 69cedbf38b
commit 7900ab35b5
14 changed files with 396 additions and 270 deletions

View File

@ -33,7 +33,7 @@ repositories {
} }
dependencies { dependencies {
deobfCompile "mezz.jei:jei_1.12:4.6.0.+" deobfCompile "mezz.jei:jei_1.12:4.7.0.+"
} }
// This is our group. I'm cpw.mods // This is our group. I'm cpw.mods
@ -46,8 +46,8 @@ targetCompatibility = 1.8
// Setup the forge minecraft plugin data. Specify the preferred forge/minecraft version here // Setup the forge minecraft plugin data. Specify the preferred forge/minecraft version here
minecraft { minecraft {
version = "1.12-14.21.0.2343" version = "1.12-14.21.0.2359"
mappings = "snapshot_20170621" mappings = "snapshot_20170623"
runDir = "run" runDir = "run"
} }

View File

@ -24,13 +24,12 @@ import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance; import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
@Mod(modid = IronChest.MOD_ID, name = "Iron Chests", dependencies = "required-after:forge@[14.21.0.2343,)", acceptedMinecraftVersions = "[1.12, 1.13)") @Mod(modid = IronChest.MOD_ID, name = "Iron Chests", dependencies = "required-after:forge@[14.21.0.2359,)", acceptedMinecraftVersions = "[1.12, 1.13)")
public class IronChest public class IronChest
{ {
public static final String MOD_ID = "ironchest"; public static final String MOD_ID = "ironchest";
@ -58,11 +57,13 @@ public class IronChest
event.getModMetadata().version = String.format("%s.%s.%s build %s", major, minor, rev, build); event.getModMetadata().version = String.format("%s.%s.%s build %s", major, minor, rev, build);
} }
ICContent.preInit(); MinecraftForge.EVENT_BUS.register(new ICContent());
NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy); NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);
proxy.registerRenderInformation();
MinecraftForge.EVENT_BUS.register(new OcelotsSitOnChestsHandler()); MinecraftForge.EVENT_BUS.register(new OcelotsSitOnChestsHandler());
MinecraftForge.EVENT_BUS.register(new MissingMappingsHandler());
} }
@EventHandler @EventHandler
@ -73,10 +74,4 @@ public class IronChest
packetHandler.registerMessage(MessageCrystalShulkerSync.Handler.class, MessageCrystalShulkerSync.class, messageId++, Side.CLIENT); packetHandler.registerMessage(MessageCrystalShulkerSync.Handler.class, MessageCrystalShulkerSync.class, messageId++, Side.CLIENT);
} }
@EventHandler
public void onMissingMappings(FMLMissingMappingsEvent event)
{
MissingMappingsHandler.onMissingMappings(event);
}
} }

View File

@ -10,92 +10,24 @@
******************************************************************************/ ******************************************************************************/
package cpw.mods.ironchest.client; package cpw.mods.ironchest.client;
import cpw.mods.ironchest.IronChest;
import cpw.mods.ironchest.client.gui.chest.GUIChest; import cpw.mods.ironchest.client.gui.chest.GUIChest;
import cpw.mods.ironchest.client.gui.shulker.GUIShulkerChest; import cpw.mods.ironchest.client.gui.shulker.GUIShulkerChest;
import cpw.mods.ironchest.client.renderer.chest.TileEntityIronChestRenderer;
import cpw.mods.ironchest.client.renderer.shulker.TileEntityIronShulkerBoxRenderer;
import cpw.mods.ironchest.common.CommonProxy; import cpw.mods.ironchest.common.CommonProxy;
import cpw.mods.ironchest.common.ICContent;
import cpw.mods.ironchest.common.blocks.chest.IronChestType; import cpw.mods.ironchest.common.blocks.chest.IronChestType;
import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType; import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType;
import cpw.mods.ironchest.common.items.ChestChangerType;
import cpw.mods.ironchest.common.items.ShulkerBoxChangerType;
import cpw.mods.ironchest.common.tileentity.chest.TileEntityIronChest; import cpw.mods.ironchest.common.tileentity.chest.TileEntityIronChest;
import cpw.mods.ironchest.common.tileentity.shulker.TileEntityIronShulkerBox; import cpw.mods.ironchest.common.tileentity.shulker.TileEntityIronShulkerBox;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class ClientProxy extends CommonProxy public class ClientProxy extends CommonProxy
{ {
@Override
public void registerRenderInformation()
{
// Chests Start
Item chestItem = Item.getItemFromBlock(ICContent.ironChestBlock);
for (IronChestType type : IronChestType.values())
{
if (type != IronChestType.WOOD)
{
//@formatter:off
ModelLoader.setCustomModelResourceLocation(chestItem, type.ordinal(), new ModelResourceLocation(chestItem.getRegistryName(), "variant=" + type.getName()));
//@formatter:on
}
ClientRegistry.bindTileEntitySpecialRenderer(type.clazz, new TileEntityIronChestRenderer());
}
for (ChestChangerType type : ChestChangerType.VALUES)
{
//@formatter:off
ModelLoader.setCustomModelResourceLocation(type.item, 0, new ModelResourceLocation(new ResourceLocation(IronChest.MOD_ID, "iron_chest_upgrades"), "variant=" + type.itemName.toLowerCase()));
//@formatter:on
}
// Chests End
// Shulkers Start
for (Block shulker : ICContent.SHULKER_BLOCKS)
{
Item shulkerBoxItem = Item.getItemFromBlock(shulker);
for (IronShulkerBoxType type : IronShulkerBoxType.values())
{
if (type != IronShulkerBoxType.VANILLA)
{
//@formatter:off
ModelLoader.setCustomModelResourceLocation(shulkerBoxItem, type.ordinal(), new ModelResourceLocation(shulkerBoxItem.getRegistryName(), "variant=" + type.getName()));
//@formatter:on
}
}
}
for (IronShulkerBoxType type : IronShulkerBoxType.values())
{
ClientRegistry.bindTileEntitySpecialRenderer(type.clazz, new TileEntityIronShulkerBoxRenderer());
}
for (ShulkerBoxChangerType type : ShulkerBoxChangerType.VALUES)
{
//@formatter:off
ModelLoader.setCustomModelResourceLocation(type.item, 0, new ModelResourceLocation(new ResourceLocation(IronChest.MOD_ID, "iron_shulker_box_upgrades"), "variant=" + type.itemName.toLowerCase()));
//@formatter:on
}
// Shulker End
}
@Override @Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
{ {

View File

@ -22,10 +22,6 @@ import net.minecraftforge.fml.common.network.IGuiHandler;
public class CommonProxy implements IGuiHandler public class CommonProxy implements IGuiHandler
{ {
public void registerRenderInformation()
{
}
@Override @Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
{ {

View File

@ -10,10 +10,9 @@
******************************************************************************/ ******************************************************************************/
package cpw.mods.ironchest.common; package cpw.mods.ironchest.common;
import java.util.List; import cpw.mods.ironchest.IronChest;
import cpw.mods.ironchest.client.renderer.chest.TileEntityIronChestRenderer;
import com.google.common.collect.Lists; import cpw.mods.ironchest.client.renderer.shulker.TileEntityIronShulkerBoxRenderer;
import cpw.mods.ironchest.common.blocks.chest.BlockIronChest; import cpw.mods.ironchest.common.blocks.chest.BlockIronChest;
import cpw.mods.ironchest.common.blocks.chest.IronChestType; import cpw.mods.ironchest.common.blocks.chest.IronChestType;
import cpw.mods.ironchest.common.blocks.shulker.BlockIronShulkerBox; import cpw.mods.ironchest.common.blocks.shulker.BlockIronShulkerBox;
@ -22,74 +21,108 @@ import cpw.mods.ironchest.common.items.ChestChangerType;
import cpw.mods.ironchest.common.items.ShulkerBoxChangerType; import cpw.mods.ironchest.common.items.ShulkerBoxChangerType;
import cpw.mods.ironchest.common.items.chest.ItemIronChest; import cpw.mods.ironchest.common.items.chest.ItemIronChest;
import cpw.mods.ironchest.common.items.shulker.ItemIronShulkerBox; import cpw.mods.ironchest.common.items.shulker.ItemIronShulkerBox;
import cpw.mods.ironchest.common.util.BehaviorDispenseIronShulkerBox; import cpw.mods.ironchest.common.lib.BlockLists;
import cpw.mods.ironchest.common.util.BlockNames;
import cpw.mods.ironchest.common.util.CreativeTab; import cpw.mods.ironchest.common.util.CreativeTab;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockDispenser; import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.EnumDyeColor; import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.event.RegistryEvent.Register;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
@ObjectHolder(IronChest.MOD_ID)
public class ICContent public class ICContent
{ {
//@formatter:off //@formatter:off
public static CreativeTab tabGeneral = new CreativeTab("IronChest", new ItemStack(Item.getItemFromBlock(Blocks.SLIME_BLOCK))); public static CreativeTab tabGeneral = new CreativeTab("IronChest", new ItemStack(Item.getItemFromBlock(Blocks.SLIME_BLOCK)));
public static BlockIronChest ironChestBlock; @ObjectHolder(BlockNames.IRON_CHEST)
public static BlockIronChest ironChestBlock = new BlockIronChest();
public static ItemIronChest ironChestItemBlock; @ObjectHolder(BlockNames.IRON_CHEST)
public static Item ironChestItemBlock = new ItemIronChest(ironChestBlock);
public static BlockIronShulkerBox ironShulkerBoxWhiteBlock; @ObjectHolder(BlockNames.WHITE_SHULKER)
public static BlockIronShulkerBox ironShulkerBoxOrangeBlock; public static BlockIronShulkerBox ironShulkerBoxWhiteBlock = new BlockIronShulkerBox(EnumDyeColor.WHITE);
public static BlockIronShulkerBox ironShulkerBoxMagentaBlock; @ObjectHolder(BlockNames.ORANGE_SHULKER)
public static BlockIronShulkerBox ironShulkerBoxLightBlueBlock; public static BlockIronShulkerBox ironShulkerBoxOrangeBlock = new BlockIronShulkerBox(EnumDyeColor.ORANGE);
public static BlockIronShulkerBox ironShulkerBoxYellowBlock; @ObjectHolder(BlockNames.MAGENTA_SHULKER)
public static BlockIronShulkerBox ironShulkerBoxLimeBlock; public static BlockIronShulkerBox ironShulkerBoxMagentaBlock = new BlockIronShulkerBox(EnumDyeColor.MAGENTA);
public static BlockIronShulkerBox ironShulkerBoxPinkBlock; @ObjectHolder(BlockNames.LIGHT_BLUE_SHULKER)
public static BlockIronShulkerBox ironShulkerBoxGrayBlock; public static BlockIronShulkerBox ironShulkerBoxLightBlueBlock = new BlockIronShulkerBox(EnumDyeColor.LIGHT_BLUE);
public static BlockIronShulkerBox ironShulkerBoxSilverBlock; @ObjectHolder(BlockNames.YELLOW_SHULKER)
public static BlockIronShulkerBox ironShulkerBoxCyanBlock; public static BlockIronShulkerBox ironShulkerBoxYellowBlock = new BlockIronShulkerBox(EnumDyeColor.YELLOW);
public static BlockIronShulkerBox ironShulkerBoxPurpleBlock; @ObjectHolder(BlockNames.LIME_SHULKER)
public static BlockIronShulkerBox ironShulkerBoxBlueBlock; public static BlockIronShulkerBox ironShulkerBoxLimeBlock = new BlockIronShulkerBox(EnumDyeColor.LIME);
public static BlockIronShulkerBox ironShulkerBoxBrownBlock; @ObjectHolder(BlockNames.PINK_SHULKER)
public static BlockIronShulkerBox ironShulkerBoxGreenBlock; public static BlockIronShulkerBox ironShulkerBoxPinkBlock = new BlockIronShulkerBox(EnumDyeColor.PINK);
public static BlockIronShulkerBox ironShulkerBoxRedBlock; @ObjectHolder(BlockNames.GRAY_SHULKER)
public static BlockIronShulkerBox ironShulkerBoxBlackBlock; public static BlockIronShulkerBox ironShulkerBoxGrayBlock = new BlockIronShulkerBox(EnumDyeColor.GRAY);
@ObjectHolder(BlockNames.SILVER_SHULKER)
public static BlockIronShulkerBox ironShulkerBoxSilverBlock = new BlockIronShulkerBox(EnumDyeColor.SILVER);
@ObjectHolder(BlockNames.CYAN_SHULKER)
public static BlockIronShulkerBox ironShulkerBoxCyanBlock = new BlockIronShulkerBox(EnumDyeColor.CYAN);
@ObjectHolder(BlockNames.PURPLE_SHULKER)
public static BlockIronShulkerBox ironShulkerBoxPurpleBlock = new BlockIronShulkerBox(EnumDyeColor.PURPLE);
@ObjectHolder(BlockNames.BLUE_SHULKER)
public static BlockIronShulkerBox ironShulkerBoxBlueBlock = new BlockIronShulkerBox(EnumDyeColor.BLUE);
@ObjectHolder(BlockNames.BROWN_SHULKER)
public static BlockIronShulkerBox ironShulkerBoxBrownBlock = new BlockIronShulkerBox(EnumDyeColor.BROWN);
@ObjectHolder(BlockNames.GREEN_SHULKER)
public static BlockIronShulkerBox ironShulkerBoxGreenBlock = new BlockIronShulkerBox(EnumDyeColor.GREEN);
@ObjectHolder(BlockNames.RED_SHULKER)
public static BlockIronShulkerBox ironShulkerBoxRedBlock = new BlockIronShulkerBox(EnumDyeColor.RED);
@ObjectHolder(BlockNames.BLACK_SHULKER)
public static BlockIronShulkerBox ironShulkerBoxBlackBlock = new BlockIronShulkerBox(EnumDyeColor.BLACK);
public static ItemIronShulkerBox ironShulkerBoxWhiteItemBlock; @ObjectHolder(BlockNames.WHITE_SHULKER)
public static ItemIronShulkerBox ironShulkerBoxOrangeItemBlock; public static ItemIronShulkerBox ironShulkerBoxWhiteItemBlock = new ItemIronShulkerBox(ironShulkerBoxWhiteBlock, EnumDyeColor.WHITE);
public static ItemIronShulkerBox ironShulkerBoxMagentaItemBlock; @ObjectHolder(BlockNames.ORANGE_SHULKER)
public static ItemIronShulkerBox ironShulkerBoxLightBlueItemBlock; public static ItemIronShulkerBox ironShulkerBoxOrangeItemBlock = new ItemIronShulkerBox(ironShulkerBoxOrangeBlock, EnumDyeColor.ORANGE);
public static ItemIronShulkerBox ironShulkerBoxYellowItemBlock; @ObjectHolder(BlockNames.MAGENTA_SHULKER)
public static ItemIronShulkerBox ironShulkerBoxLimeItemBlock; public static ItemIronShulkerBox ironShulkerBoxMagentaItemBlock = new ItemIronShulkerBox(ironShulkerBoxMagentaBlock, EnumDyeColor.MAGENTA);
public static ItemIronShulkerBox ironShulkerBoxPinkItemBlock; @ObjectHolder(BlockNames.LIGHT_BLUE_SHULKER)
public static ItemIronShulkerBox ironShulkerBoxGrayItemBlock; public static ItemIronShulkerBox ironShulkerBoxLightBlueItemBlock = new ItemIronShulkerBox(ironShulkerBoxLightBlueBlock, EnumDyeColor.LIGHT_BLUE);
public static ItemIronShulkerBox ironShulkerBoxSilverItemBlock; @ObjectHolder(BlockNames.YELLOW_SHULKER)
public static ItemIronShulkerBox ironShulkerBoxCyanItemBlock; public static ItemIronShulkerBox ironShulkerBoxYellowItemBlock = new ItemIronShulkerBox(ironShulkerBoxYellowBlock, EnumDyeColor.YELLOW);
public static ItemIronShulkerBox ironShulkerBoxPurpleItemBlock; @ObjectHolder(BlockNames.LIME_SHULKER)
public static ItemIronShulkerBox ironShulkerBoxBlueItemBlock; public static ItemIronShulkerBox ironShulkerBoxLimeItemBlock = new ItemIronShulkerBox(ironShulkerBoxLimeBlock, EnumDyeColor.LIME);
public static ItemIronShulkerBox ironShulkerBoxBrownItemBlock; @ObjectHolder(BlockNames.PINK_SHULKER)
public static ItemIronShulkerBox ironShulkerBoxGreenItemBlock; public static ItemIronShulkerBox ironShulkerBoxPinkItemBlock = new ItemIronShulkerBox(ironShulkerBoxPinkBlock, EnumDyeColor.PINK);
public static ItemIronShulkerBox ironShulkerBoxRedItemBlock; @ObjectHolder(BlockNames.GRAY_SHULKER)
public static ItemIronShulkerBox ironShulkerBoxBlackItemBlock; public static ItemIronShulkerBox ironShulkerBoxGrayItemBlock = new ItemIronShulkerBox(ironShulkerBoxGrayBlock, EnumDyeColor.GRAY);
@ObjectHolder(BlockNames.SILVER_SHULKER)
public static final List<Block> SHULKER_BLOCKS = Lists.newArrayList(); public static ItemIronShulkerBox ironShulkerBoxSilverItemBlock = new ItemIronShulkerBox(ironShulkerBoxSilverBlock, EnumDyeColor.SILVER);
public static final List<ItemBlock> SHULKER_ITEM_BLOCKS = Lists.newArrayList(); @ObjectHolder(BlockNames.CYAN_SHULKER)
public static ItemIronShulkerBox ironShulkerBoxCyanItemBlock = new ItemIronShulkerBox(ironShulkerBoxCyanBlock, EnumDyeColor.CYAN);
public static final List<Block> VANILLA_SHULKER_BLOCKS = Lists.newArrayList(); @ObjectHolder(BlockNames.PURPLE_SHULKER)
public static final List<EnumDyeColor> VANILLA_SHULKER_COLORS = Lists.newArrayList(); public static ItemIronShulkerBox ironShulkerBoxPurpleItemBlock = new ItemIronShulkerBox(ironShulkerBoxPurpleBlock, EnumDyeColor.PURPLE);
@ObjectHolder(BlockNames.BLUE_SHULKER)
public static ItemIronShulkerBox ironShulkerBoxBlueItemBlock = new ItemIronShulkerBox(ironShulkerBoxBlueBlock, EnumDyeColor.BLUE);
@ObjectHolder(BlockNames.BROWN_SHULKER)
public static ItemIronShulkerBox ironShulkerBoxBrownItemBlock = new ItemIronShulkerBox(ironShulkerBoxBrownBlock, EnumDyeColor.BROWN);
@ObjectHolder(BlockNames.GREEN_SHULKER)
public static ItemIronShulkerBox ironShulkerBoxGreenItemBlock = new ItemIronShulkerBox(ironShulkerBoxGreenBlock, EnumDyeColor.GREEN);
@ObjectHolder(BlockNames.RED_SHULKER)
public static ItemIronShulkerBox ironShulkerBoxRedItemBlock = new ItemIronShulkerBox(ironShulkerBoxRedBlock, EnumDyeColor.RED);
@ObjectHolder(BlockNames.BLACK_SHULKER)
public static ItemIronShulkerBox ironShulkerBoxBlackItemBlock = new ItemIronShulkerBox(ironShulkerBoxBlackBlock, EnumDyeColor.BLACK);
//@formatter:on //@formatter:on
public static void preInit() @SubscribeEvent
public void registerBlocks(Register<Block> event)
{ {
// Chests Start // Chests Start
ChestChangerType.buildItems(); event.getRegistry().register(ironChestBlock);
ironChestBlock = GameRegistry.register(new BlockIronChest());
ironChestItemBlock = GameRegistry.register(new ItemIronChest(ironChestBlock));
for (IronChestType typ : IronChestType.VALUES) for (IronChestType typ : IronChestType.VALUES)
{ {
@ -98,16 +131,14 @@ public class ICContent
GameRegistry.registerTileEntity(typ.clazz, "IronChest." + typ.name()); GameRegistry.registerTileEntity(typ.clazz, "IronChest." + typ.name());
} }
} }
tabGeneral.setDisplayIcon(new ItemStack(ironChestBlock, 1, IronChestType.IRON.ordinal()));
// Chests End // Chests End
// Shulkers Start // Shulkers Start
setVanillaShulkerList(); BlockLists.createVanillaShulkerBlockList();
ShulkerBoxChangerType.buildItems(); registerShulkerBlocks(event);
registerShulkerBlocks();
registerShulkerItemBlocks();
for (IronShulkerBoxType typ : IronShulkerBoxType.VALUES) for (IronShulkerBoxType typ : IronShulkerBoxType.VALUES)
{ {
@ -117,91 +148,93 @@ public class ICContent
} }
} }
for (ItemBlock block : SHULKER_ITEM_BLOCKS) BlockLists.createIronShulkerBlockList();
{
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(block, new BehaviorDispenseIronShulkerBox());
}
// Shulkers End // Shulkers End
tabGeneral.setDisplayIcon(new ItemStack(ironChestBlock, 1, IronChestType.IRON.ordinal()));
} }
private static void registerShulkerBlocks() @SubscribeEvent
public void registerItems(Register<Item> event)
{ {
SHULKER_BLOCKS.add(ironShulkerBoxWhiteBlock = GameRegistry.register(new BlockIronShulkerBox(EnumDyeColor.WHITE))); // Chests Start
SHULKER_BLOCKS.add(ironShulkerBoxOrangeBlock = GameRegistry.register(new BlockIronShulkerBox(EnumDyeColor.ORANGE))); event.getRegistry().register(ironChestItemBlock);
SHULKER_BLOCKS.add(ironShulkerBoxMagentaBlock = GameRegistry.register(new BlockIronShulkerBox(EnumDyeColor.MAGENTA)));
SHULKER_BLOCKS.add(ironShulkerBoxLightBlueBlock = GameRegistry.register(new BlockIronShulkerBox(EnumDyeColor.LIGHT_BLUE))); ChestChangerType.buildItems(event);
SHULKER_BLOCKS.add(ironShulkerBoxYellowBlock = GameRegistry.register(new BlockIronShulkerBox(EnumDyeColor.YELLOW))); // Chests End
SHULKER_BLOCKS.add(ironShulkerBoxLimeBlock = GameRegistry.register(new BlockIronShulkerBox(EnumDyeColor.LIME)));
SHULKER_BLOCKS.add(ironShulkerBoxPinkBlock = GameRegistry.register(new BlockIronShulkerBox(EnumDyeColor.PINK))); // Shulkers Start
SHULKER_BLOCKS.add(ironShulkerBoxGrayBlock = GameRegistry.register(new BlockIronShulkerBox(EnumDyeColor.GRAY))); registerShulkerItemBlocks(event);
SHULKER_BLOCKS.add(ironShulkerBoxSilverBlock = GameRegistry.register(new BlockIronShulkerBox(EnumDyeColor.SILVER)));
SHULKER_BLOCKS.add(ironShulkerBoxCyanBlock = GameRegistry.register(new BlockIronShulkerBox(EnumDyeColor.CYAN))); ShulkerBoxChangerType.buildItems(event);
SHULKER_BLOCKS.add(ironShulkerBoxPurpleBlock = GameRegistry.register(new BlockIronShulkerBox(EnumDyeColor.PURPLE)));
SHULKER_BLOCKS.add(ironShulkerBoxBlueBlock = GameRegistry.register(new BlockIronShulkerBox(EnumDyeColor.BLUE))); BlockLists.createShulkerItemList();
SHULKER_BLOCKS.add(ironShulkerBoxBrownBlock = GameRegistry.register(new BlockIronShulkerBox(EnumDyeColor.BROWN)));
SHULKER_BLOCKS.add(ironShulkerBoxGreenBlock = GameRegistry.register(new BlockIronShulkerBox(EnumDyeColor.GREEN))); BlockLists.registerBlockBehavior();
SHULKER_BLOCKS.add(ironShulkerBoxRedBlock = GameRegistry.register(new BlockIronShulkerBox(EnumDyeColor.RED))); // Shulkers End
SHULKER_BLOCKS.add(ironShulkerBoxBlackBlock = GameRegistry.register(new BlockIronShulkerBox(EnumDyeColor.BLACK)));
} }
private static void registerShulkerItemBlocks() @SubscribeEvent
public void registerModels(ModelRegistryEvent event)
{ {
//@formatter:off // Chests Start
SHULKER_ITEM_BLOCKS.add(ironShulkerBoxWhiteItemBlock = GameRegistry.register(new ItemIronShulkerBox(ironShulkerBoxWhiteBlock, EnumDyeColor.WHITE))); Item chestItem = Item.getItemFromBlock(ICContent.ironChestBlock);
SHULKER_ITEM_BLOCKS.add(ironShulkerBoxOrangeItemBlock = GameRegistry.register(new ItemIronShulkerBox(ironShulkerBoxOrangeBlock, EnumDyeColor.ORANGE)));
SHULKER_ITEM_BLOCKS.add(ironShulkerBoxMagentaItemBlock = GameRegistry.register(new ItemIronShulkerBox(ironShulkerBoxMagentaBlock, EnumDyeColor.MAGENTA))); for (IronChestType type : IronChestType.values())
SHULKER_ITEM_BLOCKS.add(ironShulkerBoxLightBlueItemBlock = GameRegistry.register(new ItemIronShulkerBox(ironShulkerBoxLightBlueBlock, EnumDyeColor.LIGHT_BLUE))); {
SHULKER_ITEM_BLOCKS.add(ironShulkerBoxYellowItemBlock = GameRegistry.register(new ItemIronShulkerBox(ironShulkerBoxYellowBlock, EnumDyeColor.YELLOW))); if (type != IronChestType.WOOD)
SHULKER_ITEM_BLOCKS.add(ironShulkerBoxLimeItemBlock = GameRegistry.register(new ItemIronShulkerBox(ironShulkerBoxLimeBlock, EnumDyeColor.LIME))); {
SHULKER_ITEM_BLOCKS.add(ironShulkerBoxPinkItemBlock = GameRegistry.register(new ItemIronShulkerBox(ironShulkerBoxPinkBlock, EnumDyeColor.PINK))); //@formatter:off
SHULKER_ITEM_BLOCKS.add(ironShulkerBoxGrayItemBlock = GameRegistry.register(new ItemIronShulkerBox(ironShulkerBoxGrayBlock, EnumDyeColor.GRAY))); ModelLoader.setCustomModelResourceLocation(chestItem, type.ordinal(), new ModelResourceLocation(chestItem.getRegistryName(), "variant=" + type.getName()));
SHULKER_ITEM_BLOCKS.add(ironShulkerBoxSilverItemBlock = GameRegistry.register(new ItemIronShulkerBox(ironShulkerBoxSilverBlock, EnumDyeColor.SILVER))); //@formatter:on
SHULKER_ITEM_BLOCKS.add(ironShulkerBoxCyanItemBlock = GameRegistry.register(new ItemIronShulkerBox(ironShulkerBoxCyanBlock, EnumDyeColor.CYAN))); }
SHULKER_ITEM_BLOCKS.add(ironShulkerBoxPurpleItemBlock = GameRegistry.register(new ItemIronShulkerBox(ironShulkerBoxPurpleBlock, EnumDyeColor.PURPLE)));
SHULKER_ITEM_BLOCKS.add(ironShulkerBoxBlueItemBlock = GameRegistry.register(new ItemIronShulkerBox(ironShulkerBoxBlueBlock, EnumDyeColor.BLUE))); ClientRegistry.bindTileEntitySpecialRenderer(type.clazz, new TileEntityIronChestRenderer());
SHULKER_ITEM_BLOCKS.add(ironShulkerBoxBrownItemBlock = GameRegistry.register(new ItemIronShulkerBox(ironShulkerBoxBrownBlock, EnumDyeColor.BROWN))); }
SHULKER_ITEM_BLOCKS.add(ironShulkerBoxGreenItemBlock = GameRegistry.register(new ItemIronShulkerBox(ironShulkerBoxGreenBlock, EnumDyeColor.GREEN)));
SHULKER_ITEM_BLOCKS.add(ironShulkerBoxRedItemBlock = GameRegistry.register(new ItemIronShulkerBox(ironShulkerBoxRedBlock, EnumDyeColor.RED))); for (ChestChangerType type : ChestChangerType.VALUES)
SHULKER_ITEM_BLOCKS.add(ironShulkerBoxBlackItemBlock = GameRegistry.register(new ItemIronShulkerBox(ironShulkerBoxBlackBlock, EnumDyeColor.BLACK))); {
//@formatter:on //@formatter:off
ModelLoader.setCustomModelResourceLocation(type.item, 0, new ModelResourceLocation(new ResourceLocation(IronChest.MOD_ID, "iron_chest_upgrades"), "variant=" + type.itemName.toLowerCase()));
//@formatter:on
}
// Chests End
// Shulkers Start
for (Block shulker : BlockLists.SHULKER_BLOCKS)
{
Item shulkerBoxItem = Item.getItemFromBlock(shulker);
for (IronShulkerBoxType type : IronShulkerBoxType.values())
{
if (type != IronShulkerBoxType.VANILLA)
{
//@formatter:off
ModelLoader.setCustomModelResourceLocation(shulkerBoxItem, type.ordinal(), new ModelResourceLocation(shulkerBoxItem.getRegistryName(), "variant=" + type.getName()));
//@formatter:on
}
}
}
for (IronShulkerBoxType type : IronShulkerBoxType.values())
{
ClientRegistry.bindTileEntitySpecialRenderer(type.clazz, new TileEntityIronShulkerBoxRenderer());
}
for (ShulkerBoxChangerType type : ShulkerBoxChangerType.VALUES)
{
//@formatter:off
ModelLoader.setCustomModelResourceLocation(type.item, 0, new ModelResourceLocation(new ResourceLocation(IronChest.MOD_ID, "iron_shulker_box_upgrades"), "variant=" + type.itemName.toLowerCase()));
//@formatter:on
}
// Shulker End
} }
private static void setVanillaShulkerList() private static void registerShulkerBlocks(Register<Block> event)
{ {
VANILLA_SHULKER_BLOCKS.add(Blocks.WHITE_SHULKER_BOX); event.getRegistry().registerAll(ironShulkerBoxWhiteBlock, ironShulkerBoxOrangeBlock, ironShulkerBoxMagentaBlock, ironShulkerBoxLightBlueBlock, ironShulkerBoxYellowBlock, ironShulkerBoxLimeBlock, ironShulkerBoxPinkBlock, ironShulkerBoxGrayBlock, ironShulkerBoxSilverBlock, ironShulkerBoxCyanBlock, ironShulkerBoxPurpleBlock, ironShulkerBoxBlueBlock, ironShulkerBoxBrownBlock, ironShulkerBoxGreenBlock, ironShulkerBoxRedBlock, ironShulkerBoxBlackBlock);
VANILLA_SHULKER_BLOCKS.add(Blocks.ORANGE_SHULKER_BOX); }
VANILLA_SHULKER_BLOCKS.add(Blocks.MAGENTA_SHULKER_BOX);
VANILLA_SHULKER_BLOCKS.add(Blocks.LIGHT_BLUE_SHULKER_BOX);
VANILLA_SHULKER_BLOCKS.add(Blocks.YELLOW_SHULKER_BOX);
VANILLA_SHULKER_BLOCKS.add(Blocks.LIME_SHULKER_BOX);
VANILLA_SHULKER_BLOCKS.add(Blocks.PINK_SHULKER_BOX);
VANILLA_SHULKER_BLOCKS.add(Blocks.GRAY_SHULKER_BOX);
VANILLA_SHULKER_BLOCKS.add(Blocks.SILVER_SHULKER_BOX);
VANILLA_SHULKER_BLOCKS.add(Blocks.CYAN_SHULKER_BOX);
VANILLA_SHULKER_BLOCKS.add(Blocks.PURPLE_SHULKER_BOX);
VANILLA_SHULKER_BLOCKS.add(Blocks.BLUE_SHULKER_BOX);
VANILLA_SHULKER_BLOCKS.add(Blocks.BROWN_SHULKER_BOX);
VANILLA_SHULKER_BLOCKS.add(Blocks.GREEN_SHULKER_BOX);
VANILLA_SHULKER_BLOCKS.add(Blocks.RED_SHULKER_BOX);
VANILLA_SHULKER_BLOCKS.add(Blocks.BLACK_SHULKER_BOX);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.WHITE); private static void registerShulkerItemBlocks(Register<Item> event)
VANILLA_SHULKER_COLORS.add(EnumDyeColor.ORANGE); {
VANILLA_SHULKER_COLORS.add(EnumDyeColor.MAGENTA); event.getRegistry().registerAll(ironShulkerBoxWhiteItemBlock, ironShulkerBoxOrangeItemBlock, ironShulkerBoxMagentaItemBlock, ironShulkerBoxLightBlueItemBlock, ironShulkerBoxYellowItemBlock, ironShulkerBoxLimeItemBlock, ironShulkerBoxPinkItemBlock, ironShulkerBoxGrayItemBlock, ironShulkerBoxSilverItemBlock, ironShulkerBoxCyanItemBlock, ironShulkerBoxPurpleItemBlock, ironShulkerBoxBlueItemBlock, ironShulkerBoxBrownItemBlock, ironShulkerBoxGreenItemBlock, ironShulkerBoxRedItemBlock, ironShulkerBoxBlackItemBlock);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.LIGHT_BLUE);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.YELLOW);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.LIME);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.PINK);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.GRAY);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.SILVER);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.CYAN);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.PURPLE);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.BLUE);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.BROWN);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.GREEN);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.RED);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.BLACK);
} }
} }

View File

@ -15,6 +15,7 @@ import javax.annotation.Nullable;
import cpw.mods.ironchest.IronChest; import cpw.mods.ironchest.IronChest;
import cpw.mods.ironchest.common.ICContent; import cpw.mods.ironchest.common.ICContent;
import cpw.mods.ironchest.common.tileentity.chest.TileEntityIronChest; import cpw.mods.ironchest.common.tileentity.chest.TileEntityIronChest;
import cpw.mods.ironchest.common.util.BlockNames;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.properties.PropertyEnum;
@ -52,7 +53,7 @@ public class BlockIronChest extends Block
{ {
super(Material.IRON); super(Material.IRON);
this.setRegistryName(new ResourceLocation(IronChest.MOD_ID, "iron_chest")); this.setRegistryName(new ResourceLocation(IronChest.MOD_ID, BlockNames.IRON_CHEST));
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, IronChestType.IRON)); this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, IronChestType.IRON));
this.setHardness(3.0F); this.setHardness(3.0F);
this.setUnlocalizedName("IronChest"); this.setUnlocalizedName("IronChest");

View File

@ -23,7 +23,7 @@ import net.minecraft.util.NonNullList;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.crafting.IRecipeFactory; import net.minecraftforge.common.crafting.IRecipeFactory;
import net.minecraftforge.common.crafting.JsonContext; import net.minecraftforge.common.crafting.JsonContext;
import net.minecraftforge.fml.common.registry.IForgeRegistryEntry.Impl; import net.minecraftforge.registries.IForgeRegistryEntry.Impl;
public class ShulkerBoxColorRecipeFactory implements IRecipeFactory public class ShulkerBoxColorRecipeFactory implements IRecipeFactory
{ {

View File

@ -17,7 +17,8 @@ import static cpw.mods.ironchest.common.blocks.chest.IronChestType.WOOD;
import cpw.mods.ironchest.common.blocks.chest.IronChestType; import cpw.mods.ironchest.common.blocks.chest.IronChestType;
import cpw.mods.ironchest.common.items.chest.ItemChestChanger; import cpw.mods.ironchest.common.items.chest.ItemChestChanger;
import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraft.item.Item;
import net.minecraftforge.event.RegistryEvent.Register;
public enum ChestChangerType public enum ChestChangerType
{ {
@ -55,22 +56,22 @@ public enum ChestChangerType
return from == this.source; return from == this.source;
} }
public ItemChestChanger buildItem() public ItemChestChanger buildItem(Register<Item> event)
{ {
this.item = new ItemChestChanger(this); this.item = new ItemChestChanger(this);
this.item.setRegistryName(this.itemName); this.item.setRegistryName(this.itemName);
GameRegistry.register(this.item); event.getRegistry().register(this.item);
return this.item; return this.item;
} }
public static void buildItems() public static void buildItems(Register<Item> event)
{ {
for (ChestChangerType type : VALUES) for (ChestChangerType type : VALUES)
{ {
type.buildItem(); type.buildItem(event);
} }
} }
} }

View File

@ -17,7 +17,8 @@ import static cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType.VANILL
import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType; import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType;
import cpw.mods.ironchest.common.items.shulker.ItemShulkerBoxChanger; import cpw.mods.ironchest.common.items.shulker.ItemShulkerBoxChanger;
import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraft.item.Item;
import net.minecraftforge.event.RegistryEvent.Register;
public enum ShulkerBoxChangerType public enum ShulkerBoxChangerType
{ {
@ -55,22 +56,22 @@ public enum ShulkerBoxChangerType
return from == this.source; return from == this.source;
} }
public ItemShulkerBoxChanger buildItem() public ItemShulkerBoxChanger buildItem(Register<Item> event)
{ {
this.item = new ItemShulkerBoxChanger(this); this.item = new ItemShulkerBoxChanger(this);
this.item.setRegistryName(this.itemName); this.item.setRegistryName(this.itemName);
GameRegistry.register(this.item); event.getRegistry().register(this.item);
return this.item; return this.item;
} }
public static void buildItems() public static void buildItems(Register<Item> event)
{ {
for (ShulkerBoxChangerType type : VALUES) for (ShulkerBoxChangerType type : VALUES)
{ {
type.buildItem(); type.buildItem(event);
} }
} }
} }

View File

@ -14,6 +14,7 @@ import java.util.Locale;
import cpw.mods.ironchest.IronChest; import cpw.mods.ironchest.IronChest;
import cpw.mods.ironchest.common.blocks.chest.IronChestType; import cpw.mods.ironchest.common.blocks.chest.IronChestType;
import cpw.mods.ironchest.common.util.BlockNames;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -25,7 +26,7 @@ public class ItemIronChest extends ItemBlock
{ {
super(block); super(block);
this.setRegistryName(new ResourceLocation(IronChest.MOD_ID, "iron_chest")); this.setRegistryName(new ResourceLocation(IronChest.MOD_ID, BlockNames.IRON_CHEST));
this.setMaxDamage(0); this.setMaxDamage(0);
this.setHasSubtypes(true); this.setHasSubtypes(true);
} }

View File

@ -16,6 +16,7 @@ import cpw.mods.ironchest.common.ICContent;
import cpw.mods.ironchest.common.blocks.shulker.BlockIronShulkerBox; import cpw.mods.ironchest.common.blocks.shulker.BlockIronShulkerBox;
import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType; import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType;
import cpw.mods.ironchest.common.items.ShulkerBoxChangerType; import cpw.mods.ironchest.common.items.ShulkerBoxChangerType;
import cpw.mods.ironchest.common.lib.BlockLists;
import cpw.mods.ironchest.common.tileentity.shulker.TileEntityIronShulkerBox; import cpw.mods.ironchest.common.tileentity.shulker.TileEntityIronShulkerBox;
import cpw.mods.ironchest.common.util.ItemTooltip; import cpw.mods.ironchest.common.util.ItemTooltip;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -56,11 +57,11 @@ public class ItemShulkerBoxChanger extends ItemTooltip
Block ironShulkerBoxBlock = worldIn.getBlockState(ironShulkerBox.getPos()).getBlock(); Block ironShulkerBoxBlock = worldIn.getBlockState(ironShulkerBox.getPos()).getBlock();
for (int i = 0; i < ICContent.SHULKER_BLOCKS.size(); i++) for (int i = 0; i < BlockLists.SHULKER_BLOCKS.size(); i++)
{ {
if (ICContent.SHULKER_BLOCKS.get(i) == ironShulkerBoxBlock) if (BlockLists.SHULKER_BLOCKS.get(i) == ironShulkerBoxBlock)
{ {
return ICContent.VANILLA_SHULKER_COLORS.get(i); return BlockLists.VANILLA_SHULKER_COLORS.get(i);
} }
} }
} }
@ -70,11 +71,11 @@ public class ItemShulkerBoxChanger extends ItemTooltip
Block shulkerBoxBlock = worldIn.getBlockState(shulkerBox.getPos()).getBlock(); Block shulkerBoxBlock = worldIn.getBlockState(shulkerBox.getPos()).getBlock();
for (int i = 0; i < ICContent.VANILLA_SHULKER_BLOCKS.size(); i++) for (int i = 0; i < BlockLists.VANILLA_SHULKER_BLOCKS.size(); i++)
{ {
if (ICContent.VANILLA_SHULKER_BLOCKS.get(i) == shulkerBoxBlock) if (BlockLists.VANILLA_SHULKER_BLOCKS.get(i) == shulkerBoxBlock)
{ {
return ICContent.VANILLA_SHULKER_COLORS.get(i); return BlockLists.VANILLA_SHULKER_COLORS.get(i);
} }
} }
} }
@ -179,9 +180,9 @@ public class ItemShulkerBoxChanger extends ItemTooltip
IBlockState iblockstate = null; IBlockState iblockstate = null;
if (ICContent.SHULKER_BLOCKS.get(shulkerBoxColor.getMetadata()) != null) if (BlockLists.SHULKER_BLOCKS.get(shulkerBoxColor.getMetadata()) != null)
{ {
Block block = ICContent.SHULKER_BLOCKS.get(shulkerBoxColor.getMetadata()); Block block = BlockLists.SHULKER_BLOCKS.get(shulkerBoxColor.getMetadata());
iblockstate = block.getDefaultState().withProperty(BlockIronShulkerBox.VARIANT_PROP, this.type.target); iblockstate = block.getDefaultState().withProperty(BlockIronShulkerBox.VARIANT_PROP, this.type.target);
} }

View File

@ -0,0 +1,110 @@
package cpw.mods.ironchest.common.lib;
import java.util.List;
import com.google.common.collect.Lists;
import cpw.mods.ironchest.common.ICContent;
import cpw.mods.ironchest.common.util.BehaviorDispenseIronShulkerBox;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDispenser;
import net.minecraft.init.Blocks;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemBlock;
public class BlockLists
{
//@formatter:off
public static final List<Block> SHULKER_BLOCKS = Lists.newArrayList();
public static final List<ItemBlock> SHULKER_ITEM_BLOCKS = Lists.newArrayList();
public static final List<Block> VANILLA_SHULKER_BLOCKS = Lists.newArrayList();
public static final List<EnumDyeColor> VANILLA_SHULKER_COLORS = Lists.newArrayList();
//@formatter:on
public static void createVanillaShulkerBlockList()
{
VANILLA_SHULKER_BLOCKS.add(Blocks.WHITE_SHULKER_BOX);
VANILLA_SHULKER_BLOCKS.add(Blocks.ORANGE_SHULKER_BOX);
VANILLA_SHULKER_BLOCKS.add(Blocks.MAGENTA_SHULKER_BOX);
VANILLA_SHULKER_BLOCKS.add(Blocks.LIGHT_BLUE_SHULKER_BOX);
VANILLA_SHULKER_BLOCKS.add(Blocks.YELLOW_SHULKER_BOX);
VANILLA_SHULKER_BLOCKS.add(Blocks.LIME_SHULKER_BOX);
VANILLA_SHULKER_BLOCKS.add(Blocks.PINK_SHULKER_BOX);
VANILLA_SHULKER_BLOCKS.add(Blocks.GRAY_SHULKER_BOX);
VANILLA_SHULKER_BLOCKS.add(Blocks.SILVER_SHULKER_BOX);
VANILLA_SHULKER_BLOCKS.add(Blocks.CYAN_SHULKER_BOX);
VANILLA_SHULKER_BLOCKS.add(Blocks.PURPLE_SHULKER_BOX);
VANILLA_SHULKER_BLOCKS.add(Blocks.BLUE_SHULKER_BOX);
VANILLA_SHULKER_BLOCKS.add(Blocks.BROWN_SHULKER_BOX);
VANILLA_SHULKER_BLOCKS.add(Blocks.GREEN_SHULKER_BOX);
VANILLA_SHULKER_BLOCKS.add(Blocks.RED_SHULKER_BOX);
VANILLA_SHULKER_BLOCKS.add(Blocks.BLACK_SHULKER_BOX);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.WHITE);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.ORANGE);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.MAGENTA);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.LIGHT_BLUE);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.YELLOW);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.LIME);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.PINK);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.GRAY);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.SILVER);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.CYAN);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.PURPLE);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.BLUE);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.BROWN);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.GREEN);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.RED);
VANILLA_SHULKER_COLORS.add(EnumDyeColor.BLACK);
}
public static void createIronShulkerBlockList()
{
SHULKER_BLOCKS.add(ICContent.ironShulkerBoxWhiteBlock);
SHULKER_BLOCKS.add(ICContent.ironShulkerBoxOrangeBlock);
SHULKER_BLOCKS.add(ICContent.ironShulkerBoxMagentaBlock);
SHULKER_BLOCKS.add(ICContent.ironShulkerBoxLightBlueBlock);
SHULKER_BLOCKS.add(ICContent.ironShulkerBoxYellowBlock);
SHULKER_BLOCKS.add(ICContent.ironShulkerBoxLimeBlock);
SHULKER_BLOCKS.add(ICContent.ironShulkerBoxPinkBlock);
SHULKER_BLOCKS.add(ICContent.ironShulkerBoxGrayBlock);
SHULKER_BLOCKS.add(ICContent.ironShulkerBoxSilverBlock);
SHULKER_BLOCKS.add(ICContent.ironShulkerBoxCyanBlock);
SHULKER_BLOCKS.add(ICContent.ironShulkerBoxPurpleBlock);
SHULKER_BLOCKS.add(ICContent.ironShulkerBoxBlueBlock);
SHULKER_BLOCKS.add(ICContent.ironShulkerBoxBrownBlock);
SHULKER_BLOCKS.add(ICContent.ironShulkerBoxGreenBlock);
SHULKER_BLOCKS.add(ICContent.ironShulkerBoxRedBlock);
SHULKER_BLOCKS.add(ICContent.ironShulkerBoxBlackBlock);
}
public static void createShulkerItemList()
{
SHULKER_ITEM_BLOCKS.add(ICContent.ironShulkerBoxWhiteItemBlock);
SHULKER_ITEM_BLOCKS.add(ICContent.ironShulkerBoxOrangeItemBlock);
SHULKER_ITEM_BLOCKS.add(ICContent.ironShulkerBoxMagentaItemBlock);
SHULKER_ITEM_BLOCKS.add(ICContent.ironShulkerBoxLightBlueItemBlock);
SHULKER_ITEM_BLOCKS.add(ICContent.ironShulkerBoxYellowItemBlock);
SHULKER_ITEM_BLOCKS.add(ICContent.ironShulkerBoxLimeItemBlock);
SHULKER_ITEM_BLOCKS.add(ICContent.ironShulkerBoxPinkItemBlock);
SHULKER_ITEM_BLOCKS.add(ICContent.ironShulkerBoxGrayItemBlock);
SHULKER_ITEM_BLOCKS.add(ICContent.ironShulkerBoxSilverItemBlock);
SHULKER_ITEM_BLOCKS.add(ICContent.ironShulkerBoxCyanItemBlock);
SHULKER_ITEM_BLOCKS.add(ICContent.ironShulkerBoxPurpleItemBlock);
SHULKER_ITEM_BLOCKS.add(ICContent.ironShulkerBoxBlueItemBlock);
SHULKER_ITEM_BLOCKS.add(ICContent.ironShulkerBoxBrownItemBlock);
SHULKER_ITEM_BLOCKS.add(ICContent.ironShulkerBoxGreenItemBlock);
SHULKER_ITEM_BLOCKS.add(ICContent.ironShulkerBoxRedItemBlock);
SHULKER_ITEM_BLOCKS.add(ICContent.ironShulkerBoxBlackItemBlock);
}
public static void registerBlockBehavior()
{
for (ItemBlock block : SHULKER_ITEM_BLOCKS)
{
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(block, new BehaviorDispenseIronShulkerBox());
}
}
}

View File

@ -0,0 +1,38 @@
package cpw.mods.ironchest.common.util;
public class BlockNames
{
public static final String IRON_CHEST = "iron_chest";
public static final String WHITE_SHULKER = "iron_shulker_box_white";
public static final String ORANGE_SHULKER = "iron_shulker_box_orange";
public static final String MAGENTA_SHULKER = "iron_shulker_box_magenta";
public static final String LIGHT_BLUE_SHULKER = "iron_shulker_box_light_blue";
public static final String YELLOW_SHULKER = "iron_shulker_box_yellow";
public static final String LIME_SHULKER = "iron_shulker_box_lime";
public static final String PINK_SHULKER = "iron_shulker_box_pink";
public static final String GRAY_SHULKER = "iron_shulker_box_gray";
public static final String SILVER_SHULKER = "iron_shulker_box_silver";
public static final String CYAN_SHULKER = "iron_shulker_box_cyan";
public static final String PURPLE_SHULKER = "iron_shulker_box_purple";
public static final String BLUE_SHULKER = "iron_shulker_box_blue";
public static final String BROWN_SHULKER = "iron_shulker_box_brown";
public static final String GREEN_SHULKER = "iron_shulker_box_green";
public static final String RED_SHULKER = "iron_shulker_box_red";
public static final String BLACK_SHULKER = "iron_shulker_box_black";
}

View File

@ -12,58 +12,75 @@ package cpw.mods.ironchest.common.util;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import cpw.mods.ironchest.IronChest;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent; import net.minecraftforge.event.RegistryEvent.MissingMappings;
import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent.MissingMapping; import net.minecraftforge.event.RegistryEvent.MissingMappings.Mapping;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.ForgeRegistries; import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.fml.common.registry.GameRegistry;
public class MissingMappingsHandler public class MissingMappingsHandler
{ {
public static void onMissingMappings(FMLMissingMappingsEvent event) @SubscribeEvent
public void missingBlockMappings(MissingMappings<Block> event)
{ {
for (MissingMapping mapping : event.get()) for (Mapping<Block> entry : event.getAllMappings())
{ {
if (mapping.resourceLocation.getResourceDomain().equals(IronChest.MOD_ID)) @Nonnull
{ String path = entry.key.getResourcePath();
@Nonnull
String path = mapping.resourceLocation.getResourcePath();
replaceOldChest(path, mapping); replaceOldChestBlock(path, entry);
replaceOldUpgrades(path, mapping);
replaceNewUpgrades(path, mapping);
}
} }
} }
private static void replaceOldChest(String path, MissingMapping mapping) @SubscribeEvent
public void missingItemMappings(MissingMappings<Item> event)
{
for (Mapping<Item> entry : event.getAllMappings())
{
@Nonnull
String path = entry.key.getResourcePath();
replaceOldChestItem(path, entry);
replaceOldUpgrades(path, entry);
replaceNewUpgrades(path, entry);
}
}
private static void replaceOldChestBlock(String path, Mapping<Block> mapping)
{ {
if (path.endsWith("blockironchest")) if (path.endsWith("blockironchest"))
{ {
path = path.replace("blockironchest", "iron_chest"); path = path.replace("blockironchest", "iron_chest");
ResourceLocation newRes = new ResourceLocation(mapping.resourceLocation.getResourceDomain(), path); ResourceLocation newRes = new ResourceLocation(mapping.key.getResourceDomain(), path);
Block block = ForgeRegistries.BLOCKS.getValue(newRes); Block block = ForgeRegistries.BLOCKS.getValue(newRes);
if (block != null) if (block != null)
{ {
if (mapping.type == GameRegistry.Type.BLOCK) mapping.remap(block);
{
mapping.remap(block);
}
else
{
mapping.remap(Item.getItemFromBlock(block));
}
} }
} }
} }
private static void replaceOldUpgrades(String path, MissingMapping mapping) private static void replaceOldChestItem(String path, Mapping<Item> mapping)
{
if (path.endsWith("blockironchest"))
{
path = path.replace("blockironchest", "iron_chest");
ResourceLocation newRes = new ResourceLocation(mapping.key.getResourceDomain(), path);
Item item = ForgeRegistries.ITEMS.getValue(newRes);
if (item != null)
{
mapping.remap(item);
}
}
}
private static void replaceOldUpgrades(String path, Mapping<Item> mapping)
{ {
if (path.endsWith("irongoldupgrade")) if (path.endsWith("irongoldupgrade"))
{ {
@ -120,7 +137,7 @@ public class MissingMappingsHandler
} }
} }
private static void replaceNewUpgrades(String path, MissingMapping mapping) private static void replaceNewUpgrades(String path, Mapping<Item> mapping)
{ {
if (path.endsWith("iron_gold_upgrade")) if (path.endsWith("iron_gold_upgrade"))
{ {
@ -177,9 +194,9 @@ public class MissingMappingsHandler
} }
} }
private static void replaceUpgradeItem(String path, MissingMapping mapping) private static void replaceUpgradeItem(String path, Mapping<Item> mapping)
{ {
ResourceLocation newRes = new ResourceLocation(mapping.resourceLocation.getResourceDomain(), path); ResourceLocation newRes = new ResourceLocation(mapping.key.getResourceDomain(), path);
Item item = ForgeRegistries.ITEMS.getValue(newRes); Item item = ForgeRegistries.ITEMS.getValue(newRes);
if (item != null) if (item != null)