use of net.minecraft.util.math.AxisAlignedBB in project ConvenientAdditions by Necr0.
the class TileEntityComposter method update.
@Override
public void update() {
if (!getWorld().isRemote) {
for (EntityItem e : getWorld().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos.getX(), pos.getY() + 1, pos.getZ(), pos.getX() + 1, pos.getY() + 1.5d, pos.getZ() + 1))) {
if (!e.isDead && !e.getEntityItem().isEmpty()) {
ItemStack i = e.getEntityItem();
i.setCount(stackHandler.insertItem(0, i, false).getCount());
if (i.isEmpty())
e.setDead();
}
}
}
IBlockState state = getWorld().getBlockState(pos);
Random rnd = new Random();
if (!getWorld().isRemote) {
if (content >= ModConfigMisc.composter_progressContent) {
progress++;
if (progress >= ModConfigMisc.composter_progressPeriod) {
progress = 0;
content -= ModConfigMisc.composter_progressContent;
if (getWorld().rand.nextFloat() < ModConfigMisc.composter_compostChance)
Helper.spawnItemInPlace(getWorld(), (double) pos.getX() + .5, (double) pos.getY() + 1.2, (double) pos.getZ() + .5, new ItemStack(ModItems.itemCompost, 1, this.spores ? 1 : 0));
if (getWorld().rand.nextFloat() < ModConfigMisc.composter_extraCompostChance)
Helper.spawnItemInPlace(getWorld(), (double) pos.getX() + .5, (double) pos.getY() + 1.2, (double) pos.getZ() + .5, new ItemStack(ModItems.itemCompost, 1, this.spores ? 1 : 0));
if (getWorld().rand.nextFloat() < ModConfigMisc.composter_dirtChunkChance)
Helper.spawnItemInPlace(getWorld(), (double) pos.getX() + .5, (double) pos.getY() + 1.2, (double) pos.getZ() + .5, new ItemStack(ModItems.itemDirtChunk));
if (getWorld().rand.nextFloat() < ModConfigMisc.composter_fertilizerChance)
Helper.spawnItemInPlace(getWorld(), (double) pos.getX() + .5, (double) pos.getY() + 1.2, (double) pos.getZ() + .5, new ItemStack(ModItems.itemFertilizer));
}
if (content >= ModConfigMisc.composter_capacity && ModConfigMisc.composter_overflowSmell) {
List<EntityPlayer> players = getWorld().getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(pos.getX() - 2, pos.getY() - 2, pos.getZ() - 2, pos.getX() + 3, pos.getY() + 3, pos.getZ() + 3));
for (EntityPlayer p : players) {
switch(rnd.nextInt(120)) {
case 0:
p.addPotionEffect(new PotionEffect(Potion.getPotionById(9), 200, 0));
break;
default:
break;
}
}
}
this.markDirty();
this.getWorld().notifyBlockUpdate(pos, state, state, 3);
} else {
this.progress = 0;
if (this.content == 0)
this.spores = false;
if (processing) {
this.processing = false;
this.markDirty();
this.getWorld().notifyBlockUpdate(pos, state, state, 3);
}
}
} else if (processing) {
if (rnd.nextInt(10) == 0)
getWorld().spawnParticle(EnumParticleTypes.SPELL_MOB, pos.getX() + .5 - ((double) (rnd.nextInt(9) - 4) / 10D), pos.getY() + .2 + (double) content / (double) ModConfigMisc.composter_capacity * .75, pos.getZ() + .5 + ((double) (rnd.nextInt(9) - 4) / 10D), 0, 0.6, 0);
if (content >= ModConfigMisc.composter_capacity)
getWorld().spawnParticle(EnumParticleTypes.SPELL_MOB, pos.getX() + .5 - ((double) (rnd.nextInt(9) - 4) / 10D), pos.getY() + .2 + (double) content / (double) ModConfigMisc.composter_capacity * .75, pos.getZ() + .5 + ((double) (rnd.nextInt(9) - 4) / 10D), 0, 0.6, 0);
}
}
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);
}
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);
}
use of net.minecraft.util.math.AxisAlignedBB in project ImmersiveEngineering by BluSunrize.
the class TileEntityCrusher method getAdvancedSelectionBounds.
@Override
public List<AxisAlignedBB> getAdvancedSelectionBounds() {
if (pos % 15 == 7)
return null;
EnumFacing fl = facing;
EnumFacing fw = facing.rotateY();
if (mirrored)
fw = fw.getOpposite();
if (pos == 4) {
List<AxisAlignedBB> list = Lists.newArrayList(new AxisAlignedBB(0, 0, 0, 1, .5f, 1).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
float minX = fl == EnumFacing.WEST ? .625f : fl == EnumFacing.EAST ? .125f : .125f;
float maxX = fl == EnumFacing.EAST ? .375f : fl == EnumFacing.WEST ? .875f : .25f;
float minZ = fl == EnumFacing.NORTH ? .625f : fl == EnumFacing.SOUTH ? .125f : .125f;
float maxZ = fl == EnumFacing.SOUTH ? .375f : fl == EnumFacing.NORTH ? .875f : .25f;
list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
minX = fl == EnumFacing.WEST ? .625f : fl == EnumFacing.EAST ? .125f : .75f;
maxX = fl == EnumFacing.EAST ? .375f : fl == EnumFacing.WEST ? .875f : .875f;
minZ = fl == EnumFacing.NORTH ? .625f : fl == EnumFacing.SOUTH ? .125f : .75f;
maxZ = fl == EnumFacing.SOUTH ? .375f : fl == EnumFacing.NORTH ? .875f : .875f;
list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
return list;
}
if ((pos > 20 && pos < 24) || (pos > 35 && pos < 39)) {
List<AxisAlignedBB> list = new ArrayList<AxisAlignedBB>(3);
float minY = .5f;
float minX = (pos % 5 == 1 && fw == EnumFacing.EAST) || (pos % 5 == 3 && fw == EnumFacing.WEST) ? .4375f : 0;
float maxX = (pos % 5 == 1 && fw == EnumFacing.WEST) || (pos % 5 == 3 && fw == EnumFacing.EAST) ? .5625f : 1;
float minZ = (pos % 5 == 1 && fw == EnumFacing.SOUTH) || (pos % 5 == 3 && fw == EnumFacing.NORTH) ? .4375f : 0;
float maxZ = (pos % 5 == 1 && fw == EnumFacing.NORTH) || (pos % 5 == 3 && fw == EnumFacing.SOUTH) ? .5625f : 1;
if (pos > 20 && pos < 24)
list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, .75f, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
else
minY = 0;
minX = (pos % 5 == 1 && fw == EnumFacing.EAST) || (pos % 5 == 3 && fw == EnumFacing.WEST) ? .1875f : (pos % 5 == 1 && fw == EnumFacing.WEST) || (pos % 5 == 3 && fw == EnumFacing.EAST) ? .5625f : 0;
maxX = (pos % 5 == 1 && fw == EnumFacing.WEST) || (pos % 5 == 3 && fw == EnumFacing.EAST) ? .8125f : (pos % 5 == 1 && fw == EnumFacing.EAST) || (pos % 5 == 3 && fw == EnumFacing.WEST) ? .4375f : 1;
minZ = (pos % 5 == 1 && fw == EnumFacing.SOUTH) || (pos % 5 == 3 && fw == EnumFacing.NORTH) ? .1875f : (pos % 5 == 1 && fw == EnumFacing.NORTH) || (pos % 5 == 3 && fw == EnumFacing.SOUTH) ? .5625f : 0;
maxZ = (pos % 5 == 1 && fw == EnumFacing.NORTH) || (pos % 5 == 3 && fw == EnumFacing.SOUTH) ? .8125f : (pos % 5 == 1 && fw == EnumFacing.SOUTH) || (pos % 5 == 3 && fw == EnumFacing.NORTH) ? .4375f : 1;
list.add(new AxisAlignedBB(minX, minY, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
return list;
}
if ((pos > 15 && pos < 19) || (pos > 30 && pos < 34) || (pos > 25 && pos < 29) || (pos > 40 && pos < 44)) {
if (pos % 15 > 9)
fl = fl.getOpposite();
List<AxisAlignedBB> list = new ArrayList<AxisAlignedBB>(3);
float minY = .5f;
float minX = (pos % 5 == 1 && fw == EnumFacing.EAST) || (pos % 5 == 3 && fw == EnumFacing.WEST) ? .4375f : fl == EnumFacing.EAST ? .4375f : 0;
float maxX = (pos % 5 == 1 && fw == EnumFacing.WEST) || (pos % 5 == 3 && fw == EnumFacing.EAST) ? .5625f : fl == EnumFacing.WEST ? .5625f : 1;
float minZ = (pos % 5 == 1 && fw == EnumFacing.SOUTH) || (pos % 5 == 3 && fw == EnumFacing.NORTH) ? .4375f : fl == EnumFacing.SOUTH ? .4375f : 0;
float maxZ = (pos % 5 == 1 && fw == EnumFacing.NORTH) || (pos % 5 == 3 && fw == EnumFacing.SOUTH) ? .5625f : fl == EnumFacing.NORTH ? .5625f : 1;
if ((pos > 15 && pos < 19) || (pos > 25 && pos < 29))
list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, .75f, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
else
minY = 0;
if (pos / 15 > 9)
fl = fl.getOpposite();
minX = (pos % 5 == 1 && fw == EnumFacing.EAST) || (pos % 5 == 3 && fw == EnumFacing.WEST) ? .1875f : fl == EnumFacing.EAST ? .1875f : fl == EnumFacing.WEST ? .5625f : 0;
maxX = (pos % 5 == 1 && fw == EnumFacing.WEST) || (pos % 5 == 3 && fw == EnumFacing.EAST) ? .8125f : fl == EnumFacing.WEST ? .8125f : fl == EnumFacing.EAST ? .4375f : 1;
minZ = (pos % 5 == 1 && fw == EnumFacing.SOUTH) || (pos % 5 == 3 && fw == EnumFacing.NORTH) ? .1875f : fl == EnumFacing.SOUTH ? .1875f : fl == EnumFacing.NORTH ? .5625f : 0;
maxZ = (pos % 5 == 1 && fw == EnumFacing.NORTH) || (pos % 5 == 3 && fw == EnumFacing.SOUTH) ? .8125f : fl == EnumFacing.NORTH ? .8125f : fl == EnumFacing.SOUTH ? .4375f : 1;
list.add(new AxisAlignedBB(minX, minY, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
if (pos != 17 && pos != 32 && pos != 27 && pos != 42) {
minX = (pos % 5 == 1 && fw == EnumFacing.EAST) || (pos % 5 == 3 && fw == EnumFacing.WEST) ? .1875f : fl == EnumFacing.EAST ? .4375f : fl == EnumFacing.WEST ? 0 : .5625f;
maxX = (pos % 5 == 1 && fw == EnumFacing.WEST) || (pos % 5 == 3 && fw == EnumFacing.EAST) ? .8125f : fl == EnumFacing.WEST ? .5625f : fl == EnumFacing.EAST ? 1 : .4375f;
minZ = (pos % 5 == 1 && fw == EnumFacing.SOUTH) || (pos % 5 == 3 && fw == EnumFacing.NORTH) ? .1875f : fl == EnumFacing.SOUTH ? .4375f : fl == EnumFacing.NORTH ? 0 : .5625f;
maxZ = (pos % 5 == 1 && fw == EnumFacing.NORTH) || (pos % 5 == 3 && fw == EnumFacing.SOUTH) ? .8125f : fl == EnumFacing.NORTH ? .5625f : fl == EnumFacing.SOUTH ? 1 : .4375f;
list.add(new AxisAlignedBB(minX, minY, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
if (pos % 15 % 10 == 1)
fw = fw.getOpposite();
if ((pos > 15 && pos < 19) || (pos > 25 && pos < 29)) {
minX = fl == EnumFacing.WEST ? .5f : fl == EnumFacing.EAST ? .25f : fw == EnumFacing.EAST ? .5f : .25f;
maxX = fl == EnumFacing.EAST ? .5f : fl == EnumFacing.WEST ? .75f : fw == EnumFacing.EAST ? .75f : .5f;
minZ = fl == EnumFacing.NORTH ? .5f : fl == EnumFacing.SOUTH ? .25f : fw == EnumFacing.SOUTH ? .5f : .25f;
maxZ = fl == EnumFacing.SOUTH ? .5f : fl == EnumFacing.NORTH ? .75f : fw == EnumFacing.SOUTH ? .75f : .5f;
list.add(new AxisAlignedBB(minX, 0, minZ, maxX, .5f, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
}
}
return list;
}
if (pos == 1 || pos == 3 || pos == 11 || pos == 13) {
List<AxisAlignedBB> list = Lists.newArrayList(new AxisAlignedBB(0, 0, 0, 1, .5f, 1).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
if (pos % 15 > 9)
fl = fl.getOpposite();
if (pos % 15 % 10 == 1)
fw = fw.getOpposite();
float minX = fl == EnumFacing.WEST ? .5f : fl == EnumFacing.EAST ? .25f : fw == EnumFacing.EAST ? .5f : .25f;
float maxX = fl == EnumFacing.EAST ? .5f : fl == EnumFacing.WEST ? .75f : fw == EnumFacing.EAST ? .75f : .5f;
float minZ = fl == EnumFacing.NORTH ? .5f : fl == EnumFacing.SOUTH ? .25f : fw == EnumFacing.SOUTH ? .5f : .25f;
float maxZ = fl == EnumFacing.SOUTH ? .5f : fl == EnumFacing.NORTH ? .75f : fw == EnumFacing.SOUTH ? .75f : .5f;
list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
return list;
}
return null;
}
use of net.minecraft.util.math.AxisAlignedBB in project ImmersiveEngineering by BluSunrize.
the class TileEntityExcavator method getAdvancedSelectionBounds.
@Override
public List<AxisAlignedBB> getAdvancedSelectionBounds() {
EnumFacing fl = facing;
EnumFacing fw = facing.rotateY();
if (mirrored)
fw = fw.getOpposite();
if (pos == 5 || pos == 23 || pos == 41) {
List list = Lists.newArrayList(new AxisAlignedBB(fw == EnumFacing.WEST ? .5f : 0, 0, fw == EnumFacing.NORTH ? .5f : 0, fw == EnumFacing.EAST ? .5f : 1, 1, fw == EnumFacing.SOUTH ? .5f : 1).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
list.add(new AxisAlignedBB(fw == EnumFacing.EAST ? .5f : fw == EnumFacing.WEST ? 0 : .25f, .25f, fw == EnumFacing.SOUTH ? .5f : fw == EnumFacing.NORTH ? 0 : .25f, fw == EnumFacing.WEST ? .5f : fw == EnumFacing.EAST ? 1 : .75f, .75f, fw == EnumFacing.NORTH ? .5f : fw == EnumFacing.SOUTH ? 1 : .75f).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
return list;
} else if (pos == 9 || pos == 12 || pos == 15) {
List list = Lists.newArrayList(new AxisAlignedBB(fw == EnumFacing.EAST ? .5f : 0, 0, fw == EnumFacing.SOUTH ? .5f : 0, fw == EnumFacing.WEST ? .5f : 1, 1, fw == EnumFacing.NORTH ? .5f : 1).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
if (pos == 9)
list.add(new AxisAlignedBB(fw == EnumFacing.WEST || fl == EnumFacing.EAST ? .5f : 0, .5f, fw == EnumFacing.NORTH || fl == EnumFacing.SOUTH ? .5f : 0, fw == EnumFacing.EAST || fl == EnumFacing.WEST ? .5f : 1, 1, fw == EnumFacing.SOUTH || fl == EnumFacing.NORTH ? .5f : 1).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
else if (pos == 12)
list.add(new AxisAlignedBB(fw == EnumFacing.WEST ? .5f : 0, .5f, fw == EnumFacing.NORTH ? .5f : 0, fw == EnumFacing.EAST ? .5f : 1, 1, fw == EnumFacing.SOUTH ? .5f : 1).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
else
list.add(new AxisAlignedBB(fw == EnumFacing.WEST || fl == EnumFacing.WEST ? .5f : 0, .5f, fw == EnumFacing.NORTH || fl == EnumFacing.NORTH ? .5f : 0, fw == EnumFacing.EAST || fl == EnumFacing.EAST ? .5f : 1, 1, fw == EnumFacing.SOUTH || fl == EnumFacing.SOUTH ? .5f : 1).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
return list;
} else if (pos == 47) {
List list = Lists.newArrayList(new AxisAlignedBB(fl == EnumFacing.EAST ? .5f : fl == EnumFacing.WEST ? .375f : 0, 0, fl == EnumFacing.SOUTH ? .5f : fl == EnumFacing.NORTH ? .375f : 0, fl == EnumFacing.WEST ? .5f : fl == EnumFacing.EAST ? .625f : 1, 1, fl == EnumFacing.NORTH ? .5f : fl == EnumFacing.SOUTH ? .625f : 1).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
list.add(new AxisAlignedBB(fl == EnumFacing.EAST ? .625f : fw == EnumFacing.EAST ? .875f : 0, 0, fl == EnumFacing.SOUTH ? .625f : fw == EnumFacing.SOUTH ? .875f : 0, fl == EnumFacing.WEST ? .375f : fw == EnumFacing.WEST ? .125f : 1, 1, fl == EnumFacing.NORTH ? .375f : fw == EnumFacing.NORTH ? .125f : 1).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
return list;
} else if (pos == 53) {
List list = Lists.newArrayList(new AxisAlignedBB(fl == EnumFacing.WEST ? .5f : fl == EnumFacing.EAST ? .375f : 0, 0, fl == EnumFacing.NORTH ? .5f : fl == EnumFacing.SOUTH ? .375f : 0, fl == EnumFacing.EAST ? .5f : fl == EnumFacing.WEST ? .625f : 1, 1, fl == EnumFacing.SOUTH ? .5f : fl == EnumFacing.NORTH ? .625f : 1).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
list.add(new AxisAlignedBB(fl == EnumFacing.WEST ? .625f : fw == EnumFacing.EAST ? .875f : 0, 0, fl == EnumFacing.NORTH ? .625f : fw == EnumFacing.SOUTH ? .875f : 0, fl == EnumFacing.EAST ? .375f : fw == EnumFacing.WEST ? .125f : 1, 1, fl == EnumFacing.SOUTH ? .375f : fw == EnumFacing.NORTH ? .125f : 1).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
return list;
}
return null;
}
Aggregations