Search in sources :

Example 81 with TileEntity

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

the class BlockPressureTube method onBlockAdded.

@Override
public void onBlockAdded(World world, int x, int y, int z) {
    super.onBlockAdded(world, x, y, z);
    TileEntity te = world.getTileEntity(x, y, z);
    if (te != null && te instanceof TileEntityPressureTube) {
        TileEntityPressureTube tePt = (TileEntityPressureTube) te;
        tePt.updateConnections(world, x, y, z);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityPressureTube(pneumaticCraft.common.tileentity.TileEntityPressureTube)

Example 82 with TileEntity

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

the class ItemRemote method onUpdate.

@Override
public void onUpdate(ItemStack remote, World worl, Entity entity, int slot, boolean holdingItem) {
    if (!worl.isRemote) {
        NBTTagCompound tag = remote.getTagCompound();
        if (tag != null) {
            if (tag.hasKey("securityX")) {
                int x = tag.getInteger("securityX");
                int y = tag.getInteger("securityY");
                int z = tag.getInteger("securityZ");
                int dimensionId = tag.getInteger("securityDimension");
                WorldServer world = null;
                for (WorldServer w : MinecraftServer.getServer().worldServers) {
                    if (w.provider.dimensionId == dimensionId) {
                        world = w;
                        break;
                    }
                }
                if (world != null) {
                    TileEntity te = world.getTileEntity(x, y, z);
                    if (!(te instanceof TileEntitySecurityStation)) {
                        tag.removeTag("securityX");
                        tag.removeTag("securityY");
                        tag.removeTag("securityZ");
                        tag.removeTag("securityDimension");
                    }
                }
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntitySecurityStation(pneumaticCraft.common.tileentity.TileEntitySecurityStation) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) WorldServer(net.minecraft.world.WorldServer)

Example 83 with TileEntity

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

the class ItemRemote method isAllowedToEdit.

private boolean isAllowedToEdit(EntityPlayer player, ItemStack remote) {
    NBTTagCompound tag = remote.getTagCompound();
    if (tag != null) {
        if (tag.hasKey("securityX")) {
            int x = tag.getInteger("securityX");
            int y = tag.getInteger("securityY");
            int z = tag.getInteger("securityZ");
            int dimensionId = tag.getInteger("securityDimension");
            WorldServer world = null;
            for (WorldServer w : MinecraftServer.getServer().worldServers) {
                if (w.provider.dimensionId == dimensionId) {
                    world = w;
                    break;
                }
            }
            if (world != null) {
                TileEntity te = world.getTileEntity(x, y, z);
                if (te instanceof TileEntitySecurityStation) {
                    boolean canAccess = ((TileEntitySecurityStation) te).doesAllowPlayer(player);
                    if (!canAccess) {
                        player.addChatComponentMessage(new ChatComponentTranslation("gui.remote.noEditRights", x, y, z));
                    }
                    return canAccess;
                }
            }
        }
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntitySecurityStation(pneumaticCraft.common.tileentity.TileEntitySecurityStation) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) WorldServer(net.minecraft.world.WorldServer)

Example 84 with TileEntity

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

the class ItemAmadronTablet method getLiquidProvider.

public static IFluidHandler getLiquidProvider(ItemStack tablet) {
    ChunkPosition pos = getLiquidProvidingLocation(tablet);
    if (pos != null) {
        int dimension = getLiquidProvidingDimension(tablet);
        TileEntity te = PneumaticCraftUtils.getTileEntity(pos, dimension);
        if (te instanceof IFluidHandler)
            return (IFluidHandler) te;
    }
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ChunkPosition(net.minecraft.world.ChunkPosition) IFluidHandler(net.minecraftforge.fluids.IFluidHandler)

Example 85 with TileEntity

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

the class PacketSecurityStation method handleServerSide.

@Override
public void handleServerSide(REQ message, EntityPlayer player) {
    TileEntity te = player.worldObj.getTileEntity(message.x, message.y, message.z);
    handleServerSide(te, message.username);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity)

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