Finsihed engineering table

This commit is contained in:
Calclavia 2014-01-12 01:03:30 +08:00
parent f073591ec8
commit d1315fb585
3 changed files with 54 additions and 20 deletions

View file

@ -1,5 +1,6 @@
package resonantinduction.archaic.engineering; package resonantinduction.archaic.engineering;
import codechicken.multipart.ControlKeyModifer;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
@ -35,15 +36,16 @@ public class BlockEngineeringTable extends BlockRI
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int hitSide, float hitX, float hitY, float hitZ) public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int hitSide, float hitX, float hitY, float hitZ)
{ {
if (hitSide == 1) TileEntity te = world.getBlockTileEntity(x, y, z);
{
if (!world.isRemote)
{
TileEntity te = world.getBlockTileEntity(x, y, z);
if (te instanceof TileEngineeringTable) if (te instanceof TileEngineeringTable)
{
TileEngineeringTable tile = (TileEngineeringTable) te;
if (hitSide == 1)
{
if (!world.isRemote)
{ {
TileEngineeringTable tile = (TileEngineeringTable) te;
ItemStack current = player.inventory.getCurrentItem(); ItemStack current = player.inventory.getCurrentItem();
@ -64,7 +66,7 @@ public class BlockEngineeringTable extends BlockRI
{ {
int slotID = j * 3 + k; int slotID = j * 3 + k;
ItemStack checkStack = tile.craftingMatrix[slotID]; ItemStack checkStack = tile.craftingMatrix[slotID];
System.out.println(slotID);
if (checkStack != null) if (checkStack != null)
{ {
EntityItem entityItem = new EntityItem(world, player.posX, player.posY, player.posZ, checkStack); EntityItem entityItem = new EntityItem(world, player.posX, player.posY, player.posZ, checkStack);
@ -74,8 +76,20 @@ public class BlockEngineeringTable extends BlockRI
} }
else if (current != null) else if (current != null)
{ {
tile.craftingMatrix[slotID] = current; if (ControlKeyModifer.isControlDown(player))
player.inventory.setInventorySlotContents(player.inventory.currentItem, null); {
tile.craftingMatrix[slotID] = current.splitStack(1);
}
else
{
tile.craftingMatrix[slotID] = current;
current = null;
}
if (current == null || current.stackSize <= 0)
{
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}
} }
break matrix; break matrix;
@ -84,10 +98,24 @@ public class BlockEngineeringTable extends BlockRI
} }
tile.onInventoryChanged(); tile.onInventoryChanged();
}
return true;
}
else if (hitSide != 0)
{
ItemStack output = tile.getStackInSlot(9);
if (output != null)
{
EntityItem entityItem = new EntityItem(world, player.posX, player.posY, player.posZ, output);
entityItem.delayBeforeCanPickup = 0;
world.spawnEntityInWorld(entityItem);
tile.onPickUpFromSlot(player, 9, output);
tile.setInventorySlotContents(9, null);
} }
} }
return true;
} }
return false; return false;

View file

@ -58,6 +58,8 @@ public class RenderEngineeringTable extends TileEntitySpecialRenderer
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glTranslated(x + (double) (i / 3) / 3d + (0.5 / 3d), y + 1.1, z + (double) (i % 3) / 3d + (0.5 / 3d)); GL11.glTranslated(x + (double) (i / 3) / 3d + (0.5 / 3d), y + 1.1, z + (double) (i % 3) / 3d + (0.5 / 3d));
GL11.glScalef(0.7f, 0.7f, 0.7f); GL11.glScalef(0.7f, 0.7f, 0.7f);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);
this.renderItem(tileEntity.worldObj, ForgeDirection.UP, tile.craftingMatrix[i], new Vector3(), 0, 0); this.renderItem(tileEntity.worldObj, ForgeDirection.UP, tile.craftingMatrix[i], new Vector3(), 0, 0);
GL11.glPopMatrix(); GL11.glPopMatrix();
} }

View file

@ -13,6 +13,7 @@ import net.minecraft.network.packet.Packet;
import resonantinduction.api.IArmbot; import resonantinduction.api.IArmbot;
import resonantinduction.api.IArmbotUseable; import resonantinduction.api.IArmbotUseable;
import resonantinduction.core.ResonantInduction; import resonantinduction.core.ResonantInduction;
import resonantinduction.core.prefab.ContainerFake;
import resonantinduction.electrical.encoder.coding.args.ArgumentData; import resonantinduction.electrical.encoder.coding.args.ArgumentData;
import calclavia.lib.network.IPacketReceiver; import calclavia.lib.network.IPacketReceiver;
import calclavia.lib.network.PacketHandler; import calclavia.lib.network.PacketHandler;
@ -245,17 +246,19 @@ public class TileEngineeringTable extends TileAdvanced implements IPacketReceive
boolean didCraft = false; boolean didCraft = false;
/** Simulate an Inventory Crafting Instance */ /** Simulate an Inventory Crafting Instance */
InventoryCrafting inventoryCrafting = this.getCraftingMatrix(); InventoryCrafting inventoryCrafting = new InventoryCrafting(new ContainerFake(this), 3, 3);
if (inventoryCrafting != null) for (int i = 0; i < this.craftingMatrix.length; i++)
{ {
ItemStack matrixOutput = CraftingManager.getInstance().findMatchingRecipe(inventoryCrafting, this.worldObj); inventoryCrafting.setInventorySlotContents(i, this.craftingMatrix[i]);
}
if (matrixOutput != null && this.getCraftingManager().getIdealRecipe(matrixOutput) != null) ItemStack matrixOutput = CraftingManager.getInstance().findMatchingRecipe(inventoryCrafting, this.worldObj);
{
this.output[craftingOutputSlot] = matrixOutput; if (matrixOutput != null && this.getCraftingManager().getIdealRecipe(matrixOutput) != null)
didCraft = true; {
} this.output[craftingOutputSlot] = matrixOutput;
didCraft = true;
} }
PacketDispatcher.sendPacketToAllPlayers(this.getDescriptionPacket()); PacketDispatcher.sendPacketToAllPlayers(this.getDescriptionPacket());
@ -404,4 +407,5 @@ public class TileEngineeringTable extends TileAdvanced implements IPacketReceive
{ {
return craftingSlots; return craftingSlots;
} }
} }