Added transporter recipe, items now drop when necessary

This commit is contained in:
Aidan Brady 2013-10-27 19:27:33 -04:00
parent cb555e90a6
commit a63573d80f
5 changed files with 55 additions and 15 deletions

View file

@ -1,6 +1,5 @@
package mekanism.client.render.tileentity; package mekanism.client.render.tileentity;
import mekanism.api.Object3D;
import mekanism.client.model.ModelTransmitter; import mekanism.client.model.ModelTransmitter;
import mekanism.client.model.ModelTransmitter.Size; import mekanism.client.model.ModelTransmitter.Size;
import mekanism.client.model.ModelTransporterBox; import mekanism.client.model.ModelTransporterBox;
@ -72,18 +71,10 @@ public class RenderLogisticalTransporter extends TileEntitySpecialRenderer
{ {
GL11.glPushMatrix(); GL11.glPushMatrix();
entityItem.setEntityItemStack(stack.itemStack); entityItem.setEntityItemStack(stack.itemStack);
Object3D offset = new Object3D(0, 0, 0).step(ForgeDirection.getOrientation(stack.getSide(tileEntity)));
float itemFix = 0; float[] pos = TransporterUtils.getStackPosition(tileEntity, stack);
if(stack.itemStack.itemID >= 256) renderer.doRenderItem(entityItem, x + pos[0], y + pos[1] - entityItem.yOffset, z + pos[2], 0, 0);
{
itemFix = 0.1F;
}
double progress = ((double)stack.progress / 100D) - 0.5;
renderer.doRenderItem(entityItem, x + 0.5 + offset.xCoord*progress, y + 0.5 + offset.yCoord*progress - entityItem.yOffset - itemFix, z + 0.5 + offset.zCoord*progress, 0, 0);
GL11.glPopMatrix(); GL11.glPopMatrix();
if(stack.color != null) if(stack.color != null)
@ -93,7 +84,7 @@ public class RenderLogisticalTransporter extends TileEntitySpecialRenderer
MekanismRenderer.glowOn(); MekanismRenderer.glowOn();
GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glColor4f(stack.color.getColor(0), stack.color.getColor(1), stack.color.getColor(2), 1.0F); GL11.glColor4f(stack.color.getColor(0), stack.color.getColor(1), stack.color.getColor(2), 1.0F);
GL11.glTranslatef((float)(x + 0.5 + offset.xCoord*progress), (float)(y + 0.5 + offset.yCoord*progress - entityItem.yOffset - 0.1F), (float)(z + 0.5 + offset.zCoord*progress)); GL11.glTranslatef((float)(x + pos[0]), (float)(y + pos[1] - entityItem.yOffset - (stack.itemStack.itemID < 256 ? 0.1 : 0)), (float)(z + pos[2]));
modelBox.render(0.0625F); modelBox.render(0.0625F);
MekanismRenderer.glowOff(); MekanismRenderer.glowOff();
GL11.glPopMatrix(); GL11.glPopMatrix();

View file

@ -412,6 +412,9 @@ public class Mekanism
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(WalkieTalkie), new Object[] { CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(WalkieTalkie), new Object[] {
" O", "SCS", " S ", Character.valueOf('O'), "ingotOsmium", Character.valueOf('S'), "ingotSteel", Character.valueOf('C'), "circuitBasic" " O", "SCS", " S ", Character.valueOf('O'), "ingotOsmium", Character.valueOf('S'), "ingotSteel", Character.valueOf('C'), "circuitBasic"
})); }));
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(Transmitter, 8, 3), new Object[] {
"S S", Character.valueOf('S'), "ingotSteel"
}));
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(MachineBlock, 1, 15), new Object[] { CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(MachineBlock, 1, 15), new Object[] {
"IPI", "ICI", "III", Character.valueOf('I'), Item.ingotIron, Character.valueOf('P'), Block.pistonBase, Character.valueOf('C'), "circuitBasic" "IPI", "ICI", "III", Character.valueOf('I'), Item.ingotIron, Character.valueOf('P'), Block.pistonBase, Character.valueOf('C'), "circuitBasic"
})); }));

View file

@ -16,7 +16,7 @@ import mekanism.common.tileentity.TileEntityLogisticalTransporter;
import mekanism.common.tileentity.TileEntityMechanicalPipe; import mekanism.common.tileentity.TileEntityMechanicalPipe;
import mekanism.common.tileentity.TileEntityPressurizedTube; import mekanism.common.tileentity.TileEntityPressurizedTube;
import mekanism.common.tileentity.TileEntityUniversalCable; import mekanism.common.tileentity.TileEntityUniversalCable;
import mekanism.common.transporter.TransporterPathfinder; import mekanism.common.transporter.TransporterStack;
import mekanism.common.util.CableUtils; import mekanism.common.util.CableUtils;
import mekanism.common.util.TransporterUtils; import mekanism.common.util.TransporterUtils;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -376,6 +376,24 @@ public class BlockTransmitter extends Block
} }
} }
@Override
public void breakBlock(World world, int x, int y, int z, int i1, int i2)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if(!world.isRemote && tileEntity instanceof TileEntityLogisticalTransporter)
{
TileEntityLogisticalTransporter transporter = (TileEntityLogisticalTransporter)world.getBlockTileEntity(x, y, z);
for(TransporterStack stack : transporter.transit)
{
TransporterUtils.drop(transporter, stack);
}
}
super.breakBlock(world, x, y, z, i1, i2);
}
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int facing, float playerX, float playerY, float playerZ) public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int facing, float playerX, float playerY, float playerZ)
{ {

View file

@ -189,7 +189,7 @@ public class TileEntityLogisticalTransporter extends TileEntity implements ITile
if(!stack.hasPath()) if(!stack.hasPath())
{ {
//drop TransporterUtils.drop(this, stack);
return false; return false;
} }

View file

@ -2,13 +2,14 @@ package mekanism.common.util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Map;
import mekanism.api.EnumColor; import mekanism.api.EnumColor;
import mekanism.api.Object3D; import mekanism.api.Object3D;
import mekanism.api.transmitters.ITransmitter; import mekanism.api.transmitters.ITransmitter;
import mekanism.common.tileentity.TileEntityLogisticalTransporter; import mekanism.common.tileentity.TileEntityLogisticalTransporter;
import mekanism.common.transporter.SlotInfo; import mekanism.common.transporter.SlotInfo;
import mekanism.common.transporter.TransporterStack;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory; import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -363,6 +364,33 @@ public final class TransporterUtils
return colors.get(colors.indexOf(color)+1); return colors.get(colors.indexOf(color)+1);
} }
public static void drop(TileEntityLogisticalTransporter tileEntity, TransporterStack stack)
{
float[] pos = TransporterUtils.getStackPosition(tileEntity, stack);
EntityItem entityItem = new EntityItem(tileEntity.worldObj, tileEntity.xCoord + pos[0], tileEntity.yCoord + pos[1], tileEntity.zCoord + pos[2], stack.itemStack);
entityItem.motionX = 0;
entityItem.motionY = 0;
entityItem.motionZ = 0;
tileEntity.worldObj.spawnEntityInWorld(entityItem);
}
public static float[] getStackPosition(TileEntityLogisticalTransporter tileEntity, TransporterStack stack)
{
Object3D offset = new Object3D(0, 0, 0).step(ForgeDirection.getOrientation(stack.getSide(tileEntity)));
float progress = ((float)stack.progress / 100F) - 0.5F;
float itemFix = 0;
if(stack.itemStack.itemID >= 256)
{
itemFix = 0.1F;
}
return new float[] {0.5F + offset.xCoord*progress, 0.5F + offset.yCoord*progress - itemFix, 0.5F + offset.zCoord*progress};
}
public static void incrementColor(TileEntityLogisticalTransporter tileEntity) public static void incrementColor(TileEntityLogisticalTransporter tileEntity)
{ {
if(tileEntity.color == null) if(tileEntity.color == null)