Search in sources :

Example 1 with Vec2d

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);
}
Also used : ItemPart(com.bluepowermod.item.ItemPart) IPart(uk.co.qmunity.lib.part.IPart) IIntegratedCircuitPart(com.bluepowermod.api.gate.IIntegratedCircuitPart) Vec2d(uk.co.qmunity.lib.vec.Vec2d)

Aggregations

IIntegratedCircuitPart (com.bluepowermod.api.gate.IIntegratedCircuitPart)1 ItemPart (com.bluepowermod.item.ItemPart)1 IPart (uk.co.qmunity.lib.part.IPart)1 Vec2d (uk.co.qmunity.lib.vec.Vec2d)1