Search in sources :

Example 26 with AxisAlignedBB

use of net.minecraft.util.math.AxisAlignedBB in project ConvenientAdditions by Necr0.

the class BlockTreeTap method getCollisionBoundingBox.

@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
    EnumFacing f = state.getValue(FACING);
    boolean b = state.getValue(BOTTLE_STATE) != EnumBottleState.empty;
    new AxisAlignedBB(5 / 16d, 4 / 16d, .0, 11 / 16d, 14 / 16d, 10 / 16d);
    double side = b ? 5 / 16d : 6 / 16d;
    double front = b ? 10 / 16d : 5 / 16d;
    return new AxisAlignedBB(f.getAxis() == Axis.X ? (f.getAxisDirection() == AxisDirection.NEGATIVE ? 0d : 1 - front) : side, b ? 4 / 16d : 10 / 16d, f.getAxis() == Axis.Z ? (f.getAxisDirection() == AxisDirection.NEGATIVE ? 0d : 1 - front) : side, f.getAxis() == Axis.X ? (f.getAxisDirection() == AxisDirection.POSITIVE ? 1d : front) : 1 - side, 14 / 16d, f.getAxis() == Axis.Z ? (f.getAxisDirection() == AxisDirection.POSITIVE ? 1d : front) : 1 - side);
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EnumFacing(net.minecraft.util.EnumFacing)

Example 27 with AxisAlignedBB

use of net.minecraft.util.math.AxisAlignedBB in project ConvenientAdditions by Necr0.

the class BlockTempLight method updateTick.

@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random r) {
    this.setTickRandomly(false);
    if (!world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(pos.add(-4, -4, -4), pos.add(4, 4, 4))).isEmpty()) {
        if (r.nextInt(6) != 0) {
            world.scheduleBlockUpdate(pos, ModBlocks.tempLightBlock, 80, 0);
            return;
        }
    }
    world.setBlockToAir(pos);
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB)

Example 28 with AxisAlignedBB

use of net.minecraft.util.math.AxisAlignedBB in project minecolonies by Minecolonies.

the class EntityFishHook method moveSomeStuff.

/**
     * Main update method thingy.
     * hopefully I'm able to reduce it somewhat...
     */
private void moveSomeStuff() {
    updateMotionAndRotation();
    double movementLimiter = AIR_MOVEMENT_LIMITER;
    if (this.onGround || this.isCollidedHorizontally) {
        movementLimiter = GROUND_MOVEMENT_LIMITER;
    }
    final byte numSteps = 5;
    double waterDensity = 0.0;
    //Check how much water is around the hook
    for (int j = 0; j < numSteps; ++j) {
        final double d3 = this.getEntityBoundingBox().minY + (this.getEntityBoundingBox().maxY - this.getEntityBoundingBox().minY) * j / numSteps;
        final double d4 = this.getEntityBoundingBox().minY + (this.getEntityBoundingBox().maxY - this.getEntityBoundingBox().minY) * (j + 1) / numSteps;
        @NotNull final AxisAlignedBB axisAlignedBB1 = new AxisAlignedBB(this.getEntityBoundingBox().minX, d3, this.getEntityBoundingBox().minZ, this.getEntityBoundingBox().maxX, d4, this.getEntityBoundingBox().maxZ);
        //If the hook is swimming
        if (this.world.isMaterialInBB(axisAlignedBB1, Material.WATER)) {
            waterDensity += 1.0 / numSteps;
        }
    }
    checkIfFishBites(waterDensity);
    final double currentDistance = waterDensity * 2.0D - 1.0;
    this.motionY += WATER_MOVEMENT_LIMITER * currentDistance;
    if (waterDensity > 0.0) {
        movementLimiter *= 0.9;
        this.motionY *= 0.8;
    }
    this.motionX *= movementLimiter;
    this.motionY *= movementLimiter;
    this.motionZ *= movementLimiter;
    this.setPosition(this.posX, this.posY, this.posZ);
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) NotNull(org.jetbrains.annotations.NotNull)

Example 29 with AxisAlignedBB

use of net.minecraft.util.math.AxisAlignedBB in project minecolonies by Minecolonies.

the class AbstractEntityAIStructure method fillItemsList.

/**
     * Fill the list of the item positions to gather.
     */
@Override
public void fillItemsList() {
    if (currentStructure == null) {
        return;
    }
    final BlockPos centerPos = currentStructure.getCenter();
    if (centerPos.getY() == 0) {
        return;
    }
    searchForItems(new AxisAlignedBB(centerPos).expand(currentStructure.getLength() / 2.0, currentStructure.getHeight(), currentStructure.getWidth()));
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) BlockPos(net.minecraft.util.math.BlockPos)

Example 30 with AxisAlignedBB

use of net.minecraft.util.math.AxisAlignedBB in project Pearcel-Mod by MiningMark48.

the class ItemCharmedPearcel method doEffects.

public static void doEffects(EntityPlayer player, ItemStack stack) {
    if (stack.getTagCompound().getString("type").equalsIgnoreCase("fire") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_fire, player) || player.isCreative())) {
        player.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, 25, 0, true, false));
        player.extinguish();
        useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_fire, false, player);
    }
    if (stack.getTagCompound().getString("type").equalsIgnoreCase("water") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_water, player) || player.isCreative())) {
        player.addPotionEffect(new PotionEffect(MobEffects.WATER_BREATHING, 25, 5, true, false));
        useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_water, false, player);
    }
    if (stack.getTagCompound().getString("type").equalsIgnoreCase("saturation") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_saturation, player) || player.isCreative())) {
        player.addPotionEffect(new PotionEffect(MobEffects.SATURATION, 25, 5, true, false));
        useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_saturation, false, player);
    }
    if (stack.getTagCompound().getString("type").equalsIgnoreCase("step_assist") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_stepAssist, player) || player.isCreative())) {
        ItemStack s = new ItemStack(ModItems.charmed_pearcel);
        if (!s.hasTagCompound()) {
            s.setTagCompound(new NBTTagCompound());
        }
        s.getTagCompound().setString("type", "step_assist");
        if (player.inventory.hasItemStack(s)) {
            player.stepHeight = 1.25F;
        }
        useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_stepAssist, false, player);
    }
    if (stack.getTagCompound().getString("type").equalsIgnoreCase("gravity") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_gravity, player) || player.isCreative())) {
        if (player.isSneaking()) {
            player.addVelocity(0D, -0.125D, 0D);
        }
        useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_gravity, false, player);
    }
    if (stack.getTagCompound().getString("type").equalsIgnoreCase("adrenaline") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_adrenaline, player) || player.isCreative())) {
        player.addPotionEffect(new PotionEffect(MobEffects.SPEED, 25, 1, true, false));
        player.addPotionEffect(new PotionEffect(MobEffects.HASTE, 25, 0, true, false));
        player.addPotionEffect(new PotionEffect(MobEffects.JUMP_BOOST, 25, 1, true, false));
        useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_adrenaline, false, player);
    }
    if (stack.getTagCompound().getString("type").equalsIgnoreCase("cloaking") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_cloaking, player) || player.isCreative())) {
        player.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY, 25, 0, true, false));
        useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_cloaking, false, player);
    }
    if (stack.getTagCompound().getString("type").equalsIgnoreCase("hearty") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_hearty, player) || player.isCreative())) {
        player.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, 25, 0, true, false));
        player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 25, 0, true, false));
        useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_hearty, false, player);
    }
    if (stack.getTagCompound().getString("type").equalsIgnoreCase("repair") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_repair, player) || player.isCreative())) {
        if (player.getHeldItemMainhand() != null) {
            if (player.getHeldItemMainhand().getItem().isDamageable() && player.getHeldItemMainhand().getItem().isDamaged(player.getHeldItemMainhand())) {
                Random rand = new Random();
                int num = rand.nextInt(100);
                if (num == 0) {
                    player.getHeldItemMainhand().getItem().setDamage(player.getHeldItemMainhand(), player.getHeldItemMainhand().getItemDamage() - 1);
                }
            }
        }
        useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_repair, false, player);
    }
    if (stack.getTagCompound().getString("type").equalsIgnoreCase("physco") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_physco, player) || player.isCreative())) {
        int x = (int) player.posX;
        int y = (int) player.posY;
        int z = (int) player.posZ;
        int range = 15;
        List<EntityCreature> creatureList = player.world.getEntitiesWithinAABB(EntityCreature.class, new AxisAlignedBB(x - range, y - range, z - range, x + range, y + range, z + range));
        for (EntityCreature creature : creatureList) {
            if (creature.isCreatureType(EnumCreatureType.MONSTER, false)) {
                List<EntityCreature> creatureList2 = creature.world.getEntitiesWithinAABB(EntityCreature.class, new AxisAlignedBB(x - range, y - range, z - range, x + range, y + range, z + range));
                for (EntityCreature creature2 : creatureList2) {
                    creature.setAttackTarget(creature2);
                }
            }
        }
        useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_physco, false, player);
    }
    if (stack.getTagCompound().getString("type").equalsIgnoreCase("third_eye") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_thirdEye, player) || player.isCreative())) {
        int x = (int) player.posX;
        int y = (int) player.posY;
        int z = (int) player.posZ;
        int range = 15;
        List<EntityLiving> entities = player.world.getEntitiesWithinAABB(EntityLiving.class, new AxisAlignedBB(x - range, y - range, z - range, x + range, y + range, z + range));
        for (EntityLiving e : entities) {
            e.addPotionEffect(new PotionEffect(MobEffects.GLOWING, 25, 0, true, false));
        }
        player.addPotionEffect(new PotionEffect(MobEffects.NIGHT_VISION, 25, 0, true, false));
        useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_thirdEye, false, player);
    }
    if (stack.getTagCompound().getString("type").equalsIgnoreCase("fall") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_fall, player) || player.isCreative())) {
        useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_fall, false, player);
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Random(java.util.Random) PotionEffect(net.minecraft.potion.PotionEffect) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Aggregations

AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)127 EntityPlayer (net.minecraft.entity.player.EntityPlayer)34 BlockPos (net.minecraft.util.math.BlockPos)31 EntityLivingBase (net.minecraft.entity.EntityLivingBase)30 Entity (net.minecraft.entity.Entity)23 EnumFacing (net.minecraft.util.EnumFacing)22 IBlockState (net.minecraft.block.state.IBlockState)17 Vec3d (net.minecraft.util.math.Vec3d)17 ArrayList (java.util.ArrayList)11 ItemStack (net.minecraft.item.ItemStack)11 TileEntity (net.minecraft.tileentity.TileEntity)10 PhysicsWrapperEntity (ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity)9 World (net.minecraft.world.World)9 Vector (ValkyrienWarfareBase.API.Vector)8 EntityItem (net.minecraft.entity.item.EntityItem)8 PotionEffect (net.minecraft.potion.PotionEffect)8 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)8 EntityAnimal (net.minecraft.entity.passive.EntityAnimal)6 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)6 Polygon (ValkyrienWarfareBase.Collision.Polygon)5