Work on bins! :)

This commit is contained in:
Aidan Brady 2013-11-11 19:27:36 -05:00
parent f6704dc5ea
commit 1ac243f091
24 changed files with 574 additions and 14 deletions

View file

@ -38,9 +38,9 @@ import mekanism.client.render.block.TransmitterRenderingHandler;
import mekanism.client.render.entity.RenderObsidianTNTPrimed; import mekanism.client.render.entity.RenderObsidianTNTPrimed;
import mekanism.client.render.entity.RenderRobit; import mekanism.client.render.entity.RenderRobit;
import mekanism.client.render.item.ItemRenderingHandler; import mekanism.client.render.item.ItemRenderingHandler;
import mekanism.client.render.tileentity.RenderBin;
import mekanism.client.render.tileentity.RenderChargepad; import mekanism.client.render.tileentity.RenderChargepad;
import mekanism.client.render.tileentity.RenderConfigurableMachine; import mekanism.client.render.tileentity.RenderConfigurableMachine;
import mekanism.client.render.tileentity.RenderCrusher;
import mekanism.client.render.tileentity.RenderDynamicTank; import mekanism.client.render.tileentity.RenderDynamicTank;
import mekanism.client.render.tileentity.RenderElectricChest; import mekanism.client.render.tileentity.RenderElectricChest;
import mekanism.client.render.tileentity.RenderElectricPump; import mekanism.client.render.tileentity.RenderElectricPump;
@ -64,6 +64,7 @@ import mekanism.common.inventory.InventoryElectricChest;
import mekanism.common.item.ItemPortableTeleporter; import mekanism.common.item.ItemPortableTeleporter;
import mekanism.common.tileentity.TileEntityAdvancedElectricMachine; import mekanism.common.tileentity.TileEntityAdvancedElectricMachine;
import mekanism.common.tileentity.TileEntityAdvancedFactory; import mekanism.common.tileentity.TileEntityAdvancedFactory;
import mekanism.common.tileentity.TileEntityBin;
import mekanism.common.tileentity.TileEntityChargepad; import mekanism.common.tileentity.TileEntityChargepad;
import mekanism.common.tileentity.TileEntityCombiner; import mekanism.common.tileentity.TileEntityCombiner;
import mekanism.common.tileentity.TileEntityCrusher; import mekanism.common.tileentity.TileEntityCrusher;
@ -243,6 +244,7 @@ public class ClientProxy extends CommonProxy
ClientRegistry.registerTileEntity(TileEntityChargepad.class, "Chargepad", new RenderChargepad()); ClientRegistry.registerTileEntity(TileEntityChargepad.class, "Chargepad", new RenderChargepad());
ClientRegistry.registerTileEntity(TileEntityLogisticalTransporter.class, "LogisticalTransporter", new RenderLogisticalTransporter()); ClientRegistry.registerTileEntity(TileEntityLogisticalTransporter.class, "LogisticalTransporter", new RenderLogisticalTransporter());
ClientRegistry.registerTileEntity(TileEntityLogisticalSorter.class, "LogisticalSorter", new RenderLogisticalSorter()); ClientRegistry.registerTileEntity(TileEntityLogisticalSorter.class, "LogisticalSorter", new RenderLogisticalSorter());
ClientRegistry.registerTileEntity(TileEntityBin.class, "Bin", new RenderBin());
} }
@Override @Override

View file

@ -6,6 +6,7 @@ import net.minecraft.client.model.PositionTextureVertex;
import net.minecraft.client.model.TexturedQuad; import net.minecraft.client.model.TexturedQuad;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;
@SideOnly(Side.CLIENT)
public class ModelBoxSelectiveFace public class ModelBoxSelectiveFace
{ {
private PositionTextureVertex[] vertexPositions; private PositionTextureVertex[] vertexPositions;

View file

@ -1,9 +1,12 @@
package mekanism.client.model; package mekanism.client.model;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@SideOnly(Side.CLIENT)
public class ModelCrusher extends ModelBase public class ModelCrusher extends ModelBase
{ {
ModelRenderer Top; ModelRenderer Top;

View file

@ -1,9 +1,12 @@
package mekanism.client.model; package mekanism.client.model;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@SideOnly(Side.CLIENT)
public class ModelElectricPump extends ModelBase public class ModelElectricPump extends ModelBase
{ {
ModelRenderer PumpHead; ModelRenderer PumpHead;

View file

@ -1,9 +1,12 @@
package mekanism.client.model; package mekanism.client.model;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import mekanism.client.render.MekanismRenderer; import mekanism.client.render.MekanismRenderer;
import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelRenderer;
@SideOnly(Side.CLIENT)
public class ModelEnergyCube extends ModelBase public class ModelEnergyCube extends ModelBase
{ {
ModelRenderer Corner1; ModelRenderer Corner1;

View file

@ -1,9 +1,12 @@
package mekanism.client.model; package mekanism.client.model;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@SideOnly(Side.CLIENT)
public class ModelGasTank extends ModelBase public class ModelGasTank extends ModelBase
{ {
ModelRenderer Panel1; ModelRenderer Panel1;

View file

@ -1,10 +1,13 @@
package mekanism.client.model; package mekanism.client.model;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import mekanism.client.render.MekanismRenderer; import mekanism.client.render.MekanismRenderer;
import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@SideOnly(Side.CLIENT)
public class ModelLogisticalSorter extends ModelBase public class ModelLogisticalSorter extends ModelBase
{ {
ModelRenderer LeftThing; ModelRenderer LeftThing;

View file

@ -1,8 +1,11 @@
package mekanism.client.model; package mekanism.client.model;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelRenderer;
@SideOnly(Side.CLIENT)
public class ModelMetallurgicInfuser extends ModelBase public class ModelMetallurgicInfuser extends ModelBase
{ {
ModelRenderer Base; ModelRenderer Base;

View file

@ -1,9 +1,12 @@
package mekanism.client.model; package mekanism.client.model;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@SideOnly(Side.CLIENT)
public class ModelObsidianTNT extends ModelBase public class ModelObsidianTNT extends ModelBase
{ {
ModelRenderer Wick9; ModelRenderer Wick9;

View file

@ -15,6 +15,7 @@ import net.minecraft.client.renderer.Tessellator;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class ModelRendererSelectiveFace public class ModelRendererSelectiveFace
{ {
public float textureWidth; public float textureWidth;

View file

@ -0,0 +1,206 @@
package mekanism.client.render.tileentity;
import mekanism.api.Object3D;
import mekanism.common.tileentity.TileEntityBin;
import mekanism.common.util.MekanismUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.common.ForgeDirection;
import org.lwjgl.opengl.GL11;
import universalelectricity.core.vector.Vector3;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/*
* Courtesy of MFFS & Assembly Line
*/
@SideOnly(Side.CLIENT)
public class RenderBin extends TileEntitySpecialRenderer
{
private final RenderBlocks renderBlocks = new RenderBlocks();
private final RenderItem renderItem = (RenderItem)RenderManager.instance.getEntityClassRenderObject(EntityItem.class);
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick)
{
renderAModelAt((TileEntityBin)tileEntity, x, y, z, partialTick);
}
@SuppressWarnings("incomplete-switch")
private void renderAModelAt(TileEntityBin tileEntity, double x, double y, double z, float partialTick)
{
if(tileEntity instanceof TileEntityBin)
{
String itemName = "None";
String amount = "";
ItemStack itemStack = tileEntity.getStack();
if(itemStack != null)
{
itemName = itemStack.getDisplayName();
amount = Integer.toString(itemStack.stackSize);
}
for(ForgeDirection side : MekanismUtils.SIDE_DIRS)
{
Object3D obj = Object3D.get(tileEntity).getFromSide(side);
if(tileEntity.worldObj.isBlockSolidOnSide(obj.xCoord, obj.yCoord, obj.zCoord, side.getOpposite()))
{
continue;
}
doLight(tileEntity.worldObj, obj);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);
if(itemStack != null)
{
GL11.glPushMatrix();
switch (side)
{
case NORTH:
GL11.glTranslated(x + 0.65, y + 0.9, z - 0.01);
break;
case SOUTH:
GL11.glTranslated(x + 0.35, y + 0.9, z + 1.01);
GL11.glRotatef(180, 0, 1, 0);
break;
case WEST:
GL11.glTranslated(x - 0.01, y + 0.9, z + 0.35);
GL11.glRotatef(90, 0, 1, 0);
break;
case EAST:
GL11.glTranslated(x + 1.01, y + 0.9, z + 0.65);
GL11.glRotatef(-90, 0, 1, 0);
break;
}
float scale = 0.03125F;
GL11.glScalef(0.6f * scale, 0.6f * scale, 0);
GL11.glRotatef(180, 0, 0, 1);
TextureManager renderEngine = Minecraft.getMinecraft().renderEngine;
GL11.glDisable(2896);
if(!ForgeHooksClient.renderInventoryItem(renderBlocks, renderEngine, itemStack, true, 0.0F, 0.0F, 0.0F))
{
renderItem.renderItemIntoGUI(getFontRenderer(), renderEngine, itemStack, 0, 0);
}
GL11.glEnable(2896);
GL11.glPopMatrix();
}
renderText(itemName, side, 0.02f, x, y - 0.35f, z);
if(amount != "")
{
renderText(amount, side, 0.02f, x, y - 0.15f, z);
}
}
}
}
private void doLight(World world, Object3D obj)
{
if(world.isBlockOpaqueCube(obj.xCoord, obj.yCoord, obj.zCoord))
{
return;
}
int br = world.getLightBrightnessForSkyBlocks(obj.xCoord, obj.yCoord, obj.zCoord, 0);
int var11 = br % 65536;
int var12 = br / 65536;
float scale = 0.6F;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, var11 * scale, var12 * scale);
}
@SuppressWarnings("incomplete-switch")
private void renderText(String text, ForgeDirection side, float maxScale, double x, double y, double z)
{
GL11.glPushMatrix();
GL11.glPolygonOffset(-10, -10);
GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
float displayWidth = 1 - (2 / 16);
float displayHeight = 1 - (2 / 16);
GL11.glTranslated(x, y, z);
switch(side)
{
case SOUTH:
GL11.glTranslatef(0, 1, 0);
GL11.glRotatef(0, 0, 1, 0);
GL11.glRotatef(90, 1, 0, 0);
break;
case NORTH:
GL11.glTranslatef(1, 1, 1);
GL11.glRotatef(180, 0, 1, 0);
GL11.glRotatef(90, 1, 0, 0);
break;
case EAST:
GL11.glTranslatef(0, 1, 1);
GL11.glRotatef(90, 0, 1, 0);
GL11.glRotatef(90, 1, 0, 0);
break;
case WEST:
GL11.glTranslatef(1, 1, 0);
GL11.glRotatef(-90, 0, 1, 0);
GL11.glRotatef(90, 1, 0, 0);
break;
}
GL11.glTranslatef(displayWidth / 2, 1F, displayHeight / 2);
GL11.glRotatef(-90, 1, 0, 0);
FontRenderer fontRenderer = getFontRenderer();
int requiredWidth = Math.max(fontRenderer.getStringWidth(text), 1);
int lineHeight = fontRenderer.FONT_HEIGHT + 2;
int requiredHeight = lineHeight * 1;
float scaler = 0.8f;
float scaleX = (displayWidth / requiredWidth);
float scale = scaleX * scaler;
if(maxScale > 0)
{
scale = Math.min(scale, maxScale);
}
GL11.glScalef(scale, -scale, scale);
GL11.glDepthMask(false);
int offsetX;
int offsetY;
int realHeight = (int) Math.floor(displayHeight / scale);
int realWidth = (int) Math.floor(displayWidth / scale);
offsetX = (realWidth - requiredWidth) / 2;
offsetY = (realHeight - requiredHeight) / 2;
GL11.glDisable(GL11.GL_LIGHTING);
fontRenderer.drawString("\u00a7f" + text, offsetX - (realWidth / 2), 1 + offsetY - (realHeight / 2), 1);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDepthMask(true);
GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);
GL11.glPopMatrix();
}
}

View file

@ -19,7 +19,7 @@ public class RenderChargepad extends TileEntitySpecialRenderer
@Override @Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick)
{ {
renderAModelAt((TileEntityChargepad)tileEntity, x, y, z, 1F); renderAModelAt((TileEntityChargepad)tileEntity, x, y, z, partialTick);
} }
private void renderAModelAt(TileEntityChargepad tileEntity, double x, double y, double z, float partialTick) private void renderAModelAt(TileEntityChargepad tileEntity, double x, double y, double z, float partialTick)

View file

@ -9,6 +9,10 @@ import net.minecraft.tileentity.TileEntity;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderCrusher extends TileEntitySpecialRenderer public class RenderCrusher extends TileEntitySpecialRenderer
{ {
private ModelCrusher model = new ModelCrusher(); private ModelCrusher model = new ModelCrusher();
@ -16,7 +20,7 @@ public class RenderCrusher extends TileEntitySpecialRenderer
@Override @Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick)
{ {
renderAModelAt((TileEntityCrusher)tileEntity, x, y, z, 1F); renderAModelAt((TileEntityCrusher)tileEntity, x, y, z, partialTick);
} }
private void renderAModelAt(TileEntityCrusher tileEntity, double x, double y, double z, float partialTick) private void renderAModelAt(TileEntityCrusher tileEntity, double x, double y, double z, float partialTick)

View file

@ -19,7 +19,7 @@ public class RenderElectricPump extends TileEntitySpecialRenderer
@Override @Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick)
{ {
renderAModelAt((TileEntityElectricPump)tileEntity, x, y, z, 1F); renderAModelAt((TileEntityElectricPump)tileEntity, x, y, z, partialTick);
} }
private void renderAModelAt(TileEntityElectricPump tileEntity, double x, double y, double z, float partialTick) private void renderAModelAt(TileEntityElectricPump tileEntity, double x, double y, double z, float partialTick)

View file

@ -9,6 +9,10 @@ import net.minecraft.tileentity.TileEntity;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderGasTank extends TileEntitySpecialRenderer public class RenderGasTank extends TileEntitySpecialRenderer
{ {
private ModelGasTank model = new ModelGasTank(); private ModelGasTank model = new ModelGasTank();
@ -16,7 +20,7 @@ public class RenderGasTank extends TileEntitySpecialRenderer
@Override @Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick)
{ {
renderAModelAt((TileEntityGasTank)tileEntity, x, y, z, 1F); renderAModelAt((TileEntityGasTank)tileEntity, x, y, z, partialTick);
} }
private void renderAModelAt(TileEntityGasTank tileEntity, double x, double y, double z, float partialTick) private void renderAModelAt(TileEntityGasTank tileEntity, double x, double y, double z, float partialTick)

View file

@ -9,6 +9,10 @@ import net.minecraft.tileentity.TileEntity;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderLogisticalSorter extends TileEntitySpecialRenderer public class RenderLogisticalSorter extends TileEntitySpecialRenderer
{ {
private ModelLogisticalSorter model = new ModelLogisticalSorter(); private ModelLogisticalSorter model = new ModelLogisticalSorter();
@ -16,7 +20,7 @@ public class RenderLogisticalSorter extends TileEntitySpecialRenderer
@Override @Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick)
{ {
renderAModelAt((TileEntityLogisticalSorter)tileEntity, x, y, z, 1F); renderAModelAt((TileEntityLogisticalSorter)tileEntity, x, y, z, partialTick);
} }
private void renderAModelAt(TileEntityLogisticalSorter tileEntity, double x, double y, double z, float partialTick) private void renderAModelAt(TileEntityLogisticalSorter tileEntity, double x, double y, double z, float partialTick)

View file

@ -9,6 +9,10 @@ import net.minecraft.tileentity.TileEntity;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderObsidianTNT extends TileEntitySpecialRenderer public class RenderObsidianTNT extends TileEntitySpecialRenderer
{ {
private ModelObsidianTNT model = new ModelObsidianTNT(); private ModelObsidianTNT model = new ModelObsidianTNT();
@ -16,7 +20,7 @@ public class RenderObsidianTNT extends TileEntitySpecialRenderer
@Override @Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick)
{ {
renderAModelAt((TileEntityObsidianTNT)tileEntity, x, y, z, 1F); renderAModelAt((TileEntityObsidianTNT)tileEntity, x, y, z, partialTick);
} }
private void renderAModelAt(TileEntityObsidianTNT tileEntity, double x, double y, double z, float partialTick) private void renderAModelAt(TileEntityObsidianTNT tileEntity, double x, double y, double z, float partialTick)

View file

@ -0,0 +1,119 @@
package mekanism.common;
import mekanism.common.inventory.InventoryBin;
import mekanism.common.item.ItemBlockBasic;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.world.World;
import cpw.mods.fml.common.ICraftingHandler;
import cpw.mods.fml.common.registry.GameRegistry;
public class BinRecipe implements IRecipe, ICraftingHandler
{
public BinRecipe()
{
GameRegistry.registerCraftingHandler(this);
}
@Override
public boolean matches(InventoryCrafting inv, World world)
{
return getCraftingResult(inv) != null;
}
private boolean isBin(ItemStack itemStack)
{
if(itemStack == null)
{
return false;
}
return itemStack.getItem() instanceof ItemBlockBasic && itemStack.getItemDamage() == 6;
}
@Override
public ItemStack getCraftingResult(InventoryCrafting inv)
{
ItemStack bin = null;
for(int i = 0; i < 9; i++)
{
ItemStack stack = inv.getStackInSlot(i);
if(isBin(stack))
{
if(bin != null)
{
return null;
}
bin = stack.copy();
}
}
if(bin == null)
{
return null;
}
int slotLoc = -1;
ItemStack addStack = null;
for(int i = 0; i < 9; i++)
{
ItemStack stack = inv.getStackInSlot(i);
if(stack != null && !isBin(stack))
{
if(addStack != null)
{
return null;
}
addStack = stack.copy();
slotLoc = i;
}
}
InventoryBin binInv = new InventoryBin(bin);
if(addStack != null)
{
if(binInv.getItemType() != null && !binInv.getItemType().isItemEqual(addStack))
{
return null;
}
ItemStack remain = binInv.add(addStack);
return bin;
}
else {
return binInv.removeStack();
}
}
@Override
public int getRecipeSize()
{
return 0;
}
@Override
public ItemStack getRecipeOutput()
{
return null;
}
@Override
public void onCrafting(EntityPlayer player, ItemStack item, IInventory craftMatrix)
{
}
@Override
public void onSmelting(EntityPlayer player, ItemStack item) {}
}

View file

@ -20,6 +20,7 @@ import mekanism.common.inventory.container.ContainerRobitSmelting;
import mekanism.common.inventory.container.ContainerTeleporter; import mekanism.common.inventory.container.ContainerTeleporter;
import mekanism.common.tileentity.TileEntityAdvancedElectricMachine; import mekanism.common.tileentity.TileEntityAdvancedElectricMachine;
import mekanism.common.tileentity.TileEntityAdvancedFactory; import mekanism.common.tileentity.TileEntityAdvancedFactory;
import mekanism.common.tileentity.TileEntityBin;
import mekanism.common.tileentity.TileEntityChargepad; import mekanism.common.tileentity.TileEntityChargepad;
import mekanism.common.tileentity.TileEntityCombiner; import mekanism.common.tileentity.TileEntityCombiner;
import mekanism.common.tileentity.TileEntityContainerBlock; import mekanism.common.tileentity.TileEntityContainerBlock;
@ -87,6 +88,7 @@ public class CommonProxy
GameRegistry.registerTileEntity(TileEntityChargepad.class, "Chargepad"); GameRegistry.registerTileEntity(TileEntityChargepad.class, "Chargepad");
GameRegistry.registerTileEntity(TileEntityLogisticalTransporter.class, "LogisticalTransporter"); GameRegistry.registerTileEntity(TileEntityLogisticalTransporter.class, "LogisticalTransporter");
GameRegistry.registerTileEntity(TileEntityLogisticalSorter.class, "LogisticalSorter"); GameRegistry.registerTileEntity(TileEntityLogisticalSorter.class, "LogisticalSorter");
GameRegistry.registerTileEntity(TileEntityBin.class, "Bin");
} }
/** /**

View file

@ -1005,7 +1005,6 @@ public class Mekanism
//Tile entities //Tile entities
GameRegistry.registerTileEntity(TileEntityBoundingBlock.class, "BoundingBlock"); GameRegistry.registerTileEntity(TileEntityBoundingBlock.class, "BoundingBlock");
GameRegistry.registerTileEntity(TileEntityTeleporter.class, "MekanismTeleporter"); GameRegistry.registerTileEntity(TileEntityTeleporter.class, "MekanismTeleporter");
GameRegistry.registerTileEntity(TileEntityBin.class, "Bin");
//Load tile entities that have special renderers. //Load tile entities that have special renderers.
proxy.registerSpecialTileEntities(); proxy.registerSpecialTileEntities();

View file

@ -8,6 +8,7 @@ import mekanism.client.ClientProxy;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.PacketHandler; import mekanism.common.PacketHandler;
import mekanism.common.PacketHandler.Transmission; import mekanism.common.PacketHandler.Transmission;
import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.network.PacketTileEntity; import mekanism.common.network.PacketTileEntity;
import mekanism.common.tileentity.TileEntityBin; import mekanism.common.tileentity.TileEntityBin;
import mekanism.common.tileentity.TileEntityDynamicTank; import mekanism.common.tileentity.TileEntityDynamicTank;
@ -26,6 +27,7 @@ import net.minecraft.util.Icon;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
@ -195,6 +197,12 @@ public class BlockBasic extends Block
return false; return false;
} }
@Override
public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side)
{
return true;
}
private boolean manageInventory(EntityPlayer player, TileEntityDynamicTank tileEntity) private boolean manageInventory(EntityPlayer player, TileEntityDynamicTank tileEntity)
{ {
ItemStack itemStack = player.getCurrentEquippedItem(); ItemStack itemStack = player.getCurrentEquippedItem();

View file

@ -0,0 +1,114 @@
package mekanism.common.inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class InventoryBin
{
public ItemStack bin;
public InventoryBin(ItemStack stack)
{
bin = stack;
}
public ItemStack getStack()
{
if(getItemCount() > 0)
{
ItemStack ret = getItemType().copy();
ret.stackSize = Math.min(64, getItemCount());
return ret;
}
return null;
}
public ItemStack removeStack()
{
ItemStack stack = getStack();
if(stack == null)
{
return null;
}
setItemCount(getItemCount() - stack.stackSize);
return stack;
}
public ItemStack add(ItemStack stack)
{
if(stack != null && stack.stackSize > 0)
{
if(getItemType() == null)
{
setItemType(stack);
}
setItemCount(getItemCount() + stack.stackSize);
}
return null;
}
public int getItemCount()
{
if(bin.stackTagCompound == null)
{
return 0;
}
return bin.stackTagCompound.getInteger("itemCount");
}
public void setItemCount(int count)
{
if(bin.stackTagCompound == null)
{
bin.setTagCompound(new NBTTagCompound());
}
bin.stackTagCompound.setInteger("itemCount", Math.max(0, count));
if(getItemCount() == 0)
{
setItemType(null);
}
}
public ItemStack getItemType()
{
if(bin.stackTagCompound == null || getItemCount() == 0)
{
return null;
}
int id = bin.stackTagCompound.getInteger("itemID");
int meta = bin.stackTagCompound.getInteger("itemMeta");
return new ItemStack(id, 1, meta);
}
public void setItemType(ItemStack stack)
{
if(bin.stackTagCompound == null)
{
bin.setTagCompound(new NBTTagCompound());
}
if(stack == null)
{
bin.stackTagCompound.removeTag("itemID");
bin.stackTagCompound.removeTag("itemMeta");
return;
}
ItemStack ret = stack.copy();
ret.stackSize = 1;
bin.stackTagCompound.setInteger("itemID", stack.itemID);
bin.stackTagCompound.setInteger("itemMeta", stack.getItemDamage());
}
}

View file

@ -28,10 +28,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento
} }
@Override @Override
public void onUpdate() public void onUpdate() {}
{
}
@Override @Override
public void writeToNBT(NBTTagCompound nbtTags) public void writeToNBT(NBTTagCompound nbtTags)
@ -103,6 +100,25 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento
@Override @Override
public ItemStack decrStackSize(int slotID, int amount) public ItemStack decrStackSize(int slotID, int amount)
{ {
if(slotID == 1)
{
return null;
}
else if(slotID == 0)
{
int toRemove = Math.min(itemCount, amount);
if(toRemove > 0)
{
ItemStack ret = itemType.copy();
ret.stackSize = toRemove;
setItemCount(itemCount-toRemove);
return ret;
}
}
return null; return null;
} }
@ -121,13 +137,67 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento
@Override @Override
public void setInventorySlotContents(int i, ItemStack itemstack) public void setInventorySlotContents(int i, ItemStack itemstack)
{ {
if(itemType != null && itemstack != null && !itemstack.isItemEqual(itemType))
{
return;
}
if(i == 0)
{
if(itemCount == 0)
{
return;
}
if(itemstack == null)
{
setItemCount(itemCount - getStack().stackSize);
}
else {
setItemCount(itemCount - (getStack().stackSize-itemstack.stackSize));
}
}
else if(i == 1)
{
if(itemstack != null && itemstack.stackSize > 0)
{
if(itemType == null)
{
setItemType(itemstack);
}
setItemCount(itemCount + itemstack.stackSize);
}
}
}
public void setItemType(ItemStack stack)
{
if(stack == null)
{
itemType = null;
return;
}
ItemStack ret = stack.copy();
ret.stackSize = 1;
itemType = ret;
}
public void setItemCount(int count)
{
itemCount = Math.max(0, count);
if(itemCount == 0)
{
setItemType(null);
}
} }
@Override @Override
public String getInvName() public String getInvName()
{ {
return null; return "Bin";
} }
@Override @Override
@ -181,6 +251,6 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento
@Override @Override
public boolean canExtractItem(int i, ItemStack itemstack, int j) public boolean canExtractItem(int i, ItemStack itemstack, int j)
{ {
return true; return itemType != null && itemType.isItemEqual(itemstack);
} }
} }

View file

@ -67,6 +67,7 @@ import cpw.mods.fml.server.FMLServerHandler;
*/ */
public final class MekanismUtils public final class MekanismUtils
{ {
public static final ForgeDirection[] SIDE_DIRS = new ForgeDirection[] {ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.WEST, ForgeDirection.EAST};
/** /**
* Checks for a new version of Mekanism. * Checks for a new version of Mekanism.
*/ */