Search in sources :

Example 1 with EntityMinecartChest

use of net.minecraft.entity.item.EntityMinecartChest in project Wurst-MC-1.12 by Wurst-Imperium.

the class ChestEspMod method onUpdate.

@Override
public void onUpdate() {
    ArrayList<AxisAlignedBB> basicNew = new ArrayList<>();
    ArrayList<AxisAlignedBB> basicEmpty = new ArrayList<>();
    ArrayList<AxisAlignedBB> basicNotEmpty = new ArrayList<>();
    ArrayList<AxisAlignedBB> trappedNew = new ArrayList<>();
    ArrayList<AxisAlignedBB> trappedEmpty = new ArrayList<>();
    ArrayList<AxisAlignedBB> trappedNotEmpty = new ArrayList<>();
    ArrayList<AxisAlignedBB> enderChests = new ArrayList<>();
    for (TileEntity tileEntity : WMinecraft.getWorld().loadedTileEntityList) if (tileEntity instanceof TileEntityChest) {
        // ignore other block in double chest
        TileEntityChest chest = (TileEntityChest) tileEntity;
        if (chest.adjacentChestXPos != null || chest.adjacentChestZPos != null)
            continue;
        // get hitbox
        AxisAlignedBB bb = WBlock.getBoundingBox(chest.getPos());
        if (bb == null)
            continue;
        // larger box for double chest
        if (chest.adjacentChestXNeg != null) {
            BlockPos pos2 = chest.adjacentChestXNeg.getPos();
            AxisAlignedBB bb2 = WBlock.getBoundingBox(pos2);
            bb = bb.union(bb2);
        } else if (chest.adjacentChestZNeg != null) {
            BlockPos pos2 = chest.adjacentChestZNeg.getPos();
            AxisAlignedBB bb2 = WBlock.getBoundingBox(pos2);
            bb = bb.union(bb2);
        }
        // add to appropriate list
        boolean trapped = WTileEntity.isTrappedChest(chest);
        if (emptyChests.contains(chest.getPos()))
            if (trapped)
                trappedEmpty.add(bb);
            else
                basicEmpty.add(bb);
        else if (nonEmptyChests.contains(chest.getPos()))
            if (trapped)
                trappedNotEmpty.add(bb);
            else
                basicNotEmpty.add(bb);
        else if (trapped)
            trappedNew.add(bb);
        else
            basicNew.add(bb);
    } else if (tileEntity instanceof TileEntityEnderChest) {
        AxisAlignedBB bb = WBlock.getBoundingBox(((TileEntityEnderChest) tileEntity).getPos());
        enderChests.add(bb);
    }
    GL11.glNewList(normalChests, GL11.GL_COMPILE);
    GL11.glColor4f(0, 1, 0, 0.25F);
    renderBoxes(basicNew, solidBox);
    GL11.glColor4f(0, 1, 0, 0.5F);
    renderBoxes(basicNew, outlinedBox);
    renderBoxes(basicEmpty, outlinedBox);
    renderBoxes(basicNotEmpty, outlinedBox);
    renderBoxes(basicNotEmpty, crossBox);
    GL11.glColor4f(1, 0.5F, 0, 0.25F);
    renderBoxes(trappedNew, solidBox);
    GL11.glColor4f(1, 0.5F, 0, 0.5F);
    renderBoxes(trappedNew, outlinedBox);
    renderBoxes(trappedEmpty, outlinedBox);
    renderBoxes(trappedNotEmpty, outlinedBox);
    renderBoxes(trappedNotEmpty, crossBox);
    GL11.glColor4f(0, 1, 1, 0.25F);
    renderBoxes(enderChests, solidBox);
    GL11.glColor4f(0, 1, 1, 0.5F);
    renderBoxes(enderChests, outlinedBox);
    GL11.glEndList();
    // minecarts
    minecarts.clear();
    for (Entity entity : WMinecraft.getWorld().loadedEntityList) if (entity instanceof EntityMinecartChest)
        minecarts.add(entity);
    // chest counter
    chestCounter = basicNew.size() + basicEmpty.size() + basicNotEmpty.size() + trappedNew.size() + trappedEmpty.size() + trappedNotEmpty.size() + enderChests.size() + minecarts.size();
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) TileEntity(net.minecraft.tileentity.TileEntity) WTileEntity(net.wurstclient.compatibility.WTileEntity) Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) WTileEntity(net.wurstclient.compatibility.WTileEntity) TileEntityChest(net.minecraft.tileentity.TileEntityChest) EntityMinecartChest(net.minecraft.entity.item.EntityMinecartChest) ArrayList(java.util.ArrayList) BlockPos(net.minecraft.util.math.BlockPos) TileEntityEnderChest(net.minecraft.tileentity.TileEntityEnderChest)

Example 2 with EntityMinecartChest

use of net.minecraft.entity.item.EntityMinecartChest in project PneumaticCraft by MineMaarten.

the class TileEntityAirCannon method getPayloadEntity.

// warning: no null-check for inventory slot 0
private Entity getPayloadEntity() {
    if (getUpgrades(ItemMachineUpgrade.UPGRADE_DISPENSER_DAMAGE, getUpgradeSlots()) > 0) {
        Item item = inventory[0].getItem();
        if (item == Item.getItemFromBlock(Blocks.tnt)) {
            EntityTNTPrimed tnt = new EntityTNTPrimed(worldObj);
            tnt.fuse = 80;
            return tnt;
        } else if (item == Items.experience_bottle)
            return new EntityExpBottle(worldObj);
        else if (item == Items.potionitem) {
            EntityPotion potion = new EntityPotion(worldObj);
            potion.setPotionDamage(inventory[0].getItemDamage());
            return potion;
        } else if (item == Items.arrow)
            return new EntityArrow(worldObj);
        else if (item == Items.egg)
            return new EntityEgg(worldObj);
        else // EntitySmallFireball(worldObj);
        if (item == Items.snowball)
            return new EntitySnowball(worldObj);
        else if (item == Items.spawn_egg)
            return ItemMonsterPlacer.spawnCreature(worldObj, inventory[0].getItemDamage(), 0, 0, 0);
        else if (item == Items.minecart)
            return new EntityMinecartEmpty(worldObj);
        else if (item == Items.chest_minecart)
            return new EntityMinecartChest(worldObj);
        else if (item == Items.furnace_minecart)
            return new EntityMinecartFurnace(worldObj);
        else if (item == Items.hopper_minecart)
            return new EntityMinecartHopper(worldObj);
        else if (item == Items.tnt_minecart)
            return new EntityMinecartTNT(worldObj);
        else if (item == Items.boat)
            return new EntityBoat(worldObj);
    }
    EntityItem item = new EntityItem(worldObj);
    item.setEntityItemStack(inventory[0].copy());
    // 1200 ticks left to live, = 60s.
    item.age = 4800;
    // add
    item.lifespan += Math.min(getUpgrades(ItemMachineUpgrade.UPGRADE_ITEM_LIFE, getUpgradeSlots()) * 600, 4800);
    // min.
    return item;
}
Also used : EntityArrow(net.minecraft.entity.projectile.EntityArrow) EntityMinecartChest(net.minecraft.entity.item.EntityMinecartChest) EntityTNTPrimed(net.minecraft.entity.item.EntityTNTPrimed) EntityMinecartTNT(net.minecraft.entity.item.EntityMinecartTNT) EntityBoat(net.minecraft.entity.item.EntityBoat) EntityMinecartFurnace(net.minecraft.entity.item.EntityMinecartFurnace) EntityMinecartHopper(net.minecraft.entity.item.EntityMinecartHopper) EntityExpBottle(net.minecraft.entity.item.EntityExpBottle) EntityEgg(net.minecraft.entity.projectile.EntityEgg) Item(net.minecraft.item.Item) EntityItem(net.minecraft.entity.item.EntityItem) EntitySnowball(net.minecraft.entity.projectile.EntitySnowball) EntityPotion(net.minecraft.entity.projectile.EntityPotion) EntityMinecartEmpty(net.minecraft.entity.item.EntityMinecartEmpty) EntityItem(net.minecraft.entity.item.EntityItem)

Aggregations

EntityMinecartChest (net.minecraft.entity.item.EntityMinecartChest)2 ArrayList (java.util.ArrayList)1 Entity (net.minecraft.entity.Entity)1 EntityBoat (net.minecraft.entity.item.EntityBoat)1 EntityExpBottle (net.minecraft.entity.item.EntityExpBottle)1 EntityItem (net.minecraft.entity.item.EntityItem)1 EntityMinecartEmpty (net.minecraft.entity.item.EntityMinecartEmpty)1 EntityMinecartFurnace (net.minecraft.entity.item.EntityMinecartFurnace)1 EntityMinecartHopper (net.minecraft.entity.item.EntityMinecartHopper)1 EntityMinecartTNT (net.minecraft.entity.item.EntityMinecartTNT)1 EntityTNTPrimed (net.minecraft.entity.item.EntityTNTPrimed)1 EntityArrow (net.minecraft.entity.projectile.EntityArrow)1 EntityEgg (net.minecraft.entity.projectile.EntityEgg)1 EntityPotion (net.minecraft.entity.projectile.EntityPotion)1 EntitySnowball (net.minecraft.entity.projectile.EntitySnowball)1 Item (net.minecraft.item.Item)1 TileEntity (net.minecraft.tileentity.TileEntity)1 TileEntityChest (net.minecraft.tileentity.TileEntityChest)1 TileEntityEnderChest (net.minecraft.tileentity.TileEntityEnderChest)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1