public void eventHandler(PipeEventItem.DropItem event) {
if (container.getWorldObj().isRemote) {
return;
}
Position p = new Position(container.xCoord, container.yCoord,
container.zCoord, event.direction);
p.moveForwards(1.0);
ItemStack stack = event.entity.getEntityItem();
EntityPlayer player = CoreProxy.proxy.getBuildCraftPlayer((WorldServer) getWorld(),
(int) p.x, (int) p.y, (int) p.z).get();
switch (event.direction) {
case DOWN:
player.rotationPitch = 90;
player.rotationYaw = 0;
break;
case UP:
player.rotationPitch = 270;
player.rotationYaw = 0;
break;
case NORTH:
player.rotationPitch = 0;
player.rotationYaw = 180;
break;
case SOUTH:
player.rotationPitch = 0;
player.rotationYaw = 0;
break;
case WEST:
player.rotationPitch = 0;
player.rotationYaw = 90;
break;
case EAST:
player.rotationPitch = 0;
player.rotationYaw = 270;
break;
case UNKNOWN:
break;
}
/**
* Check if there's a handler for this item type.
*/
for (IStripesHandler handler : PipeManager.stripesHandlers) {
if (handler.getType() == StripesHandlerType.ITEM_USE
&& handler.shouldHandle(stack)) {
if (handler.handle(getWorld(), (int) p.x, (int) p.y, (int) p.z,
event.direction, stack, player, this)) {
return;
}
}
}
/**
* Special, generic actions not handled by the handler.
*/
if (convertPipe(transport, event.item)) {
int moves = 0;
while (stack.stackSize > 0) {
if (getWorld().getBlock((int) p.x, (int) p.y, (int) p.z) != Blocks.air) {
break;
}
stack.getItem().onItemUse(new ItemStack(stack.getItem(), 1, stack.getItemDamage()),
player, getWorld(), (int) p.x, (int) p.y, (int) p.z, 1, 0, 0, 0
);
stack.stackSize--;
p.moveForwards(1.0);
moves++;
}
if (getWorld().getBlock((int) p.x, (int) p.y, (int) p.z) != Blocks.air) {
p.moveBackwards(1.0);
stack.stackSize++;
getWorld().setBlockToAir((int) p.x, (int) p.y, (int) p.z);
}
BuildCraftTransport.pipeItemsStripes.onItemUse(new ItemStack(