本文整理匯總了Java中net.minecraft.entity.item.EntityXPOrb類的典型用法代碼示例。如果您正苦於以下問題:Java EntityXPOrb類的具體用法?Java EntityXPOrb怎麽用?Java EntityXPOrb使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
EntityXPOrb類屬於net.minecraft.entity.item包,在下文中一共展示了EntityXPOrb類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCastTick
import net.minecraft.entity.item.EntityXPOrb; //導入依賴的package包/類
@Override
public void onCastTick(World world, EntityPlayer player, ItemStack stack) {
if (!world.isRemote) {
BlockPos centerPos = player.getPosition();
AxisAlignedBB area = new AxisAlignedBB(centerPos).expandXyz(3F);
for (Entity entity : world.getEntitiesWithinAABBExcludingEntity(player, area)) {
if (entity instanceof EntityLivingBase) {
WorldServer worldServer = (WorldServer) world;
if (player.getItemInUseCount() % 10 == 0 && consumePower(player)) {
MessageSoulDrainFX message = new MessageSoulDrainFX(entity.posX,
entity.posY + (entity.height / 2.0F), entity.posZ, player.posX,
player.posY + (player.height / 2.0F), player.posZ);
PacketHandler.INSTANCE.sendToAllAround(message, new NetworkRegistry.TargetPoint(
player.dimension, player.posX, player.posY, player.posZ, 128));
entity.attackEntityFrom(DamageSource.magic, 1);
world.spawnEntity(new EntityXPOrb(world, entity.posX, entity.posY + 0.5, entity.posZ, 1));
}
}
}
}
}
示例2: onItemPickup
import net.minecraft.entity.item.EntityXPOrb; //導入依賴的package包/類
/**
* Called whenever an item is picked up from walking over it. Args: pickedUpEntity, stackSize
*/
public void onItemPickup(Entity p_71001_1_, int p_71001_2_)
{
if (!p_71001_1_.isDead && !this.worldObj.isRemote)
{
EntityTracker entitytracker = ((WorldServer)this.worldObj).getEntityTracker();
if (p_71001_1_ instanceof EntityItem)
{
entitytracker.sendToAllTrackingEntity(p_71001_1_, new S0DPacketCollectItem(p_71001_1_.getEntityId(), this.getEntityId()));
}
if (p_71001_1_ instanceof EntityArrow)
{
entitytracker.sendToAllTrackingEntity(p_71001_1_, new S0DPacketCollectItem(p_71001_1_.getEntityId(), this.getEntityId()));
}
if (p_71001_1_ instanceof EntityXPOrb)
{
entitytracker.sendToAllTrackingEntity(p_71001_1_, new S0DPacketCollectItem(p_71001_1_.getEntityId(), this.getEntityId()));
}
}
}
示例3: handleCollectItem
import net.minecraft.entity.item.EntityXPOrb; //導入依賴的package包/類
public void handleCollectItem(SPacketCollectItem packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Entity entity = this.clientWorldController.getEntityByID(packetIn.getCollectedItemEntityID());
EntityLivingBase entitylivingbase = (EntityLivingBase)this.clientWorldController.getEntityByID(packetIn.getEntityID());
if (entitylivingbase == null)
{
entitylivingbase = this.gameController.thePlayer;
}
if (entity != null)
{
if (entity instanceof EntityXPOrb)
{
this.clientWorldController.playSound(entity.posX, entity.posY, entity.posZ, SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.PLAYERS, 0.2F, ((this.avRandomizer.nextFloat() - this.avRandomizer.nextFloat()) * 0.7F + 1.0F) * 2.0F, false);
}
else
{
this.clientWorldController.playSound(entity.posX, entity.posY, entity.posZ, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((this.avRandomizer.nextFloat() - this.avRandomizer.nextFloat()) * 0.7F + 1.0F) * 2.0F, false);
}
this.gameController.effectRenderer.addEffect(new ParticleItemPickup(this.clientWorldController, entity, entitylivingbase, 0.5F));
this.clientWorldController.removeEntityFromWorld(packetIn.getCollectedItemEntityID());
}
}
示例4: handleCollectItem
import net.minecraft.entity.item.EntityXPOrb; //導入依賴的package包/類
public void handleCollectItem(S0DPacketCollectItem packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Entity entity = this.clientWorldController.getEntityByID(packetIn.getCollectedItemEntityID());
EntityLivingBase entitylivingbase = (EntityLivingBase)this.clientWorldController.getEntityByID(packetIn.getEntityID());
if (entitylivingbase == null)
{
entitylivingbase = this.gameController.thePlayer;
}
if (entity != null)
{
if (entity instanceof EntityXPOrb)
{
this.clientWorldController.playSoundAtEntity(entity, "random.orb", 0.2F, ((this.avRandomizer.nextFloat() - this.avRandomizer.nextFloat()) * 0.7F + 1.0F) * 2.0F);
}
else
{
this.clientWorldController.playSoundAtEntity(entity, "random.pop", 0.2F, ((this.avRandomizer.nextFloat() - this.avRandomizer.nextFloat()) * 0.7F + 1.0F) * 2.0F);
}
this.gameController.effectRenderer.addEffect(new EntityPickupFX(this.clientWorldController, entity, entitylivingbase, 0.5F));
this.clientWorldController.removeEntityFromWorld(packetIn.getCollectedItemEntityID());
}
}
示例5: handleCollectItem
import net.minecraft.entity.item.EntityXPOrb; //導入依賴的package包/類
public void handleCollectItem(S0DPacketCollectItem packetIn) {
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Entity entity = this.clientWorldController.getEntityByID(packetIn.getCollectedItemEntityID());
EntityLivingBase entitylivingbase = (EntityLivingBase) this.clientWorldController
.getEntityByID(packetIn.getEntityID());
if (entitylivingbase == null) {
entitylivingbase = this.gameController.thePlayer;
}
if (entity != null) {
if (entity instanceof EntityXPOrb) {
this.clientWorldController.playSoundAtEntity(entity, "random.orb", 0.2F,
((this.avRandomizer.nextFloat() - this.avRandomizer.nextFloat()) * 0.7F + 1.0F) * 2.0F);
} else {
this.clientWorldController.playSoundAtEntity(entity, "random.pop", 0.2F,
((this.avRandomizer.nextFloat() - this.avRandomizer.nextFloat()) * 0.7F + 1.0F) * 2.0F);
}
this.gameController.effectRenderer
.addEffect(new EntityPickupFX(this.clientWorldController, entity, entitylivingbase, 0.5F));
this.clientWorldController.removeEntityFromWorld(packetIn.getCollectedItemEntityID());
}
}
示例6: handleCollectItem
import net.minecraft.entity.item.EntityXPOrb; //導入依賴的package包/類
public void handleCollectItem(SPacketCollectItem packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Entity entity = this.clientWorldController.getEntityByID(packetIn.getCollectedItemEntityID());
EntityLivingBase entitylivingbase = (EntityLivingBase)this.clientWorldController.getEntityByID(packetIn.getEntityID());
if (entitylivingbase == null)
{
entitylivingbase = this.gameController.player;
}
if (entity != null)
{
SoundEvent soundevent = entity instanceof EntityXPOrb ? SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP : SoundEvents.ENTITY_ITEM_PICKUP;
this.clientWorldController.playSound(entity.posX, entity.posY, entity.posZ, soundevent, SoundCategory.PLAYERS, 0.2F, ((this.avRandomizer.nextFloat() - this.avRandomizer.nextFloat()) * 0.7F + 1.0F) * 2.0F, false);
if (entity instanceof EntityItem)
{
((EntityItem)entity).getEntityItem().func_190920_e(packetIn.func_191208_c());
}
this.gameController.effectRenderer.addEffect(new ParticleItemPickup(this.clientWorldController, entity, entitylivingbase, 0.5F));
this.clientWorldController.removeEntityFromWorld(packetIn.getCollectedItemEntityID());
}
}
示例7: useRecipe
import net.minecraft.entity.item.EntityXPOrb; //導入依賴的package包/類
@Override
public void useRecipe(MerchantRecipe recipe) {
recipe.incrementToolUses();
if (recipe.getItemToBuy().getItem() instanceof ItemWeapon) {
this.loadout.setStackInSlot(ItemFromData.getData(recipe.getItemToBuy()).getInt(PropertyType.SLOT), recipe.getItemToBuy());
this.switchSlot(0);
}
else if(recipe.getItemToBuy().getItem() instanceof ItemWearable) {
this.setItemStackToSlot(EntityEquipmentSlot.HEAD, recipe.getItemToBuy());
}
this.livingSoundTime = -this.getTalkInterval();
this.playSound(SoundEvents.ENTITY_VILLAGER_YES, this.getSoundVolume(), this.getSoundPitch());
int i = 3 + this.rand.nextInt(4);
this.lastTrader = this.trader;
this.tradeCount.put(this.trader,
this.tradeCount.containsKey(trader) ? this.tradeCount.get(this.trader) + 1 : 1);
this.traderFollowTicks = Math.min(4800, this.tradeCount.get(this.trader) * 250 + 350);
if (recipe.getRewardsExp())
this.world.spawnEntity(new EntityXPOrb(this.world, this.posX, this.posY + 0.5D, this.posZ, i));
}
示例8: onItemPickup
import net.minecraft.entity.item.EntityXPOrb; //導入依賴的package包/類
/**
* Called when the entity picks up an item.
*/
public void onItemPickup(Entity entityIn, int quantity)
{
if (!entityIn.isDead && !this.worldObj.isRemote)
{
EntityTracker entitytracker = ((WorldServer)this.worldObj).getEntityTracker();
if (entityIn instanceof EntityItem)
{
entitytracker.sendToAllTrackingEntity(entityIn, new SPacketCollectItem(entityIn.getEntityId(), this.getEntityId()));
}
if (entityIn instanceof EntityArrow)
{
entitytracker.sendToAllTrackingEntity(entityIn, new SPacketCollectItem(entityIn.getEntityId(), this.getEntityId()));
}
if (entityIn instanceof EntityXPOrb)
{
entitytracker.sendToAllTrackingEntity(entityIn, new SPacketCollectItem(entityIn.getEntityId(), this.getEntityId()));
}
}
}
示例9: protectedUpdate
import net.minecraft.entity.item.EntityXPOrb; //導入依賴的package包/類
@Override
public void protectedUpdate() {
super.protectedUpdate();
this.getWorld().getEntitiesWithinAABB(EntityXPOrb.class, getWorkingArea().expand(2, 2, 2)).stream().filter(entityXPOrb -> !entityXPOrb.isDead).forEach(entityXPOrb -> {
if (this.outExp.fill(new FluidStack(FluidsRegistry.ESSENCE, (int) (entityXPOrb.getXpValue() * 20 * BlockRegistry.mobRelocatorBlock.getEssenceMultiplier())), false) > 0) {
this.outExp.fill(new FluidStack(FluidsRegistry.ESSENCE, (int) (entityXPOrb.getXpValue() * 20 * BlockRegistry.mobRelocatorBlock.getEssenceMultiplier())), true);
}
entityXPOrb.setDead();
});
}
示例10: getEntityTrackingRange
import net.minecraft.entity.item.EntityXPOrb; //導入依賴的package包/類
/**
* Gets the range an entity should be 'tracked' by players and visible in
* the client.
*
* @param entity
* @param defaultRange Default range defined by Mojang
* @return
*/
public static int getEntityTrackingRange(Entity entity, int defaultRange)
{
SpigotWorldConfig config = entity.worldObj.getSpigotConfig(); // Cauldron
int range = defaultRange;
if ( entity instanceof EntityPlayerMP )
{
range = config.playerTrackingRange;
} else if ( entity.defaultActivationState || entity instanceof EntityGhast )
{
range = defaultRange;
} else if ( entity.activationType == 1 )
{
range = config.monsterTrackingRange;
} else if ( entity.activationType == 2 )
{
range = config.animalTrackingRange;
} else if ( entity instanceof EntityItemFrame || entity instanceof EntityPainting || entity instanceof EntityItem || entity instanceof EntityXPOrb )
{
range = config.miscTrackingRange;
}
// Cauldron start - allow for 0 to disable tracking ranges
if (range == 0)
{
return defaultRange;
}
// Cauldron end
return Math.min( config.maxTrackingRange, range );
}
示例11: smeltAndSpawn
import net.minecraft.entity.item.EntityXPOrb; //導入依賴的package包/類
private void smeltAndSpawn(EntityItem e) {
ItemStack copy = e.getItem().copy();
ItemStack is = copy.splitStack(1);
if (rng.nextDouble() < 0.7d) {
ItemStack result = FurnaceRecipes.instance().getSmeltingResult(is).copy();
e.getEntityWorld().spawnEntity(new EntityItem(e.getEntityWorld(), e.posX, e.posY, e.posZ, result));
} else {
e.getEntityWorld().spawnEntity(new EntityXPOrb(e.getEntityWorld(), e.posX, e.posY, e.posZ, 2));
}
e.setItem(copy);
}
示例12: onCrafting
import net.minecraft.entity.item.EntityXPOrb; //導入依賴的package包/類
@Override
protected void onCrafting(ItemStack stack) {
stack.onCrafting(this.player.world, this.player, this.removeCount);
if (!this.player.world.isRemote) {
int i = this.removeCount;
CraftiniumSmelt smelt = CraftiniumSmeltRegistry.findMatchingXp(stack, this.player.world, this.forge);
float f = smelt == null ? 0 : smelt.experience(stack, this.player.world, this.forge);
if (f == 0.0F) {
i = 0;
} else if (f < 1.0F) {
int j = MathHelper.floor((float) i * f);
if (j < MathHelper.ceil((float) i * f) && Math.random() < (double) ((float) i * f - (float) j)) {
++j;
}
i = j;
}
while (i > 0) {
int k = EntityXPOrb.getXPSplit(i);
i -= k;
this.player.world.spawnEntity(new EntityXPOrb(this.player.world, this.player.posX, this.player.posY + 0.5D, this.player.posZ + 0.5D, k));
}
}
this.removeCount = 0;
net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerSmeltedEvent(player, stack);
}
示例13: onDeathUpdate
import net.minecraft.entity.item.EntityXPOrb; //導入依賴的package包/類
/**
* handles entity death timer, experience orb and particle creation
*/
protected void onDeathUpdate()
{
++this.deathTime;
if (this.deathTime == 20)
{
if (!this.worldObj.isRemote && (this.recentlyHit > 0 || this.isPlayer()) && this.canDropLoot() && this.worldObj.getGameRules().getBoolean("doMobLoot"))
{
int i = this.getExperiencePoints(this.attackingPlayer);
while (i > 0)
{
int j = EntityXPOrb.getXPSplit(i);
i -= j;
this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j));
}
}
this.setDead();
for (int k = 0; k < 20; ++k)
{
double d2 = this.rand.nextGaussian() * 0.02D;
double d0 = this.rand.nextGaussian() * 0.02D;
double d1 = this.rand.nextGaussian() * 0.02D;
this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_NORMAL, this.posX + (double)(this.rand.nextFloat() * this.width * 2.0F) - (double)this.width, this.posY + (double)(this.rand.nextFloat() * this.height), this.posZ + (double)(this.rand.nextFloat() * this.width * 2.0F) - (double)this.width, d2, d0, d1, new int[0]);
}
}
}
示例14: useRecipe
import net.minecraft.entity.item.EntityXPOrb; //導入依賴的package包/類
public void useRecipe(MerchantRecipe recipe)
{
recipe.incrementToolUses();
this.livingSoundTime = -this.getTalkInterval();
this.playSound("mob.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.getName();
}
else
{
this.lastBuyingPlayer = null;
}
i += 5;
}
if (recipe.getItemToBuy().getItem() == Items.emerald)
{
this.wealth += recipe.getItemToBuy().stackSize;
}
if (recipe.getRewardsExp())
{
this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY + 0.5D, this.posZ, i));
}
}
示例15: S11PacketSpawnExperienceOrb
import net.minecraft.entity.item.EntityXPOrb; //導入依賴的package包/類
public S11PacketSpawnExperienceOrb(EntityXPOrb xpOrb)
{
this.entityID = xpOrb.getEntityId();
this.posX = MathHelper.floor_double(xpOrb.posX * 32.0D);
this.posY = MathHelper.floor_double(xpOrb.posY * 32.0D);
this.posZ = MathHelper.floor_double(xpOrb.posZ * 32.0D);
this.xpValue = xpOrb.getXpValue();
}