Posted 24 March 2012 - 10:59 AM
Hi,
I've recently noticed that computercraft can't place items (like buildcraft pipes etc)
the simple solution for it I've found by comparing the computer-craft code and the buildcraft-code:
buildcraft simply uses "onItemUse" with a "fake" EntityPlayer.
if I remove the ItemBlock-check in takePlaceableItem and change the place-method to
oh and the "getTempPlayer"-method I adapted from buildcraft:
now my turtle can place every item as the player would
I've recently noticed that computercraft can't place items (like buildcraft pipes etc)
the simple solution for it I've found by comparing the computer-craft code and the buildcraft-code:
buildcraft simply uses "onItemUse" with a "fake" EntityPlayer.
if I remove the ItemBlock-check in takePlaceableItem and change the place-method to
Item item = itemStack.getItem();
if(item == null)
return false;
if (item.onItemUse(itemStack, getTempPlayer(worldObj), worldObj, x, y - 1, z, 1)) {
if (item instanceof ItemComputer)
((ItemComputer) item).setupComputerAfterPlacement(itemStack, worldObj, x, y, z);
Block block = Block.blocksList[worldObj.getBlockId(x, y, z)];
if(block != null)
mod_CCTurtle.playBlockSound(worldObj, x + 0.5F, y + 0.5F, z + 0.5F, block);
return true;
}
oh and the "getTempPlayer"-method I adapted from buildcraft:
private static EntityPlayer tempPlayer = null;
private static EntityPlayer getTempPlayer(World world) {
if (tempPlayer == null) {
tempPlayer = new EntityPlayer(world) {
@Override
public void func_6420_o() {
}
};
}
return tempPlayer;
}
now my turtle can place every item as the player would