Search in sources :

Example 6 with Cube

use of com.builtbroken.mc.imp.transform.region.Cube in project Engine by VoltzEngine-Project.

the class TileMulti method read.

@Override
public boolean read(ByteBuf buf, int id, EntityPlayer player, PacketType type) {
    if (worldObj.isRemote) {
        if (id == 1) {
            //Update host data for client use
            Pos pos = new Pos(buf);
            if (pos.isZero()) {
                this.setHost(null);
            } else {
                TileEntity tile = pos.getTileEntity(worldObj);
                if (tile instanceof IMultiTileHost) {
                    this.setHost((IMultiTileHost) tile);
                }
            }
            //Update should render
            boolean prev = shouldRenderBlock;
            shouldRenderBlock = buf.readBoolean();
            //Update render bounds
            if (buf.readBoolean()) {
                overrideRenderBounds = new Cube(buf);
            } else {
                overrideRenderBounds = new Cube(0, 0, 0, 1, 1, 1);
            }
            if (prev != shouldRenderBlock) {
                worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord);
            }
            return true;
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Pos(com.builtbroken.mc.imp.transform.vector.Pos) Cube(com.builtbroken.mc.imp.transform.region.Cube) IMultiTileHost(com.builtbroken.mc.api.tile.multiblock.IMultiTileHost)

Example 7 with Cube

use of com.builtbroken.mc.imp.transform.region.Cube in project Engine by VoltzEngine-Project.

the class PacketSelectionData method decodeInto.

@Override
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
    RenderSelection.cube_render_list.clear();
    RenderSelection.region_render_list.clear();
    //Read selection
    RenderSelection.selection = new Cube(buffer);
    //Read other player's selections to render
    int count = buffer.readInt();
    if (count > 0)
        for (int i = 0; i < count; i++) {
            RenderSelection.cube_render_list.add(new Cube(buffer));
        }
    //Read region bounds
    count = buffer.readInt();
    if (count > 0)
        for (int i = 0; i < count; i++) {
            RenderSelection.region_render_list.add(new Cube(buffer));
        }
}
Also used : Cube(com.builtbroken.mc.imp.transform.region.Cube)

Example 8 with Cube

use of com.builtbroken.mc.imp.transform.region.Cube in project Engine by VoltzEngine-Project.

the class AbstractTileTest method testGetCollisionBounds.

@Test
public void testGetCollisionBounds() {
    FakeWorld world = FakeWorld.newWorld("TestGetCollisionBounds");
    world.setBlock(0, 0, 0, block);
    Tile tile = ((Tile) world.getTileEntity(0, 0, 0));
    Cube cube = tile.getCollisionBounds();
    if (cube != null) {
    //TODO test too see if cube is valid
    }
}
Also used : Cube(com.builtbroken.mc.imp.transform.region.Cube) FakeWorld(com.builtbroken.mc.testing.junit.world.FakeWorld) PacketTile(com.builtbroken.mc.core.network.packet.PacketTile) BlockTile(com.builtbroken.mc.prefab.tile.BlockTile) Tile(com.builtbroken.mc.prefab.tile.Tile) Test(org.junit.Test)

Example 9 with Cube

use of com.builtbroken.mc.imp.transform.region.Cube in project ICBM-Classic by BuiltBrokenModding.

the class BlastRedmatter method doEntityMovement.

protected void doEntityMovement() {
    float entityRadius = this.getRadius() * 2;
    Cube cube = new Cube(position.add(0.5).sub(entityRadius), position.add(0.5).add(entityRadius));
    AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(cube.min().x(), cube.min().y(), cube.min().z(), cube.max().x(), cube.max().y(), cube.max().z());
    List<Entity> allEntities = this.world().getEntitiesWithinAABB(Entity.class, bounds);
    boolean doExplosion = true;
    for (Entity entity : allEntities) {
        doExplosion = !this.affectEntity(entityRadius, entity, doExplosion);
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) Entity(net.minecraft.entity.Entity) Cube(com.builtbroken.mc.imp.transform.region.Cube)

Example 10 with Cube

use of com.builtbroken.mc.imp.transform.region.Cube in project ICBM-Classic by BuiltBrokenModding.

the class BlastEMP method doExplode.

@Override
public void doExplode() {
    if (!world().isRemote) {
        if (this.effectBlocks) {
            for (int x = (int) -this.getRadius(); x < (int) this.getRadius(); x++) {
                for (int y = (int) -this.getRadius(); y < (int) this.getRadius(); y++) {
                    for (int z = (int) -this.getRadius(); z < (int) this.getRadius(); z++) {
                        double dist = MathHelper.sqrt_double((x * x + y * y + z * z));
                        Pos searchPosition = new Pos(x, y, z).add(position);
                        if (dist > this.getRadius()) {
                            continue;
                        }
                        if (Math.round(position.x() + y) == position.yi()) {
                            world().spawnParticle("largesmoke", searchPosition.x(), searchPosition.y(), searchPosition.z(), 0, 0, 0);
                        }
                        Block block = searchPosition.getBlock(world());
                        TileEntity tileEntity = searchPosition.getTileEntity(world());
                        //TODO more EMP effect to UniversalEnergySystem to better support cross mod support
                        if (block != null) {
                            //}
                            if (block instanceof IEMPBlock) {
                                ((IEMPBlock) block).onEMP(world(), searchPosition.xi(), searchPosition.yi(), searchPosition.zi(), this);
                            }
                        }
                        if (tileEntity != null) {
                            //if (tileEntity instanceof IFortronStorage)
                            //{
                            //    ((IFortronStorage) tileEntity).provideFortron((int) world().rand.nextFloat() * ((IFortronStorage) tileEntity).getFortronCapacity(), true);
                            //}
                            UniversalEnergySystem.clearEnergy(tileEntity, true);
                        }
                    }
                }
            }
        }
        if (this.effectEntities) {
            // Drop all missiles
            List<Entity> entitiesNearby = RadarRegistry.getAllLivingObjectsWithin(world(), new Cube(position.sub(getRadius()), position.add(getRadius())), null);
            for (Entity entity : entitiesNearby) {
                if (entity instanceof IMissile && !entity.isEntityEqual(this.controller)) {
                    if (((IMissile) entity).getTicksInAir() > -1) {
                        ((IMissile) entity).dropMissileAsItem();
                    }
                }
            }
            int maxFx = 10;
            AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(position.x() - this.getRadius(), position.y() - this.getRadius(), position.z() - this.getRadius(), position.x() + this.getRadius(), position.y() + this.getRadius(), position.z() + this.getRadius());
            List<Entity> entities = world().getEntitiesWithinAABB(Entity.class, bounds);
            for (Entity entity : entities) {
                if (entity instanceof EntityLivingBase) {
                    if (this.world().isRemote && maxFx > 0) {
                        ICBMClassic.proxy.spawnShock(this.world(), this.position, new Pos(entity), 20);
                        maxFx--;
                    }
                    if (entity instanceof EntityCreeper) {
                        if (!this.world().isRemote) {
                            try {
                                ((EntityCreeper) entity).getDataWatcher().updateObject(17, (byte) 1);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    }
                    if (entity instanceof EntityPlayer) {
                        IInventory inventory = ((EntityPlayer) entity).inventory;
                        for (int i = 0; i < inventory.getSizeInventory(); i++) {
                            ItemStack itemStack = inventory.getStackInSlot(i);
                            if (itemStack != null) {
                                if (itemStack.getItem() instanceof IEMPItem) {
                                    ((IEMPItem) itemStack.getItem()).onEMP(itemStack, entity, this);
                                }
                                UniversalEnergySystem.clearEnergy(itemStack, true);
                            }
                        }
                    }
                } else if (entity instanceof EntityExplosive) {
                    entity.setDead();
                }
            }
        }
        VEProviderShockWave.spawnEffect(world(), position.x(), position.y(), position.z(), 0, 0, 0, 0, 0, 255, 1, 3);
        VEProviderShockWave.spawnEffect(world(), position.x(), position.y(), position.z(), 0, 0, 0, 0, 0, 255, 3, 3);
        VEProviderShockWave.spawnEffect(world(), position.x(), position.y(), position.z(), 0, 0, 0, 0, 0, 255, 5, 3);
        this.world().playSoundEffect(position.x(), position.y(), position.z(), ICBMClassic.PREFIX + "emp", 4.0F, (1.0F + (world().rand.nextFloat() - world().rand.nextFloat()) * 0.2F) * 0.7F);
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) IInventory(net.minecraft.inventory.IInventory) Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) IEMPItem(resonant.api.explosion.IEMPItem) IEMPBlock(resonant.api.explosion.IEMPBlock) TileEntity(net.minecraft.tileentity.TileEntity) IMissile(resonant.api.explosion.IMissile) EntityCreeper(net.minecraft.entity.monster.EntityCreeper) Pos(com.builtbroken.mc.imp.transform.vector.Pos) Cube(com.builtbroken.mc.imp.transform.region.Cube) EntityLivingBase(net.minecraft.entity.EntityLivingBase) IEMPBlock(resonant.api.explosion.IEMPBlock) Block(net.minecraft.block.Block) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityExplosive(icbm.classic.content.entity.EntityExplosive) ItemStack(net.minecraft.item.ItemStack)

Aggregations

Cube (com.builtbroken.mc.imp.transform.region.Cube)21 Pos (com.builtbroken.mc.imp.transform.vector.Pos)8 IRadioWaveReceiver (com.builtbroken.mc.api.map.radio.IRadioWaveReceiver)5 ArrayList (java.util.ArrayList)4 Entity (net.minecraft.entity.Entity)4 PacketTile (com.builtbroken.mc.core.network.packet.PacketTile)3 BlockTile (com.builtbroken.mc.prefab.tile.BlockTile)3 Tile (com.builtbroken.mc.prefab.tile.Tile)3 FakeWorld (com.builtbroken.mc.testing.junit.world.FakeWorld)3 TileEntity (net.minecraft.tileentity.TileEntity)3 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)3 Test (org.junit.Test)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)2 IRadioWaveSender (com.builtbroken.mc.api.map.radio.IRadioWaveSender)1 IMultiTileHost (com.builtbroken.mc.api.tile.multiblock.IMultiTileHost)1 PacketSelectionData (com.builtbroken.mc.core.network.packet.PacketSelectionData)1 RadioMap (com.builtbroken.mc.lib.world.radio.RadioMap)1 Region (com.builtbroken.mc.modflag.Region)1 EntityExplosive (icbm.classic.content.entity.EntityExplosive)1