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 EntityCheeseCubeEyeBoss method onDeathUpdate.
@Override
protected void onDeathUpdate() {
++this.deathTicks;
if (this.deathTicks >= 180 && this.deathTicks <= 200) {
float f = (this.rand.nextFloat() - 0.5F) * 1.5F;
float f1 = (this.rand.nextFloat() - 0.5F) * 2.0F;
float f2 = (this.rand.nextFloat() - 0.5F) * 1.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 = 150;
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));
}
}
this.move(MoverType.SELF, 0.0D, -0.10000000149011612D, 0.0D);
if (this.deathTicks == 200 && !this.world.isRemote) {
i = 150;
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.CHALOS_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.CHALOS_DUNGEON_KEY, 1, 0), 0.5F);
super.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 EntitySpaceFishHook method handleHookRetraction.
@Override
public int handleHookRetraction() {
if (!this.world.isRemote && this.angler != null) {
int i = 0;
if (this.caughtEntity != null) {
this.bringInHookedEntity();
this.world.setEntityState(this, (byte) 31);
i = this.caughtEntity instanceof EntityItem ? 3 : 5;
} else if (this.ticksCatchable > 0) {
LootContext.Builder lootBuilder = new LootContext.Builder((WorldServer) this.world);
lootBuilder.withLuck(this.luck + this.angler.getLuck());
double x = MathHelper.floor(this.posX);
double y = MathHelper.floor(this.getEntityBoundingBox().minY) + 1.0F;
double z = MathHelper.floor(this.posZ);
Block block = this.world.getBlockState(new BlockPos(x, y - 1, z)).getBlock();
ResourceLocation resource = block instanceof IFishableLiquidBlock ? ((IFishableLiquidBlock) block).getLootTable() : this.world.provider instanceof IGalacticraftWorldProvider ? MPLootTables.SPACE_FISHING : LootTableList.GAMEPLAY_FISHING;
for (ItemStack itemStack : this.world.getLootTableManager().getLootTableFromLocation(resource).generateLootForPools(this.rand, lootBuilder.build())) {
EntityItem entityItem = new EntityItem(this.world, this.posX, this.posY, this.posZ, itemStack);
double d0 = this.angler.posX - this.posX;
double d1 = this.angler.posY - this.posY;
double d2 = this.angler.posZ - this.posZ;
double d3 = MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
entityItem.motionX = d0 * 0.1D;
entityItem.motionY = d1 * 0.1D + MathHelper.sqrt(d3) * 0.08D;
entityItem.motionZ = d2 * 0.1D;
this.world.spawnEntity(entityItem);
this.angler.world.spawnEntity(new EntityXPOrb(this.angler.world, this.angler.posX, this.angler.posY + 0.5D, this.angler.posZ + 0.5D, this.rand.nextInt(6) + 1));
Item item = itemStack.getItem();
if (item == Items.FISH || item == Items.COOKED_FISH) {
this.angler.addStat(StatList.FISH_CAUGHT, 1);
}
}
i = 1;
}
if (this.inGround) {
i = 2;
}
this.setDead();
return i;
} else {
return 0;
}
}
use of net.minecraft.entity.item.EntityXPOrb in project GregTech by GregTechCE.
the class ToolMetaItemListener method onXpOrbPickup.
@SubscribeEvent
public static void onXpOrbPickup(PlayerPickupXpEvent event) {
EntityPlayer player = event.getEntityPlayer();
EntityXPOrb xpOrb = event.getOrb();
ItemStack itemStack = EnchantmentHelper.getEnchantedItem(Enchantments.MENDING, player);
if (!itemStack.isEmpty() && itemStack.getItem() instanceof ToolMetaItem) {
ToolMetaItem<?> toolMetaItem = (ToolMetaItem<?>) itemStack.getItem();
int maxDurabilityRegain = xpToDurability(xpOrb.xpValue);
int durabilityRegained = toolMetaItem.regainItemDurability(itemStack, maxDurabilityRegain);
xpOrb.xpValue -= durabilityToXp(durabilityRegained);
}
}
use of net.minecraft.entity.item.EntityXPOrb in project Gaia-Dimension by Andromander.
the class SlotGlitter method onCrafting.
@Override
protected void onCrafting(ItemStack par1ItemStack) {
par1ItemStack.onCrafting(thePlayer.world, thePlayer, stackSize);
if (!thePlayer.world.isRemote) {
int i = stackSize;
float f = RestructurerRecipes.instance().getExperience(par1ItemStack);
int j;
if (f == 0.0F)
i = 0;
else if (f < 1.0F) {
j = MathHelper.floor(i * f);
if (j < MathHelper.ceil(i * f) && (float) Math.random() < i * f - j)
++j;
i = j;
}
while (i > 0) {
j = EntityXPOrb.getXPSplit(i);
i -= j;
thePlayer.world.spawnEntity(new EntityXPOrb(thePlayer.world, thePlayer.posX, thePlayer.posY + 0.5D, thePlayer.posZ + 0.5D, j));
}
}
stackSize = 0;
MinecraftForge.EVENT_BUS.post(new GDEvents.ItemGlitteredEvent(thePlayer, par1ItemStack));
}
Aggregations