use of buildcraft.api.transport.IStripesHandler in project BuildCraft by BuildCraft.
the class PipeItemsStripes method eventHandler.
public void eventHandler(PipeEventItem.DropItem event) {
if (container.getWorld().isRemote) {
return;
}
EnumFacing direction = actionDir.face;
if (direction == null) {
direction = event.direction;
}
Vec3d p = Utils.convert(container.getPos()).add(Utils.convert(direction));
ItemStack stack = event.entity.getEntityItem();
EntityPlayer player = CoreProxy.proxy.getBuildCraftPlayer((WorldServer) getWorld(), Utils.convertFloor(p)).get();
switch(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;
}
/**
* 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(), Utils.convertFloor(p), direction, stack, player, this)) {
event.entity = null;
return;
}
}
}
}
use of buildcraft.api.transport.IStripesHandler in project BuildCraft by BuildCraft.
the class PipeItemsStripes method updateEntity.
@Override
public void updateEntity() {
super.updateEntity();
if (container.getWorld().isRemote) {
return;
}
if (battery.getEnergyStored() >= 10) {
EnumPipePart o = actionDir;
if (o == EnumPipePart.CENTER) {
o = EnumPipePart.fromFacing(getOpenOrientation());
}
if (o != EnumPipePart.CENTER) {
Vec3d vec = Utils.convert(container.getPos()).add(Utils.convert(o.face));
BlockPos veci = Utils.convertFloor(vec);
if (!BlockUtil.isUnbreakableBlock(getWorld(), Utils.convertFloor(vec))) {
IBlockState state = getWorld().getBlockState(Utils.convertFloor(vec));
Block block = state.getBlock();
if (block instanceof BlockLiquid || block instanceof IFluidBlock) {
return;
}
ItemStack stack = new ItemStack(block, 1, block.getMetaFromState(state));
EntityPlayer player = CoreProxy.proxy.getBuildCraftPlayer((WorldServer) getWorld(), veci).get();
if (battery.useEnergy(10, 10, false) != 10) {
return;
}
for (IStripesHandler handler : PipeManager.stripesHandlers) {
if (handler.getType() == StripesHandlerType.BLOCK_BREAK && handler.shouldHandle(stack)) {
if (handler.handle(getWorld(), veci, o.face, stack, player, this)) {
return;
}
}
}
List<ItemStack> stacks = block.getDrops(getWorld(), veci, state, 0);
if (stacks != null) {
for (ItemStack s : stacks) {
if (s != null) {
sendItem(s, o.opposite().face);
}
}
}
getWorld().setBlockToAir(veci);
}
}
return;
}
}
use of buildcraft.api.transport.IStripesHandler in project BuildCraft by BuildCraft.
the class AIRobotStripesHandler method update.
@Override
public void update() {
if (useToBlock == null) {
setSuccess(false);
terminate();
return;
}
useCycles++;
if (useCycles > 60) {
ItemStack stack = robot.getHeldItem();
EnumFacing direction = EnumFacing.NORTH;
EntityPlayer player = CoreProxy.proxy.getBuildCraftPlayer((WorldServer) robot.worldObj, useToBlock).get();
player.rotationPitch = 0;
player.rotationYaw = 180;
for (IStripesHandler handler : PipeManager.stripesHandlers) {
if (handler.getType() == StripesHandlerType.ITEM_USE && handler.shouldHandle(stack)) {
if (handler.handle(robot.worldObj, useToBlock, direction, stack, player, this)) {
robot.setItemInUse(null);
terminate();
return;
}
}
}
terminate();
}
}
Aggregations