Search in sources :

Example 46 with AxisAlignedBB

use of net.minecraft.util.math.AxisAlignedBB in project MorePlanets by SteveKunG.

the class RenderInfectedElderGuardian method shouldRender.

@Override
public boolean shouldRender(EntityInfectedElderGuardian entity, ICamera camera, double camX, double camY, double camZ) {
    if (super.shouldRender(entity, camera, camX, camY, camZ)) {
        return true;
    } else {
        if (entity.hasTargetedEntity()) {
            EntityLivingBase entitylivingbase = entity.getTargetedEntity();
            if (entitylivingbase != null) {
                Vec3d vec3 = this.getPosition(entitylivingbase, entitylivingbase.height * 0.5D, 1.0F);
                Vec3d vec31 = this.getPosition(entity, entity.getEyeHeight(), 1.0F);
                if (camera.isBoundingBoxInFrustum(new AxisAlignedBB(vec31.x, vec31.y, vec31.z, vec3.x, vec3.y, vec3.z))) {
                    return true;
                }
            }
        }
        return false;
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EntityLivingBase(net.minecraft.entity.EntityLivingBase) Vec3d(net.minecraft.util.math.Vec3d)

Example 47 with AxisAlignedBB

use of net.minecraft.util.math.AxisAlignedBB in project MorePlanets by SteveKunG.

the class BlockMultalicCrystal method getBoundingBox.

@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) {
    EnumFacing facing = state.getValue(BlockStateHelper.FACING_ALL);
    double box = 0.0625D;
    switch(facing) {
        case NORTH:
        default:
            return new AxisAlignedBB(0.0D + box, 0.0D + box, 0.0D + box, 1.0D - box, 1.0D - box, 1.0D);
        case EAST:
            return new AxisAlignedBB(0.0D, 0.0D + box, 0.0D + box, 1.0D - box, 1.0D - box, 1.0D - box);
        case WEST:
            return new AxisAlignedBB(0.0D + box, 0.0D + box, 0.0D + box, 1.0D, 1.0D - box, 1.0D - box);
        case SOUTH:
            return new AxisAlignedBB(0.0D + box, 0.0D + box, 0.0D, 1.0D - box, 1.0D - box, 1.0D - box);
        case UP:
            return new AxisAlignedBB(0.0D + box, 0.0D, 0.0D + box, 1.0D - box, 1.0D - box, 1.0D - box);
        case DOWN:
            return new AxisAlignedBB(0.0D + box, 0.0D + box, 0.0D + box, 1.0D - box, 1.0D, 1.0D - box);
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EnumFacing(net.minecraft.util.EnumFacing)

Example 48 with AxisAlignedBB

use of net.minecraft.util.math.AxisAlignedBB in project MorePlanets by SteveKunG.

the class TileEntityAncientChestMP method update.

@Override
public void update() {
    this.checkForAdjacentChests();
    int i = this.pos.getX();
    int j = this.pos.getY();
    int k = this.pos.getZ();
    ++this.ticksSinceSync;
    float f;
    if (!this.world.isRemote && this.numPlayersUsing != 0 && (this.ticksSinceSync + i + j + k) % 200 == 0) {
        this.numPlayersUsing = 0;
        f = 5.0F;
        List list = this.world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(i - f, j - f, k - f, i + 1 + f, j + 1 + f, k + 1 + f));
        Iterator iterator = list.iterator();
        while (iterator.hasNext()) {
            EntityPlayer entityplayer = (EntityPlayer) iterator.next();
            if (entityplayer.openContainer instanceof ContainerChest) {
                IInventory iinventory = ((ContainerChest) entityplayer.openContainer).getLowerChestInventory();
                if (iinventory == this || iinventory instanceof InventoryLargeChest && ((InventoryLargeChest) iinventory).isPartOfLargeChest(this)) {
                    ++this.numPlayersUsing;
                }
            }
        }
    }
    this.prevLidAngle = this.lidAngle;
    f = 0.1F;
    double d2;
    if (this.numPlayersUsing > 0 && this.lidAngle == 0.0F && this.adjacentChestZNeg == null && this.adjacentChestXNeg == null) {
        double d1 = i + 0.5D;
        d2 = k + 0.5D;
        if (this.adjacentChestZPos != null) {
            d2 += 0.5D;
        }
        if (this.adjacentChestXPos != null) {
            d1 += 0.5D;
        }
        this.world.playSound((EntityPlayer) null, d1, j + 0.5D, d2, SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F);
    }
    if (this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F) {
        float f1 = this.lidAngle;
        if (this.numPlayersUsing > 0) {
            this.lidAngle += f;
        } else {
            this.lidAngle -= f;
        }
        if (this.lidAngle > 1.0F) {
            this.lidAngle = 1.0F;
        }
        float f2 = 0.5F;
        if (this.lidAngle < f2 && f1 >= f2 && this.adjacentChestZNeg == null && this.adjacentChestXNeg == null) {
            d2 = i + 0.5D;
            double d0 = k + 0.5D;
            if (this.adjacentChestZPos != null) {
                d0 += 0.5D;
            }
            if (this.adjacentChestXPos != null) {
                d2 += 0.5D;
            }
            this.world.playSound((EntityPlayer) null, d2, j + 0.5D, d0, SoundEvents.BLOCK_CHEST_CLOSE, SoundCategory.BLOCKS, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F);
        }
        if (this.lidAngle < 0.0F) {
            this.lidAngle = 0.0F;
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Iterator(java.util.Iterator) EntityPlayer(net.minecraft.entity.player.EntityPlayer) List(java.util.List) NonNullList(net.minecraft.util.NonNullList)

Example 49 with AxisAlignedBB

use of net.minecraft.util.math.AxisAlignedBB in project MorePlanets by SteveKunG.

the class ItemBlockSlabMP method tryPlace.

private boolean tryPlace(EntityPlayer player, ItemStack itemStack, World world, BlockPos pos, Object variantInStack, BlockSlabMP half, BlockSlabMP doubleSlab) {
    IBlockState state = world.getBlockState(pos);
    if (state.getBlock() == half) {
        Comparable comparable = state.getValue(half.getVariantProperty());
        if (comparable == variantInStack) {
            IBlockState state1 = doubleSlab.getDefaultState().withProperty((IProperty) half.getVariantProperty(), comparable);
            AxisAlignedBB axisalignedbb = state1.getCollisionBoundingBox(world, pos);
            if (axisalignedbb != Block.NULL_AABB && world.checkNoEntityCollision(axisalignedbb.offset(pos)) && world.setBlockState(pos, state1, 11)) {
                SoundType soundtype = doubleSlab.getSoundType(state1, world, pos, player);
                world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
                itemStack.shrink(1);
            }
            return true;
        }
    }
    return false;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) SoundType(net.minecraft.block.SoundType) IBlockState(net.minecraft.block.state.IBlockState)

Example 50 with AxisAlignedBB

use of net.minecraft.util.math.AxisAlignedBB in project MorePlanets by SteveKunG.

the class EntityInfectedCrystallizeWorm method onDeath.

@Override
public void onDeath(DamageSource source) {
    if (!this.world.isRemote) {
        if (this.rand.nextInt(5) == 0) {
            List<EntityPlayer> playerList = this.world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(this.posX - 2.5D, this.posY - 1.5D, this.posZ - 2.5D, this.posX + 2.5D, this.posY + 1.5D, this.posZ + 2.5D));
            EntityAlbetiusWorm worm = new EntityAlbetiusWorm(this.world);
            for (EntityPlayer player : playerList) {
                player.addPotionEffect(new PotionEffect(MPPotions.INFECTED_CRYSTALLIZE, 24, 0));
            }
            this.world.playSound(null, this.posX, this.posY, this.posZ, MPSounds.INFECTED_MOB_EXPLODE, SoundCategory.HOSTILE, 1.0F, 1.0F);
            this.world.createExplosion(this, this.posX, this.posY, this.posZ, 0.5F + this.rand.nextInt(2), this.world.getGameRules().getBoolean("mobGriefing"));
            worm.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rand.nextFloat() * 360.0F, 0.0F);
            this.world.spawnEntity(worm);
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) PotionEffect(net.minecraft.potion.PotionEffect) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Aggregations

AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)597 BlockPos (net.minecraft.util.math.BlockPos)194 Entity (net.minecraft.entity.Entity)133 EntityPlayer (net.minecraft.entity.player.EntityPlayer)119 IBlockState (net.minecraft.block.state.IBlockState)110 Vec3d (net.minecraft.util.math.Vec3d)95 EntityLivingBase (net.minecraft.entity.EntityLivingBase)93 EnumFacing (net.minecraft.util.EnumFacing)88 ItemStack (net.minecraft.item.ItemStack)77 World (net.minecraft.world.World)69 TileEntity (net.minecraft.tileentity.TileEntity)67 List (java.util.List)48 ArrayList (java.util.ArrayList)47 RayTraceResult (net.minecraft.util.math.RayTraceResult)45 EntityItem (net.minecraft.entity.item.EntityItem)43 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)41 Block (net.minecraft.block.Block)36 PotionEffect (net.minecraft.potion.PotionEffect)36 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)25 Nullable (javax.annotation.Nullable)24