Search in sources :

Example 76 with TileEntity

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

the class DistanceTileEntitySorter method compare.

@Override
public int compare(Object arg0, Object arg1) {
    TileEntity c1 = (TileEntity) arg0;
    TileEntity c2 = (TileEntity) arg0;
    return Double.compare(PneumaticCraftUtils.distBetween(c1.xCoord, c1.yCoord, c1.zCoord, entity.posX, entity.posY, entity.posZ), PneumaticCraftUtils.distBetween(c2.xCoord, c2.yCoord, c2.zCoord, entity.posX, entity.posY, entity.posZ));
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity)

Example 77 with TileEntity

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

the class ModuleAirGrate method coolHeatSinks.

private void coolHeatSinks(World world, int x, int y, int z, int range) {
    if (grateRange > 2) {
        int curTeIndex = (int) (world.getTotalWorldTime() % 27);
        x += dir.offsetX * 2;
        y += dir.offsetY * 2;
        z += dir.offsetZ * 2;
        TileEntity te = world.getTileEntity(x - 1 + curTeIndex % 3, y - 1 + curTeIndex / 3 % 3, z - 1 + curTeIndex / 9 % 3);
        if (te instanceof TileEntityHeatSink)
            heatSinks.add((TileEntityHeatSink) te);
        Iterator<TileEntityHeatSink> iterator = heatSinks.iterator();
        while (iterator.hasNext()) {
            TileEntityHeatSink heatSink = iterator.next();
            if (heatSink.isInvalid()) {
                iterator.remove();
            } else {
                for (int i = 0; i < 4; i++) heatSink.onFannedByAirGrate();
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityHeatSink(pneumaticCraft.common.tileentity.TileEntityHeatSink)

Example 78 with TileEntity

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

the class ModuleRegulatorTube method renderModule.

@Override
protected void renderModule() {
    super.renderModule();
    if (isFake()) {
        if (!hasTicked) {
            TileEntityPneumaticBase tile = (TileEntityPneumaticBase) getTube();
            NetworkHandler.sendToServer(new PacketDescriptionPacketRequest(tile.xCoord, tile.yCoord, tile.zCoord));
            TileEntity neighbor = tile.getWorldObj().getTileEntity(tile.xCoord + dir.offsetX, tile.yCoord + dir.offsetY, tile.zCoord + dir.offsetZ);
            inLine = neighbor instanceof IPneumaticMachine;
            if (inLine) {
                inverted = ((IPneumaticMachine) neighbor).getAirHandler().getPressure(dir) > tile.getPressure(ForgeDirection.UNKNOWN);
                NetworkHandler.sendToServer(new PacketDescriptionPacketRequest(neighbor.xCoord, neighbor.yCoord, neighbor.zCoord));
            }
            hasTicked = true;
        }
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        if (inLine && !inverted) {
            GL11.glColor4d(0, 1, 0, 0.3);
        } else {
            GL11.glColor4d(1, 0, 0, 0.3);
        }
        GL11.glPushMatrix();
        GL11.glTranslated(0, 1, 0.2 + ClientTickHandler.TICKS % 20 * 0.015);
        GL11.glRotated(90, 1, 0, 0);
        RenderUtils.render3DArrow();
        GL11.glColor4d(1, 1, 1, 1);
        GL11.glPopMatrix();
        GL11.glDisable(GL11.GL_BLEND);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) PacketDescriptionPacketRequest(pneumaticCraft.common.network.PacketDescriptionPacketRequest) IPneumaticMachine(pneumaticCraft.api.tileentity.IPneumaticMachine) TileEntityPneumaticBase(pneumaticCraft.common.tileentity.TileEntityPneumaticBase)

Example 79 with TileEntity

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

the class CommandAmazonDelivery method processCommand.

@Override
public void processCommand(ICommandSender sender, String[] args) {
    if (args.length < 2)
        throw new WrongUsageException("command.deliverAmazon.args");
    int x, y, z;
    int curArg;
    String regex = "-?\\d+";
    if (args[0].matches(regex)) {
        if (args.length < 4)
            throw new WrongUsageException("command.deliverAmazon.args");
        if (!args[1].matches(regex) || !args[2].matches(regex))
            throw new WrongUsageException("command.deliverAmazon.coords");
        x = Integer.parseInt(args[0]);
        y = Integer.parseInt(args[1]);
        z = Integer.parseInt(args[2]);
        curArg = 3;
    } else {
        EntityPlayerMP player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(args[0]);
        if (player != null) {
            x = (int) Math.floor(player.posX);
            y = (int) Math.floor(player.posY) + 1;
            z = (int) Math.floor(player.posZ);
            curArg = 1;
        } else {
            throw new WrongUsageException("command.deliverAmazon.playerName");
        }
    }
    if (args.length < curArg + 3)
        throw new WrongUsageException("command.deliverAmazon.args");
    if (!args[curArg].matches(regex) || !args[curArg + 1].matches(regex) || !args[curArg + 2].matches(regex))
        throw new WrongUsageException("command.deliverAmazon.coords");
    TileEntity te = sender.getEntityWorld().getTileEntity(Integer.parseInt(args[curArg]), Integer.parseInt(args[curArg + 1]), Integer.parseInt(args[curArg + 2]));
    IInventory inv = IOHelper.getInventoryForTE(te);
    if (inv != null) {
        List<ItemStack> deliveredStacks = new ArrayList<ItemStack>();
        for (int i = 0; i < inv.getSizeInventory() && deliveredStacks.size() < 65; i++) {
            if (inv.getStackInSlot(i) != null)
                deliveredStacks.add(inv.getStackInSlot(i));
        }
        if (deliveredStacks.size() > 0) {
            PneumaticRegistry.getInstance().deliverItemsAmazonStyle(sender.getEntityWorld(), x, y, z, deliveredStacks.toArray(new ItemStack[deliveredStacks.size()]));
            sender.addChatMessage(new ChatComponentTranslation("command.deliverAmazon.success"));
        } else {
            sender.addChatMessage(new ChatComponentTranslation("command.deliverAmazon.noItems"));
        }
    } else {
        throw new WrongUsageException("command.deliverAmazon.noInventory");
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IInventory(net.minecraft.inventory.IInventory) WrongUsageException(net.minecraft.command.WrongUsageException) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) ArrayList(java.util.ArrayList) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack)

Example 80 with TileEntity

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

the class BlockPressureTube method randomDisplayTick.

@Override
@SideOnly(Side.CLIENT)
public /**
     * A randomly called display update to be able to add particles or other items for display
     */
void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) {
    TileEntity te = par1World.getTileEntity(par2, par3, par4);
    if (te instanceof TileEntityPressureTube) {
        TileEntityPressureTube tePt = (TileEntityPressureTube) te;
        int l = 0;
        for (TubeModule module : tePt.modules) if (module != null)
            l = Math.max(l, module.getRedstoneLevel());
        if (l > 0) {
            // for(int i = 0; i < 4; i++){
            double d0 = par2 + 0.5D + (par5Random.nextFloat() - 0.5D) * 0.5D;
            double d1 = par3 + 0.5D + (par5Random.nextFloat() - 0.5D) * 0.5D;
            double d2 = par4 + 0.5D + (par5Random.nextFloat() - 0.5D) * 0.5D;
            float f = l / 15.0F;
            float f1 = f * 0.6F + 0.4F;
            float f2 = f * f * 0.7F - 0.5F;
            float f3 = f * f * 0.6F - 0.7F;
            if (f2 < 0.0F) {
                f2 = 0.0F;
            }
            if (f3 < 0.0F) {
                f3 = 0.0F;
            }
            // PacketDispatcher.sendPacketToAllPlayers(PacketHandlerPneumaticCraft.spawnParticle("reddust",
            // d0, d1, d2, (double)f1, (double)f2, (double)f3));
            par1World.spawnParticle("reddust", d0, d1, d2, f1, f2, f3);
        // }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TubeModule(pneumaticCraft.common.block.tubes.TubeModule) ItemTubeModule(pneumaticCraft.common.item.ItemTubeModule) TileEntityPressureTube(pneumaticCraft.common.tileentity.TileEntityPressureTube) SideOnly(cpw.mods.fml.relauncher.SideOnly)

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