Search in sources :

Example 1 with EntityLogisticsDrone

use of pneumaticCraft.common.entity.living.EntityLogisticsDrone in project PneumaticCraft by MineMaarten.

the class ItemLogisticsDrone method onItemUse.

@Override
public boolean onItemUse(ItemStack iStack, EntityPlayer player, World world, int x, int y, int z, int side, float vecX, float vecY, float vecZ) {
    if (!world.isRemote) {
        EntityDrone drone = new EntityLogisticsDrone(world, player);
        ForgeDirection dir = ForgeDirection.getOrientation(side);
        drone.setPosition(x + 0.5 + dir.offsetX, y + 0.5 + dir.offsetY, z + 0.5 + dir.offsetZ);
        world.spawnEntityInWorld(drone);
        NBTTagCompound stackTag = iStack.getTagCompound();
        NBTTagCompound entityTag = new NBTTagCompound();
        drone.writeEntityToNBT(entityTag);
        if (stackTag != null) {
            entityTag.setFloat("currentAir", stackTag.getFloat("currentAir"));
            entityTag.setInteger("color", stackTag.getInteger("color"));
            NBTTagCompound invTag = stackTag.getCompoundTag("UpgradeInventory");
            if (invTag != null)
                entityTag.setTag("Inventory", invTag.copy());
        }
        drone.readEntityFromNBT(entityTag);
        addLogisticsProgram(x, y, z, drone.progWidgets);
        if (iStack.hasDisplayName())
            drone.setCustomNameTag(iStack.getDisplayName());
        drone.naturallySpawned = false;
        drone.onSpawnWithEgg(null);
        iStack.stackSize--;
    }
    return true;
}
Also used : EntityDrone(pneumaticCraft.common.entity.living.EntityDrone) EntityLogisticsDrone(pneumaticCraft.common.entity.living.EntityLogisticsDrone) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Aggregations

NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)1 EntityDrone (pneumaticCraft.common.entity.living.EntityDrone)1 EntityLogisticsDrone (pneumaticCraft.common.entity.living.EntityLogisticsDrone)1