Changes and stuff

This commit is contained in:
ganymedes01 2014-12-02 18:25:03 -02:00
parent 4e8a047082
commit 9a26003f86
9 changed files with 107 additions and 104 deletions

View File

@ -10,6 +10,7 @@
******************************************************************************/
package cpw.mods.ironchest;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@ -20,6 +21,7 @@ import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
@ -32,10 +34,14 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MathHelper;
import net.minecraft.world.Explosion;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import com.google.common.collect.Lists;
public class BlockIronChest extends BlockContainer
{
public static final PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", IronChestType.class);
@ -80,10 +86,10 @@ public class BlockIronChest extends BlockContainer
return true;
}
/*if (world.isSideSolid(i, j + 1, k, ForgeDirection.DOWN))
if (world.isSideSolid(pos.add(0, 1, 0), EnumFacing.DOWN))
{
return true;
}*/
}
if (world.isRemote)
{
@ -131,15 +137,15 @@ public class BlockIronChest extends BlockContainer
return new BlockState(this, new IProperty[] { VARIANT_PROP });
}
/*@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune)
@Override
public ArrayList<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
{
ArrayList<ItemStack> items = Lists.newArrayList();
ItemStack stack = new ItemStack(this,1,metadata);
IronChestType.values()[IronChestType.validateMeta(metadata)].adornItemDrop(stack);
ItemStack stack = new ItemStack(this,1,getMetaFromState(state));
IronChestType.values()[IronChestType.validateMeta(getMetaFromState(state))].adornItemDrop(stack);
items.add(stack);
return items;
}*/
}
@Override
public void onBlockAdded(World world, BlockPos pos, IBlockState blockState)
@ -234,20 +240,20 @@ 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)
@Override
public float getExplosionResistance(World world, BlockPos pos, Entity exploder, Explosion explosion)
{
TileEntity te = world.getTileEntity(x, y, z);
TileEntity te = world.getTileEntity(pos);
if (te instanceof TileEntityIronChest)
{
TileEntityIronChest teic = (TileEntityIronChest) te;
if (teic.getType().isExplosionResistant())
{
return 10000f;
return 10000F;
}
}
return super.getExplosionResistance(par1Entity, world, x, y, z, explosionX, explosionY, explosionZ);
}*/
return super.getExplosionResistance(world, pos, exploder, explosion);
}
@Override
public boolean hasComparatorInputOverride() {
@ -265,30 +271,29 @@ public class BlockIronChest extends BlockContainer
return 0;
}
/*private static final ForgeDirection[] validRotationAxes = new ForgeDirection[] { UP, DOWN };
private static final EnumFacing[] validRotationAxes = new EnumFacing[] { EnumFacing.UP, EnumFacing.DOWN };
@Override
public ForgeDirection[] getValidRotations(World worldObj, int x, int y, int z)
public EnumFacing[] getValidRotations(World worldObj, BlockPos pos)
{
return validRotationAxes;
}
@Override
public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis)
public boolean rotateBlock(World worldObj, BlockPos pos, EnumFacing axis)
{
if (worldObj.isRemote)
{
return false;
}
if (axis == UP || axis == DOWN)
if (axis == EnumFacing.UP || axis == EnumFacing.DOWN)
{
TileEntity tileEntity = worldObj.getTileEntity(x, y, z);
TileEntity tileEntity = worldObj.getTileEntity(pos);
if (tileEntity instanceof TileEntityIronChest) {
TileEntityIronChest icte = (TileEntityIronChest) tileEntity;
icte.rotateAround(axis);
icte.rotateAround();
}
return true;
}
return false;
}*/
}
}
}

View File

@ -14,14 +14,10 @@ import static cpw.mods.ironchest.IronChestType.IRON;
import static cpw.mods.ironchest.IronChestType.OBSIDIAN;
import static cpw.mods.ironchest.IronChestType.SILVER;
import static cpw.mods.ironchest.IronChestType.WOOD;
import cpw.mods.ironchest.client.ModelHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import cpw.mods.ironchest.client.ModelHelper;
public enum ChestChangerType {
IRONGOLD(IRON, GOLD, "ironGoldUpgrade", "Iron to Gold Chest Upgrade", "mmm", "msm", "mmm"),

View File

@ -12,6 +12,7 @@ package cpw.mods.ironchest;
import net.minecraft.client.Minecraft;
import net.minecraft.init.Blocks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
@ -40,8 +41,6 @@ public class IronChest
PacketHandler.INSTANCE.ordinal();
}
private static boolean run = false;
@EventHandler
public void load(FMLInitializationEvent evt)
{
@ -63,9 +62,6 @@ public class IronChest
ChestChangerType.generateRecipes();
NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);
proxy.registerRenderInformation();
// if (OCELOTS_SITONCHESTS)
// {
// MinecraftForge.EVENT_BUS.register(new OcelotsSitOnChestsHandler());
// }
MinecraftForge.EVENT_BUS.register(new OcelotsSitOnChestsHandler());
}
}

View File

@ -2,6 +2,8 @@ package cpw.mods.ironchest;
import net.minecraft.entity.ai.EntityAIOcelotSit;
import net.minecraft.entity.passive.EntityOcelot;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public class IronChestAIOcelotSit extends EntityAIOcelotSit
{
@ -10,13 +12,13 @@ public class IronChestAIOcelotSit extends EntityAIOcelotSit
super(par1EntityOcelot, par2);
}
/* @Override
protected boolean func_151486_a(World world, int x, int y, int z)
@Override
protected boolean func_179488_a(World world, BlockPos pos)
{
if (world.getBlock(x, y, z) == IronChest.ironChestBlock)
if (world.getBlockState(pos).getBlock() == IronChest.ironChestBlock)
{
return true;
}
return super.func_151486_a(world, x, y, z);
return super.func_179488_a(world, pos);
}
*/}
}

View File

@ -15,7 +15,6 @@ import java.util.Arrays;
import java.util.List;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
@ -204,9 +203,6 @@ public enum IronChestType implements IStringSerializable
return this == OBSIDIAN;
}
private static String[] sideNames = { "top", "front", "side" };
private static int[] sideMapping = { 0, 0, 2, 1, 2, 2, 2 };
public Slot makeSlot(IInventory chestInventory, int index, int x, int y)
{
return new ValidatingSlot(chestInventory, index, x, y, this);
@ -216,6 +212,7 @@ public enum IronChestType implements IStringSerializable
{
return itemFilter == null || itemstack == null || itemstack.getItem() == itemFilter;
}
public void adornItemDrop(ItemStack item)
{
if (this == DIRTCHEST9000)
@ -223,4 +220,4 @@ public enum IronChestType implements IStringSerializable
item.setTagInfo("dirtchest", new NBTTagByte((byte) 1));
}
}
}
}

View File

@ -10,7 +10,6 @@
******************************************************************************/
package cpw.mods.ironchest;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
@ -22,8 +21,6 @@ import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemChestChanger extends Item
{

View File

@ -5,9 +5,11 @@ import java.util.List;
import net.minecraft.entity.ai.EntityAIOcelotSit;
import net.minecraft.entity.ai.EntityAITasks;
import net.minecraft.entity.passive.EntityOcelot;
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
/*public class OcelotsSitOnChestsHandler {
public class OcelotsSitOnChestsHandler {
@SubscribeEvent
public void changeSittingTaskForOcelots(LivingEvent.LivingUpdateEvent evt)
{
@ -24,4 +26,4 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
}
}
}
}*/
}

View File

@ -26,6 +26,7 @@ import net.minecraft.network.Packet;
import net.minecraft.server.gui.IUpdatePlayerListBox;
import net.minecraft.tileentity.TileEntityLockable;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.EnumFacing;
public class TileEntityIronChest extends TileEntityLockable implements IUpdatePlayerListBox, IInventory
{
@ -519,13 +520,16 @@ public class TileEntityIronChest extends TileEntityLockable implements IUpdatePl
return type.acceptsStack(itemstack);
}
/*void rotateAround(ForgeDirection axis)
void rotateAround()
{
setFacing((byte)ForgeDirection.getOrientation(facing).getRotation(axis).ordinal());
worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, IronChest.ironChestBlock, 2, getFacing());
}*/
facing++;
if(facing > EnumFacing.EAST.ordinal())
{
facing = EnumFacing.NORTH.ordinal();
}
setFacing(facing);
worldObj.addBlockEvent(pos, IronChest.ironChestBlock, 2, facing);
}
public void wasPlaced(EntityLivingBase entityliving, ItemStack itemStack)
{
@ -568,5 +572,10 @@ public class TileEntityIronChest extends TileEntityLockable implements IUpdatePl
{
return "IronChest:" + type.name();
}
}
@Override
public boolean canRenderBreaking()
{
return true;
}
}

View File

@ -10,25 +10,14 @@
******************************************************************************/
package cpw.mods.ironchest.client;
import static org.lwjgl.opengl.GL11.glColor4f;
import static org.lwjgl.opengl.GL11.glDisable;
import static org.lwjgl.opengl.GL11.glEnable;
import static org.lwjgl.opengl.GL11.glPopMatrix;
import static org.lwjgl.opengl.GL11.glPushMatrix;
import static org.lwjgl.opengl.GL11.glRotatef;
import static org.lwjgl.opengl.GL11.glScalef;
import static org.lwjgl.opengl.GL11.glTranslatef;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelChest;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.RenderEntityItem;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
@ -37,17 +26,15 @@ import net.minecraft.util.ResourceLocation;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.primitives.SignedBytes;
import cpw.mods.ironchest.BlockIronChest;
import cpw.mods.ironchest.IronChest;
import cpw.mods.ironchest.IronChestType;
import cpw.mods.ironchest.MappableItemStackWrapper;
import cpw.mods.ironchest.TileEntityIronChest;
public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer
{
private static Map<MappableItemStackWrapper, Integer> renderList = new HashMap<MappableItemStackWrapper, Integer>();
private static Map<IronChestType, ResourceLocation> locations;
static {
@ -69,16 +56,12 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer
{
model = new ModelChest();
random = new Random();
itemRenderer = new RenderEntityItem(Minecraft.getMinecraft().getRenderManager(), Minecraft.getMinecraft().getRenderItem()); /*{
itemRenderer = new RenderEntityItem(Minecraft.getMinecraft().getRenderManager(), Minecraft.getMinecraft().getRenderItem()){
@Override
public byte getMiniBlockCount(ItemStack stack, byte original) {
public int func_177078_a(ItemStack stack) {
return SignedBytes.saturatedCast(Math.min(stack.stackSize / 32, 15) + 1);
}
@Override
public byte getMiniItemCount(ItemStack stack, byte original) {
return SignedBytes.saturatedCast(Math.min(stack.stackSize / 32, 7) + 1);
}
@Override
public boolean shouldBob() {
return false;
}
@ -86,10 +69,10 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer
public boolean shouldSpreadItems() {
return false;
}
};*/
};
}
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, int breakStage)
{
if (tile == null) {
return;
@ -104,12 +87,23 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer
type = (IronChestType)state.getValue(BlockIronChest.VARIANT_PROP);
}
bindTexture(locations.get(type));
glPushMatrix();
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F);
glScalef(1.0F, -1F, -1F);
glTranslatef(0.5F, 0.5F, 0.5F);
if (breakStage >= 0)
{
bindTexture(DESTROY_STAGES[breakStage]);
GlStateManager.matrixMode(5890);
GlStateManager.pushMatrix();
GlStateManager.scale(4.0F, 4.0F, 1.0F);
GlStateManager.translate(0.0625F, 0.0625F, 0.0625F);
GlStateManager.matrixMode(5888);
} else
bindTexture(locations.get(type));
GlStateManager.pushMatrix();
if(type == IronChestType.CRYSTAL)
GlStateManager.disableCull();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.translate((float) x, (float) y + 1.0F, (float) z + 1.0F);
GlStateManager.scale(1.0F, -1F, -1F);
GlStateManager.translate(0.5F, 0.5F, 0.5F);
int k = 0;
if (facing == 2) {
k = 180;
@ -123,16 +117,25 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer
if (facing == 5) {
k = -90;
}
glRotatef(k, 0.0F, 1.0F, 0.0F);
glTranslatef(-0.5F, -0.5F, -0.5F);
GlStateManager.rotate(k, 0.0F, 1.0F, 0.0F);
GlStateManager.translate(-0.5F, -0.5F, -0.5F);
float lidangle = tile.prevLidAngle + (tile.lidAngle - tile.prevLidAngle) * partialTick;
lidangle = 1.0F - lidangle;
lidangle = 1.0F - lidangle * lidangle * lidangle;
model.chestLid.rotateAngleX = -((lidangle * 3.141593F) / 2.0F);
// Render the chest itself
model.renderAll();
glPopMatrix();
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
if (breakStage >= 0)
{
GlStateManager.matrixMode(5890);
GlStateManager.popMatrix();
GlStateManager.matrixMode(5888);
}
if(type == IronChestType.CRYSTAL)
GlStateManager.enableCull();
GlStateManager.popMatrix();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
if (type.isTransparent() && tile.getDistanceSq(this.rendererDispatcher.field_147560_j, this.rendererDispatcher.field_147561_k, this.rendererDispatcher.field_147558_l) < 128d) {
random.setSeed(254L);
float shiftX;
@ -145,9 +148,8 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer
shift = 8;
blockScale = 0.85F;
}
glPushMatrix();
glDisable(2896 /* GL_LIGHTING */);
glTranslatef((float) x, (float) y, (float) z);
GlStateManager.pushMatrix();
GlStateManager.translate((float) x, (float) y, (float) z);
EntityItem customitem = new EntityItem(this.getWorld());
customitem.hoverStart = 0f;
for (ItemStack item : tile.getTopItemStacks()) {
@ -162,24 +164,21 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer
shiftY = shifts[shift][1];
shiftZ = shifts[shift][2];
shift++;
glPushMatrix();
glTranslatef(shiftX, shiftY, shiftZ);
glRotatef(timeD, 0.0F, 1.0F, 0.0F);
glScalef(blockScale, blockScale, blockScale);
GlStateManager.pushMatrix();
GlStateManager.translate(shiftX, shiftY, shiftZ);
GlStateManager.rotate(timeD, 0.0F, 1.0F, 0.0F);
GlStateManager.scale(blockScale, blockScale, blockScale);
customitem.setEntityItemStack(item);
itemRenderer.doRender(customitem, 0, 0, 0, 0, 0);
glPopMatrix();
GlStateManager.popMatrix();
}
glEnable(2896 /* GL_LIGHTING */);
glPopMatrix();
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.popMatrix();
}
}
@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partialTick, int p_180535_9_)
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partialTick, int breakStage)
{
render((TileEntityIronChest) tileentity, x, y, z, partialTick);
render((TileEntityIronChest) tileentity, x, y, z, partialTick, breakStage);
}
}
}