use of net.minecraft.util.math.AxisAlignedBB in project MorePlanets by SteveKunG.
the class EntityBlackHole method onUpdate.
@Override
public void onUpdate() {
super.onUpdate();
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
this.move(MoverType.SELF, 0.0D, 0.0D, 0.0D);
int range = this.getRange();
List<Entity> entitiesAroundBH = this.world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(this.posX - range, this.posY - range, this.posZ - range, this.posX + range, this.posY + range, this.posZ + range));
for (Entity entity : entitiesAroundBH) {
if (!(entity instanceof EntityPlayer && ((EntityPlayer) entity).capabilities.isCreativeMode) && !(entity instanceof IImmuneBlackHole && ((IImmuneBlackHole) entity).isImmune())) {
double motionX = this.posX - entity.posX;
double motionY = this.posY - entity.posY;
double motionZ = this.posZ - entity.posZ;
if (entity instanceof EntityItem || entity instanceof EntityFallingBlock) {
motionY = this.posY - entity.posY + 0.5D;
}
entity.motionX = motionX * this.getPullSpeed();
entity.motionY = motionY * this.getPullSpeed();
entity.motionZ = motionZ * this.getPullSpeed();
List<Entity> entityNearBH = this.world.getEntitiesWithinAABB(entity.getClass(), new AxisAlignedBB(this.posX - 0.25D, this.posY - 0.25D, this.posZ - 0.25D, this.posX + 0.25D, this.posY + 0.5D, this.posZ + 0.25D));
for (Entity near : entityNearBH) {
if (near instanceof EntityLivingBase) {
((EntityLivingBase) near).addPotionEffect(new PotionEffect(MobEffects.BLINDNESS, 32767, 0, false, false));
}
if (near instanceof EntityPlayer) {
near.attackEntityFrom(DamageSourceMP.BLACK_HOLE, 10.0F);
}
if (!(near instanceof EntityPlayer) && !(near instanceof EntityBlackHole)) {
near.setDead();
}
}
}
}
if (this.lifeTick == 0) {
this.world.playSound(null, this.posX, this.posY, this.posZ, MPSounds.BLACK_HOLE_CREATED, SoundCategory.AMBIENT, 2.0F, 1.0F);
}
if (this.lifeTick < this.getMaxLife()) {
this.lifeTick++;
}
if (this.lifeTick % 80 == 0 && this.spawnBlockRadiusTick < 15) {
this.spawnBlockRadiusTick++;
}
if (this.lifeTick % 20 == 0) {
this.world.playSound(null, this.posX, this.posY, this.posZ, MPSounds.BLACK_HOLE_AMBIENT, SoundCategory.AMBIENT, 2.0F, 1.0F);
}
if (!this.world.isRemote) {
if (this.lifeTick == this.getMaxLife()) {
this.setDead();
if (ConfigManagerMP.enableBlackHoleExplosion) {
this.world.createExplosion(null, this.posX, this.posY, this.posZ, 128.0F, true);
}
}
this.spawnFallingBlock();
} else {
for (int i = 0; i < 16; ++i) {
double d0 = this.posX + this.rand.nextFloat();
double d1 = this.posY - 0.5D + this.rand.nextFloat();
double d2 = this.posZ + this.rand.nextFloat();
double d3 = (this.rand.nextFloat() - 0.5D) * 0.5D;
double d4 = (this.rand.nextFloat() - 0.5D) * 0.5D;
double d5 = (this.rand.nextFloat() - 0.5D) * 0.5D;
int j = this.rand.nextInt(2) * 2 - 1;
d0 = this.posX + 0.25D * j;
d3 = this.rand.nextFloat() * 2.0F * j;
d2 = this.posZ + 0.25D * j;
d5 = this.rand.nextFloat() * 2.0F * j;
MorePlanetsCore.PROXY.spawnParticle(EnumParticleTypesMP.DARK_PORTAL, d0, d1, d2, d3, d4, d5);
}
}
}
use of net.minecraft.util.math.AxisAlignedBB in project MorePlanets by SteveKunG.
the class TileEntityJuicerEgg method update.
@Override
public void update() {
super.update();
if (!this.world.isRemote) {
double radius = 1.05D;
double radiusPlayer = 5.0D;
List<Entity> list = this.world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(this.pos.getX() - radius, this.pos.getY() - radius, this.pos.getZ() - radius, this.pos.getX() + radius, this.pos.getY() + radius, this.pos.getZ() + radius));
List<EntityPlayer> playerList = this.world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(this.pos.getX() - radiusPlayer, this.pos.getY() - radiusPlayer, this.pos.getZ() - radiusPlayer, this.pos.getX() + radiusPlayer, this.pos.getY() + radiusPlayer, this.pos.getZ() + radiusPlayer));
if (!list.isEmpty()) {
for (Entity entity : list) {
if (entity instanceof EntityArrow) {
EntityArrow arrow = (EntityArrow) entity;
if (arrow.inTile == NibiruBlocks.JUICER_EGG) {
arrow.setDead();
this.world.destroyBlock(this.pos, false);
if (this.world.rand.nextInt(5) == 0) {
EntityJuicer juicer = new EntityJuicer(this.world);
juicer.setLocationAndAngles(this.pos.getX() + 0.5D, this.pos.getY() + 1.0D, this.pos.getZ() + 0.5D, 0.0F, 0.0F);
this.world.spawnEntity(juicer);
}
if (this.world.rand.nextInt(10) == 0) {
if (!playerList.isEmpty()) {
for (EntityPlayer player : playerList) {
EntityJuicer juicer = new EntityJuicer(this.world);
juicer.setLocationAndAngles(this.pos.getX() + 0.5D, this.pos.getY() + 1.0D, this.pos.getZ() + 0.5D, 0.0F, 0.0F);
this.world.spawnEntity(juicer);
juicer.startRiding(player);
}
}
}
}
}
}
}
}
}
use of net.minecraft.util.math.AxisAlignedBB in project MorePlanets by SteveKunG.
the class TileEntityVeinPortal method update.
@Override
public void update() {
super.update();
if (this.age < 5L) {
this.age++;
}
if (!this.world.isRemote) {
if (this.age < 5L) {
ArrayList<TileEntity> attachedList = new ArrayList<>();
for (int x = this.getPos().getX() - 1; x < this.getPos().getX() + 2; x++) {
for (int z = this.getPos().getZ() - 1; z < this.getPos().getZ() + 2; z++) {
TileEntity tile = this.world.getTileEntity(new BlockPos(x, this.getPos().getY(), z));
if (tile instanceof TileEntityVeinPortal) {
attachedList.add(tile);
}
}
}
if (attachedList.size() == 9) {
this.world.setBlockState(this.getPos(), NibiruBlocks.VEIN_PORTAL.getDefaultState(), 3);
TileEntityVeinPortal portal = this;
this.isMiddle = true;
this.world.setTileEntity(this.getPos(), portal);
for (int x = -1; x < 2; x++) {
for (int z = -1; z < 2; z++) {
BlockPos vecToAdd = new BlockPos(this.getPos().getX() + x, this.getPos().getY(), this.getPos().getZ() + z);
if (!vecToAdd.equals(this.getPos())) {
this.world.setBlockState(vecToAdd, NibiruBlocks.VEIN_PORTAL.getDefaultState(), 3);
this.delayToTeleport = 120;
}
}
}
}
if (this.isMiddle) {
if (!this.spawnedBoss) {
EntityVeinFloater vein = new EntityVeinFloater(this.world);
vein.setLocationAndAngles(this.getPos().getX() + 0.5D, this.getPos().getY() + 64, this.getPos().getZ() + 0.5D, 0.0F, 0.0F);
this.world.spawnEntity(vein);
this.spawnedBoss = true;
}
for (int yRender = this.pos.getY(); yRender < 99; yRender++) {
this.world.setBlockToAir(new BlockPos(this.pos.getX(), yRender + 1, this.pos.getZ()));
this.world.notifyBlockUpdate(this.pos, this.world.getBlockState(this.pos), NibiruBlocks.VEIN_PORTAL.getDefaultState(), 3);
}
}
}
}
if (this.isMiddle) {
EntityPlayer player = this.world.getClosestPlayer(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), 64, false);
List<EntityVeinFloater> vein = this.world.getEntitiesWithinAABB(EntityVeinFloater.class, new AxisAlignedBB(this.getPos().getX() - 256, this.getPos().getY() - 256, this.getPos().getZ() - 256, this.getPos().getX() + 256, this.getPos().getY() + 256, this.getPos().getZ() + 256));
if (this.delayToTeleport > 0) {
this.delayToTeleport--;
}
if (this.delayToTeleport == 1) {
if (player instanceof EntityPlayerMP) {
EntityPlayerMP playerMP = (EntityPlayerMP) player;
playerMP.dismountRidingEntity();
playerMP.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 120, 10));
playerMP.connection.setPlayerLocation(playerMP.posX, playerMP.posY + 64, playerMP.posZ, playerMP.rotationYaw, playerMP.rotationPitch);
}
}
if (this.renderTicks % 50 == 0 && vein.isEmpty()) {
this.isMiddle = false;
}
}
}
use of net.minecraft.util.math.AxisAlignedBB in project MorePlanets by SteveKunG.
the class BlockVinesMP method getBoundingBox.
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
state = state.getActualState(source, pos);
int i = 0;
AxisAlignedBB axisalignedbb = FULL_BLOCK_AABB;
if (state.getValue(UP).booleanValue()) {
axisalignedbb = UP_AABB;
++i;
}
if (state.getValue(NORTH).booleanValue()) {
axisalignedbb = NORTH_AABB;
++i;
}
if (state.getValue(EAST).booleanValue()) {
axisalignedbb = EAST_AABB;
++i;
}
if (state.getValue(SOUTH).booleanValue()) {
axisalignedbb = SOUTH_AABB;
++i;
}
if (state.getValue(WEST).booleanValue()) {
axisalignedbb = WEST_AABB;
++i;
}
return i == 1 ? axisalignedbb : FULL_BLOCK_AABB;
}
use of net.minecraft.util.math.AxisAlignedBB in project MorePlanets by SteveKunG.
the class TileEntityChestMP 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;
if (!this.world.isRemote && this.numPlayersUsing != 0 && (this.ticksSinceSync + i + j + k) % 200 == 0) {
this.numPlayersUsing = 0;
float f = 5.0F;
for (EntityPlayer entityplayer : this.world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(i - f, j - f, k - f, i + 1 + f, j + 1 + f, k + 1 + f))) {
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;
float f1 = 0.1F;
if (this.numPlayersUsing > 0 && this.lidAngle == 0.0F && this.adjacentChestZNeg == null && this.adjacentChestXNeg == null) {
double d1 = i + 0.5D;
double 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 f2 = this.lidAngle;
if (this.numPlayersUsing > 0) {
this.lidAngle += f1;
} else {
this.lidAngle -= f1;
}
if (this.lidAngle > 1.0F) {
this.lidAngle = 1.0F;
}
float f3 = 0.5F;
if (this.lidAngle < f3 && f2 >= f3 && this.adjacentChestZNeg == null && this.adjacentChestXNeg == null) {
double d3 = i + 0.5D;
double d0 = k + 0.5D;
if (this.adjacentChestZPos != null) {
d0 += 0.5D;
}
if (this.adjacentChestXPos != null) {
d3 += 0.5D;
}
this.world.playSound((EntityPlayer) null, d3, 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;
}
}
}
Aggregations