use of net.minecraft.util.AxisAlignedBB in project BluePower by Qmunity.
the class TileTransposer method suckEntity.
private void suckEntity() {
ForgeDirection direction = getFacingDirection();
AxisAlignedBB box = AxisAlignedBB.getBoundingBox(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ, xCoord + direction.offsetX + 1, yCoord + direction.offsetY + 1, zCoord + direction.offsetZ + 1);
for (EntityItem entity : (List<EntityItem>) worldObj.getEntitiesWithinAABB(EntityItem.class, box)) {
ItemStack stack = entity.getEntityItem();
if (isItemAccepted(stack) && !entity.isDead) {
addItemToOutputBuffer(stack, getAcceptedItemColor(stack));
entity.setDead();
}
}
}
use of net.minecraft.util.AxisAlignedBB in project malmo by Microsoft.
the class BlockDrawingHelper method DrawPrimitive.
/**
* Draw a solid sphere made up of Minecraft blocks.
* @param s Contains information about the sphere to be drawn.
* @param w The world in which to draw.
* @throws Exception Throws an exception if the block type is not recognised.
*/
private void DrawPrimitive(DrawSphere s, World w) throws Exception {
XMLBlockState blockType = new XMLBlockState(s.getType(), s.getColour(), null, s.getVariant());
if (!blockType.isValid())
throw new Exception("Unrecognised block type: " + s.getType().value());
int radius = s.getRadius();
for (int x = s.getX() - radius; x <= s.getX() + radius; x++) {
for (int y = s.getY() - radius; y <= s.getY() + radius; y++) {
for (int z = s.getZ() - radius; z <= s.getZ() + radius; z++) {
if ((z - s.getZ()) * (z - s.getZ()) + (y - s.getY()) * (y - s.getY()) + (x - s.getX()) * (x - s.getX()) <= (radius * radius)) {
BlockPos pos = new BlockPos(x, y, z);
setBlockState(w, pos, blockType);
AxisAlignedBB aabb = new AxisAlignedBB(pos, pos).expand(0.5, 0.5, 0.5);
clearEntities(w, aabb.minX, aabb.minY, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ);
}
}
}
}
}
use of net.minecraft.util.AxisAlignedBB in project PneumaticCraft by MineMaarten.
the class EntityTrackUpgradeHandler method update.
@Override
@SideOnly(Side.CLIENT)
public void update(EntityPlayer player, int rangeUpgrades) {
ItemStack helmetStack = player.getCurrentArmor(3);
String entityFilter = "";
if (helmetStack != null)
entityFilter = NBTUtil.getString(helmetStack, "entityFilter");
double entityTrackRange = ENTITY_TRACKING_RANGE + rangeUpgrades * PneumaticValues.RANGE_UPGRADE_HELMET_RANGE_INCREASE;
AxisAlignedBB bbBox = getAABBFromRange(player, rangeUpgrades);
List<Entity> mobs = player.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, bbBox);
if (mobs.contains(player))
mobs.remove(player);
for (int i = 0; i < mobs.size(); i++) {
if (player.getDistanceToEntity(mobs.get(i)) > entityTrackRange || !PneumaticCraftUtils.isEntityValidForFilter(entityFilter, mobs.get(i)) || MinecraftForge.EVENT_BUS.post(new EntityTrackEvent(mobs.get(i))))
continue;
boolean inList = false;
for (int j = 0; j < targets.size(); j++) {
if (targets.get(j).entity == mobs.get(i)) {
inList = true;
// cancel
targets.get(j).ticksExisted = Math.abs(targets.get(j).ticksExisted);
// targets
break;
}
}
if (!inList) {
//player.worldObj.playSoundAtEntity(player, Sounds.CANNON_SOUND, 1.0F, 1.0F);
targets.add(new RenderTarget(mobs.get(i)));
if (mobs.get(i) instanceof EntityMob && !isEntityWithinPlayerFOV(player, mobs.get(i))) {
// HUDHandler.instance().addMessage(new ArmorMessage("A mob is sneaking up on you!", new ArrayList<String>(), 60, 0x70FF0000));
}
}
}
for (int j = 0; j < targets.size(); j++) {
RenderTarget target = targets.get(j);
if (target.entity.isDead || player.getDistanceToEntity(target.entity) > entityTrackRange + 5 || !PneumaticCraftUtils.isEntityValidForFilter(entityFilter, target.entity)) {
if (target.ticksExisted > 0) {
target.ticksExisted = -60;
} else if (target.ticksExisted == -1) {
targets.remove(target);
j--;
}
}
}
if (targets.size() > ENTITY_TRACK_THRESHOLD) {
if (!shouldStopSpamOnEntityTracking) {
shouldStopSpamOnEntityTracking = true;
HUDHandler.instance().addMessage(new ArmorMessage("Stopped spam on Entity Tracker", new ArrayList<String>(), 60, 0x7700AA00));
}
} else {
shouldStopSpamOnEntityTracking = false;
}
List<String> text = new ArrayList<String>();
for (RenderTarget target : targets) {
boolean wasNegative = target.ticksExisted < 0;
target.ticksExisted += CommonHUDHandler.getHandlerForPlayer(player).getSpeedFromUpgrades();
if (target.ticksExisted >= 0 && wasNegative)
target.ticksExisted = -1;
target.update();
if (target.isLookingAtTarget) {
if (target.isInitialized()) {
text.add(EnumChatFormatting.GRAY + target.entity.getCommandSenderName());
text.addAll(target.getEntityText());
} else {
text.add(EnumChatFormatting.GRAY + "Acquiring target...");
}
}
}
if (text.size() == 0) {
text.add("Filter mode: " + (entityFilter.equals("") ? "None" : entityFilter));
}
entityTrackInfo.setText(text);
//Remove entities that don't need to be tracked anymore.
Iterator<Entry<Entity, Integer>> iterator = targetingEntities.entrySet().iterator();
while (iterator.hasNext()) {
Entry<Entity, Integer> entry = iterator.next();
Entity entity = entry.getKey();
if (entry.getValue() >= 0)
entry.setValue(entry.getValue() + 1);
if (entity.isDead || !player.worldObj.getLoadedEntityList().contains(entity) || entry.getValue() > 50)
iterator.remove();
}
}
use of net.minecraft.util.AxisAlignedBB in project PneumaticCraft by MineMaarten.
the class BlockPressureTube method collisionRayTrace.
@Override
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 origin, Vec3 direction) {
MovingObjectPosition bestMOP = null;
AxisAlignedBB bestAABB = null;
setBlockBounds(BBConstants.PRESSURE_PIPE_MIN_POS, BBConstants.PRESSURE_PIPE_MIN_POS, BBConstants.PRESSURE_PIPE_MIN_POS, BBConstants.PRESSURE_PIPE_MAX_POS, BBConstants.PRESSURE_PIPE_MAX_POS, BBConstants.PRESSURE_PIPE_MAX_POS);
MovingObjectPosition mop = super.collisionRayTrace(world, x, y, z, origin, direction);
if (isCloserMOP(origin, bestMOP, mop)) {
bestMOP = mop;
bestAABB = AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
}
TileEntityPressureTube tube = ModInteractionUtils.getInstance().getTube(world.getTileEntity(x, y, z));
for (int i = 0; i < 6; i++) {
if (tube.sidesConnected[i]) {
setBlockBounds(boundingBoxes[i]);
mop = super.collisionRayTrace(world, x, y, z, origin, direction);
if (isCloserMOP(origin, bestMOP, mop)) {
bestMOP = mop;
bestAABB = AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
}
}
}
//unknown indicates we hit the tube.
if (bestMOP != null)
bestMOP.hitInfo = ForgeDirection.UNKNOWN;
TubeModule[] modules = tube.modules;
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (modules[dir.ordinal()] != null) {
setBlockBounds(modules[dir.ordinal()].boundingBoxes[dir.ordinal()]);
mop = super.collisionRayTrace(world, x, y, z, origin, direction);
if (isCloserMOP(origin, bestMOP, mop)) {
mop.hitInfo = dir;
bestMOP = mop;
bestAABB = AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
}
}
}
if (bestAABB != null)
setBlockBounds(bestAABB);
return bestMOP;
}
use of net.minecraft.util.AxisAlignedBB in project PneumaticCraft by MineMaarten.
the class EntityPotionCloud method onUpdate.
@Override
public void onUpdate() {
age++;
radius -= 0.001D;
if (radius <= 0.0D && !worldObj.isRemote) {
EntityItem seed = new EntityItem(worldObj, posX, posY, posZ, new ItemStack(Itemss.plasticPlant, 1, ItemPlasticPlants.POTION_PLANT_DAMAGE));
seed.lifespan = 300;
ItemPlasticPlants.markInactive(seed);
worldObj.spawnEntityInWorld(seed);
setDead();
}
if (age % 60 == 0) {
motionX += (rand.nextDouble() - 0.5D) * 0.1D;
motionY += (rand.nextDouble() - 0.6D) * 0.1D;
motionZ += (rand.nextDouble() - 0.5D) * 0.1D;
}
super.onUpdate();
moveEntity(motionX, motionY, motionZ);
if (worldObj.isRemote) {
int potionColor = getPotionID() < Potion.potionTypes.length && Potion.potionTypes[getPotionID()] != null ? Potion.potionTypes[getPotionID()].getLiquidColor() : 0xFFFFFF;
for (int i = 0; i < 4; i++) worldObj.spawnParticle("mobSpell", posX + (rand.nextDouble() - 0.5D) * 2 * radius, posY + (rand.nextDouble() - 0.5D) * 2 * radius, posZ + (rand.nextDouble() - 0.5D) * 2 * radius, (potionColor >> 16 & 255) / 255.0F, (potionColor >> 8 & 255) / 255.0F, (potionColor >> 0 & 255) / 255.0F);
} else if (getPotionID() >= Potion.potionTypes.length) {
setDead();
}
AxisAlignedBB bbBox = AxisAlignedBB.getBoundingBox(posX - radius, posY - radius, posZ - radius, posX + radius, posY + radius, posZ + radius);
List<EntityLivingBase> entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, bbBox);
for (EntityLivingBase entity : entities) {
entity.addPotionEffect(new PotionEffect(getPotionID(), 200));
}
}
Aggregations