Obsidian chests, phase 1, hopefully separated from the 1.5 update code
This commit is contained in:
parent
5a057fad2c
commit
ad0fe8a429
|
@ -19,6 +19,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import net.minecraft.block.BlockContainer;
|
import net.minecraft.block.BlockContainer;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLiving;
|
import net.minecraft.entity.EntityLiving;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -227,7 +228,7 @@ public class BlockIronChest extends BlockContainer {
|
||||||
entityitem.motionZ = (float) random.nextGaussian() * f3;
|
entityitem.motionZ = (float) random.nextGaussian() * f3;
|
||||||
if (itemstack.hasTagCompound())
|
if (itemstack.hasTagCompound())
|
||||||
{
|
{
|
||||||
entityitem.func_92014_d().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
|
entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
|
||||||
}
|
}
|
||||||
world.spawnEntityInWorld(entityitem);
|
world.spawnEntityInWorld(entityitem);
|
||||||
}
|
}
|
||||||
|
@ -247,4 +248,19 @@ public class BlockIronChest extends BlockContainer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ)
|
||||||
|
{
|
||||||
|
TileEntity te = world.getBlockTileEntity(x, y, z);
|
||||||
|
if (te instanceof TileEntityIronChest)
|
||||||
|
{
|
||||||
|
TileEntityIronChest teic = (TileEntityIronChest) te;
|
||||||
|
if (teic.getType().isExplosionResistant())
|
||||||
|
{
|
||||||
|
return 10000f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.getExplosionResistance(par1Entity, world, x, y, z, explosionX, explosionY, explosionZ);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ public enum IronChestType {
|
||||||
COPPER(45, 9, false, "Copper Chest", "copperchest.png", 3, Arrays.asList("ingotCopper"), TileEntityCopperChest.class, "mmmmCmmmm"),
|
COPPER(45, 9, false, "Copper Chest", "copperchest.png", 3, Arrays.asList("ingotCopper"), TileEntityCopperChest.class, "mmmmCmmmm"),
|
||||||
SILVER(72, 9, false, "Silver Chest", "silverchest.png", 4, Arrays.asList("ingotSilver"), TileEntitySilverChest.class, "mmmm3mmmm", "mGmG0GmGm"),
|
SILVER(72, 9, false, "Silver Chest", "silverchest.png", 4, Arrays.asList("ingotSilver"), TileEntitySilverChest.class, "mmmm3mmmm", "mGmG0GmGm"),
|
||||||
CRYSTAL(108, 12, true, "Crystal Chest", "crystalchest.png", 5, Arrays.asList("blockGlass"), TileEntityCrystalChest.class, "GGGGPGGGG"),
|
CRYSTAL(108, 12, true, "Crystal Chest", "crystalchest.png", 5, Arrays.asList("blockGlass"), TileEntityCrystalChest.class, "GGGGPGGGG"),
|
||||||
|
OBSIDIAN(108, 12, false, "Obsidian Chest", "obsidianchest.png", 6, Arrays.asList("obsidian"), TileEntityObsidianChest.class, "OOOO4OOOO"),
|
||||||
WOOD(0, 0, false, "", "", -1, Arrays.asList("blockPlanks"), null);
|
WOOD(0, 0, false, "", "", -1, Arrays.asList("blockPlanks"), null);
|
||||||
int size;
|
int size;
|
||||||
private int rowLength;
|
private int rowLength;
|
||||||
|
@ -194,4 +195,9 @@ public enum IronChestType {
|
||||||
return validateMeta(ordinal()) == ordinal();
|
return validateMeta(ordinal()) == ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isExplosionResistant()
|
||||||
|
{
|
||||||
|
return this == OBSIDIAN;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package cpw.mods.ironchest;
|
||||||
|
|
||||||
|
public class TileEntityObsidianChest extends TileEntityIronChest {
|
||||||
|
|
||||||
|
public TileEntityObsidianChest()
|
||||||
|
{
|
||||||
|
super(IronChestType.OBSIDIAN);
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,10 +22,13 @@ import cpw.mods.ironchest.TileEntityIronChest;
|
||||||
|
|
||||||
public class GUIChest extends GuiContainer {
|
public class GUIChest extends GuiContainer {
|
||||||
public enum GUI {
|
public enum GUI {
|
||||||
IRON(184, 202, "/cpw/mods/ironchest/sprites/ironcontainer.png", IronChestType.IRON), GOLD(184, 256, "/cpw/mods/ironchest/sprites/goldcontainer.png",
|
IRON(184, 202, "/cpw/mods/ironchest/sprites/ironcontainer.png", IronChestType.IRON),
|
||||||
IronChestType.GOLD), DIAMOND(238, 256, "/cpw/mods/ironchest/sprites/diamondcontainer.png", IronChestType.DIAMOND), COPPER(184, 184,
|
GOLD(184, 256, "/cpw/mods/ironchest/sprites/goldcontainer.png", IronChestType.GOLD),
|
||||||
"/cpw/mods/ironchest/sprites/coppercontainer.png", IronChestType.COPPER), SILVER(184, 238, "/cpw/mods/ironchest/sprites/silvercontainer.png",
|
DIAMOND(238, 256, "/cpw/mods/ironchest/sprites/diamondcontainer.png", IronChestType.DIAMOND),
|
||||||
IronChestType.SILVER), CRYSTAL(238, 256, "/cpw/mods/ironchest/sprites/diamondcontainer.png", IronChestType.CRYSTAL);
|
COPPER(184, 184, "/cpw/mods/ironchest/sprites/coppercontainer.png", IronChestType.COPPER),
|
||||||
|
SILVER(184, 238, "/cpw/mods/ironchest/sprites/silvercontainer.png", IronChestType.SILVER),
|
||||||
|
CRYSTAL(238, 256, "/cpw/mods/ironchest/sprites/diamondcontainer.png", IronChestType.CRYSTAL),
|
||||||
|
OBSIDIAN(238, 256, "/cpw/mods/ironchest/sprites/diamondcontainer.png", IronChestType.OBSIDIAN);
|
||||||
|
|
||||||
private int xSize;
|
private int xSize;
|
||||||
private int ySize;
|
private int ySize;
|
||||||
|
|
|
@ -39,6 +39,7 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.client.IItemRenderer;
|
import net.minecraftforge.client.IItemRenderer;
|
||||||
import net.minecraftforge.client.MinecraftForgeClient;
|
import net.minecraftforge.client.MinecraftForgeClient;
|
||||||
|
@ -75,31 +76,22 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
|
||||||
public byte getMiniBlockCountForItemStack(ItemStack stack) {
|
public byte getMiniBlockCountForItemStack(ItemStack stack) {
|
||||||
return SignedBytes.saturatedCast(Math.min(stack.stackSize / 32, 15) + 1);
|
return SignedBytes.saturatedCast(Math.min(stack.stackSize / 32, 15) + 1);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public byte getMiniItemCountForItemStack(ItemStack stack) {
|
public byte getMiniItemCountForItemStack(ItemStack stack) {
|
||||||
return SignedBytes.saturatedCast(Math.min(stack.stackSize / 32, 7) + 1);
|
return SignedBytes.saturatedCast(Math.min(stack.stackSize / 32, 7) + 1);
|
||||||
};
|
}
|
||||||
|
@Override
|
||||||
public boolean shouldBob() {
|
public boolean shouldBob() {
|
||||||
return false;
|
return false;
|
||||||
};
|
}
|
||||||
|
@Override
|
||||||
public boolean shouldSpreadItems() {
|
public boolean shouldSpreadItems() {
|
||||||
return false;
|
return false;
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
itemRenderer.setRenderManager(RenderManager.instance);
|
itemRenderer.setRenderManager(RenderManager.instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void overrideTexture(Object obj)
|
|
||||||
{
|
|
||||||
if (obj instanceof Item)
|
|
||||||
{
|
|
||||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(((Item) obj).getTextureFile()));
|
|
||||||
}
|
|
||||||
else if (obj instanceof Block)
|
|
||||||
{
|
|
||||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(((Block) obj).getTextureFile()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void render(TileEntityIronChest tile, double x, double y, double z, float partialTick) {
|
public void render(TileEntityIronChest tile, double x, double y, double z, float partialTick) {
|
||||||
if (tile == null) {
|
if (tile == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -176,7 +168,7 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
|
||||||
glTranslatef(shiftX, shiftY, shiftZ);
|
glTranslatef(shiftX, shiftY, shiftZ);
|
||||||
glRotatef(timeD, 0.0F, 1.0F, 0.0F);
|
glRotatef(timeD, 0.0F, 1.0F, 0.0F);
|
||||||
glScalef(blockScale, blockScale, blockScale);
|
glScalef(blockScale, blockScale, blockScale);
|
||||||
customitem.func_92013_a(item);
|
customitem.func_92058_a(item);
|
||||||
itemRenderer.doRenderItem(customitem, 0, 0, 0, 0, 0);
|
itemRenderer.doRenderItem(customitem, 0, 0, 0, 0, 0);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 5.7 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
Binary file not shown.
Loading…
Reference in New Issue