More Armbot + Imprinter Tweaks
This commit is contained in:
parent
d94cc46cef
commit
4cce5df0f6
5 changed files with 60 additions and 47 deletions
|
@ -17,6 +17,8 @@ public interface IArmbot
|
||||||
*/
|
*/
|
||||||
public void grabEntity(Entity entity);
|
public void grabEntity(Entity entity);
|
||||||
|
|
||||||
|
public void grabItem(ItemStack itemStack);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Drops a specific entity from the Armbot's hand.
|
* Drops a specific entity from the Armbot's hand.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -129,21 +129,22 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
|
||||||
|
|
||||||
if (block != null)
|
if (block != null)
|
||||||
{
|
{
|
||||||
if (Block.isNormalCube(block.blockID))
|
if (Block.isNormalCube(block.blockID) && block.getBlockHardness(this.worldObj, handPosition.intX(), handPosition.intY(), handPosition.intZ()) != -1)
|
||||||
{
|
{
|
||||||
TileEntity tileEntity = this.getHandPosition().getTileEntity(this.worldObj);
|
TileEntity tileEntity = this.getHandPosition().getTileEntity(this.worldObj);
|
||||||
|
|
||||||
if (tileEntity == null)
|
if (tileEntity == null)
|
||||||
{
|
{
|
||||||
block.dropBlockAsItem(this.worldObj, this.xCoord, this.yCoord, this.zCoord, handPosition.getBlockMetadata(this.worldObj), 0);
|
if (!this.worldObj.isRemote)
|
||||||
|
{
|
||||||
|
block.dropBlockAsItem(this.worldObj, handPosition.intX(), handPosition.intY(), handPosition.intZ(), handPosition.getBlockMetadata(this.worldObj), 0);
|
||||||
|
}
|
||||||
|
|
||||||
handPosition.setBlockWithNotify(this.worldObj, 0);
|
handPosition.setBlockWithNotify(this.worldObj, 0);
|
||||||
}
|
}
|
||||||
else
|
else if (!(tileEntity instanceof IArmbotUseable))
|
||||||
{
|
{
|
||||||
if (!(tileEntity instanceof IArmbotUseable))
|
handPosition.setBlockWithNotify(this.worldObj, 0);
|
||||||
{
|
|
||||||
block.dropBlockAsItem(this.worldObj, this.xCoord, this.yCoord, this.zCoord, handPosition.getBlockMetadata(this.worldObj), 0);
|
|
||||||
handPosition.setBlockWithNotify(this.worldObj, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,7 +233,7 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
|
||||||
if (this.ticks % 5 == 0 && FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT)
|
if (this.ticks % 5 == 0 && FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT)
|
||||||
{
|
{
|
||||||
// sound is 0.25 seconds long (20 ticks/second)
|
// sound is 0.25 seconds long (20 ticks/second)
|
||||||
this.worldObj.playSound(this.xCoord, this.yCoord, this.zCoord, "assemblyline.conveyor", 2f, 1.7f, true);
|
this.worldObj.playSound(this.xCoord, this.yCoord, this.zCoord, "assemblyline.conveyor", 0.8f, 1.7f, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Math.abs(this.renderYaw - this.rotationYaw) < this.ROTATION_SPEED + 0.1f)
|
if (Math.abs(this.renderYaw - this.rotationYaw) < this.ROTATION_SPEED + 0.1f)
|
||||||
|
@ -915,7 +916,7 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
|
||||||
{
|
{
|
||||||
if (entity instanceof EntityItem)
|
if (entity instanceof EntityItem)
|
||||||
{
|
{
|
||||||
this.grabbedItems.add(((EntityItem) entity).getEntityItem());
|
this.grabItem(((EntityItem) entity).getEntityItem());
|
||||||
entity.setDead();
|
entity.setDead();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -924,6 +925,12 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void grabItem(ItemStack itemStack)
|
||||||
|
{
|
||||||
|
this.grabbedItems.add(itemStack);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dropEntity(Entity entity)
|
public void dropEntity(Entity entity)
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class CommandRotateBy extends Command
|
||||||
if (Math.abs(this.tileEntity.rotationPitch - this.targetRotationPitch) > 0.001f)
|
if (Math.abs(this.tileEntity.rotationPitch - this.targetRotationPitch) > 0.001f)
|
||||||
this.tileEntity.rotationPitch = this.targetRotationPitch;
|
this.tileEntity.rotationPitch = this.targetRotationPitch;
|
||||||
|
|
||||||
if (this.ticks < this.totalTicks) { return true; }
|
//if (this.ticks < this.totalTicks) { return true; }
|
||||||
if (Math.abs(this.tileEntity.renderPitch - this.tileEntity.rotationPitch) > 0.001f) { return true; }
|
if (Math.abs(this.tileEntity.renderPitch - this.tileEntity.rotationPitch) > 0.001f) { return true; }
|
||||||
if (Math.abs(this.tileEntity.renderYaw - this.tileEntity.rotationYaw) > 0.001f) { return true; }
|
if (Math.abs(this.tileEntity.renderYaw - this.tileEntity.rotationYaw) > 0.001f) { return true; }
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class CommandRotateTo extends Command
|
||||||
this.tileEntity.rotationYaw = this.targetRotationYaw;
|
this.tileEntity.rotationYaw = this.targetRotationYaw;
|
||||||
this.tileEntity.rotationPitch = this.targetRotationPitch;
|
this.tileEntity.rotationPitch = this.targetRotationPitch;
|
||||||
|
|
||||||
if (this.ticks < this.totalTicks) { return true; }
|
//if (this.ticks < this.totalTicks) { return true; }
|
||||||
if (Math.abs(this.tileEntity.renderPitch - this.tileEntity.rotationPitch) > 0.001f) { return true; }
|
if (Math.abs(this.tileEntity.renderPitch - this.tileEntity.rotationPitch) > 0.001f) { return true; }
|
||||||
if (Math.abs(this.tileEntity.renderYaw - this.tileEntity.rotationYaw) > 0.001f) { return true; }
|
if (Math.abs(this.tileEntity.renderYaw - this.tileEntity.rotationYaw) > 0.001f) { return true; }
|
||||||
|
|
||||||
|
|
|
@ -382,46 +382,54 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/**
|
try
|
||||||
* Fail to, hence consume from crafting grid.
|
|
||||||
*/
|
|
||||||
InventoryCrafting inventoryCrafting = this.getCraftingMatrix();
|
|
||||||
GameRegistry.onItemCrafted(entityPlayer, itemStack, inventoryCrafting);
|
|
||||||
|
|
||||||
for (int var3 = 0; var3 < inventoryCrafting.getSizeInventory(); ++var3)
|
|
||||||
{
|
{
|
||||||
ItemStack var4 = inventoryCrafting.getStackInSlot(var3);
|
/**
|
||||||
|
* Fail to, hence consume from crafting grid.
|
||||||
|
*/
|
||||||
|
InventoryCrafting inventoryCrafting = this.getCraftingMatrix();
|
||||||
|
GameRegistry.onItemCrafted(entityPlayer, itemStack, inventoryCrafting);
|
||||||
|
|
||||||
if (var4 != null)
|
for (int var3 = 0; var3 < inventoryCrafting.getSizeInventory(); ++var3)
|
||||||
{
|
{
|
||||||
inventoryCrafting.decrStackSize(var3, 1);
|
ItemStack var4 = inventoryCrafting.getStackInSlot(var3);
|
||||||
|
|
||||||
if (var4.getItem().hasContainerItem())
|
if (var4 != null)
|
||||||
{
|
{
|
||||||
ItemStack var5 = var4.getItem().getContainerItemStack(var4);
|
inventoryCrafting.decrStackSize(var3, 1);
|
||||||
|
|
||||||
if (var5.isItemStackDamageable() && var5.getItemDamage() > var5.getMaxDamage())
|
if (var4.getItem().hasContainerItem())
|
||||||
{
|
{
|
||||||
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(entityPlayer, var5));
|
ItemStack var5 = var4.getItem().getContainerItemStack(var4);
|
||||||
var5 = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (var5 != null && (!var4.getItem().doesContainerItemLeaveCraftingGrid(var4) || !entityPlayer.inventory.addItemStackToInventory(var5)))
|
if (var5.isItemStackDamageable() && var5.getItemDamage() > var5.getMaxDamage())
|
||||||
{
|
|
||||||
if (inventoryCrafting.getStackInSlot(var3) == null)
|
|
||||||
{
|
{
|
||||||
inventoryCrafting.setInventorySlotContents(var3, var5);
|
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(entityPlayer, var5));
|
||||||
|
var5 = null;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (var5 != null && (!var4.getItem().doesContainerItemLeaveCraftingGrid(var4) || !entityPlayer.inventory.addItemStackToInventory(var5)))
|
||||||
{
|
{
|
||||||
entityPlayer.dropPlayerItem(var5);
|
if (inventoryCrafting.getStackInSlot(var3) == null)
|
||||||
|
{
|
||||||
|
inventoryCrafting.setInventorySlotContents(var3, var5);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
entityPlayer.dropPlayerItem(var5);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
this.replaceCraftingMatrix(inventoryCrafting);
|
this.replaceCraftingMatrix(inventoryCrafting);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
System.out.println("Imprinter: Failed to craft");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -614,26 +622,22 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Armbot
|
* Tries to let the Armbot craft an item.
|
||||||
*
|
|
||||||
* @param tileEntity
|
|
||||||
* @param heldEntity
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean onUse(IArmbot armbot, String[] args)
|
public boolean onUse(IArmbot armbot, String[] args)
|
||||||
{
|
{
|
||||||
this.onInventoryChanged();
|
this.onInventoryChanged();
|
||||||
TileEntityArmbot armbotTile = (TileEntityArmbot) armbot;
|
|
||||||
|
|
||||||
if (this.imprinterMatrix[3] != null)
|
if (this.imprinterMatrix[2] != null)
|
||||||
{
|
{
|
||||||
armbot.grabEntity(new EntityItem(this.worldObj, this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, this.imprinterMatrix[3]));
|
armbot.grabItem(this.imprinterMatrix[2].copy());
|
||||||
this.imprinterMatrix[3] = null;
|
this.onPickUpFromResult(null, this.imprinterMatrix[2]);
|
||||||
|
this.imprinterMatrix[2] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* if (armbotTile.getGrabbedEntities().size() > 0) { Entity heldEntity =
|
* OLD CODE if (armbotTile.getGrabbedEntities().size() > 0) { Entity heldEntity =
|
||||||
* armbot.getGrabbedEntities().get(0);
|
* armbot.getGrabbedEntities().get(0);
|
||||||
*
|
*
|
||||||
* if (heldEntity != null) { if (heldEntity instanceof EntityItem) { ItemStack stack =
|
* if (heldEntity != null) { if (heldEntity instanceof EntityItem) { ItemStack stack =
|
||||||
|
|
Loading…
Reference in a new issue