Implement PlayerPickupXpEvent, fired when a player aquires XP from a EntityXPOrb. Closes #942

This commit is contained in:
Lex Manos 2014-01-24 16:31:38 -08:00
parent 2e47771860
commit 6c6f664c30
4 changed files with 52 additions and 10 deletions

View File

@ -72,7 +72,7 @@
if (p_147108_1_ instanceof GuiMainMenu)
{
this.gameSettings.showDebugInfo = false;
@@ -1338,7 +1352,7 @@
@@ -1337,7 +1351,7 @@
if (this.thePlayer.isCurrentToolAdventureModeExempt(i, j, k))
{
@ -81,7 +81,7 @@
this.thePlayer.swingItem();
}
}
@@ -1419,11 +1433,12 @@
@@ -1418,11 +1432,12 @@
int j = this.objectMouseOver.blockY;
int k = this.objectMouseOver.blockZ;
@ -96,7 +96,7 @@
{
flag = false;
this.thePlayer.swingItem();
@@ -1450,7 +1465,8 @@
@@ -1449,7 +1464,8 @@
{
ItemStack itemstack1 = this.thePlayer.inventory.getCurrentItem();
@ -106,7 +106,7 @@
{
this.entityRenderer.itemRenderer.resetEquippedProgress2();
}
@@ -1652,6 +1668,8 @@
@@ -1651,6 +1667,8 @@
while (Mouse.next())
{
@ -115,7 +115,7 @@
i = Mouse.getEventButton();
if (isRunningOnMac && i == 0 && (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157)))
@@ -2122,6 +2140,11 @@
@@ -2121,6 +2139,11 @@
// JAVADOC METHOD $$ func_71353_a
public void loadWorld(WorldClient par1WorldClient, String par2Str)
{
@ -127,7 +127,7 @@
if (par1WorldClient == null)
{
NetHandlerPlayClient nethandlerplayclient = this.func_147114_u();
@@ -2134,6 +2157,18 @@
@@ -2133,6 +2156,18 @@
if (this.theIntegratedServer != null)
{
this.theIntegratedServer.initiateShutdown();
@ -146,7 +146,7 @@
}
this.theIntegratedServer = null;
@@ -2289,113 +2324,10 @@
@@ -2288,113 +2323,10 @@
if (this.objectMouseOver != null)
{
boolean flag = this.thePlayer.capabilities.isCreativeMode;
@ -262,7 +262,7 @@
if (flag)
{
j = this.thePlayer.inventoryContainer.inventorySlots.size() - 9 + this.thePlayer.inventory.currentItem;
@@ -2565,9 +2497,16 @@
@@ -2564,9 +2496,16 @@
par1PlayerUsageSnooper.addData("gl_max_texture_size", Integer.valueOf(getGLMaximumTextureSize()));
}
@ -279,7 +279,7 @@
for (int i = 16384; i > 0; i >>= 1)
{
GL11.glTexImage2D(GL11.GL_PROXY_TEXTURE_2D, 0, GL11.GL_RGBA, i, i, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer)null);
@@ -2575,6 +2514,7 @@
@@ -2574,6 +2513,7 @@
if (j != 0)
{

View File

@ -0,0 +1,19 @@
--- ../src-base/minecraft/net/minecraft/entity/item/EntityXPOrb.java
+++ ../src-work/minecraft/net/minecraft/entity/item/EntityXPOrb.java
@@ -9,6 +9,8 @@
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.event.entity.player.PlayerPickupXpEvent;
public class EntityXPOrb extends Entity
{
@@ -218,6 +220,7 @@
{
if (this.field_70532_c == 0 && par1EntityPlayer.xpCooldown == 0)
{
+ if (MinecraftForge.EVENT_BUS.post(new PlayerPickupXpEvent(par1EntityPlayer, this))) return;
par1EntityPlayer.xpCooldown = 2;
this.worldObj.playSoundAtEntity(par1EntityPlayer, "random.orb", 0.1F, 0.5F * ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.8F));
par1EntityPlayer.onItemPickup(this, 1);

View File

@ -0,0 +1,21 @@
package net.minecraftforge.event.entity.player;
import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.entity.player.EntityPlayer;
/**
* 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.
*/
@Cancelable
public class PlayerPickupXpEvent extends PlayerEvent
{
public final EntityXPOrb orb;
public PlayerPickupXpEvent(EntityPlayer player, EntityXPOrb orb)
{
super(player);
this.orb = orb;
}
}

View File

@ -169,4 +169,6 @@ public net.minecraft.util.DamageSource *() #All methods public, most are already
# ItemBlock
public net.minecraft.item.ItemBlock field_150939_a # block
# EntityAITasks
public net.minecraft.entity.ai.EntityAITasks field_75782_a # taskEntries
public net.minecraft.entity.ai.EntityAITasks field_75782_a # taskEntries
# EntityXPOrb
public net.minecraft.entity.item.EntityXPOrb field_70530_e # xpValue