Search in sources :

Example 66 with TileEntity

use of net.minecraft.tileentity.TileEntity in project PneumaticCraft by MineMaarten.

the class BlockPneumaticDoor method rotateBlock.

@Override
public boolean rotateBlock(World world, EntityPlayer player, int x, int y, int z, ForgeDirection face) {
    int meta = world.getBlockMetadata(x, y, z);
    if (meta < 6) {
        super.rotateBlock(world, player, x, y, z, face);
        world.setBlockMetadataWithNotify(x, y + 1, z, world.getBlockMetadata(x, y, z) + 6, 3);
        TileEntity te = world.getTileEntity(x, y, z);
        if (te instanceof TileEntityPneumaticDoor) {
            ((TileEntityPneumaticDoor) te).rightGoing = true;
            ((TileEntityPneumaticDoor) te).setRotation(0);
            TileEntity topDoor = world.getTileEntity(x, y + 1, z);
            if (topDoor instanceof TileEntityPneumaticDoor) {
                ((TileEntityPneumaticDoor) topDoor).sendDescriptionPacket();
            }
        }
    } else {
        return rotateBlock(world, player, x, y - 1, z, face);
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityPneumaticDoor(pneumaticCraft.common.tileentity.TileEntityPneumaticDoor)

Example 67 with TileEntity

use of net.minecraft.tileentity.TileEntity in project PneumaticCraft by MineMaarten.

the class BlockPneumaticDoor method setBlockBoundsBasedOnState.

@Override
public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int x, int y, int z) {
    if (isTrackingPlayerEye) {
        setBlockBounds(0, 0, 0, 1, 1, 1);
    } else {
        float xMin = 0;
        float zMin = 0;
        float xMax = 1;
        float zMax = 1;
        TileEntity te = blockAccess.getTileEntity(x, y, z);
        int meta = blockAccess.getBlockMetadata(x, y, z);
        if (te instanceof TileEntityPneumaticDoor) {
            TileEntityPneumaticDoor door = (TileEntityPneumaticDoor) te;
            float cosinus = 13 / 16F - (float) Math.sin(Math.toRadians(door.rotation)) * 13 / 16F;
            float sinus = 13 / 16F - (float) Math.cos(Math.toRadians(door.rotation)) * 13 / 16F;
            if (door.rightGoing) {
                switch(ForgeDirection.getOrientation(meta % 6)) {
                    case NORTH:
                        zMin = cosinus;
                        xMax = 1 - sinus;
                        break;
                    case WEST:
                        xMin = cosinus;
                        zMin = sinus;
                        break;
                    case SOUTH:
                        zMax = 1 - cosinus;
                        xMin = sinus;
                        break;
                    case EAST:
                        xMax = 1 - cosinus;
                        zMax = 1 - sinus;
                        break;
                }
            } else {
                switch(ForgeDirection.getOrientation(meta % 6)) {
                    case NORTH:
                        zMin = cosinus;
                        xMin = sinus;
                        break;
                    case WEST:
                        xMin = cosinus;
                        zMax = 1 - sinus;
                        break;
                    case SOUTH:
                        zMax = 1 - cosinus;
                        xMax = 1 - sinus;
                        break;
                    case EAST:
                        xMax = 1 - cosinus;
                        zMin = sinus;
                        break;
                }
            }
        }
        setBlockBounds(xMin, meta < 6 ? 0 : -1, zMin, xMax, meta < 6 ? 2 : 1, zMax);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityPneumaticDoor(pneumaticCraft.common.tileentity.TileEntityPneumaticDoor)

Example 68 with TileEntity

use of net.minecraft.tileentity.TileEntity in project PneumaticCraft by MineMaarten.

the class DroneAIExternalProgram method isValidPosition.

@Override
protected boolean isValidPosition(ChunkPosition pos) {
    if (traversedPositions.add(pos)) {
        curSlot = 0;
        TileEntity te = drone.getWorld().getTileEntity(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
        return te instanceof IInventory;
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IInventory(net.minecraft.inventory.IInventory)

Example 69 with TileEntity

use of net.minecraft.tileentity.TileEntity in project PneumaticCraft by MineMaarten.

the class DroneAILiquidImport method emptyTank.

private boolean emptyTank(ChunkPosition pos, boolean simulate) {
    if (drone.getTank().getFluidAmount() == drone.getTank().getCapacity()) {
        drone.addDebugEntry("gui.progWidget.liquidImport.debug.fullDroneTank");
        abort();
        return false;
    } else {
        TileEntity te = drone.getWorld().getTileEntity(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
        if (te instanceof IFluidHandler) {
            IFluidHandler tank = (IFluidHandler) te;
            for (int i = 0; i < 6; i++) {
                if (((ISidedWidget) widget).getSides()[i]) {
                    FluidStack importedFluid = tank.drain(ForgeDirection.getOrientation(i), Integer.MAX_VALUE, false);
                    if (importedFluid != null && ((ILiquidFiltered) widget).isFluidValid(importedFluid.getFluid())) {
                        int filledAmount = drone.getTank().fill(importedFluid, false);
                        if (filledAmount > 0) {
                            if (((ICountWidget) widget).useCount())
                                filledAmount = Math.min(filledAmount, getRemainingCount());
                            if (!simulate) {
                                decreaseCount(drone.getTank().fill(tank.drain(ForgeDirection.getOrientation(i), filledAmount, true), true));
                            }
                            return true;
                        }
                    }
                }
            }
            drone.addDebugEntry("gui.progWidget.liquidImport.debug.emptiedToMax", pos);
        } else if (!((ICountWidget) widget).useCount() || getRemainingCount() >= 1000) {
            Fluid fluid = FluidRegistry.lookupFluidForBlock(drone.getWorld().getBlock(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ));
            if (fluid != null && ((ILiquidFiltered) widget).isFluidValid(fluid) && drone.getTank().fill(new FluidStack(fluid, 1000), false) == 1000 && FluidUtils.isSourceBlock(drone.getWorld(), pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ)) {
                if (!simulate) {
                    decreaseCount(1000);
                    drone.getTank().fill(new FluidStack(fluid, 1000), true);
                    drone.getWorld().setBlockToAir(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
                }
                return true;
            }
        }
        return false;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ILiquidFiltered(pneumaticCraft.common.progwidgets.ILiquidFiltered) FluidStack(net.minecraftforge.fluids.FluidStack) Fluid(net.minecraftforge.fluids.Fluid) ICountWidget(pneumaticCraft.common.progwidgets.ICountWidget) IFluidHandler(net.minecraftforge.fluids.IFluidHandler)

Example 70 with TileEntity

use of net.minecraft.tileentity.TileEntity in project PneumaticCraft by MineMaarten.

the class HackableMobSpawner method onHackFinished.

@Override
public void onHackFinished(World world, int x, int y, int z, EntityPlayer player) {
    if (!world.isRemote) {
        NBTTagCompound tag = new NBTTagCompound();
        TileEntity te = world.getTileEntity(x, y, z);
        te.writeToNBT(tag);
        tag.setShort("RequiredPlayerRange", (short) 0);
        te.readFromNBT(tag);
        world.markBlockForUpdate(x, y, z);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Aggregations

TileEntity (net.minecraft.tileentity.TileEntity)822 ItemStack (net.minecraft.item.ItemStack)149 BlockPos (net.minecraft.util.math.BlockPos)130 Block (net.minecraft.block.Block)83 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)76 EnumFacing (net.minecraft.util.EnumFacing)62 ArrayList (java.util.ArrayList)61 IBlockState (net.minecraft.block.state.IBlockState)61 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)57 IInventory (net.minecraft.inventory.IInventory)49 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)44 World (net.minecraft.world.World)43 EntityItem (net.minecraft.entity.item.EntityItem)39 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)35 FluidStack (net.minecraftforge.fluids.FluidStack)29 EntityPlayer (net.minecraft.entity.player.EntityPlayer)28 HashMap (java.util.HashMap)25 IFluidHandler (net.minecraftforge.fluids.IFluidHandler)23 AMVector3 (am2.api.math.AMVector3)21 Entity (net.minecraft.entity.Entity)21