Skip to content

Commit

Permalink
General: Could @Adaptivity update the localizations for all of the ne…
Browse files Browse the repository at this point in the history
…w items
  • Loading branch information
tattyseal committed Oct 15, 2014
1 parent bcdaa4c commit bf9cce3
Show file tree
Hide file tree
Showing 21 changed files with 246 additions and 35 deletions.
4 changes: 4 additions & 0 deletions src/main/java/me/modforgery/cc/CompactChests.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import me.modforgery.cc.client.render.RenderChest;
import me.modforgery.cc.configuration.ConfigurationHandler;
import me.modforgery.cc.creativetabs.CreativeTabChest;
import me.modforgery.cc.event.CCHandler;
import me.modforgery.cc.init.ChestBlocks;
import me.modforgery.cc.init.ChestItems;
import me.modforgery.cc.init.ChestReferences;
Expand All @@ -32,6 +33,7 @@
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.MinecraftForge;

/**
* Created by Toby on 19/08/2014.
Expand Down Expand Up @@ -76,6 +78,8 @@ public void postInitialization(FMLPostInitializationEvent fmlPostInitializationE

proxy.registerRenderers();

MinecraftForge.EVENT_BUS.register(new CCHandler());

switch(difficulty)
{
case 0:
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/me/modforgery/cc/block/BlockChest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.modforgery.cc.block;

import me.modforgery.cc.CompactChests;
import me.modforgery.cc.tileentity.TileEntityChest;
import me.modforgery.cc.tileentity.TileEntityDoubleChest;
import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
Expand All @@ -12,6 +13,8 @@
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

Expand Down Expand Up @@ -54,8 +57,13 @@ public boolean isOpaqueCube()
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float j, float k, float l)
{
player.openGui(CompactChests.instance(), guiID, world, x, y, z);
return true;
if(!player.isSneaking())
{
player.openGui(CompactChests.instance(), guiID, world, x, y, z);
return true;
}

return false;
}

/**
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/me/modforgery/cc/block/BlockSextupleChest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package me.modforgery.cc.block;

import me.modforgery.cc.creativetabs.CreativeTabChest;
import me.modforgery.cc.tileentity.TileEntityQuintupleChest;
import me.modforgery.cc.tileentity.TileEntitySextupleChest;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

/**
* Created by Toby on 19/08/2014.
*/
public class BlockSextupleChest extends BlockChest
{
public BlockSextupleChest()
{
super(4);

setBlockName("sextuplechest");
setHardness(1f);
setResistance(1f);

setCreativeTab(CreativeTabChest.tab);
}

@Override
public TileEntity createNewTileEntity(World world, int dim)
{
return new TileEntitySextupleChest();
}
}
4 changes: 4 additions & 0 deletions src/main/java/me/modforgery/cc/client/GuiHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ public Object getServerGuiElement(int ID, EntityPlayer player, World world, int
case 1: return new ContainerTripleChest(player, world, x, y, z, false);
case 2: return new ContainerQuadrupleChest(player, world, x, y, z, false);
case 3: return new ContainerQuintupleChest(player, world, x, y, z, false);
case 4: return new ContainerSextupleChest(player, world, x, y, z, false);
case 100: return new ContainerSingleChest(player, world, x, y, z, true);
case 101: return new ContainerDoubleChest(player, world, x, y, z, true);
case 102: return new ContainerTripleChest(player, world, x, y, z, true);
case 103: return new ContainerQuadrupleChest(player, world, x, y, z, true);
case 104: return new ContainerQuintupleChest(player, world, x, y, z, true);
case 105: return new ContainerSextupleChest(player, world, x, y, z, true);
default: return null;
}
}
Expand All @@ -38,11 +40,13 @@ public Object getClientGuiElement(int ID, EntityPlayer player, World world, int
case 1: return new GuiTripleChest((Container) getServerGuiElement(ID, player, world, x, y, z), player, world, x, y, z);
case 2: return new GuiQuadrupleChest((Container) getServerGuiElement(ID, player, world, x, y, z), player, world, x, y, z);
case 3: return new GuiQuintupleChest((Container) getServerGuiElement(ID, player, world, x, y, z), player, world, x, y, z);
case 4: return new GuiSextupleChest((Container) getServerGuiElement(ID, player, world, x, y, z), player, world, x, y, z);
case 100: return new GuiSingleChest((Container) getServerGuiElement(ID, player, world, x, y, z), player, world, x, y, z);
case 101: return new GuiDoubleChest((Container) getServerGuiElement(ID, player, world, x, y, z), player, world, x, y, z);
case 102: return new GuiTripleChest((Container) getServerGuiElement(ID, player, world, x, y, z), player, world, x, y, z);
case 103: return new GuiQuadrupleChest((Container) getServerGuiElement(ID, player, world, x, y, z), player, world, x, y, z);
case 104: return new GuiQuintupleChest((Container) getServerGuiElement(ID, player, world, x, y, z), player, world, x, y, z);
case 105: return new GuiSextupleChest((Container) getServerGuiElement(ID, player, world, x, y, z), player, world, x, y, z);
default: return null;
}
}
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/me/modforgery/cc/client/GuiSextupleChest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package me.modforgery.cc.client;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.world.World;

/**
* Created by Toby on 19/08/2014.
*/
public class GuiSextupleChest extends GuiChest
{
public GuiSextupleChest(Container serverGuiElement, EntityPlayer player, World world, int x, int y, int z)
{
super("sextuple", 338, 256, serverGuiElement, player, world, x, y, z, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void renderTileEntityAt(TileEntityChest chest, double x, double y, double
GL11.glPopMatrix();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

ItemStack stack = chest.getStackInSlot(0);
ItemStack stack = chest.getStackInSlot(0);//chest.getSizeInventory() - 1);

if(stack != null)
{
Expand Down
63 changes: 63 additions & 0 deletions src/main/java/me/modforgery/cc/event/CCHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package me.modforgery.cc.event;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import me.modforgery.cc.block.BlockChest;
import me.modforgery.cc.init.ChestBlocks;
import me.modforgery.cc.tileentity.TileEntityChest;
import net.minecraft.block.Block;
import net.minecraft.entity.item.EntityTNTPrimed;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;

/**
* Created by Toby on 18/09/2014.
*/
public class CCHandler
{
@SubscribeEvent
public void onEntity(EntityJoinWorldEvent event)
{
if(event.entity instanceof EntityTNTPrimed)
{
EntityTNTPrimed tnt = (EntityTNTPrimed) event.entity;

if(event.world.getTileEntity((int) tnt.posX, (int) tnt.posY - 1, (int) tnt.posZ) instanceof TileEntityChest)
{
TileEntityChest chest = (TileEntityChest) event.world.getTileEntity((int) tnt.posX, (int) tnt.posY - 1, (int) tnt.posZ);

ItemStack[] items = chest.items;

BlockChest block = (BlockChest) event.world.getBlock((int) tnt.posX, (int) tnt.posY - 1, (int) tnt.posZ);

Block upgradeTo = ChestBlocks.doubleChest;

if(block == ChestBlocks.doubleChest)
{
upgradeTo = ChestBlocks.tripleChest;
}
else if(block == ChestBlocks.tripleChest)
{
upgradeTo = ChestBlocks.quadrupleChest;
}
else if(block == ChestBlocks.quadrupleChest)
{
upgradeTo = ChestBlocks.quintupleChest;
}
else if(block == ChestBlocks.quintupleChest)
{
return;
}

event.world.createExplosion(tnt, tnt.posX, tnt.posY, tnt.posZ, 2f, false);
tnt.setDead();

event.world.setBlock((int) tnt.posX, (int) tnt.posY - 1, (int) tnt.posZ, Blocks.air);
event.world.setTileEntity((int) tnt.posX, (int) tnt.posY - 1, (int) tnt.posZ, null);

event.world.setBlock((int) tnt.posX, (int) tnt.posY - 1, (int) tnt.posZ, upgradeTo);
//((TileEntityChest) event.world.getTileEntity((int) tnt.posX, (int) tnt.posY - 1, (int) tnt.posZ)).items = items;
}
}
}
}
15 changes: 7 additions & 8 deletions src/main/java/me/modforgery/cc/init/ChestBlocks.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
package me.modforgery.cc.init;

import cpw.mods.fml.common.registry.GameRegistry;
import me.modforgery.cc.block.BlockDoubleChest;
import me.modforgery.cc.block.BlockQuadrupleChest;
import me.modforgery.cc.block.BlockQuintupleChest;
import me.modforgery.cc.block.BlockTripleChest;
import me.modforgery.cc.tileentity.TileEntityDoubleChest;
import me.modforgery.cc.tileentity.TileEntityQuadrupleChest;
import me.modforgery.cc.tileentity.TileEntityQuintupleChest;
import me.modforgery.cc.tileentity.TileEntityTripleChest;
import me.modforgery.cc.block.*;
import me.modforgery.cc.tileentity.*;
import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;

Expand All @@ -21,6 +15,7 @@ public class ChestBlocks
public static Block tripleChest;
public static Block quadrupleChest;
public static Block quintupleChest;
public static Block sextupleChest;

public static void init()
{
Expand All @@ -39,5 +34,9 @@ public static void init()
quintupleChest = new BlockQuintupleChest();
GameRegistry.registerBlock(quintupleChest, "quintupleChest");
GameRegistry.registerTileEntity(TileEntityQuintupleChest.class, "quintupleChest");

sextupleChest = new BlockSextupleChest();
GameRegistry.registerBlock(sextupleChest, "sextupleChest");
GameRegistry.registerTileEntity(TileEntitySextupleChest.class, "sextupleChest");
}
}
5 changes: 5 additions & 0 deletions src/main/java/me/modforgery/cc/init/ChestItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class ChestItems
public static Item triple_backpack;
public static Item quadruple_backpack;
public static Item quintuple_backpack;
public static Item sextuple_backpack;


public static void init()
{
Expand All @@ -31,5 +33,8 @@ public static void init()

quintuple_backpack = new ItemQuintupleBackpack();
GameRegistry.registerItem(quintuple_backpack, "quintuple_backpack");

sextuple_backpack = new ItemSextupleBackpack();
GameRegistry.registerItem(sextuple_backpack, "sextuple_backpack");
}
}
12 changes: 12 additions & 0 deletions src/main/java/me/modforgery/cc/item/ItemSextupleBackpack.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package me.modforgery.cc.item;

/**
* Created by Toby on 28/08/2014.
*/
public class ItemSextupleBackpack extends ItemBackpack
{
public ItemSextupleBackpack()
{
super(5);
}
}
8 changes: 4 additions & 4 deletions src/main/java/me/modforgery/cc/proxy/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
import me.modforgery.cc.client.render.ChestItemRenderer;
import me.modforgery.cc.client.render.RenderChest;
import me.modforgery.cc.init.ChestBlocks;
import me.modforgery.cc.tileentity.TileEntityDoubleChest;
import me.modforgery.cc.tileentity.TileEntityQuadrupleChest;
import me.modforgery.cc.tileentity.TileEntityQuintupleChest;
import me.modforgery.cc.tileentity.TileEntityTripleChest;
import me.modforgery.cc.tileentity.*;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.client.MinecraftForgeClient;

Expand All @@ -24,11 +21,14 @@ public void registerRenderers()
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTripleChest.class, new RenderChest("triple"));
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityQuadrupleChest.class, new RenderChest("quadruple"));
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityQuintupleChest.class, new RenderChest("quintuple"));
ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySextupleChest.class, new RenderChest("sextuple"));

MinecraftForgeClient.registerItemRenderer(ItemBlock.getItemFromBlock(ChestBlocks.doubleChest), new ChestItemRenderer("double"));
MinecraftForgeClient.registerItemRenderer(ItemBlock.getItemFromBlock(ChestBlocks.tripleChest), new ChestItemRenderer("triple"));
MinecraftForgeClient.registerItemRenderer(ItemBlock.getItemFromBlock(ChestBlocks.quadrupleChest), new ChestItemRenderer("quadruple"));
MinecraftForgeClient.registerItemRenderer(ItemBlock.getItemFromBlock(ChestBlocks.quintupleChest), new ChestItemRenderer("quintuple"));
MinecraftForgeClient.registerItemRenderer(ItemBlock.getItemFromBlock(ChestBlocks.sextupleChest), new ChestItemRenderer("sextuple"));

}

@Override
Expand Down
Loading

0 comments on commit bf9cce3

Please sign in to comment.