From 2a76f7740e85beba4f753d3cc773c4c3e73c4a22 Mon Sep 17 00:00:00 2001 From: Mithion Date: Fri, 22 Mar 2013 15:04:00 -0400 Subject: [PATCH 1/8] Entity Extended Properties Changes Adds IExtendedEntityProperties interface, which specifies three methods that are needed: Init, Save, and Load. Adds the EntityConstructing event, which is called during the constructor of Entity. It is needed there so that the reference is in place during the ReadNBT call. Adds hooks into Entity that allow registration of IExtendedEntityProperties classes, as well as saving and loading to NBT. --- .../common/IExtendedEntityProperties.java | 31 +++++ .../event/entity/EntityEvent.java | 8 ++ .../net/minecraft/entity/Entity.java.patch | 112 ++++++++++++++++-- 3 files changed, 140 insertions(+), 11 deletions(-) create mode 100644 common/net/minecraftforge/common/IExtendedEntityProperties.java diff --git a/common/net/minecraftforge/common/IExtendedEntityProperties.java b/common/net/minecraftforge/common/IExtendedEntityProperties.java new file mode 100644 index 000000000..d3f5586f5 --- /dev/null +++ b/common/net/minecraftforge/common/IExtendedEntityProperties.java @@ -0,0 +1,31 @@ +package net.minecraftforge.common; + +import net.minecraft.entity.Entity; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +public interface IExtendedEntityProperties { + /** + * Called when the entity that this class is attached to is saved. + * Any custom entity data that needs saving should be saved here. + * @param compound The compound to save to. + */ + public void saveNBTData(NBTTagCompound compound); + + /** + * Called when the entity that this class is attached to is loaded. + * In order to hook into this, you will need to subscribe to the EntityConstructing event. + * Otherwise, you will need to initialize manually. + * @param compound The compound to load from. + */ + public void loadNBTData(NBTTagCompound compound); + + /** + * Used to initialize the extended properties with the entity that this is attached to, as well + * as the world object. + * Called automatically if you register with the EntityConstructing event. + * @param entity The entity that this extended properties is attached to + * @param world The world in which the entity exists + */ + public void init(Entity entity, World world); +} diff --git a/common/net/minecraftforge/event/entity/EntityEvent.java b/common/net/minecraftforge/event/entity/EntityEvent.java index 318c16d42..f7d287dd4 100644 --- a/common/net/minecraftforge/event/entity/EntityEvent.java +++ b/common/net/minecraftforge/event/entity/EntityEvent.java @@ -1,6 +1,7 @@ package net.minecraftforge.event.entity; import net.minecraft.entity.Entity; +import net.minecraft.world.World; import net.minecraftforge.event.Event; public class EntityEvent extends Event @@ -11,6 +12,13 @@ public class EntityEvent extends Event { this.entity = entity; } + + public static class EntityConstructing extends EntityEvent + { + public EntityConstructing(Entity entity){ + super(entity); + } + } public static class CanUpdate extends EntityEvent { diff --git a/patches/minecraft/net/minecraft/entity/Entity.java.patch b/patches/minecraft/net/minecraft/entity/Entity.java.patch index 320de7e31..e427ccf8e 100644 --- a/patches/minecraft/net/minecraft/entity/Entity.java.patch +++ b/patches/minecraft/net/minecraft/entity/Entity.java.patch @@ -1,14 +1,17 @@ --- ../src_base/minecraft/net/minecraft/entity/Entity.java +++ ../src_work/minecraft/net/minecraft/entity/Entity.java -@@ -2,6 +2,7 @@ +@@ -1,7 +1,10 @@ + package net.minecraft.entity; ++import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; ++import java.util.HashMap; import java.util.List; import java.util.Random; import java.util.UUID; -@@ -13,8 +14,13 @@ +@@ -13,8 +16,13 @@ import net.minecraft.crash.CrashReportCategory; import net.minecraft.enchantment.EnchantmentProtection; import net.minecraft.entity.effect.EntityLightningBolt; @@ -22,7 +25,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagDouble; -@@ -25,6 +31,7 @@ +@@ -25,12 +33,16 @@ import net.minecraft.util.DamageSource; import net.minecraft.util.Direction; import net.minecraft.util.MathHelper; @@ -30,7 +33,16 @@ import net.minecraft.util.ReportedException; import net.minecraft.util.StatCollector; import net.minecraft.util.Vec3; -@@ -225,6 +232,11 @@ + import net.minecraft.world.Explosion; + import net.minecraft.world.World; + import net.minecraft.world.WorldServer; ++import net.minecraftforge.common.IExtendedEntityProperties; ++import net.minecraftforge.common.MinecraftForge; ++import net.minecraftforge.event.entity.EntityEvent; + + public abstract class Entity + { +@@ -225,6 +237,13 @@ private boolean invulnerable; private UUID entityUniqueID; public EnumEntitySize myEntitySize; @@ -39,10 +51,27 @@ + public boolean captureDrops = false; + public ArrayList capturedDrops = new ArrayList(); + private UUID persistentID; ++ ++ private HashMap extendedProperties; public Entity(World par1World) { -@@ -554,7 +566,7 @@ +@@ -274,6 +293,14 @@ + this.dataWatcher.addObject(0, Byte.valueOf((byte)0)); + this.dataWatcher.addObject(1, Short.valueOf((short)300)); + this.entityInit(); ++ ++ extendedProperties = new HashMap(); ++ ++ MinecraftForge.EVENT_BUS.post(new EntityEvent.EntityConstructing(this)); ++ ++ for (IExtendedEntityProperties props : this.extendedProperties.values()){ ++ props.init(this, par1World); ++ } + } + + protected abstract void entityInit(); +@@ -554,7 +581,7 @@ if (!this.worldObj.isRemote) { this.setFlag(0, this.fire > 0); @@ -51,7 +80,7 @@ } this.firstUpdate = false; -@@ -1534,6 +1546,10 @@ +@@ -1534,6 +1561,21 @@ par1NBTTagCompound.setInteger("PortalCooldown", this.timeUntilPortal); par1NBTTagCompound.setLong("UUIDMost", this.entityUniqueID.getMostSignificantBits()); par1NBTTagCompound.setLong("UUIDLeast", this.entityUniqueID.getLeastSignificantBits()); @@ -59,10 +88,21 @@ + { + par1NBTTagCompound.setCompoundTag("ForgeData", customEntityData); + } ++ ++ for (String identifier : this.extendedProperties.keySet()){ ++ try{ ++ IExtendedEntityProperties props = this.extendedProperties.get(identifier); ++ props.saveNBTData(par1NBTTagCompound); ++ }catch (Throwable t){ ++ FMLLog.severe("Failed to save extended properties for %s. This is a mod issue.", identifier); ++ t.printStackTrace(); ++ } ++ } ++ this.writeEntityToNBT(par1NBTTagCompound); if (this.ridingEntity != null) -@@ -1604,6 +1620,15 @@ +@@ -1604,6 +1646,26 @@ this.setPosition(this.posX, this.posY, this.posZ); this.setRotation(this.rotationYaw, this.rotationPitch); @@ -70,6 +110,17 @@ + { + customEntityData = par1NBTTagCompound.getCompoundTag("ForgeData"); + } ++ ++ for (String identifier : this.extendedProperties.keySet()){ ++ try{ ++ IExtendedEntityProperties props = this.extendedProperties.get(identifier); ++ props.loadNBTData(par1NBTTagCompound); ++ }catch (Throwable t){ ++ FMLLog.severe("Failed to load extended properties for %s. This is a mod issue.", identifier); ++ t.printStackTrace(); ++ } ++ } ++ + //Rawr, legacy code, Vanilla added a UUID, keep this so older maps will convert properly + if (par1NBTTagCompound.hasKey("PersistentIDMSB") && par1NBTTagCompound.hasKey("PersistentIDLSB")) + { @@ -78,7 +129,7 @@ this.readEntityFromNBT(par1NBTTagCompound); } catch (Throwable throwable) -@@ -1698,7 +1723,14 @@ +@@ -1698,7 +1760,14 @@ { EntityItem entityitem = new EntityItem(this.worldObj, this.posX, this.posY + (double)par2, this.posZ, par1ItemStack); entityitem.delayBeforeCanPickup = 10; @@ -94,7 +145,7 @@ return entityitem; } -@@ -2056,7 +2088,7 @@ +@@ -2056,7 +2125,7 @@ */ public boolean isRiding() { @@ -103,7 +154,7 @@ } /** -@@ -2400,7 +2432,7 @@ +@@ -2400,7 +2469,7 @@ public float func_82146_a(Explosion par1Explosion, World par2World, int par3, int par4, int par5, Block par6Block) { @@ -112,7 +163,7 @@ } public boolean func_96091_a(Explosion par1Explosion, World par2World, int par3, int par4, int par5, int par6, float par7) -@@ -2455,4 +2487,100 @@ +@@ -2455,4 +2524,139 @@ { return this.getEntityName(); } @@ -211,5 +262,44 @@ + public boolean isCreatureType(EnumCreatureType type, boolean forSpawnCount) + { + return type.getCreatureClass().isAssignableFrom(this.getClass()); ++ } ++ ++ /** ++ * Register the instance of IExtendedProperties into the entity's collection. ++ * @param identifier The identifier which you can use to retrieve these properties for the entity. ++ * @param properties The instanceof IExtendedProperties to register ++ * @return The identifier that was used to register the extended properties. Empty String indicates an error. If your requested key already existed, this will return a modified one that is unique. ++ */ ++ public String registerExtendedProperties(String identifier, IExtendedEntityProperties properties){ ++ if (identifier == null){ ++ FMLLog.warning("Someone is attempting to register extended properties using a null identifier. This is not allowed. Aborting. This may have caused instability."); ++ return ""; ++ } ++ if (properties == null){ ++ FMLLog.warning("Someone is attempting to register null extended properties. This is not allowed. Aborting. This may have caused instability."); ++ return ""; ++ } ++ ++ String baseIdentifier = identifier; ++ int identifierModCount = 1; ++ while (this.extendedProperties.containsKey(identifier)){ ++ identifier = String.format("%s%d", baseIdentifier, identifierModCount); ++ } ++ ++ if (baseIdentifier != identifier){ ++ FMLLog.info("An attempt was made to register exended properties using an existing key. The duplicate identifier (%s) has been remapped to %s.", baseIdentifier, identifier); ++ } ++ ++ this.extendedProperties.put(identifier, properties); ++ return identifier; ++ } ++ ++ /** ++ * Gets the extended properties identified by the passed in key ++ * @param identifier The key that identifies the extended properties. ++ * @return The instance of IExtendedProperties that was found, or null. ++ */ ++ public IExtendedEntityProperties getExtendedProperties(String identifier){ ++ return this.extendedProperties.get(identifier); + } } From fa2cbe2671fc04383db83619b324cfc9d5f1dc24 Mon Sep 17 00:00:00 2001 From: Mithion Date: Fri, 22 Mar 2013 15:05:23 -0400 Subject: [PATCH 2/8] Brewing Stand Changes Added an event on potion ingredient applied. Event contains the item stacks of each of the potions being brewed as well as any remaining ingredients. Changed TileEntityBrewingStand and SlotBrewingStandPotion to look for instanceof ItemPotion rather than potion.itemID --- .../event/brewing/PotionBrewedEvent.java | 14 ++++++ .../SlotBrewingStandPotion.java.patch | 27 +++++++++++ .../TileEntityBrewingStand.java.patch | 47 ++++++++++++++++++- 3 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 common/net/minecraftforge/event/brewing/PotionBrewedEvent.java create mode 100644 patches/minecraft/net/minecraft/inventory/SlotBrewingStandPotion.java.patch diff --git a/common/net/minecraftforge/event/brewing/PotionBrewedEvent.java b/common/net/minecraftforge/event/brewing/PotionBrewedEvent.java new file mode 100644 index 000000000..3012b9726 --- /dev/null +++ b/common/net/minecraftforge/event/brewing/PotionBrewedEvent.java @@ -0,0 +1,14 @@ +package net.minecraftforge.event.brewing; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.event.Event; + +public class PotionBrewedEvent extends Event{ + /** + * The brewing stacks in the brewing stand. Each index has the possibility to be null, so make sure you check. + */ + public ItemStack[] brewingStacks; + public PotionBrewedEvent(ItemStack[] brewingStacks){ + this.brewingStacks = brewingStacks; + } +} diff --git a/patches/minecraft/net/minecraft/inventory/SlotBrewingStandPotion.java.patch b/patches/minecraft/net/minecraft/inventory/SlotBrewingStandPotion.java.patch new file mode 100644 index 000000000..369d9ffe8 --- /dev/null +++ b/patches/minecraft/net/minecraft/inventory/SlotBrewingStandPotion.java.patch @@ -0,0 +1,27 @@ +--- ../src_base/minecraft/net/minecraft/inventory/SlotBrewingStandPotion.java ++++ ../src_work/minecraft/net/minecraft/inventory/SlotBrewingStandPotion.java +@@ -2,6 +2,7 @@ + + import net.minecraft.entity.player.EntityPlayer; + import net.minecraft.item.Item; ++import net.minecraft.item.ItemPotion; + import net.minecraft.item.ItemStack; + import net.minecraft.stats.AchievementList; + +@@ -35,7 +36,7 @@ + + public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack) + { +- if (par2ItemStack.itemID == Item.potion.itemID && par2ItemStack.getItemDamage() > 0) ++ if (par2ItemStack.getItem() instanceof ItemPotion && par2ItemStack.getItemDamage() > 0) + { + this.player.addStat(AchievementList.potion, 1); + } +@@ -48,6 +49,6 @@ + */ + public static boolean canHoldPotion(ItemStack par0ItemStack) + { +- return par0ItemStack != null && (par0ItemStack.itemID == Item.potion.itemID || par0ItemStack.itemID == Item.glassBottle.itemID); ++ return par0ItemStack != null && (par0ItemStack.getItem() instanceof ItemPotion || par0ItemStack.itemID == Item.glassBottle.itemID); + } + } diff --git a/patches/minecraft/net/minecraft/tileentity/TileEntityBrewingStand.java.patch b/patches/minecraft/net/minecraft/tileentity/TileEntityBrewingStand.java.patch index 699bee7a4..570091bca 100644 --- a/patches/minecraft/net/minecraft/tileentity/TileEntityBrewingStand.java.patch +++ b/patches/minecraft/net/minecraft/tileentity/TileEntityBrewingStand.java.patch @@ -1,6 +1,33 @@ --- ../src_base/minecraft/net/minecraft/tileentity/TileEntityBrewingStand.java +++ ../src_work/minecraft/net/minecraft/tileentity/TileEntityBrewingStand.java -@@ -184,7 +184,7 @@ +@@ -11,6 +11,8 @@ + import net.minecraft.nbt.NBTTagCompound; + import net.minecraft.nbt.NBTTagList; + import net.minecraft.potion.PotionHelper; ++import net.minecraftforge.common.MinecraftForge; ++import net.minecraftforge.event.brewing.PotionBrewedEvent; + + public class TileEntityBrewingStand extends TileEntity implements ISidedInventory + { +@@ -122,7 +124,7 @@ + + for (int i = 0; i < 3; ++i) + { +- if (this.brewingItemStacks[i] != null && this.brewingItemStacks[i].itemID == Item.potion.itemID) ++ if (this.brewingItemStacks[i] != null && this.brewingItemStacks[i].getItem() instanceof ItemPotion) + { + int j = this.brewingItemStacks[i].getItemDamage(); + int k = this.getPotionResult(j, itemstack); +@@ -161,7 +163,7 @@ + + for (int i = 0; i < 3; ++i) + { +- if (this.brewingItemStacks[i] != null && this.brewingItemStacks[i].itemID == Item.potion.itemID) ++ if (this.brewingItemStacks[i] != null && this.brewingItemStacks[i].getItem() instanceof ItemPotion) + { + int j = this.brewingItemStacks[i].getItemDamage(); + int k = this.getPotionResult(j, itemstack); +@@ -184,7 +186,7 @@ if (Item.itemsList[itemstack.itemID].hasContainerItem()) { @@ -9,3 +36,21 @@ } else { +@@ -195,6 +197,8 @@ + this.brewingItemStacks[3] = null; + } + } ++ ++ MinecraftForge.EVENT_BUS.post(new PotionBrewedEvent(brewingItemStacks)); + } + } + +@@ -343,7 +347,7 @@ + */ + public boolean isStackValidForSlot(int par1, ItemStack par2ItemStack) + { +- return par1 == 3 ? Item.itemsList[par2ItemStack.itemID].isPotionIngredient() : par2ItemStack.itemID == Item.potion.itemID || par2ItemStack.itemID == Item.glassBottle.itemID; ++ return par1 == 3 ? Item.itemsList[par2ItemStack.itemID].isPotionIngredient() : par2ItemStack.getItem() instanceof ItemPotion || par2ItemStack.itemID == Item.glassBottle.itemID; + } + + @SideOnly(Side.CLIENT) From ee6dce2390d3161d33fe656765aaa8fcf98dde58 Mon Sep 17 00:00:00 2001 From: Mithion Date: Fri, 22 Mar 2013 15:05:58 -0400 Subject: [PATCH 3/8] Player Flyable Fall Event Adds an event to EntityPlayer that is posted on player fall when the player has flight capabilities. --- .../entity/player/PlayerFlyableFallEvent.java | 21 +++++++ .../entity/player/EntityPlayer.java.patch | 60 +++++++++++-------- 2 files changed, 56 insertions(+), 25 deletions(-) create mode 100644 common/net/minecraftforge/event/entity/player/PlayerFlyableFallEvent.java diff --git a/common/net/minecraftforge/event/entity/player/PlayerFlyableFallEvent.java b/common/net/minecraftforge/event/entity/player/PlayerFlyableFallEvent.java new file mode 100644 index 000000000..0565b2ece --- /dev/null +++ b/common/net/minecraftforge/event/entity/player/PlayerFlyableFallEvent.java @@ -0,0 +1,21 @@ +package net.minecraftforge.event.entity.player; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.event.Cancelable; + +/** + * Occurs when a player falls, but is able to fly. Doesn't need to be cancelable, this is mainly for notification purposes. + * @author Mithion + * + */ +public class PlayerFlyableFallEvent extends PlayerEvent{ + + public float distance; + + public PlayerFlyableFallEvent(EntityPlayer player, float f) + { + super(player); + this.distance = f; + } + +} diff --git a/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch b/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch index abcb44eb5..3583806d5 100644 --- a/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch +++ b/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch @@ -1,6 +1,6 @@ --- ../src_base/minecraft/net/minecraft/entity/player/EntityPlayer.java +++ ../src_work/minecraft/net/minecraft/entity/player/EntityPlayer.java -@@ -66,8 +66,21 @@ +@@ -66,8 +66,22 @@ import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; @@ -13,6 +13,7 @@ +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.PlayerFlyableFallEvent; +import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent; + public abstract class EntityPlayer extends EntityLiving implements ICommandSender @@ -22,7 +23,7 @@ /** Inventory of the player */ public InventoryPlayer inventory = new InventoryPlayer(this); private InventoryEnderChest theInventoryEnderChest = new InventoryEnderChest(); -@@ -268,6 +281,7 @@ +@@ -268,6 +282,7 @@ if (itemstack == this.itemInUse) { @@ -30,7 +31,7 @@ if (this.itemInUseCount <= 25 && this.itemInUseCount % 4 == 0) { this.updateItemUse(itemstack, 5); -@@ -528,11 +542,11 @@ +@@ -528,11 +543,11 @@ this.cameraYaw = 0.0F; this.addMountedMovementStat(this.posX - d0, this.posY - d1, this.posZ - d2); @@ -44,7 +45,7 @@ } } -@@ -661,6 +675,9 @@ +@@ -661,6 +676,9 @@ this.setPosition(this.posX, this.posY, this.posZ); this.motionY = 0.10000000149011612D; @@ -54,7 +55,7 @@ if (this.username.equals("Notch")) { this.dropPlayerItemWithRandomChoice(new ItemStack(Item.appleRed, 1), true); -@@ -669,6 +686,20 @@ +@@ -669,6 +687,20 @@ if (!this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")) { this.inventory.dropAllItems(); @@ -75,7 +76,7 @@ } if (par1DamageSource != null) -@@ -719,7 +750,20 @@ +@@ -719,7 +751,20 @@ */ public EntityItem dropOneItem(boolean par1) { @@ -97,7 +98,7 @@ } /** -@@ -728,7 +772,7 @@ +@@ -728,7 +773,7 @@ */ public EntityItem dropPlayerItem(ItemStack par1ItemStack) { @@ -106,7 +107,7 @@ } /** -@@ -780,15 +824,28 @@ +@@ -780,15 +825,28 @@ */ public void joinEntityItemWithWorld(EntityItem par1EntityItem) { @@ -137,7 +138,7 @@ if (f > 1.0F) { -@@ -799,7 +856,9 @@ +@@ -799,7 +857,9 @@ { float f1 = (float)(i * i + 1); @@ -148,7 +149,7 @@ { f += f1 * 0.08F; } -@@ -830,7 +889,8 @@ +@@ -830,7 +890,8 @@ f /= 5.0F; } @@ -158,7 +159,7 @@ } /** -@@ -838,7 +898,7 @@ +@@ -838,7 +899,7 @@ */ public boolean canHarvestBlock(Block par1Block) { @@ -167,7 +168,7 @@ } /** -@@ -1096,12 +1156,22 @@ +@@ -1096,12 +1157,22 @@ { if (!this.isEntityInvulnerable()) { @@ -191,7 +192,7 @@ par2 = this.applyPotionDamageCalculations(par1DamageSource, par2); this.addExhaustion(par1DamageSource.getHungerDamage()); int j = this.getHealth(); -@@ -1144,6 +1214,10 @@ +@@ -1144,6 +1215,10 @@ public boolean interactWith(Entity par1Entity) { @@ -202,7 +203,7 @@ if (par1Entity.interact(this)) { return true; -@@ -1187,7 +1261,9 @@ +@@ -1187,7 +1262,9 @@ */ public void destroyCurrentEquippedItem() { @@ -212,7 +213,7 @@ } /** -@@ -1204,6 +1280,15 @@ +@@ -1204,6 +1281,15 @@ */ public void attackTargetEntityWithCurrentItem(Entity par1Entity) { @@ -228,7 +229,7 @@ if (par1Entity.canAttackWithItem()) { if (!par1Entity.func_85031_j(this)) -@@ -1378,6 +1463,12 @@ +@@ -1378,6 +1464,12 @@ */ public EnumStatus sleepInBedAt(int par1, int par2, int par3) { @@ -241,7 +242,7 @@ if (!this.worldObj.isRemote) { if (this.isPlayerSleeping() || !this.isEntityAlive()) -@@ -1417,6 +1508,11 @@ +@@ -1417,6 +1509,11 @@ { int l = this.worldObj.getBlockMetadata(par1, par2, par3); int i1 = BlockBed.getDirection(l); @@ -253,7 +254,7 @@ float f = 0.5F; float f1 = 0.5F; -@@ -1487,10 +1583,12 @@ +@@ -1487,10 +1584,12 @@ ChunkCoordinates chunkcoordinates = this.playerLocation; ChunkCoordinates chunkcoordinates1 = this.playerLocation; @@ -270,7 +271,7 @@ if (chunkcoordinates1 == null) { -@@ -1527,7 +1625,9 @@ +@@ -1527,7 +1626,9 @@ */ private boolean isInBed() { @@ -281,7 +282,7 @@ } /** -@@ -1542,9 +1642,12 @@ +@@ -1542,9 +1643,12 @@ ichunkprovider.loadChunk(par1ChunkCoordinates.posX - 3 >> 4, par1ChunkCoordinates.posZ + 3 >> 4); ichunkprovider.loadChunk(par1ChunkCoordinates.posX + 3 >> 4, par1ChunkCoordinates.posZ + 3 >> 4); @@ -297,7 +298,7 @@ return chunkcoordinates1; } else -@@ -1566,10 +1669,13 @@ +@@ -1566,10 +1670,13 @@ { if (this.playerLocation != null) { @@ -315,7 +316,16 @@ { case 0: return 90.0F; -@@ -1876,7 +1982,7 @@ +@@ -1834,6 +1941,8 @@ + } + + super.fall(par1); ++ }else{ ++ MinecraftForge.EVENT_BUS.post(new PlayerFlyableFallEvent(this, par1)); + } + } + +@@ -1876,7 +1985,7 @@ { if (par1ItemStack.getItem().requiresMultipleRenderPasses()) { @@ -324,7 +334,7 @@ } if (this.itemInUse != null && par1ItemStack.itemID == Item.bow.itemID) -@@ -1898,6 +2004,7 @@ +@@ -1898,6 +2007,7 @@ return Item.bow.func_94599_c(0); } } @@ -332,7 +342,7 @@ } return icon; -@@ -2137,6 +2244,14 @@ +@@ -2137,6 +2247,14 @@ } this.theInventoryEnderChest = par1EntityPlayer.theInventoryEnderChest; @@ -347,7 +357,7 @@ } /** -@@ -2208,7 +2323,14 @@ +@@ -2208,7 +2326,14 @@ */ public void setCurrentItemOrArmor(int par1, ItemStack par2ItemStack) { From 833e9f0c88e728971c6ac66453d6c1104c896af0 Mon Sep 17 00:00:00 2001 From: Mithion Date: Sat, 23 Mar 2013 12:58:24 -0400 Subject: [PATCH 4/8] Access Transformer Changes AT changes and corresponding class changes. Additions (all made public): EntityLiving.targetTasks PotionHelper.potionRequirements PotionHelper.potionAmplifiers PotionEffect.duration Potion.setIconIndex Item.setPotionEffect Block.blockHardness Block.blockResistance --- common/forge_at.cfg | 11 +++++++++++ .../net/minecraft/block/Block.java.patch | 13 +++++++++++++ .../net/minecraft/entity/EntityLiving.java.patch | 9 +++++++++ .../minecraft/net/minecraft/item/Item.java.patch | 9 +++++++++ .../net/minecraft/potion/Potion.java.patch | 11 +++++++++++ .../net/minecraft/potion/PotionEffect.java.patch | 9 +++++++++ .../net/minecraft/potion/PotionHelper.java.patch | 15 +++++++++++++++ 7 files changed, 77 insertions(+) create mode 100644 patches/minecraft/net/minecraft/potion/Potion.java.patch create mode 100644 patches/minecraft/net/minecraft/potion/PotionHelper.java.patch diff --git a/common/forge_at.cfg b/common/forge_at.cfg index eba1e5a89..b08619228 100644 --- a/common/forge_at.cfg +++ b/common/forge_at.cfg @@ -41,6 +41,8 @@ protected ri.* #FD:EntityMinecart/* # All private -> protected # Block public apa.(ILaif;)V #MD:Block/(ILnet/minecraft/src/Material;) #Constructor public apa.(IILaif;)V #MD:Block/(IILnet/minecraft/src/Material;) #Constructor +public apa.cB #FD: Block/field_72029_cc #blockResistance +public apa.cA #FD: Block/field_71989_cb #blockHardness # -- MISSING MAPPING public amq.r()Lamq; #MD:Block/func_71912_p #setRequiresSelfNotify public apa.a(Lape;)Lapa; #MD:Block/func_71884_a #setStepSound public apa.b(F)Lapa; #MD:Block/func_71894_b #setResistance @@ -60,6 +62,7 @@ public api.d #FD:BlockLeavesBase/field_72131_c #graphicsLevel public wk.(I)V #MD:Item/(I) #Constructor public wk.e(I)Lwk; #MD:Item/func_77656_e #setMaxDamage public-f wk.h(Lwm;)Llx; #MD:Item/func_77650_f #getIconIndex +public wk.c(Ljava/lang/String;)Lwk; #MD: Item/func_77631_c #setPotionEffect # RailLogic public alc #CL:BlockBaseRailLogic public alc.a()I #MD:BlockBaseRailLogic/func_94505_a #getNAdjacentTiles @@ -93,6 +96,7 @@ public-f aab.A #FD:World/field_72982_D #villageCollectionObj public aab.G #FD:World/field_72993_I #activeChunkSet # EntityLiving public ng.be #FD:EntityLiving/field_70728_aV #experienceValue +public ng.bp #FD: EntityLiving/field_70715_bh #targetTasks # GuiFlatPresets public axm.a(Ljava/lang/String;ILaav;Ljava/util/List;[Laei;)V #MD:GuiFlatPresets/func_82294_a public axm.a(Ljava/lang/String;ILaav;[Laei;)V #MD:GuiFlatPresets/func_82297_a @@ -135,3 +139,10 @@ public bil.a #TextureMap/field_94255_a public bil.b #TextureMap/field_94253_b public bil.c #TextureMap/field_94254_c public bil.d #TextureMap/field_94251_d +#Potion +public mk.b(II)Lmk; #MD: ItemPotion/func_76399_b #setIconIndex +#PotionHelper +public xu.m #FD: PotionHelper/field_77927_l #potionRequirements +public xu.n #FD: PotionHelper/field_77928_m #potionAmplifiers +#PotionEffect +public ml.b #FD: PotionEffect/field_76460_b #duration diff --git a/patches/minecraft/net/minecraft/block/Block.java.patch b/patches/minecraft/net/minecraft/block/Block.java.patch index ce936955c..ad5153209 100644 --- a/patches/minecraft/net/minecraft/block/Block.java.patch +++ b/patches/minecraft/net/minecraft/block/Block.java.patch @@ -53,6 +53,19 @@ /** * used as foreach item, if item.tab = current tab, display it on the screen */ +@@ -253,10 +269,10 @@ + public final int blockID; + + /** Indicates how many hits it takes to break a block. */ +- protected float blockHardness; ++ public float blockHardness; + + /** Indicates the blocks resistance to explosions. */ +- protected float blockResistance; ++ public float blockResistance; + + /** + * set to true when Block's constructor is called through the chain of super()'s. Note: Never used @@ -454,9 +470,10 @@ return this.needsRandomTick; } diff --git a/patches/minecraft/net/minecraft/entity/EntityLiving.java.patch b/patches/minecraft/net/minecraft/entity/EntityLiving.java.patch index 746c3041b..f57d9bf48 100644 --- a/patches/minecraft/net/minecraft/entity/EntityLiving.java.patch +++ b/patches/minecraft/net/minecraft/entity/EntityLiving.java.patch @@ -20,6 +20,15 @@ public abstract class EntityLiving extends Entity { /** +@@ -186,7 +192,7 @@ + private EntityBodyHelper bodyHelper; + private PathNavigate navigator; + public final EntityAITasks tasks; +- protected final EntityAITasks targetTasks; ++ public final EntityAITasks targetTasks; + + /** The active target the Task system uses for tracking */ + private EntityLiving attackTarget; @@ -398,6 +404,7 @@ public void setAttackTarget(EntityLiving par1EntityLiving) { diff --git a/patches/minecraft/net/minecraft/item/Item.java.patch b/patches/minecraft/net/minecraft/item/Item.java.patch index 4dbff738b..de2727fb2 100644 --- a/patches/minecraft/net/minecraft/item/Item.java.patch +++ b/patches/minecraft/net/minecraft/item/Item.java.patch @@ -36,6 +36,15 @@ } itemsList[256 + par1] = this; +@@ -566,7 +572,7 @@ + /** + * Sets the string representing this item's effect on a potion when used as an ingredient. + */ +- protected Item setPotionEffect(String par1Str) ++ public Item setPotionEffect(String par1Str) + { + this.potionEffect = par1Str; + return this; @@ -640,6 +646,10 @@ float f7 = f4 * f5; float f8 = f3 * f5; diff --git a/patches/minecraft/net/minecraft/potion/Potion.java.patch b/patches/minecraft/net/minecraft/potion/Potion.java.patch new file mode 100644 index 000000000..0f1151a3a --- /dev/null +++ b/patches/minecraft/net/minecraft/potion/Potion.java.patch @@ -0,0 +1,11 @@ +--- ../src_base/minecraft/net/minecraft/potion/Potion.java ++++ ../src_work/minecraft/net/minecraft/potion/Potion.java +@@ -104,7 +104,7 @@ + /** + * Sets the index for the icon displayed in the player's inventory when the status is active. + */ +- protected Potion setIconIndex(int par1, int par2) ++ public Potion setIconIndex(int par1, int par2) + { + this.statusIconIndex = par1 + par2 * 8; + return this; diff --git a/patches/minecraft/net/minecraft/potion/PotionEffect.java.patch b/patches/minecraft/net/minecraft/potion/PotionEffect.java.patch index b7d12191d..374c6c06d 100644 --- a/patches/minecraft/net/minecraft/potion/PotionEffect.java.patch +++ b/patches/minecraft/net/minecraft/potion/PotionEffect.java.patch @@ -14,6 +14,15 @@ import net.minecraft.nbt.NBTTagCompound; public class PotionEffect +@@ -11,7 +16,7 @@ + private int potionID; + + /** The duration of the potion effect */ +- private int duration; ++ public int duration; + + /** The amplifier of the potion effect */ + private int amplifier; @@ -24,6 +29,9 @@ @SideOnly(Side.CLIENT) private boolean field_100013_f; diff --git a/patches/minecraft/net/minecraft/potion/PotionHelper.java.patch b/patches/minecraft/net/minecraft/potion/PotionHelper.java.patch new file mode 100644 index 000000000..8b087fc0b --- /dev/null +++ b/patches/minecraft/net/minecraft/potion/PotionHelper.java.patch @@ -0,0 +1,15 @@ +--- ../src_base/minecraft/net/minecraft/potion/PotionHelper.java ++++ ../src_work/minecraft/net/minecraft/potion/PotionHelper.java +@@ -22,10 +22,10 @@ + public static final String glowstoneEffect; + public static final String gunpowderEffect; + public static final String field_82818_l; +- private static final HashMap potionRequirements = new HashMap(); ++ public static final HashMap potionRequirements = new HashMap(); + + /** Potion effect amplifier map */ +- private static final HashMap potionAmplifiers = new HashMap(); ++ public static final HashMap potionAmplifiers = new HashMap(); + private static final HashMap field_77925_n; + + /** An array of possible potion prefix names, as translation IDs. */ From 4de9793ec947ef60bbd75122453da6933572a6d9 Mon Sep 17 00:00:00 2001 From: Mithion Date: Sat, 23 Mar 2013 12:59:06 -0400 Subject: [PATCH 5/8] Enderman Teleport Event New event when an enderman teleports that allows the teleport location to either be modified or completely cancelled. --- .../entity/living/EndermanTeleportEvent.java | 26 ++++++++++++ .../entity/monster/EntityEnderman.java.patch | 41 +++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 common/net/minecraftforge/event/entity/living/EndermanTeleportEvent.java create mode 100644 patches/minecraft/net/minecraft/entity/monster/EntityEnderman.java.patch diff --git a/common/net/minecraftforge/event/entity/living/EndermanTeleportEvent.java b/common/net/minecraftforge/event/entity/living/EndermanTeleportEvent.java new file mode 100644 index 000000000..a2d0688d4 --- /dev/null +++ b/common/net/minecraftforge/event/entity/living/EndermanTeleportEvent.java @@ -0,0 +1,26 @@ +package net.minecraftforge.event.entity.living; + +import net.minecraft.entity.EntityLiving; +import net.minecraftforge.event.Cancelable; +import net.minecraftforge.event.Event; + +/** + * Event for when an Enderman teleports. Can be used to either modify the target position, or cancel the teleport outright. + * @author Mithion + * + */ +@Cancelable +public class EndermanTeleportEvent extends LivingEvent{ + + public double targetX; + public double targetY; + public double targetZ; + + public EndermanTeleportEvent(EntityLiving entity, double targetX, double targetY, double targetZ) + { + super(entity); + this.targetX = targetX; + this.targetY = targetY; + this.targetZ = targetZ; + } +} diff --git a/patches/minecraft/net/minecraft/entity/monster/EntityEnderman.java.patch b/patches/minecraft/net/minecraft/entity/monster/EntityEnderman.java.patch new file mode 100644 index 000000000..c47dee917 --- /dev/null +++ b/patches/minecraft/net/minecraft/entity/monster/EntityEnderman.java.patch @@ -0,0 +1,41 @@ +--- ../src_base/minecraft/net/minecraft/entity/monster/EntityEnderman.java ++++ ../src_work/minecraft/net/minecraft/entity/monster/EntityEnderman.java +@@ -11,6 +11,8 @@ + import net.minecraft.util.MathHelper; + import net.minecraft.util.Vec3; + import net.minecraft.world.World; ++import net.minecraftforge.common.MinecraftForge; ++import net.minecraftforge.event.entity.living.EndermanTeleportEvent; + + public class EntityEnderman extends EntityMob + { +@@ -264,12 +266,17 @@ + */ + protected boolean teleportTo(double par1, double par3, double par5) + { ++ EndermanTeleportEvent event = new EndermanTeleportEvent(this, par1, par3, par5); ++ if (!MinecraftForge.EVENT_BUS.post(event)){ ++ return false; ++ } ++ + double d3 = this.posX; + double d4 = this.posY; + double d5 = this.posZ; +- this.posX = par1; +- this.posY = par3; +- this.posZ = par5; ++ this.posX = event.targetX; ++ this.posY = event.targetY; ++ this.posZ = event.targetZ; + boolean flag = false; + int i = MathHelper.floor_double(this.posX); + int j = MathHelper.floor_double(this.posY); +@@ -296,7 +303,7 @@ + } + + if (flag1) +- { ++ { + this.setPosition(this.posX, this.posY, this.posZ); + + if (this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty() && !this.worldObj.isAnyLiquid(this.boundingBox)) From 81ff5d78961b8bafa107d991dcc9747c4ab28384 Mon Sep 17 00:00:00 2001 From: Mithion Date: Sat, 23 Mar 2013 13:40:13 -0400 Subject: [PATCH 6/8] Enderman attackEntityFrom changed Changed so that if the teleport fails upon being attacked, Endermen will take damage as normal. --- .../minecraft/entity/monster/EntityEnderman.java.patch | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/patches/minecraft/net/minecraft/entity/monster/EntityEnderman.java.patch b/patches/minecraft/net/minecraft/entity/monster/EntityEnderman.java.patch index c47dee917..e597f28b5 100644 --- a/patches/minecraft/net/minecraft/entity/monster/EntityEnderman.java.patch +++ b/patches/minecraft/net/minecraft/entity/monster/EntityEnderman.java.patch @@ -39,3 +39,12 @@ this.setPosition(this.posX, this.posY, this.posZ); if (this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty() && !this.worldObj.isAnyLiquid(this.boundingBox)) +@@ -439,7 +446,7 @@ + } + } + +- return false; ++ return super.attackEntityFrom(par1DamageSource, par2); + } + else + { From e13dff305eae348f5d7ceda90b7062eb0f2ae83c Mon Sep 17 00:00:00 2001 From: Mithion Date: Sat, 23 Mar 2013 14:12:42 -0400 Subject: [PATCH 7/8] Ender Teleport Changes Renamed Ender Teleport Event and added it in to ender pearls. --- ...portEvent.java => EnderTeleportEvent.java} | 6 ++-- .../entity/item/EntityEnderPearl.java.patch | 28 +++++++++++++++++++ .../entity/monster/EntityEnderman.java.patch | 4 +-- 3 files changed, 33 insertions(+), 5 deletions(-) rename common/net/minecraftforge/event/entity/living/{EndermanTeleportEvent.java => EnderTeleportEvent.java} (59%) create mode 100644 patches/minecraft/net/minecraft/entity/item/EntityEnderPearl.java.patch diff --git a/common/net/minecraftforge/event/entity/living/EndermanTeleportEvent.java b/common/net/minecraftforge/event/entity/living/EnderTeleportEvent.java similarity index 59% rename from common/net/minecraftforge/event/entity/living/EndermanTeleportEvent.java rename to common/net/minecraftforge/event/entity/living/EnderTeleportEvent.java index a2d0688d4..7ae23c2a1 100644 --- a/common/net/minecraftforge/event/entity/living/EndermanTeleportEvent.java +++ b/common/net/minecraftforge/event/entity/living/EnderTeleportEvent.java @@ -5,18 +5,18 @@ import net.minecraftforge.event.Cancelable; import net.minecraftforge.event.Event; /** - * Event for when an Enderman teleports. Can be used to either modify the target position, or cancel the teleport outright. + * Event for when an Enderman teleports or an ender pearl is used. Can be used to either modify the target position, or cancel the teleport outright. * @author Mithion * */ @Cancelable -public class EndermanTeleportEvent extends LivingEvent{ +public class EnderTeleportEvent extends LivingEvent{ public double targetX; public double targetY; public double targetZ; - public EndermanTeleportEvent(EntityLiving entity, double targetX, double targetY, double targetZ) + public EnderTeleportEvent(EntityLiving entity, double targetX, double targetY, double targetZ) { super(entity); this.targetX = targetX; diff --git a/patches/minecraft/net/minecraft/entity/item/EntityEnderPearl.java.patch b/patches/minecraft/net/minecraft/entity/item/EntityEnderPearl.java.patch new file mode 100644 index 000000000..836b40c6e --- /dev/null +++ b/patches/minecraft/net/minecraft/entity/item/EntityEnderPearl.java.patch @@ -0,0 +1,28 @@ +--- ../src_base/minecraft/net/minecraft/entity/item/EntityEnderPearl.java ++++ ../src_work/minecraft/net/minecraft/entity/item/EntityEnderPearl.java +@@ -8,6 +8,8 @@ + import net.minecraft.util.DamageSource; + import net.minecraft.util.MovingObjectPosition; + import net.minecraft.world.World; ++import net.minecraftforge.common.MinecraftForge; ++import net.minecraftforge.event.entity.living.EnderTeleportEvent; + + public class EntityEnderPearl extends EntityThrowable + { +@@ -50,9 +52,13 @@ + + if (!entityplayermp.playerNetServerHandler.connectionClosed && entityplayermp.worldObj == this.worldObj) + { +- this.getThrower().setPositionAndUpdate(this.posX, this.posY, this.posZ); +- this.getThrower().fallDistance = 0.0F; +- this.getThrower().attackEntityFrom(DamageSource.fall, 5); ++ EnderTeleportEvent event = new EnderTeleportEvent(entityplayermp, this.posX, this.posY, this.posZ); ++ if (!MinecraftForge.EVENT_BUS.post(event)){ ++ this.getThrower().setPositionAndUpdate(event.targetX, event.targetY, event.targetZ); ++ this.getThrower().fallDistance = 0.0F; ++ this.getThrower().attackEntityFrom(DamageSource.fall, 5); ++ } ++ + } + } + diff --git a/patches/minecraft/net/minecraft/entity/monster/EntityEnderman.java.patch b/patches/minecraft/net/minecraft/entity/monster/EntityEnderman.java.patch index e597f28b5..24ec55cfe 100644 --- a/patches/minecraft/net/minecraft/entity/monster/EntityEnderman.java.patch +++ b/patches/minecraft/net/minecraft/entity/monster/EntityEnderman.java.patch @@ -5,7 +5,7 @@ import net.minecraft.util.Vec3; import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; -+import net.minecraftforge.event.entity.living.EndermanTeleportEvent; ++import net.minecraftforge.event.entity.living.EnderTeleportEvent; public class EntityEnderman extends EntityMob { @@ -13,7 +13,7 @@ */ protected boolean teleportTo(double par1, double par3, double par5) { -+ EndermanTeleportEvent event = new EndermanTeleportEvent(this, par1, par3, par5); ++ EnderTeleportEvent event = new EnderTeleportEvent(this, par1, par3, par5); + if (!MinecraftForge.EVENT_BUS.post(event)){ + return false; + } From b8856e9ed9fa209804fa0d82b9b6bb1d9a070c74 Mon Sep 17 00:00:00 2001 From: Mithion Date: Sat, 23 Mar 2013 14:15:20 -0400 Subject: [PATCH 8/8] quick bugfix in entityenderman reversed boolean check on event result --- .../net/minecraft/entity/monster/EntityEnderman.java.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/minecraft/net/minecraft/entity/monster/EntityEnderman.java.patch b/patches/minecraft/net/minecraft/entity/monster/EntityEnderman.java.patch index 24ec55cfe..4a1e678a2 100644 --- a/patches/minecraft/net/minecraft/entity/monster/EntityEnderman.java.patch +++ b/patches/minecraft/net/minecraft/entity/monster/EntityEnderman.java.patch @@ -14,7 +14,7 @@ protected boolean teleportTo(double par1, double par3, double par5) { + EnderTeleportEvent event = new EnderTeleportEvent(this, par1, par3, par5); -+ if (!MinecraftForge.EVENT_BUS.post(event)){ ++ if (MinecraftForge.EVENT_BUS.post(event)){ + return false; + } +