use of net.minecraft.entity.item.ExperienceOrbEntity in project Fragile-Glass by fredtargaryen.
the class SugarCauldronBlock method onBlockActivated.
@Override
public ActionResultType onBlockActivated(BlockState state, World w, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
ItemStack heldItemStack = player.inventory.getCurrentItem();
Item heldItem = heldItemStack.getItem();
if (w.isRemote) {
if (state.get(AGE_0_7).equals(1) && heldItem == FragileGlassBase.ITEM_SUGAR_BLOCK) {
this.splash(w, pos.getX(), pos.getY(), pos.getZ());
}
return ActionResultType.SUCCESS;
} else {
int i1 = state.get(AGE_0_7);
if (i1 == 0) {
if (heldItem == Items.WATER_BUCKET) {
if (!player.abilities.isCreativeMode) {
player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Items.BUCKET));
}
w.playSound(null, pos, SoundEvents.ENTITY_FISHING_BOBBER_SPLASH, SoundCategory.BLOCKS, 1.0F, 1.0F);
w.setBlockState(pos, state.with(AGE_0_7, 1));
return ActionResultType.SUCCESS;
}
} else if (i1 == 1) {
if (heldItem == FragileGlassBase.ITEM_SUGAR_BLOCK) {
if (!player.abilities.isCreativeMode) {
ItemStack newStack = heldItemStack.copy();
newStack.grow(-1);
player.inventory.setInventorySlotContents(player.inventory.currentItem, newStack);
}
w.playSound(null, pos, SoundEvents.ENTITY_FISHING_BOBBER_SPLASH, SoundCategory.BLOCKS, 1.0F, 1.0F);
w.setBlockState(pos, state.with(AGE_0_7, 2), 3);
return ActionResultType.CONSUME;
}
} else if (i1 == 6) {
w.addEntity(new ItemEntity(w, (double) pos.getX() + 0.5D, (double) pos.getY() + 1.0D, (double) pos.getZ() + 0.5D, new ItemStack(FragileGlassBase.FRAGILE_GLASS, WorldgenConfig.GLASS_YIELD.get())));
w.addEntity(new ExperienceOrbEntity(w, (double) pos.getX() + 0.5D, (double) pos.getY() + 1.0D, (double) pos.getZ() + 0.5D, 4));
w.setBlockState(pos, state.with(AGE_0_7, 0), 3);
return ActionResultType.SUCCESS;
}
}
return ActionResultType.FAIL;
}
use of net.minecraft.entity.item.ExperienceOrbEntity in project SophisticatedBackpacks by P3pp3rF1y.
the class MagnetUpgradeWrapper method pickupXpOrbs.
private int pickupXpOrbs(@Nullable LivingEntity entity, World world, BlockPos pos) {
List<ExperienceOrbEntity> xpEntities = world.getEntitiesOfClass(ExperienceOrbEntity.class, new AxisAlignedBB(pos).inflate(upgradeItem.getRadius()), e -> true);
if (xpEntities.isEmpty()) {
return COOLDOWN_TICKS;
}
int cooldown = COOLDOWN_TICKS;
for (ExperienceOrbEntity xpOrb : xpEntities) {
if (xpOrb.isAlive() && !canNotPickup(xpOrb, entity) && !tryToFillTank(xpOrb, entity, world)) {
cooldown = FULL_COOLDOWN_TICKS;
break;
}
}
return cooldown;
}
use of net.minecraft.entity.item.ExperienceOrbEntity in project endergetic by team-abnormals.
the class BoofloBreedGoal method impregnateBooflo.
protected void impregnateBooflo() {
final BabyEntitySpawnEvent event = new net.minecraftforge.event.entity.living.BabyEntitySpawnEvent(this.booflo, this.mate, null);
final boolean cancelled = MinecraftForge.EVENT_BUS.post(event);
if (cancelled) {
this.booflo.resetInLove();
this.mate.resetInLove();
return;
}
ServerPlayerEntity serverplayerentity = this.booflo.getLoveCause();
if (serverplayerentity == null && this.mate.getLoveCause() != null) {
serverplayerentity = this.mate.getLoveCause();
}
if (serverplayerentity != null) {
serverplayerentity.awardStat(Stats.ANIMALS_BRED);
EECriteriaTriggers.BRED_BOOFLO.trigger(serverplayerentity);
}
if (!this.mate.isPregnant()) {
this.booflo.setPregnant(true);
}
this.booflo.resetInLove();
this.mate.resetInLove();
this.booflo.breedDelay = 1400;
this.mate.breedDelay = 1400;
this.booflo.level.broadcastEntityEvent(this.booflo, (byte) 18);
if (this.booflo.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
this.booflo.level.addFreshEntity(new ExperienceOrbEntity(this.booflo.level, this.booflo.getX(), this.booflo.getY(), this.booflo.getZ(), this.booflo.getRandom().nextInt(7) + 1));
}
}
use of net.minecraft.entity.item.ExperienceOrbEntity in project ChocolateQuestRepoured by TeamChocoQuest.
the class EntityCQRNetherDragon method dropExperience.
private void dropExperience(int p_184668_1_, double x, double y, double z) {
while (p_184668_1_ > 0) {
int i = ExperienceOrbEntity.getExperienceValue(p_184668_1_);
p_184668_1_ -= i;
ExperienceOrbEntity xp = new ExperienceOrbEntity(this.level, x, y, z, i);
xp.setInvulnerable(true);
this.level.addFreshEntity(xp);
}
}
use of net.minecraft.entity.item.ExperienceOrbEntity in project ChocolateQuestRepoured by TeamChocoQuest.
the class EntityCQRWalkerKing method dropExperience.
private void dropExperience(int p_184668_1_) {
while (p_184668_1_ > 0) {
int i = ExperienceOrbEntity.getExperienceValue(p_184668_1_);
p_184668_1_ -= i;
this.level.addFreshEntity(new ExperienceOrbEntity(this.level, this.getX(), this.getY(), this.getZ(), i));
}
}
Aggregations