use of net.minecraft.entity.item.EntityXPOrb in project MineFactoryReloaded by powercrystals.
the class TileEntitySewer method updateEntity.
@Override
public void updateEntity() {
super.updateEntity();
if (worldObj.isRemote) {
return;
}
_tick++;
if (_nextSewerCheckTick <= worldObj.getTotalWorldTime()) {
Area a = new Area(BlockPosition.fromFactoryTile(this), _areaManager.getRadius(), 0, 0);
_jammed = false;
for (BlockPosition bp : a.getPositionsBottomFirst()) {
if (worldObj.getBlockId(bp.x, bp.y, bp.z) == MineFactoryReloadedCore.machineBlocks.get(0).blockID && worldObj.getBlockMetadata(bp.x, bp.y, bp.z) == Machine.Sewer.getMeta() && !(bp.x == xCoord && bp.y == yCoord && bp.z == zCoord)) {
_jammed = true;
break;
}
}
_nextSewerCheckTick = worldObj.getTotalWorldTime() + 800 + worldObj.rand.nextInt(800);
}
if (_tick >= 31 && !_jammed) {
_tick = 0;
List<?> entities = worldObj.getEntitiesWithinAABB(EntityLiving.class, _areaManager.getHarvestArea().toAxisAlignedBB());
double massFound = 0;
for (Object o : entities) {
if (o instanceof EntityAnimal || o instanceof EntityVillager) {
massFound += Math.pow(((EntityLiving) o).boundingBox.getAverageEdgeLength(), 2);
} else if (o instanceof EntityPlayer && ((EntityPlayer) o).isSneaking()) {
massFound += Math.pow(((EntityLiving) o).boundingBox.getAverageEdgeLength(), 2);
}
}
if (massFound > 0) {
_tank.fill(LiquidDictionary.getLiquid("sewage", (int) (25 * massFound)), true);
} else // TODO: add a second tank to the sewer for essence
if (_tank.getLiquid() == null || _tank.getLiquid().isLiquidEqual(LiquidDictionary.getLiquid("mobEssence", 1))) {
int maxAmount = Math.max(_tank.getCapacity() - (_tank.getLiquid() != null ? _tank.getLiquid().amount : 0), 0);
if (maxAmount < 0) {
return;
}
entities = worldObj.getEntitiesWithinAABB(EntityXPOrb.class, _areaManager.getHarvestArea().toAxisAlignedBB());
for (Object o : entities) {
Entity e = (Entity) o;
if (e != null & e instanceof EntityXPOrb && !e.isDead) {
EntityXPOrb orb = (EntityXPOrb) o;
int found = Math.min(orb.xpValue, maxAmount);
orb.xpValue -= found;
if (orb.xpValue <= 0) {
orb.setDead();
found = Math.max(found, 0);
}
if (found > 0) {
found = (int) (found * 66.66666667f);
maxAmount -= found;
_tank.fill(LiquidDictionary.getLiquid("mobEssence", found), true);
if (maxAmount <= 0) {
break;
}
}
}
}
}
}
}
use of net.minecraft.entity.item.EntityXPOrb in project BetterWithAddons by DaedalusGame.
the class SoulSandHandler method handleXP.
private void handleXP() {
if (TrackedItemsIterator == null || !TrackedItemsIterator.hasNext()) {
TrackedItems.addAll(TrackedItemsAdd);
TrackedItemsAdd.clear();
TrackedItemsIterator = TrackedItems.iterator();
} else {
EntityXPOrb entity = TrackedItemsIterator.next();
World world = entity.world;
int xpValue = entity.getXpValue();
BlockPos pos = entity.getPosition();
boolean remove = false;
if (entity.isDead)
remove = true;
else {
IBlockState state = world.getBlockState(pos);
if (state.getBlock() != BWMBlocks.AESTHETIC || state.getValue(BlockAesthetic.TYPE) != BlockAesthetic.EnumType.DUNG)
return;
if (!isValidInfusionWall(world, pos.up(), EnumFacing.DOWN) || !isValidInfusionWall(world, pos.down(), EnumFacing.UP) || !isValidInfusionWall(world, pos.south(), EnumFacing.NORTH) || !isValidInfusionWall(world, pos.north(), EnumFacing.SOUTH) || !isValidInfusionWall(world, pos.west(), EnumFacing.EAST) || !isValidInfusionWall(world, pos.east(), EnumFacing.WEST))
return;
AxisAlignedBB aabb = new AxisAlignedBB(pos);
List<EntityXPOrb> orbs = world.getEntitiesWithinAABB(EntityXPOrb.class, aabb);
int totalxp = 0;
for (EntityXPOrb orb : orbs) {
totalxp += orb.getXpValue();
orb.setDead();
}
if (world.rand.nextInt(50) < totalxp) {
world.setBlockState(pos, Blocks.SOUL_SAND.getDefaultState());
for (int i = 0; i < 3; i++) world.playEvent(2004, pos, 0);
// TODO: burn everybody
}
}
if (remove)
TrackedItemsIterator.remove();
}
}
use of net.minecraft.entity.item.EntityXPOrb in project MorePlanets by SteveKunG.
the class EntityNibiruVillager method useRecipe.
@Override
public void useRecipe(MerchantRecipe recipe) {
recipe.incrementToolUses();
this.livingSoundTime = -this.getTalkInterval();
this.playSound(SoundEvents.ENTITY_VILLAGER_YES, this.getSoundVolume(), this.getSoundPitch());
int i = 3 + this.rand.nextInt(4);
if (recipe.getToolUses() == 1 || this.rand.nextInt(5) == 0) {
this.timeUntilReset = 40;
this.needsInitilization = true;
this.isWillingToMate = true;
if (this.buyingPlayer != null) {
this.lastBuyingPlayer = this.buyingPlayer.getUniqueID();
} else {
this.lastBuyingPlayer = null;
}
i += 5;
}
if (recipe.getItemToBuy().getItem() == Items.EMERALD) {
this.wealth += recipe.getItemToBuy().getCount();
}
if (recipe.getRewardsExp()) {
this.world.spawnEntity(new EntityXPOrb(this.world, this.posX, this.posY + 0.5D, this.posZ, i));
}
}
use of net.minecraft.entity.item.EntityXPOrb in project MorePlanets by SteveKunG.
the class EntityVeinFloater method onDeathUpdate.
@Override
protected void onDeathUpdate() {
this.world.playEvent(1010, this.getPosition(), 0);
++this.deathTicks;
if (this.deathTicks >= 180 && this.deathTicks <= 200) {
float f = (this.rand.nextFloat() - 0.5F) * 5.5F;
float f1 = (this.rand.nextFloat() - 0.5F) * 28.0F;
float f2 = (this.rand.nextFloat() - 0.5F) * 5.5F;
this.world.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, this.posX + f, this.posY + 2.0D + f1, this.posZ + f2, 0.0D, 0.0D, 0.0D);
}
int i;
int j;
if (!this.world.isRemote) {
if (this.deathTicks >= 180 && this.deathTicks % 5 == 0) {
GalacticraftCore.packetPipeline.sendToAllAround(new PacketSimple(EnumSimplePacket.C_PLAY_SOUND_EXPLODE, GCCoreUtil.getDimensionID(this.world), new Object[] {}), new TargetPoint(GCCoreUtil.getDimensionID(this.world), this.posX, this.posY, this.posZ, 40.0D));
}
if (this.deathTicks > 150 && this.deathTicks % 5 == 0) {
i = 200;
while (i > 0) {
j = EntityXPOrb.getXPSplit(i);
i -= j;
this.world.spawnEntity(new EntityXPOrb(this.world, this.posX, this.posY, this.posZ, j));
}
}
if (this.deathTicks == 40) {
GalacticraftCore.packetPipeline.sendToAllAround(new PacketSimple(EnumSimplePacket.C_PLAY_SOUND_BOSS_DEATH, GCCoreUtil.getDimensionID(this.world), new Object[] { this.getSoundPitch() - 0.1F }), new TargetPoint(GCCoreUtil.getDimensionID(this.world), this.posX, this.posY, this.posZ, 40.0D));
}
}
if (this.deathTicks == 200 && !this.world.isRemote) {
i = 200;
while (i > 0) {
j = EntityXPOrb.getXPSplit(i);
i -= j;
this.world.spawnEntity(new EntityXPOrb(this.world, this.posX, this.posY, this.posZ, j));
}
this.entityDropItem(new ItemStack(NibiruItems.NIBIRU_DUNGEON_KEY, 1, this.rand.nextBoolean() ? 1 : 2), 0.5F);
this.setDead();
if (this.spawner != null) {
this.spawner.isBossDefeated = true;
this.spawner.boss = null;
this.spawner.spawned = false;
}
}
}
use of net.minecraft.entity.item.EntityXPOrb in project MorePlanets by SteveKunG.
the class EntityBlackHoleStorage 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);
if (this.mainTilePos != null) {
TileEntity tile = this.world.getTileEntity(this.mainTilePos);
if (tile == null || !(tile instanceof TileEntityBlackHoleStorage)) {
this.setDead();
}
}
if (!this.isDisable()) {
boolean collectAll = this.getCollectMode().equals("item_and_xp");
if (this.getCollectMode().equals("item") || collectAll) {
int range = 12;
List<EntityItem> entitiesAroundBH = this.world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(this.posX - range, this.posY - range, this.posZ - range, this.posX + range, this.posY + range, this.posZ + range));
for (EntityItem entity : entitiesAroundBH) {
double motionX = this.posX - entity.posX;
double motionY = this.posY - entity.posY + 0.5D;
double motionZ = this.posZ - entity.posZ;
entity.motionX = motionX * 0.1F;
entity.motionY = motionY * 0.1F;
entity.motionZ = motionZ * 0.1F;
}
}
if (this.getCollectMode().equals("xp") || collectAll) {
int range = 12;
List<EntityXPOrb> entitiesAroundBH = this.world.getEntitiesWithinAABB(EntityXPOrb.class, new AxisAlignedBB(this.posX - range, this.posY - range, this.posZ - range, this.posX + range, this.posY + range, this.posZ + range));
for (EntityXPOrb entity : entitiesAroundBH) {
double motionX = this.posX - entity.posX;
double motionY = this.posY - entity.posY + 0.5D;
double motionZ = this.posZ - entity.posZ;
entity.motionX = motionX * 0.1F;
entity.motionY = motionY * 0.1F;
entity.motionZ = motionZ * 0.1F;
entity.delayBeforeCanPickup = 5;
}
}
if (this.world.isRemote) {
for (int i = 0; i < 16; ++i) {
double d0 = this.posX + this.rand.nextFloat();
double d1 = this.posY + 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);
}
}
}
}
Aggregations