use of uk.co.qmunity.lib.vec.Vec3d in project BluePower by Qmunity.
the class GateIntegratedCircuit method getBundledDeviceOnSide.
@Override
public IBundledDevice getBundledDeviceOnSide(ForgeDirection side) {
side = new Vec3d(0, 0, 0).add(side).rotate(0, 90 * -getRotation(), 0).toForgeDirection();
IPart p = getCircuitPartOnSide(side);
if (p == null)
return null;
if (p instanceof IBundledDevice)
return (IBundledDevice) p;
return null;
}
use of uk.co.qmunity.lib.vec.Vec3d in project BluePower by Qmunity.
the class GateNullCell method onActivated.
// In-world customization
@Override
public boolean onActivated(EntityPlayer player, QMovingObjectPosition mop, ItemStack item) {
Vec3d hit = new Vec3d(mop.hitVec).sub(mop.blockX, mop.blockY, mop.blockZ).rotateUndo(getFace(), Vec3d.center);
if (item != null) {
if (item.getItem() instanceof ItemPart) {
IPart part = ((ItemPart) item.getItem()).createPart(item, player, null, null);
if (part != null && part instanceof PartRedwireFaceUninsulated) {
PartRedwireFace wire = (PartRedwireFace) part;
if (hit.getY() > 2 / 16D) {
if (typeB == null) {
if (getWorld().isRemote)
return true;
typeB = wire.getRedwireType(ForgeDirection.UNKNOWN);
bundledB = false;
inWorldB = true;
getRedstoneConnectionCache().recalculateConnections();
sendUpdatePacket();
if (!player.capabilities.isCreativeMode)
item.stackSize--;
return true;
}
} else {
if (typeA == null) {
if (getWorld().isRemote)
return true;
typeA = wire.getRedwireType(ForgeDirection.UNKNOWN);
bundledA = false;
inWorldA = true;
getRedstoneConnectionCache().recalculateConnections();
sendUpdatePacket();
if (!player.capabilities.isCreativeMode)
item.stackSize--;
return true;
}
}
}
} else if (item.getItem() instanceof IScrewdriver && player.isSneaking()) {
if (hit.getY() > 2 / 16D && ((hit.getY() <= 4 / 16D && hit.getX() > 0.5 - 1 / 16D && hit.getX() > 0.5 + 1 / 16D) || hit.getY() > 4 / 16D)) {
if (typeB != null) {
if (getWorld().isRemote)
return true;
IOHelper.spawnItemInWorld(getWorld(), typeB.getPartInfo(MinecraftColor.NONE, bundledB).getStack(), getX() + 0.5, getY() + 0.5, getZ() + 0.5);
typeB = null;
bundledB = false;
inWorldB = false;
((IScrewdriver) item.getItem()).damage(item, 1, player, false);
getRedstoneConnectionCache().recalculateConnections();
sendUpdatePacket();
return true;
}
} else if (hit.getY() > 2 / 16D) {
if (typeA != null) {
if (getWorld().isRemote)
return true;
IOHelper.spawnItemInWorld(getWorld(), typeA.getPartInfo(MinecraftColor.NONE, bundledA).getStack(), getX() + 0.5, getY() + 0.5, getZ() + 0.5);
typeA = null;
bundledA = false;
inWorldA = false;
((IScrewdriver) item.getItem()).damage(item, 1, player, false);
getRedstoneConnectionCache().recalculateConnections();
sendUpdatePacket();
return true;
}
}
}
}
return super.onActivated(player, mop, item);
}
Aggregations