Re-add PlayerGiveXpEvent & PlayerChangeLevelEvent (#6165)

This commit is contained in:
FireController1847 authored and LexManos committed 2019-10-14 10:37:44 -07:00
1 parent 8248eb6ea1
commit 94cbf72e39
5 files changed
+207 -14

No files matched your search

@@ -19,27 +19,21 @@
package net.minecraftforge.event.entity.player;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraft.entity.item.ExperienceOrbEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraftforge.eventbus.api.Cancelable;
/**
* This event is called when a player collides with a EntityXPOrb on the ground.
* The event can be canceled, and no further processing will be done.
* Use {@link PlayerXpEvent.PickupXp}
*/
@Cancelable
public class PlayerPickupXpEvent extends PlayerEvent
@Deprecated
public class PlayerPickupXpEvent extends PlayerXpEvent.PickupXp
{
private final ExperienceOrbEntity orb;
public PlayerPickupXpEvent(PlayerEntity player, ExperienceOrbEntity orb)
{
super(player);
this.orb = orb;
super(player, orb);
}
public ExperienceOrbEntity getOrb()
{
return orb;
}
}
@@ -0,0 +1,121 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.event.entity.player;
import net.minecraft.entity.item.ExperienceOrbEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
/**
* PlayerXpEvent is fired whenever an event involving player experience occurs. <br>
* If a method utilizes this {@link net.minecraftforge.eventbus.api.Event} as its parameter, the method will
* receive every child event of this class.<br>
* <br>
* All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.
*/
public class PlayerXpEvent extends PlayerEvent
{
public PlayerXpEvent(PlayerEntity player)
{
super(player);
}
/**
* This event is fired after the player collides with an experience orb, but before the player has been given the experience.
* It can be cancelled, and no further processing will be done.
*/
@Cancelable
public static class PickupXp extends PlayerXpEvent
{
private final ExperienceOrbEntity orb;
public PickupXp(PlayerEntity player, ExperienceOrbEntity orb)
{
super(player);
this.orb = orb;
}
public ExperienceOrbEntity getOrb()
{
return orb;
}
}
/**
* This event is fired when the player's experience changes through the {@link PlayerEntity#giveExperiencePoints} method.
* It can be cancelled, and no further processing will be done.
*/
@Cancelable
public static class XpChange extends PlayerXpEvent
{
private int amount;
public XpChange(PlayerEntity player, int amount)
{
super(player);
this.amount = amount;
}
public int getAmount()
{
return this.amount;
}
public void setAmount(int amount)
{
this.amount = amount;
}
}
/**
* This event is fired when the player's experience level changes through the {@link PlayerEntity#addExperienceLevel} method.
* It can be cancelled, and no further processing will be done.
*/
@Cancelable
public static class LevelChange extends PlayerXpEvent
{
private int levels;
public LevelChange(PlayerEntity player, int levels)
{
super(player);
this.levels = levels;
}
public int getLevels()
{
return this.levels;
}
public void setLevels(int levels)
{
this.levels = levels;
}
}
}