use of net.minecraft.entity.item.EntityXPOrb in project EnderIO by SleepyTrousers.
the class TileKillerJoe method hooverXP.
// ------------------------------- XP
private void hooverXP() {
double maxDist = Math.max(KillerJoeConfig.killerJoeHooverXpHeight.get(), Math.max(KillerJoeConfig.killerJoeHooverXpLength.get(), KillerJoeConfig.killerJoeHooverXpWidth.get()));
List<EntityXPOrb> xp = world.getEntitiesWithinAABB(EntityXPOrb.class, getHooverBounds(), null);
for (EntityXPOrb entity : xp) {
double xDist = (getPos().getX() + 0.5D - entity.posX);
double yDist = (getPos().getY() + 0.5D - entity.posY);
double zDist = (getPos().getZ() + 0.5D - entity.posZ);
double totalDistance = Math.sqrt(xDist * xDist + yDist * yDist + zDist * zDist);
if (totalDistance < 1.5) {
hooverXP(entity);
if (!needsMending()) {
return;
}
} else if (MagnetUtil.shouldAttract(getPos(), entity)) {
double d = 1 - (Math.max(0.1, totalDistance) / maxDist);
double speed = 0.01 + (d * 0.02);
entity.motionX += xDist / totalDistance * speed;
entity.motionZ += zDist / totalDistance * speed;
entity.motionY += yDist / totalDistance * speed;
if (yDist > 0.5) {
entity.motionY = 0.12;
}
// force client sync because this movement is server-side only
boolean silent = entity.isSilent();
entity.setSilent(!silent);
entity.setSilent(silent);
}
}
}
use of net.minecraft.entity.item.EntityXPOrb in project EnderIO by SleepyTrousers.
the class TileXPVacuum method doHoover.
private void doHoover() {
boolean pickUpThisTick = xpCon.getFluidAmount() == 0;
for (EntityXPOrb entity : world.getEntitiesWithinAABB(EntityXPOrb.class, new BoundingBox(getPos()).expand(VacuumConfig.vacuumXPRange.get()), this)) {
// note the Predicate parameter
double x = (pos.getX() + 0.5D - entity.posX);
double y = (pos.getY() + 0.5D - entity.posY);
double z = (pos.getZ() + 0.5D - entity.posZ);
double distance = Math.sqrt(x * x + y * y + z * z);
if (distance < 1.25) {
if (pickUpThisTick && !world.isRemote && !entity.isDead) {
int xpValue = entity.getXpValue();
xpCon.addExperience(xpValue);
entity.setDead();
}
} else {
double distScale = Math.min(1d, Math.max(0.25d, 1d - distance / VacuumConfig.vacuumXPRange.get()));
distScale *= distScale;
entity.motionX += x / distance * distScale * speed;
if (entity.posY < pos.getY()) {
entity.motionY += y / distance * distScale * speed + .03;
} else {
entity.motionY += y / distance * distScale * speed;
}
entity.motionZ += z / distance * distScale * speed;
}
}
}
use of net.minecraft.entity.item.EntityXPOrb in project BloodMagic by WayofTime.
the class ItemSigilMagnetism method onSigilUpdate.
@Override
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
if (PlayerHelper.isFakePlayer(player))
return;
int range = 5;
int verticalRange = 5;
float posX = Math.round(player.posX);
float posY = (float) (player.posY - player.getEyeHeight());
float posZ = Math.round(player.posZ);
List<EntityItem> entities = player.getEntityWorld().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(posX - 0.5f, posY - 0.5f, posZ - 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f).expand(range, verticalRange, range));
List<EntityXPOrb> xpOrbs = player.getEntityWorld().getEntitiesWithinAABB(EntityXPOrb.class, new AxisAlignedBB(posX - 0.5f, posY - 0.5f, posZ - 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f).expand(range, verticalRange, range));
for (EntityItem entity : entities) {
if (entity != null && !world.isRemote && !entity.isDead) {
entity.onCollideWithPlayer(player);
}
}
for (EntityXPOrb xpOrb : xpOrbs) {
if (xpOrb != null && !world.isRemote) {
xpOrb.onCollideWithPlayer(player);
}
}
}
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;
for (EntityItem entity : 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))) {
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;
for (EntityXPOrb entity : 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))) {
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;
MorePlanetsMod.PROXY.spawnParticle(EnumParticleTypesMP.DARK_PORTAL, d0, d1, d2, d3, d4, d5);
}
}
}
}
use of net.minecraft.entity.item.EntityXPOrb in project MorePlanets by SteveKunG.
the class EntityMiniVeinFloater method onDeathUpdate.
@Override
protected void onDeathUpdate() {
++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));
}
TileEntityTreasureChestMP chest = null;
if (this.spawner != null && this.spawner.getChestPos() != null) {
TileEntity chestTest = this.world.getTileEntity(this.spawner.getChestPos());
if (chestTest != null && chestTest instanceof TileEntityTreasureChestMP) {
chest = (TileEntityTreasureChestMP) chestTest;
}
}
if (chest == null) {
chest = TileEntityTreasureChestMP.findClosest(this, MPItems.NIBIRU_DUNGEON_KEY);
}
if (chest != null) {
double dist = this.getDistanceSq(chest.getPos().getX() + 0.5, chest.getPos().getY() + 0.5, chest.getPos().getZ() + 0.5);
if (dist < 1000 * 1000) {
if (!chest.locked) {
chest.locked = true;
}
int slot = this.rand.nextInt(chest.getSizeInventory());
chest.setLootTable(MPLootTables.COMMON_SPACE_DUNGEON, this.rand.nextLong());
chest.setInventorySlotContents(slot, MPLootTables.getTieredKey(this.rand, 4));
}
}
this.entityDropItem(new ItemStack(MPItems.NIBIRU_DUNGEON_KEY_BOW), 0.5F);
this.setDead();
if (this.spawner != null) {
this.spawner.isBossDefeated = true;
this.spawner.boss = null;
this.spawner.spawned = false;
}
}
}
Aggregations