use of uk.co.qmunity.lib.vec.Vec2d in project BluePower by Qmunity.
the class GateIntegratedCircuit method onActivated.
@Override
public boolean onActivated(final EntityPlayer player, QMovingObjectPosition hit, ItemStack item) {
Vec2d v = new Vec2d(hit.hitVec.xCoord - hit.blockX, hit.hitVec.zCoord - hit.blockZ).sub(0.5, 0.5).rotate(90 * -getRotation()).add(0.5, 0.5);
int x = (int) (v.getX() * getSize());
int z = (int) (v.getY() * getSize());
if (getPart(x, z) == null && item != null && item.getItem() instanceof ItemPart) {
IPart part = ((ItemPart) item.getItem()).createPart(item, player, getWorld(), hit);
if (part instanceof IIntegratedCircuitPart) {
if (!getWorld().isRemote) {
setPart(x, z, (IIntegratedCircuitPart) part);
sendUpdatePacket(part, -1);
}
return true;
}
}
return super.onActivated(player, hit, item);
}
Aggregations