New EntityItem related events
Fixed player death event in SMP Added Player specific drops event Added generic EntityJoinWorldEvent
This commit is contained in:
parent
da501613ac
commit
03d1e51764
13 changed files with 417 additions and 55 deletions
|
@ -51,6 +51,7 @@ public aji.k # worldObj
|
|||
public ain.c # graphicsLevel
|
||||
# Item
|
||||
public rh.e(I)Lrh; # setMaxDamage
|
||||
public-f rh.f(Lrj;)I # getIconIndex
|
||||
# ItemAxe
|
||||
public rf.<init>()V # constructor
|
||||
# ItemPickaxe
|
||||
|
@ -58,3 +59,7 @@ public rq.<init>()V # constructor
|
|||
# RailLogic
|
||||
public ahi
|
||||
public ahi.a(Lahi;)I # getNAdjacentTiles
|
||||
#EntityPlayer
|
||||
public og.a(Lnj;)V # joinEntityItemWithWorld
|
||||
#EntityPlayerMP
|
||||
public atg.a(Lnj;)V # joinEntityItemWithWorld
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.*;
|
|||
import cpw.mods.fml.common.FMLLog;
|
||||
|
||||
import net.minecraft.src.*;
|
||||
import net.minecraftforge.event.entity.item.ItemTossEvent;
|
||||
import net.minecraftforge.event.entity.living.*;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.*;
|
||||
|
||||
|
@ -338,4 +339,21 @@ public class ForgeHooks
|
|||
{
|
||||
MinecraftForge.EVENT_BUS.post(new LivingJumpEvent(entity));
|
||||
}
|
||||
|
||||
public static EntityItem onPlayerTossEvent(EntityPlayer player, ItemStack item)
|
||||
{
|
||||
player.captureDrops = true;
|
||||
EntityItem ret = player.dropPlayerItemWithRandomChoice(item, false);
|
||||
player.capturedDrops.clear();
|
||||
player.captureDrops = false;
|
||||
|
||||
ItemTossEvent event = new ItemTossEvent(ret, player);
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
player.joinEntityItemWithWorld(event.entityItem);
|
||||
return event.entityItem;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package net.minecraftforge.event.entity;
|
||||
|
||||
import net.minecraft.src.Entity;
|
||||
import net.minecraft.src.World;
|
||||
|
||||
public class EntityJoinWorldEvent extends EntityEvent
|
||||
{
|
||||
|
||||
public final World world;
|
||||
|
||||
public EntityJoinWorldEvent(Entity entity, World world)
|
||||
{
|
||||
super(entity);
|
||||
this.world = world;
|
||||
}
|
||||
}
|
29
common/net/minecraftforge/event/entity/item/ItemEvent.java
Normal file
29
common/net/minecraftforge/event/entity/item/ItemEvent.java
Normal file
|
@ -0,0 +1,29 @@
|
|||
package net.minecraftforge.event.entity.item;
|
||||
|
||||
import net.minecraft.src.EntityItem;
|
||||
import net.minecraftforge.event.entity.EntityEvent;
|
||||
|
||||
/**
|
||||
* Base class for all EntityItem events. Contains a reference to the
|
||||
* EntityItem of interest. For most EntityItem events, there's little to no
|
||||
* additional useful data from the firing method that isn't already contained
|
||||
* within the EntityItem instance.
|
||||
*/
|
||||
public class ItemEvent extends EntityEvent
|
||||
{
|
||||
/**
|
||||
* The relevant EntityItem for this event, already cast for you.
|
||||
*/
|
||||
public final EntityItem entityItem;
|
||||
|
||||
/**
|
||||
* Creates a new event for an EntityItem.
|
||||
*
|
||||
* @param itemEntity The EntityItem for this event
|
||||
*/
|
||||
public ItemEvent(EntityItem itemEntity)
|
||||
{
|
||||
super(itemEntity);
|
||||
this.entityItem = itemEntity;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package net.minecraftforge.event.entity.item;
|
||||
|
||||
import net.minecraft.src.EntityItem;
|
||||
import net.minecraftforge.event.Cancelable;
|
||||
import net.minecraftforge.event.entity.EntityEvent;
|
||||
|
||||
/**
|
||||
* Event that is fired when an EntityItem's age has reached its maximum
|
||||
* lifespan. Canceling this event will prevent the EntityItem from being
|
||||
* flagged as dead, thus staying it's removal from the world. If canceled
|
||||
* it will add more time to the entitie's life equal to extraLife.
|
||||
*/
|
||||
@Cancelable
|
||||
public class ItemExpireEvent extends ItemEvent
|
||||
{
|
||||
|
||||
public int extraLife;
|
||||
|
||||
/**
|
||||
* Creates a new event for an expiring EntityItem.
|
||||
*
|
||||
* @param entityItem The EntityItem being deleted.
|
||||
* @param extraLife The amount of time to be added to this entities lifespan if the event is canceled.
|
||||
*/
|
||||
public ItemExpireEvent(EntityItem entityItem, int extraLife)
|
||||
{
|
||||
super(entityItem);
|
||||
this.extraLife = extraLife;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package net.minecraftforge.event.entity.item;
|
||||
|
||||
import net.minecraft.src.EntityItem;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraftforge.event.Cancelable;
|
||||
import net.minecraftforge.event.entity.EntityEvent;
|
||||
|
||||
/**
|
||||
* Event that is fired whenever a player tosses (Q) an item or drag-n-drops a
|
||||
* stack of items outside the inventory GUI screens. Canceling the event will
|
||||
* stop the items from entering the world, but will not prevent them being
|
||||
* removed from the inventory - and thus removed from the system.
|
||||
*/
|
||||
@Cancelable
|
||||
public class ItemTossEvent extends ItemEvent
|
||||
{
|
||||
|
||||
/**
|
||||
* The player tossing the item.
|
||||
*/
|
||||
public final EntityPlayer player;
|
||||
|
||||
/**
|
||||
* Creates a new event for EntityItems tossed by a player.
|
||||
*
|
||||
* @param entityItem The EntityItem being tossed.
|
||||
* @param player The player tossing the item.
|
||||
*/
|
||||
public ItemTossEvent(EntityItem entityItem, EntityPlayer player)
|
||||
{
|
||||
super(entityItem);
|
||||
this.player = player;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package net.minecraftforge.event.entity.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.src.*;
|
||||
import net.minecraftforge.event.Cancelable;
|
||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||
|
||||
/**
|
||||
* Child class of LivingDropEvent that is fired specifically when a
|
||||
* player dies. Canceling the event will prevent ALL drops from entering the
|
||||
* world.
|
||||
*/
|
||||
@Cancelable
|
||||
public class PlayerDropsEvent extends LivingDropsEvent
|
||||
{
|
||||
public final EntityPlayer entityPlayer;
|
||||
|
||||
/**
|
||||
* Creates a new event containing all the items that will drop into the
|
||||
* world when a player dies.
|
||||
* @param entity The dying player.
|
||||
* @param source The source of the damage which is killing the player.
|
||||
* @param drops List of all drops entering the world.
|
||||
*/
|
||||
public PlayerDropsEvent(EntityPlayer entity, DamageSource source, ArrayList<EntityItem> drops, boolean recentlyHit)
|
||||
{
|
||||
super(entity, source, drops,
|
||||
(source.getEntity() instanceof EntityPlayer) ?
|
||||
EnchantmentHelper.getLootingModifier(((EntityPlayer)source.getEntity()).inventory) : 0,
|
||||
recentlyHit, 0);
|
||||
|
||||
this.entityPlayer = entity;
|
||||
}
|
||||
}
|
|
@ -15,8 +15,8 @@
|
|||
public EnumEntitySize myEntitySize;
|
||||
+ /** Forge: Used to store custom data for each entity. */
|
||||
+ private NBTTagCompound customEntityData;
|
||||
+ protected boolean captureDrops = false;
|
||||
+ protected ArrayList<EntityItem> capturedDrops = new ArrayList<EntityItem>();
|
||||
+ public boolean captureDrops = false;
|
||||
+ public ArrayList<EntityItem> capturedDrops = new ArrayList<EntityItem>();
|
||||
|
||||
public Entity(World par1World)
|
||||
{
|
||||
|
|
|
@ -1,28 +1,67 @@
|
|||
--- ../src_base/common/net/minecraft/src/EntityItem.java
|
||||
+++ ../src_work/common/net/minecraft/src/EntityItem.java
|
||||
@@ -1,6 +1,9 @@
|
||||
@@ -1,6 +1,10 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Iterator;
|
||||
+
|
||||
+import net.minecraftforge.common.MinecraftForge;
|
||||
+import net.minecraftforge.event.entity.item.ItemExpireEvent;
|
||||
+import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
@@ -122,6 +125,11 @@
|
||||
{
|
||||
this.setDead();
|
||||
}
|
||||
@@ -20,6 +24,11 @@
|
||||
|
||||
/** The EntityItem's random initial float height. */
|
||||
public float hoverStart = (float)(Math.random() * Math.PI * 2.0D);
|
||||
+
|
||||
+ if (this.item == null || this.item.stackSize <= 0)
|
||||
+ /**
|
||||
+ * The maximum age of this EntityItem. The item is expired once this is reached.
|
||||
+ */
|
||||
+ public int lifespan = 6000;
|
||||
|
||||
public EntityItem(World par1World, double par2, double par4, double par6, ItemStack par8ItemStack)
|
||||
{
|
||||
@@ -32,6 +41,7 @@
|
||||
this.motionX = (double)((float)(Math.random() * 0.20000000298023224D - 0.10000000149011612D));
|
||||
this.motionY = 0.20000000298023224D;
|
||||
this.motionZ = (double)((float)(Math.random() * 0.20000000298023224D - 0.10000000149011612D));
|
||||
+ this.lifespan = (par8ItemStack.getItem() == null ? 6000 : par8ItemStack.getItem().getEntityLifespan(par8ItemStack, par1World));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,7 +128,20 @@
|
||||
|
||||
++this.age;
|
||||
|
||||
- if (this.age >= 6000)
|
||||
+ if (this.age >= lifespan)
|
||||
+ {
|
||||
+ ItemExpireEvent event = new ItemExpireEvent(this, (item.getItem() == null ? 6000 : item.getItem().getEntityLifespan(item, worldObj)));
|
||||
+ if (MinecraftForge.EVENT_BUS.post(event))
|
||||
+ {
|
||||
+ lifespan += event.extraLife;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ this.setDead();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (this.item == null || this.item.stackSize <= 0)
|
||||
{
|
||||
this.setDead();
|
||||
}
|
||||
@@ -208,6 +231,7 @@
|
||||
{
|
||||
par1NBTTagCompound.setShort("Health", (short)((byte)this.health));
|
||||
par1NBTTagCompound.setShort("Age", (short)this.age);
|
||||
+ par1NBTTagCompound.setInteger("Lifespan", lifespan);
|
||||
|
||||
public boolean func_70289_a(EntityItem par1EntityItem)
|
||||
@@ -225,7 +233,7 @@
|
||||
if (this.item != null)
|
||||
{
|
||||
@@ -225,10 +249,15 @@
|
||||
NBTTagCompound var2 = par1NBTTagCompound.getCompoundTag("Item");
|
||||
this.item = ItemStack.loadItemStackFromNBT(var2);
|
||||
|
||||
|
@ -31,7 +70,15 @@
|
|||
{
|
||||
this.setDead();
|
||||
}
|
||||
@@ -238,9 +246,21 @@
|
||||
+
|
||||
+ if (par1NBTTagCompound.hasKey("Lifespan"))
|
||||
+ {
|
||||
+ lifespan = par1NBTTagCompound.getInteger("Lifespan");
|
||||
+ }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -238,9 +267,21 @@
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--- ../src_base/common/net/minecraft/src/EntityPlayer.java
|
||||
+++ ../src_work/common/net/minecraft/src/EntityPlayer.java
|
||||
@@ -7,6 +7,15 @@
|
||||
@@ -7,6 +7,16 @@
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -12,11 +12,12 @@
|
|||
+import net.minecraftforge.event.entity.player.AttackEntityEvent;
|
||||
+import net.minecraftforge.event.entity.player.EntityInteractEvent;
|
||||
+import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
|
||||
+import net.minecraftforge.event.entity.player.PlayerDropsEvent;
|
||||
+import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent;
|
||||
|
||||
public abstract class EntityPlayer extends EntityLiving implements ICommandSender
|
||||
{
|
||||
@@ -222,6 +231,7 @@
|
||||
@@ -222,6 +232,7 @@
|
||||
|
||||
if (var1 == this.itemInUse)
|
||||
{
|
||||
|
@ -24,7 +25,36 @@
|
|||
if (this.itemInUseCount <= 25 && this.itemInUseCount % 4 == 0)
|
||||
{
|
||||
this.updateItemUse(var1, 5);
|
||||
@@ -627,7 +637,16 @@
|
||||
@@ -574,12 +585,28 @@
|
||||
this.setPosition(this.posX, this.posY, this.posZ);
|
||||
this.motionY = 0.10000000149011612D;
|
||||
|
||||
+ captureDrops = true;
|
||||
+ capturedDrops.clear();
|
||||
+
|
||||
if (this.username.equals("Notch"))
|
||||
{
|
||||
this.dropPlayerItemWithRandomChoice(new ItemStack(Item.appleRed, 1), true);
|
||||
}
|
||||
|
||||
this.inventory.dropAllItems();
|
||||
+ captureDrops = false;
|
||||
+
|
||||
+ if (!worldObj.isRemote)
|
||||
+ {
|
||||
+ PlayerDropsEvent event = new PlayerDropsEvent(this, par1DamageSource, capturedDrops, recentlyHit > 0);
|
||||
+ if (!MinecraftForge.EVENT_BUS.post(event))
|
||||
+ {
|
||||
+ for (EntityItem item : capturedDrops)
|
||||
+ {
|
||||
+ joinEntityItemWithWorld(item);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
|
||||
if (par1DamageSource != null)
|
||||
{
|
||||
@@ -627,7 +654,16 @@
|
||||
*/
|
||||
public EntityItem dropOneItem()
|
||||
{
|
||||
|
@ -36,13 +66,35 @@
|
|||
+ }
|
||||
+ if (stack.getItem().onDroppedByPlayer(stack, this))
|
||||
+ {
|
||||
+ return dropPlayerItemWithRandomChoice(inventory.decrStackSize(inventory.currentItem, 1), false);
|
||||
+ return ForgeHooks.onPlayerTossEvent(this, inventory.decrStackSize(inventory.currentItem, 1));
|
||||
+ }
|
||||
+ return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -693,13 +712,21 @@
|
||||
@@ -636,7 +672,7 @@
|
||||
*/
|
||||
public EntityItem dropPlayerItem(ItemStack par1ItemStack)
|
||||
{
|
||||
- return this.dropPlayerItemWithRandomChoice(par1ItemStack, false);
|
||||
+ return ForgeHooks.onPlayerTossEvent(this, par1ItemStack);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -688,18 +724,33 @@
|
||||
*/
|
||||
protected void joinEntityItemWithWorld(EntityItem par1EntityItem)
|
||||
{
|
||||
- this.worldObj.spawnEntityInWorld(par1EntityItem);
|
||||
+ if (captureDrops)
|
||||
+ {
|
||||
+ capturedDrops.add(par1EntityItem);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ this.worldObj.spawnEntityInWorld(par1EntityItem);
|
||||
+ }
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns how strong the player is against the specified block at this moment
|
||||
|
@ -67,7 +119,7 @@
|
|||
{
|
||||
var2 += (float)(var3 * var3 + 1);
|
||||
}
|
||||
@@ -992,12 +1019,23 @@
|
||||
@@ -992,12 +1043,23 @@
|
||||
*/
|
||||
protected void damageEntity(DamageSource par1DamageSource, int par2)
|
||||
{
|
||||
|
@ -92,7 +144,7 @@
|
|||
par2 = this.applyPotionDamageCalculations(par1DamageSource, par2);
|
||||
this.addExhaustion(par1DamageSource.getHungerDamage());
|
||||
this.health -= par2;
|
||||
@@ -1032,6 +1070,10 @@
|
||||
@@ -1032,6 +1094,10 @@
|
||||
|
||||
public boolean interactWith(Entity par1Entity)
|
||||
{
|
||||
|
@ -103,7 +155,7 @@
|
|||
if (par1Entity.interact(this))
|
||||
{
|
||||
return true;
|
||||
@@ -1075,7 +1117,9 @@
|
||||
@@ -1075,7 +1141,9 @@
|
||||
*/
|
||||
public void destroyCurrentEquippedItem()
|
||||
{
|
||||
|
@ -113,7 +165,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
@@ -1104,6 +1148,15 @@
|
||||
@@ -1104,6 +1172,15 @@
|
||||
*/
|
||||
public void attackTargetEntityWithCurrentItem(Entity par1Entity)
|
||||
{
|
||||
|
@ -129,7 +181,7 @@
|
|||
if (par1Entity.canAttackWithItem())
|
||||
{
|
||||
int var2 = this.inventory.getDamageVsEntity(par1Entity);
|
||||
@@ -1247,6 +1300,12 @@
|
||||
@@ -1247,6 +1324,12 @@
|
||||
*/
|
||||
public EnumStatus sleepInBedAt(int par1, int par2, int par3)
|
||||
{
|
||||
|
@ -142,7 +194,7 @@
|
|||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
if (this.isPlayerSleeping() || !this.isEntityAlive())
|
||||
@@ -1286,6 +1345,11 @@
|
||||
@@ -1286,6 +1369,11 @@
|
||||
{
|
||||
int var9 = this.worldObj.getBlockMetadata(par1, par2, par3);
|
||||
int var5 = BlockBed.getDirection(var9);
|
||||
|
@ -154,7 +206,7 @@
|
|||
float var10 = 0.5F;
|
||||
float var7 = 0.5F;
|
||||
|
||||
@@ -1356,10 +1420,12 @@
|
||||
@@ -1356,10 +1444,12 @@
|
||||
ChunkCoordinates var4 = this.playerLocation;
|
||||
ChunkCoordinates var5 = this.playerLocation;
|
||||
|
||||
|
@ -171,7 +223,7 @@
|
|||
|
||||
if (var5 == null)
|
||||
{
|
||||
@@ -1396,7 +1462,9 @@
|
||||
@@ -1396,7 +1486,9 @@
|
||||
*/
|
||||
private boolean isInBed()
|
||||
{
|
||||
|
@ -182,7 +234,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
@@ -1411,13 +1479,15 @@
|
||||
@@ -1411,13 +1503,15 @@
|
||||
var2.loadChunk(par1ChunkCoordinates.posX - 3 >> 4, par1ChunkCoordinates.posZ + 3 >> 4);
|
||||
var2.loadChunk(par1ChunkCoordinates.posX + 3 >> 4, par1ChunkCoordinates.posZ + 3 >> 4);
|
||||
|
||||
|
@ -200,7 +252,7 @@
|
|||
return var3;
|
||||
}
|
||||
}
|
||||
@@ -1431,8 +1501,11 @@
|
||||
@@ -1431,8 +1525,11 @@
|
||||
{
|
||||
if (this.playerLocation != null)
|
||||
{
|
||||
|
@ -214,7 +266,7 @@
|
|||
|
||||
switch (var2)
|
||||
{
|
||||
@@ -1725,6 +1798,7 @@
|
||||
@@ -1725,6 +1822,7 @@
|
||||
return 101;
|
||||
}
|
||||
}
|
||||
|
|
40
patches/common/net/minecraft/src/EntityPlayerMP.java.patch
Normal file
40
patches/common/net/minecraft/src/EntityPlayerMP.java.patch
Normal file
|
@ -0,0 +1,40 @@
|
|||
--- ../src_base/common/net/minecraft/src/EntityPlayerMP.java
|
||||
+++ ../src_work/common/net/minecraft/src/EntityPlayerMP.java
|
||||
@@ -8,6 +8,9 @@
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraftforge.common.ForgeHooks;
|
||||
+import net.minecraftforge.common.MinecraftForge;
|
||||
+import net.minecraftforge.event.entity.player.PlayerDropsEvent;
|
||||
|
||||
public class EntityPlayerMP extends EntityPlayer implements ICrafting
|
||||
{
|
||||
@@ -329,8 +332,27 @@
|
||||
*/
|
||||
public void onDeath(DamageSource par1DamageSource)
|
||||
{
|
||||
+ if (ForgeHooks.onLivingDeath(this, par1DamageSource))
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
this.mcServer.getConfigurationManager().sendPacketToAllPlayers(new Packet3Chat(par1DamageSource.getDeathMessage(this)));
|
||||
+
|
||||
+ captureDrops = true;
|
||||
+ capturedDrops.clear();
|
||||
+
|
||||
this.inventory.dropAllItems();
|
||||
+
|
||||
+ captureDrops = false;
|
||||
+ PlayerDropsEvent event = new PlayerDropsEvent(this, par1DamageSource, capturedDrops, recentlyHit > 0);
|
||||
+ if (!MinecraftForge.EVENT_BUS.post(event))
|
||||
+ {
|
||||
+ for (EntityItem item : capturedDrops)
|
||||
+ {
|
||||
+ joinEntityItemWithWorld(item);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
/**
|
|
@ -37,7 +37,7 @@
|
|||
Vec3 var23 = var13.addVector((double)var18 * var21, (double)var17 * var21, (double)var20 * var21);
|
||||
return par1World.rayTraceBlocks_do_do(var13, var23, par3, !par3);
|
||||
}
|
||||
@@ -650,4 +662,199 @@
|
||||
@@ -650,4 +662,212 @@
|
||||
{
|
||||
StatList.initStats();
|
||||
}
|
||||
|
@ -235,5 +235,18 @@
|
|||
+ return null;
|
||||
+ }
|
||||
+ return new ItemStack(getContainerItem());
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Retrieves the normal 'lifespan' of this item when it is dropped on the ground as a EntityItem.
|
||||
+ * This is in ticks, standard result is 6000, or 5 mins.
|
||||
+ *
|
||||
+ * @param itemStack The current ItemStack
|
||||
+ * @param world The world the entity is in
|
||||
+ * @return The normal lifespan in ticks.
|
||||
+ */
|
||||
+ public int getEntityLifespan(ItemStack itemStack, World world)
|
||||
+ {
|
||||
+ return 6000;
|
||||
+ }
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
--- ../src_base/common/net/minecraft/src/World.java
|
||||
+++ ../src_work/common/net/minecraft/src/World.java
|
||||
@@ -10,8 +10,21 @@
|
||||
@@ -10,8 +10,22 @@
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
+import net.minecraftforge.common.MinecraftForge;
|
||||
+import net.minecraftforge.common.ForgeDirection;
|
||||
+import net.minecraftforge.event.entity.EntityEvent;
|
||||
+import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
+import net.minecraftforge.event.world.WorldEvent;
|
||||
+import net.minecraftforge.event.entity.PlaySoundAtEntityEvent;
|
||||
+
|
||||
|
@ -22,7 +23,7 @@
|
|||
/**
|
||||
* boolean; if true updates scheduled by scheduleBlockUpdate happen immediately
|
||||
*/
|
||||
@@ -167,6 +180,7 @@
|
||||
@@ -167,6 +181,7 @@
|
||||
this.chunkProvider = this.createChunkProvider();
|
||||
this.calculateInitialSkylight();
|
||||
this.calculateInitialWeather();
|
||||
|
@ -30,7 +31,7 @@
|
|||
}
|
||||
|
||||
public World(ISaveHandler par1ISaveHandler, String par2Str, WorldSettings par3WorldSettings, WorldProvider par4WorldProvider, Profiler par5Profiler)
|
||||
@@ -213,6 +227,7 @@
|
||||
@@ -213,6 +228,7 @@
|
||||
|
||||
this.calculateInitialSkylight();
|
||||
this.calculateInitialWeather();
|
||||
|
@ -38,7 +39,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
@@ -269,7 +284,8 @@
|
||||
@@ -269,7 +285,8 @@
|
||||
*/
|
||||
public boolean isAirBlock(int par1, int par2, int par3)
|
||||
{
|
||||
|
@ -48,7 +49,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
@@ -278,7 +294,8 @@
|
||||
@@ -278,7 +295,8 @@
|
||||
public boolean blockHasTileEntity(int par1, int par2, int par3)
|
||||
{
|
||||
int var4 = this.getBlockId(par1, par2, par3);
|
||||
|
@ -58,7 +59,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
@@ -1009,7 +1026,7 @@
|
||||
@@ -1009,7 +1027,7 @@
|
||||
int var12 = this.getBlockMetadata(var8, var9, var10);
|
||||
Block var13 = Block.blocksList[var11];
|
||||
|
||||
|
@ -67,7 +68,7 @@
|
|||
{
|
||||
MovingObjectPosition var14 = var13.collisionRayTrace(this, var8, var9, var10, par1Vec3, par2Vec3);
|
||||
|
||||
@@ -1209,6 +1226,12 @@
|
||||
@@ -1209,6 +1227,12 @@
|
||||
*/
|
||||
public void playSoundAtEntity(Entity par1Entity, String par2Str, float par3, float par4)
|
||||
{
|
||||
|
@ -80,7 +81,19 @@
|
|||
if (par1Entity != null && par2Str != null)
|
||||
{
|
||||
Iterator var5 = this.worldAccesses.iterator();
|
||||
@@ -1887,7 +1910,7 @@
|
||||
@@ -1309,6 +1333,11 @@
|
||||
EntityPlayer var5 = (EntityPlayer)par1Entity;
|
||||
this.playerEntities.add(var5);
|
||||
this.updateAllPlayersSleepingFlag();
|
||||
+ }
|
||||
+
|
||||
+ if (!var4 && MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(par1Entity, this)))
|
||||
+ {
|
||||
+ return false;
|
||||
}
|
||||
|
||||
this.getChunkFromChunkCoords(var2, var3).addEntity(par1Entity);
|
||||
@@ -1887,7 +1916,7 @@
|
||||
|
||||
if (var8 != null)
|
||||
{
|
||||
|
@ -89,7 +102,7 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
@@ -1897,6 +1920,10 @@
|
||||
@@ -1897,6 +1926,10 @@
|
||||
|
||||
if (!this.entityRemoval.isEmpty())
|
||||
{
|
||||
|
@ -100,7 +113,7 @@
|
|||
this.loadedTileEntityList.removeAll(this.entityRemoval);
|
||||
this.entityRemoval.clear();
|
||||
}
|
||||
@@ -1917,7 +1944,9 @@
|
||||
@@ -1917,7 +1950,9 @@
|
||||
{
|
||||
this.loadedTileEntityList.add(var9);
|
||||
}
|
||||
|
@ -111,7 +124,7 @@
|
|||
if (this.chunkExists(var9.xCoord >> 4, var9.zCoord >> 4))
|
||||
{
|
||||
Chunk var10 = this.getChunkFromChunkCoords(var9.xCoord >> 4, var9.zCoord >> 4);
|
||||
@@ -1927,8 +1956,6 @@
|
||||
@@ -1927,8 +1962,6 @@
|
||||
var10.setChunkBlockTileEntity(var9.xCoord & 15, var9.yCoord, var9.zCoord & 15, var9);
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +133,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -1941,13 +1968,13 @@
|
||||
@@ -1941,13 +1974,13 @@
|
||||
|
||||
public void addTileEntity(Collection par1Collection)
|
||||
{
|
||||
|
@ -141,7 +154,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -1968,8 +1995,14 @@
|
||||
@@ -1968,8 +2001,14 @@
|
||||
int var3 = MathHelper.floor_double(par1Entity.posX);
|
||||
int var4 = MathHelper.floor_double(par1Entity.posZ);
|
||||
byte var5 = 32;
|
||||
|
@ -158,7 +171,7 @@
|
|||
{
|
||||
par1Entity.lastTickPosX = par1Entity.posX;
|
||||
par1Entity.lastTickPosY = par1Entity.posY;
|
||||
@@ -2204,6 +2237,14 @@
|
||||
@@ -2204,6 +2243,14 @@
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -173,7 +186,7 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
@@ -2510,25 +2551,21 @@
|
||||
@@ -2510,25 +2557,21 @@
|
||||
*/
|
||||
public void setBlockTileEntity(int par1, int par2, int par3, TileEntity par4TileEntity)
|
||||
{
|
||||
|
@ -214,7 +227,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -2537,27 +2574,10 @@
|
||||
@@ -2537,27 +2580,10 @@
|
||||
*/
|
||||
public void removeBlockTileEntity(int par1, int par2, int par3)
|
||||
{
|
||||
|
@ -246,7 +259,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -2583,7 +2603,8 @@
|
||||
@@ -2583,7 +2609,8 @@
|
||||
*/
|
||||
public boolean isBlockNormalCube(int par1, int par2, int par3)
|
||||
{
|
||||
|
@ -256,7 +269,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
@@ -2591,8 +2612,7 @@
|
||||
@@ -2591,8 +2618,7 @@
|
||||
*/
|
||||
public boolean doesBlockHaveSolidTopSurface(int par1, int par2, int par3)
|
||||
{
|
||||
|
@ -266,7 +279,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
@@ -2608,7 +2628,7 @@
|
||||
@@ -2608,7 +2634,7 @@
|
||||
if (var5 != null && !var5.isEmpty())
|
||||
{
|
||||
Block var6 = Block.blocksList[this.getBlockId(par1, par2, par3)];
|
||||
|
@ -275,7 +288,7 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
@@ -3035,7 +3055,7 @@
|
||||
@@ -3035,7 +3061,7 @@
|
||||
|
||||
private int computeBlockLightValue(int par1, int par2, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
|
@ -284,7 +297,7 @@
|
|||
int var8 = this.getSavedLightValue(EnumSkyBlock.Block, par2 - 1, par3, par4) - par6;
|
||||
int var9 = this.getSavedLightValue(EnumSkyBlock.Block, par2 + 1, par3, par4) - par6;
|
||||
int var10 = this.getSavedLightValue(EnumSkyBlock.Block, par2, par3 - 1, par4) - par6;
|
||||
@@ -3303,10 +3323,10 @@
|
||||
@@ -3303,10 +3329,10 @@
|
||||
public List getEntitiesWithinAABBExcludingEntity(Entity par1Entity, AxisAlignedBB par2AxisAlignedBB)
|
||||
{
|
||||
this.entitiesWithinAABBExcludingEntity.clear();
|
||||
|
@ -299,7 +312,7 @@
|
|||
|
||||
for (int var7 = var3; var7 <= var4; ++var7)
|
||||
{
|
||||
@@ -3327,10 +3347,10 @@
|
||||
@@ -3327,10 +3353,10 @@
|
||||
*/
|
||||
public List getEntitiesWithinAABB(Class par1Class, AxisAlignedBB par2AxisAlignedBB)
|
||||
{
|
||||
|
@ -314,7 +327,25 @@
|
|||
ArrayList var7 = new ArrayList();
|
||||
|
||||
for (int var8 = var3; var8 <= var4; ++var8)
|
||||
@@ -3460,7 +3480,10 @@
|
||||
@@ -3419,11 +3445,14 @@
|
||||
*/
|
||||
public void addLoadedEntities(List par1List)
|
||||
{
|
||||
- this.loadedEntityList.addAll(par1List);
|
||||
-
|
||||
for (int var2 = 0; var2 < par1List.size(); ++var2)
|
||||
{
|
||||
- this.obtainEntitySkin((Entity)par1List.get(var2));
|
||||
+ Entity entity = (Entity)par1List.get(var2);
|
||||
+ if (!MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(entity, this)))
|
||||
+ {
|
||||
+ loadedEntityList.add(entity);
|
||||
+ this.obtainEntitySkin(entity);
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3460,7 +3489,10 @@
|
||||
{
|
||||
var9 = null;
|
||||
}
|
||||
|
@ -326,7 +357,19 @@
|
|||
return par1 > 0 && var9 == null && var10.canPlaceBlockOnSide(this, par2, par3, par4, par6);
|
||||
}
|
||||
}
|
||||
@@ -3958,4 +3981,65 @@
|
||||
@@ -3701,7 +3733,10 @@
|
||||
|
||||
if (!this.loadedEntityList.contains(par1Entity))
|
||||
{
|
||||
- this.loadedEntityList.add(par1Entity);
|
||||
+ if (!MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(par1Entity, this)))
|
||||
+ {
|
||||
+ loadedEntityList.add(par1Entity);
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3958,4 +3993,65 @@
|
||||
var7.destroyBlockPartially(par1, par2, par3, par4, par5);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue