Items done, <1000 errors whoot!

This commit is contained in:
LexManos 2016-03-01 23:38:31 -08:00
parent ad788880e5
commit 8863aab9e5
40 changed files with 1136 additions and 1348 deletions

View File

@ -19,8 +19,12 @@
return flag;
}
}
@@ -456,6 +463,7 @@
if (itemstack.stackSize == 0)
@@ -453,9 +460,10 @@
{
p_187101_1_.func_184611_a(p_187101_4_, itemstack);
- if (itemstack.stackSize == 0)
+ if (itemstack.stackSize <= 0)
{
p_187101_1_.func_184611_a(p_187101_4_, (ItemStack)null);
+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(p_187101_1_, itemstack, p_187101_4_);

View File

@ -1,5 +1,16 @@
--- ../src-base/minecraft/net/minecraft/item/Item.java
+++ ../src-work/minecraft/net/minecraft/item/Item.java
@@ -58,8 +58,8 @@
public class Item
{
- public static final RegistryNamespaced<ResourceLocation, Item> itemRegistry = new RegistryNamespaced();
- private static final Map<Block, Item> BLOCK_TO_ITEM = Maps.<Block, Item>newHashMap();
+ public static final RegistryNamespaced<ResourceLocation, Item> itemRegistry = net.minecraftforge.fml.common.registry.GameData.getItemRegistry();;
+ private static final Map<Block, Item> BLOCK_TO_ITEM = net.minecraftforge.fml.common.registry.GameData.getBlockItemMap();
private static final IItemPropertyGetter field_185046_b = new IItemPropertyGetter()
{
@SideOnly(Side.CLIENT)
@@ -104,6 +104,9 @@
private Item containerItem;
private String unlocalizedName;
@ -35,7 +46,661 @@
}
protected RayTraceResult getMovingObjectPositionFromPlayer(World worldIn, EntityPlayer playerIn, boolean useLiquids)
@@ -935,6 +940,10 @@
@@ -385,6 +390,10 @@
float f6 = f3 * f4;
float f7 = f2 * f4;
double d3 = 5.0D;
+ if (playerIn instanceof net.minecraft.entity.player.EntityPlayerMP)
+ {
+ d3 = ((net.minecraft.entity.player.EntityPlayerMP)playerIn).theItemInWorldManager.getBlockReachDistance();
+ }
Vec3d vec3d1 = vec3d.addVector((double)f6 * d3, (double)f5 * d3, (double)f7 * d3);
return worldIn.rayTraceBlocks(vec3d, vec3d1, useLiquids, !useLiquids, false);
}
@@ -422,11 +431,642 @@
return false;
}
+ @Deprecated // Use ItemStack sensitive version below.
public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot p_111205_1_)
{
return HashMultimap.<String, AttributeModifier>create();
}
+ /* ======================================== FORGE START =====================================*/
+ /**
+ * ItemStack sensitive version of getItemAttributeModifiers
+ */
+ public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack)
+ {
+ return this.getItemAttributeModifiers(slot);
+ }
+
+ /**
+ * Called when a player drops the item into the world,
+ * returning false from this will prevent the item from
+ * being removed from the players inventory and spawning
+ * in the world
+ *
+ * @param player The player that dropped the item
+ * @param item The item stack, before the item is removed.
+ */
+ public boolean onDroppedByPlayer(ItemStack item, EntityPlayer player)
+ {
+ return true;
+ }
+
+ /**
+ * Allow the item one last chance to modify its name used for the
+ * tool highlight useful for adding something extra that can't be removed
+ * by a user in the displayed name, such as a mode of operation.
+ *
+ * @param item the ItemStack for the item.
+ * @param the name that will be displayed unless it is changed in this method.
+ */
+ public String getHighlightTip( ItemStack item, String displayName )
+ {
+ return displayName;
+ }
+
+ /**
+ * This is called when the item is used, before the block is activated.
+ * @param stack The Item Stack
+ * @param player The Player that used the item
+ * @param world The Current World
+ * @param pos Target position
+ * @param side The side of the target hit
+ * @return Return true to prevent any further processing.
+ */
+ public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
+ {
+ return false;
+ }
+
+ /**
+ * Metadata-sensitive version of getStrVsBlock
+ * @param itemstack The Item Stack
+ * @param state The block state
+ * @return The damage strength
+ */
+ public float getDigSpeed(ItemStack itemstack, net.minecraft.block.state.IBlockState state)
+ {
+ return getStrVsBlock(itemstack, state.getBlock());
+ }
+
+ protected boolean canRepair = true;
+ /**
+ * Called by CraftingManager to determine if an item is reparable.
+ * @return True if reparable
+ */
+ public boolean isRepairable()
+ {
+ return canRepair && isDamageable();
+ }
+
+ /**
+ * Call to disable repair recipes.
+ * @return The current Item instance
+ */
+ public Item setNoRepair()
+ {
+ canRepair = false;
+ return this;
+ }
+
+ /**
+ * Called before a block is broken. Return true to prevent default block harvesting.
+ *
+ * Note: In SMP, this is called on both client and server sides!
+ *
+ * @param itemstack The current ItemStack
+ * @param pos Block's position in world
+ * @param player The Player that is wielding the item
+ * @return True to prevent harvesting, false to continue as normal
+ */
+ public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, EntityPlayer player)
+ {
+ return false;
+ }
+
+ /**
+ * Called each tick while using an item.
+ * @param stack The Item being used
+ * @param player The Player using the item
+ * @param count The amount of time in tick the item has been used for continuously
+ */
+ public void onUsingTick(ItemStack stack, EntityPlayer player, int count)
+ {
+ }
+
+ /**
+ * Called when the player Left Clicks (attacks) an entity.
+ * Processed before damage is done, if return value is true further processing is canceled
+ * and the entity is not attacked.
+ *
+ * @param stack The Item being used
+ * @param player The player that is attacking
+ * @param entity The entity being attacked
+ * @return True to cancel the rest of the interaction.
+ */
+ public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
+ {
+ return false;
+ }
+
+ /**
+ * Player, Render pass, and item usage sensitive version of getIconIndex.
+ *
+ * @param stack The item stack to get the icon for.
+ * @param player The player holding the item
+ * @param useRemaining The ticks remaining for the active item.
+ * @return Null to use default model, or a custom ModelResourceLocation for the stage of use.
+ */
+ @SideOnly(Side.CLIENT)
+ public net.minecraft.client.renderer.block.model.ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining)
+ {
+ return null;
+ }
+
+ /**
+ * ItemStack sensitive version of getContainerItem.
+ * Returns a full ItemStack instance of the result.
+ *
+ * @param itemStack The current ItemStack
+ * @return The resulting ItemStack
+ */
+ public ItemStack getContainerItem(ItemStack itemStack)
+ {
+ if (!hasContainerItem(itemStack))
+ {
+ return null;
+ }
+ return new ItemStack(getContainerItem());
+ }
+
+ /**
+ * ItemStack sensitive version of hasContainerItem
+ * @param stack The current item stack
+ * @return True if this item has a 'container'
+ */
+ public boolean hasContainerItem(ItemStack stack)
+ {
+ return hasContainerItem();
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * Determines if this Item has a special entity for when they are in the world.
+ * Is called when a EntityItem is spawned in the world, if true and Item#createCustomEntity
+ * returns non null, the EntityItem will be destroyed and the new Entity will be added to the world.
+ *
+ * @param stack The current item stack
+ * @return True of the item has a custom entity, If true, Item#createCustomEntity will be called
+ */
+ public boolean hasCustomEntity(ItemStack stack)
+ {
+ return false;
+ }
+
+ /**
+ * This function should return a new entity to replace the dropped item.
+ * Returning null here will not kill the EntityItem and will leave it to function normally.
+ * Called when the item it placed in a world.
+ *
+ * @param world The world object
+ * @param location The EntityItem object, useful for getting the position of the entity
+ * @param itemstack The current item stack
+ * @return A new Entity object to spawn or null
+ */
+ public Entity createEntity(World world, Entity location, ItemStack itemstack)
+ {
+ return null;
+ }
+
+ /**
+ * Called by the default implemetation of EntityItem's onUpdate method, allowing for cleaner
+ * control over the update of the item without having to write a subclass.
+ *
+ * @param entityItem The entity Item
+ * @return Return true to skip any further update code.
+ */
+ public boolean onEntityItemUpdate(net.minecraft.entity.item.EntityItem entityItem)
+ {
+ return false;
+ }
+
+ /**
+ * Gets a list of tabs that items belonging to this class can display on,
+ * combined properly with getSubItems allows for a single item to span
+ * many sub-items across many tabs.
+ *
+ * @return A list of all tabs that this item could possibly be one.
+ */
+ public CreativeTabs[] getCreativeTabs()
+ {
+ return new CreativeTabs[]{ getCreativeTab() };
+ }
+
+ /**
+ * Determines the base experience for a player when they remove this item from a furnace slot.
+ * This number must be between 0 and 1 for it to be valid.
+ * This number will be multiplied by the stack size to get the total experience.
+ *
+ * @param item The item stack the player is picking up.
+ * @return The amount to award for each item.
+ */
+ public float getSmeltingExperience(ItemStack item)
+ {
+ return -1; //-1 will default to the old lookups.
+ }
+
+ /**
+ * Generates the base Random item for a specific instance of the chest gen,
+ * Enchanted books use this to pick a random enchantment.
+ *
+ * @param chest The chest category to generate for
+ * @param rnd World RNG
+ * @param original Original result registered with the chest gen hooks.
+ * @return New values to use as the random item, typically this will be original
+ */
+ public net.minecraft.util.WeightedRandomChestContent getChestGenBase(net.minecraftforge.common.ChestGenHooks chest, Random rnd, net.minecraft.util.WeightedRandomChestContent original)
+ {
+ if (this instanceof ItemEnchantedBook)
+ {
+ return ((ItemEnchantedBook)this).getRandom(rnd,
+ original.minStackSize,
+ original.maxStackSize, original.itemWeight);
+ }
+ return original;
+ }
+
+ /**
+ *
+ * Should this item, when held, allow sneak-clicks to pass through to the underlying block?
+ *
+ * @param world The world
+ * @param pos Block position in world
+ * @param player The Player that is wielding the item
+ * @return
+ */
+ public boolean doesSneakBypassUse(World world, BlockPos pos, EntityPlayer player)
+ {
+ return false;
+ }
+
+ /**
+ * Called to tick armor in the armor slot. Override to do something
+ */
+ public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack){}
+
+ /**
+ * Determines if the specific ItemStack can be placed in the specified armor slot.
+ *
+ * @param stack The ItemStack
+ * @param armorType Armor slot ID: 0: Helmet, 1: Chest, 2: Legs, 3: Boots
+ * @param entity The entity trying to equip the armor
+ * @return True if the given ItemStack can be inserted in the slot
+ */
+ public boolean isValidArmor(ItemStack stack, int armorType, Entity entity)
+ {
+ if (this instanceof ItemArmor)
+ {
+ return ((ItemArmor)this).armorType == armorType;
+ }
+
+ if (armorType == 0)
+ {
+ return this == Item.getItemFromBlock(Blocks.pumpkin) || this == Items.skull;
+ }
+
+ return false;
+ }
+
+ /**
+ * Allow or forbid the specific book/item combination as an anvil enchant
+ *
+ * @param stack The item
+ * @param book The book
+ * @return if the enchantment is allowed
+ */
+ public boolean isBookEnchantable(ItemStack stack, ItemStack book)
+ {
+ return true;
+ }
+
+ /**
+ * Called by RenderBiped and RenderPlayer to determine the armor texture that
+ * should be use for the currently equipped item.
+ * This will only be called on instances of ItemArmor.
+ *
+ * Returning null from this function will use the default value.
+ *
+ * @param stack ItemStack for the equipped armor
+ * @param entity The entity wearing the armor
+ * @param slot The slot the armor is in
+ * @param type The subtype, can be null or "overlay"
+ * @return Path of texture to bind, or null to use default
+ */
+ public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the font renderer used to render tooltips and overlays for this item.
+ * Returning null will use the standard font renderer.
+ *
+ * @param stack The current item stack
+ * @return A instance of FontRenderer or null to use default
+ */
+ @SideOnly(Side.CLIENT)
+ public net.minecraft.client.gui.FontRenderer getFontRenderer(ItemStack stack)
+ {
+ return null;
+ }
+
+ /**
+ * Override this method to have an item handle its own armor rendering.
+ *
+ * @param entityLiving The entity wearing the armor
+ * @param itemStack The itemStack to render the model of
+ * @param armorSlot 0=head, 1=torso, 2=legs, 3=feet
+ * @param _default Original armor model. Will have attributes set.
+ * @return A ModelBiped to render instead of the default
+ */
+ @SideOnly(Side.CLIENT)
+ public net.minecraft.client.model.ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot, net.minecraft.client.model.ModelBiped _default)
+ {
+ return null;
+ }
+
+ /**
+ * Called when a entity tries to play the 'swing' animation.
+ *
+ * @param entityLiving The entity swinging the item.
+ * @param stack The Item stack
+ * @return True to cancel any further processing by EntityLiving
+ */
+ public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack stack)
+ {
+ return false;
+ }
+
+ /**
+ * Called when the client starts rendering the HUD, for whatever item the player currently has as a helmet.
+ * This is where pumpkins would render there overlay.
+ *
+ * @param stack The ItemStack that is equipped
+ * @param player Reference to the current client entity
+ * @param resolution Resolution information about the current viewport and configured GUI Scale
+ * @param partialTicks Partial ticks for the renderer, useful for interpolation
+ */
+ @SideOnly(Side.CLIENT)
+ public void renderHelmetOverlay(ItemStack stack, EntityPlayer player, net.minecraft.client.gui.ScaledResolution resolution, float partialTicks){}
+
+ /**
+ * Return the itemDamage represented by this ItemStack. Defaults to the itemDamage field on ItemStack, but can be overridden here for other sources such as NBT.
+ *
+ * @param stack The itemstack that is damaged
+ * @return the damage value
+ */
+ public int getDamage(ItemStack stack)
+ {
+ return stack.itemDamage;
+ }
+
+ /**
+ * This used to be 'display damage' but its really just 'aux' data in the ItemStack, usually shares the same variable as damage.
+ * @param stack
+ * @return
+ */
+ public int getMetadata(ItemStack stack)
+ {
+ return stack.itemDamage;
+ }
+
+ /**
+ * Determines if the durability bar should be rendered for this item.
+ * Defaults to vanilla stack.isDamaged behavior.
+ * But modders can use this for any data they wish.
+ *
+ * @param stack The current Item Stack
+ * @return True if it should render the 'durability' bar.
+ */
+ public boolean showDurabilityBar(ItemStack stack)
+ {
+ return stack.isItemDamaged();
+ }
+
+ /**
+ * Queries the percentage of the 'Durability' bar that should be drawn.
+ *
+ * @param stack The current ItemStack
+ * @return 1.0 for 100% 0 for 0%
+ */
+ public double getDurabilityForDisplay(ItemStack stack)
+ {
+ return (double)stack.getItemDamage() / (double)stack.getMaxDamage();
+ }
+
+ /**
+ * Return the maxDamage for this ItemStack. Defaults to the maxDamage field in this item,
+ * but can be overridden here for other sources such as NBT.
+ *
+ * @param stack The itemstack that is damaged
+ * @return the damage value
+ */
+ public int getMaxDamage(ItemStack stack)
+ {
+ return getMaxDamage();
+ }
+
+ /**
+ * Return if this itemstack is damaged. Note only called if {@link #isDamageable()} is true.
+ * @param stack the stack
+ * @return if the stack is damaged
+ */
+ public boolean isDamaged(ItemStack stack)
+ {
+ return stack.itemDamage > 0;
+ }
+
+ /**
+ * Set the damage for this itemstack. Note, this method is responsible for zero checking.
+ * @param stack the stack
+ * @param damage the new damage value
+ */
+ public void setDamage(ItemStack stack, int damage)
+ {
+ stack.itemDamage = damage;
+
+ if (stack.itemDamage < 0)
+ {
+ stack.itemDamage = 0;
+ }
+ }
+
+ /**
+ * ItemStack sensitive version of {@link #canHarvestBlock(Block)}
+ * @param state The block trying to harvest
+ * @param stack The itemstack used to harvest the block
+ * @return true if can harvest the block
+ */
+ public boolean canHarvestBlock(IBlockState state, ItemStack stack)
+ {
+ return canHarvestBlock(state);
+ }
+
+ /**
+ * Gets the maximum number of items that this stack should be able to hold.
+ * This is a ItemStack (and thus NBT) sensitive version of Item.getItemStackLimit()
+ *
+ * @param stack The ItemStack
+ * @return THe maximum number this item can be stacked to
+ */
+ public int getItemStackLimit(ItemStack stack)
+ {
+ return this.getItemStackLimit();
+ }
+
+ private java.util.Map<String, Integer> toolClasses = new java.util.HashMap<String, Integer>();
+ /**
+ * Sets or removes the harvest level for the specified tool class.
+ *
+ * @param toolClass Class
+ * @param level Harvest level:
+ * Wood: 0
+ * Stone: 1
+ * Iron: 2
+ * Diamond: 3
+ * Gold: 0
+ */
+ public void setHarvestLevel(String toolClass, int level)
+ {
+ if (level < 0)
+ toolClasses.remove(toolClass);
+ else
+ toolClasses.put(toolClass, level);
+ }
+
+ public java.util.Set<String> getToolClasses(ItemStack stack)
+ {
+ return toolClasses.keySet();
+ }
+
+ /**
+ * Queries the harvest level of this item stack for the specifred tool class,
+ * Returns -1 if this tool is not of the specified type
+ *
+ * @param stack This item stack instance
+ * @param toolClass Tool Class
+ * @return Harvest level, or -1 if not the specified tool type.
+ */
+ public int getHarvestLevel(ItemStack stack, String toolClass)
+ {
+ Integer ret = toolClasses.get(toolClass);
+ return ret == null ? -1 : ret;
+ }
+
+ /**
+ * ItemStack sensitive version of getItemEnchantability
+ *
+ * @param stack The ItemStack
+ * @return the item echantability value
+ */
+ public int getItemEnchantability(ItemStack stack)
+ {
+ return getItemEnchantability();
+ }
+
+ /**
+ * Whether this Item can be used as a payment to activate the vanilla beacon.
+ * @param stack the ItemStack
+ * @return true if this Item can be used
+ */
+ public boolean isBeaconPayment(ItemStack stack)
+ {
+ return this == Items.emerald || this == Items.diamond || this == Items.gold_ingot || this == Items.iron_ingot;
+ }
+
+ /**
+ * Determine if the player switching between these two item stacks
+ * @param oldStack The old stack that was equipped
+ * @param newStack The new stack
+ * @param slotChanged If the current equipped slot was changed,
+ * Vanilla does not play the animation if you switch between two
+ * slots that hold the exact same item.
+ * @return True to play the item change animation
+ */
+ public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
+ {
+ return !ItemStack.areItemStacksEqual(oldStack, newStack);
+ }
+
+ private ResourceLocation registryName = null;
+ /**
+ * Sets a unique name for this Item. This should be used for uniquely identify the instance of the Item.
+ * This is the valid replacement for the atrocious 'getUnlocalizedName().substring(6)' stuff that everyone does.
+ * Unlocalized names have NOTHING to do with unique identifiers. As demonstrated by vanilla blocks and items.
+ *
+ * The supplied name will be prefixed with the currently active mod's modId.
+ * If the supplied name already has a prefix that is different, it will be used and a warning will be logged.
+ *
+ * If a name already exists, or this Item is already registered in a registry, then an IllegalStateException is thrown.
+ *
+ * Returns 'this' to allow for chaining.
+ *
+ * @param name Unique registry name
+ * @return This instance
+ */
+ public final Item setRegistryName(String name)
+ {
+ if (getRegistryName() != null)
+ throw new IllegalStateException("Attempted to set registry name on block with exisiting registry name! New: " + name + " Old: " + getRegistryName());
+ int index = name.lastIndexOf(':');
+ String oldPrefix = index == -1 ? "" : name.substring(0, index);
+ name = index == -1 ? name : name.substring(index + 1);
+ net.minecraftforge.fml.common.ModContainer mc = net.minecraftforge.fml.common.Loader.instance().activeModContainer();
+ String prefix = mc == null ? "minecraft" : mc.getModId();
+ if (!oldPrefix.equals(prefix) && oldPrefix.length() > 0)
+ {
+ net.minecraftforge.fml.common.FMLLog.bigWarning("Dangerous alternative prefix %s for name %s, invalid registry invocation/invalid name?", oldPrefix, name);
+ prefix = oldPrefix;
+ }
+ this.registryName = new ResourceLocation(prefix, name);
+ return this;
+ }
+ public final Item setRegistryName(ResourceLocation name){ return setRegistryName(name.toString()); }
+ public final Item setRegistryName(String modID, String name){ return setRegistryName(modID + ":" + name); }
+
+ /**
+ * A unique identifier for this block, if this block is registered in the game registry it will return that name.
+ * Otherwise it will return the name set in setRegistryName().
+ * If neither are valid null is returned.
+ *
+ * @return Unique identifier or null.
+ */
+ public final String getRegistryName()
+ {
+ if (delegate.getResourceName() != null) return delegate.getResourceName().toString();
+ return registryName != null ? registryName.toString() : null;
+ }
+
+ /**
+ * Called from ItemStack.setItem, will hold extra data for the life of this ItemStack.
+ * Can be retrieved from stack.getCapabilities()
+ * The NBT can be null if this is not called from readNBT or if the item the stack is
+ * changing FROM is different then this item, or the previous item had no capabilities.
+ *
+ * This is called BEFORE the stacks item is set so you can use stack.getItem() to see the OLD item.
+ * Remember that getItem CAN return null.
+ *
+ * @param stack The ItemStack
+ * @param nbt NBT of this item serialized, or null.
+ * @return A holder instance associated with this ItemStack where you can hold capabilities for the life of this item.
+ */
+ public net.minecraftforge.common.capabilities.ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt)
+ {
+ return null;
+ }
+ /* ======================================== FORGE END =====================================*/
+
public static void registerItems()
{
registerItemBlock(Blocks.stone, (new ItemMultiTexture(Blocks.stone, Blocks.stone, new Function<ItemStack, String>()
@@ -935,6 +1575,10 @@
private final float damageVsEntity;
private final int enchantability;
@ -46,3 +711,41 @@
private ToolMaterial(int harvestLevel, int maxUses, float efficiency, float damageVsEntity, int enchantability)
{
this.harvestLevel = harvestLevel;
@@ -969,9 +1613,36 @@
return this.enchantability;
}
+ @Deprecated // Use getRepairItemStack below
public Item getRepairItem()
{
- return this == WOOD ? Item.getItemFromBlock(Blocks.planks) : (this == STONE ? Item.getItemFromBlock(Blocks.cobblestone) : (this == GOLD ? Items.gold_ingot : (this == IRON ? Items.iron_ingot : (this == DIAMOND ? Items.diamond : null))));
+ switch (this)
+ {
+ case WOOD: return Item.getItemFromBlock(Blocks.planks);
+ case STONE: return Item.getItemFromBlock(Blocks.cobblestone);
+ case GOLD: return Items.gold_ingot;
+ case IRON: return Items.iron_ingot;
+ case DIAMOND: return Items.diamond;
+ default: return customCraftingMaterial;
+ }
}
+
+ public ToolMaterial setRepairItem(ItemStack stack)
+ {
+ if (this.repairMaterial != null || customCraftingMaterial != null) throw new RuntimeException("Can not change already set repair material");
+ if (this == WOOD || this == STONE || this == GOLD || this == IRON || this == DIAMOND) throw new RuntimeException("Can not change vanilla tool repair materials");
+ this.repairMaterial = stack;
+ this.customCraftingMaterial = stack.getItem();
+ return this;
+ }
+
+ public ItemStack getRepairItemStack()
+ {
+ if (repairMaterial != null) return repairMaterial;
+ Item ret = this.getRepairItem();
+ if (ret == null) return null;
+ repairMaterial = new ItemStack(ret, 1, net.minecraftforge.oredict.OreDictionary.WILDCARD_VALUE);
+ return repairMaterial;
+ }
}
}

View File

@ -1,6 +1,15 @@
--- ../src-base/minecraft/net/minecraft/item/ItemArmor.java
+++ ../src-work/minecraft/net/minecraft/item/ItemArmor.java
@@ -267,7 +267,15 @@
@@ -235,6 +235,8 @@
private final int[] damageReductionAmountArray;
private final int enchantability;
private final SoundEvent field_185020_j;
+ //Added by forge for custom Armor materials.
+ public Item customCraftingMaterial = null;
private ArmorMaterial(String p_i46796_3_, int p_i46796_4_, int[] p_i46796_5_, int p_i46796_6_, SoundEvent p_i46796_7_)
{
@@ -267,7 +269,15 @@
public Item getRepairItem()
{

View File

@ -1,6 +1,24 @@
--- ../src-base/minecraft/net/minecraft/item/ItemBlock.java
+++ ../src-work/minecraft/net/minecraft/item/ItemBlock.java
@@ -121,7 +121,7 @@
@@ -50,16 +50,8 @@
int i = this.getMetadata(stack.getMetadata());
IBlockState iblockstate1 = this.block.onBlockPlaced(worldIn, pos, hitX, hitY, hitZ, p_180614_9_, i, playerIn);
- if (worldIn.setBlockState(pos, iblockstate1, 11))
+ if (placeBlockAt(stack, playerIn, worldIn, pos, hitX, hitY, hitZ, p_180614_9_, iblockstate1))
{
- iblockstate1 = worldIn.getBlockState(pos);
-
- if (iblockstate1.getBlock() == this.block)
- {
- setTileEntityNBT(worldIn, playerIn, pos, stack);
- this.block.onBlockPlacedBy(worldIn, pos, iblockstate1, playerIn, stack);
- }
-
SoundType soundtype = this.block.func_185467_w();
worldIn.func_184133_a(playerIn, pos, soundtype.func_185841_e(), SoundCategory.BLOCKS, (soundtype.func_185843_a() + 1.0F) / 2.0F, soundtype.func_185847_b() * 0.8F);
--stack.stackSize;
@@ -121,7 +113,7 @@
{
Block block = worldIn.getBlockState(pos).getBlock();
@ -9,7 +27,7 @@
{
side = EnumFacing.UP;
}
@@ -159,4 +159,26 @@
@@ -159,4 +151,26 @@
{
return this.block;
}

View File

@ -0,0 +1,31 @@
--- ../src-base/minecraft/net/minecraft/item/ItemBow.java
+++ ../src-work/minecraft/net/minecraft/item/ItemBow.java
@@ -90,6 +90,10 @@
boolean flag = entityplayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantments.field_185312_x, stack) > 0;
ItemStack itemstack = this.func_185060_a(entityplayer);
+ int i = this.getMaxItemUseDuration(stack) - timeLeft;
+ i = net.minecraftforge.event.ForgeEventFactory.onArrowLoose(stack, worldIn, (EntityPlayer)playerIn, i, itemstack != null || flag);
+ if (i < 0) return;
+
if (itemstack != null || flag)
{
if (itemstack == null)
@@ -97,7 +101,6 @@
itemstack = new ItemStack(Items.arrow);
}
- int i = this.getMaxItemUseDuration(stack) - timeLeft;
float f = func_185059_b(i);
if ((double)f >= 0.1D)
@@ -189,6 +192,9 @@
{
boolean flag = this.func_185060_a(playerIn) != null;
+ ActionResult<ItemStack> ret = net.minecraftforge.event.ForgeEventFactory.onArrowNock(itemStackIn, worldIn, playerIn, p_77659_4_, flag);
+ if (ret != null) return ret;
+
if (!playerIn.capabilities.isCreativeMode && !flag)
{
return !flag ? new ActionResult(EnumActionResult.FAIL, itemStackIn) : new ActionResult(EnumActionResult.PASS, itemStackIn);

View File

@ -0,0 +1,11 @@
--- ../src-base/minecraft/net/minecraft/item/ItemBucket.java
+++ ../src-work/minecraft/net/minecraft/item/ItemBucket.java
@@ -36,6 +36,8 @@
{
boolean flag = this.isFull == Blocks.air;
RayTraceResult raytraceresult = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, flag);
+ ActionResult<ItemStack> ret = net.minecraftforge.event.ForgeEventFactory.onBucketUse(playerIn, worldIn, itemStackIn, raytraceresult);
+ if (ret != null) return ret;
if (raytraceresult == null)
{

View File

@ -0,0 +1,11 @@
--- ../src-base/minecraft/net/minecraft/item/ItemEmptyMap.java
+++ ../src-work/minecraft/net/minecraft/item/ItemEmptyMap.java
@@ -25,7 +25,7 @@
worldIn.setItemData(s, mapdata);
mapdata.scale = 0;
mapdata.calculateMapCenter(playerIn.posX, playerIn.posZ, mapdata.scale);
- mapdata.dimension = (byte)worldIn.provider.func_186058_p().func_186068_a();
+ mapdata.dimension = worldIn.provider.func_186058_p().func_186068_a();
mapdata.field_186210_e = true;
mapdata.markDirty();
--itemStackIn.stackSize;

View File

@ -0,0 +1,11 @@
--- ../src-base/minecraft/net/minecraft/item/ItemFlintAndSteel.java
+++ ../src-work/minecraft/net/minecraft/item/ItemFlintAndSteel.java
@@ -31,7 +31,7 @@
}
else
{
- if (worldIn.getBlockState(pos).func_185904_a() == Material.air)
+ if (worldIn.isAirBlock(pos))
{
worldIn.func_184133_a(playerIn, pos, SoundEvents.field_187649_bu, SoundCategory.BLOCKS, 1.0F, itemRand.nextFloat() * 0.4F + 0.8F);
worldIn.setBlockState(pos, Blocks.fire.getDefaultState(), 11);

View File

@ -0,0 +1,17 @@
--- ../src-base/minecraft/net/minecraft/item/ItemHoe.java
+++ ../src-work/minecraft/net/minecraft/item/ItemHoe.java
@@ -45,10 +45,13 @@
}
else
{
+ int hook = net.minecraftforge.event.ForgeEventFactory.onHoeUse(stack, playerIn, worldIn, pos);
+ if (hook != 0) return hook > 0 ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
+
IBlockState iblockstate = worldIn.getBlockState(pos);
Block block = iblockstate.getBlock();
- if (hitX != EnumFacing.DOWN && worldIn.getBlockState(pos.up()).func_185904_a() == Material.air)
+ if (hitX != EnumFacing.DOWN && worldIn.isAirBlock(pos.up()))
{
if (block == Blocks.grass || block == Blocks.field_185774_da)
{

View File

@ -1,16 +1,18 @@
++++ REJECTED PATCH 1
--- ../src-base/minecraft/net/minecraft/item/ItemLilyPad.java
+++ ../src-work/minecraft/net/minecraft/item/ItemLilyPad.java
@@ -47,6 +47,15 @@
if (iblockstate.getBlock().getMaterial() == Material.water && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0 && worldIn.isAirBlock(blockpos1))
if (iblockstate.func_185904_a() == Material.water && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0 && worldIn.isAirBlock(blockpos1))
{
+ // special case for handling block placement with water lilies
+ net.minecraftforge.common.util.BlockSnapshot blocksnapshot = net.minecraftforge.common.util.BlockSnapshot.getBlockSnapshot(worldIn, blockpos1);
worldIn.setBlockState(blockpos1, Blocks.waterlily.getDefaultState());
+ worldIn.setBlockState(blockpos1, Blocks.waterlily.getDefaultState());
+ if (net.minecraftforge.event.ForgeEventFactory.onPlayerBlockPlace(playerIn, blocksnapshot, net.minecraft.util.EnumFacing.UP).isCanceled())
+ {
+ blocksnapshot.restore(true, false);
+ return itemStackIn;
+ return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
+ }
+
worldIn.setBlockState(blockpos1, Blocks.waterlily.getDefaultState(), 11);
if (!playerIn.capabilities.isCreativeMode)
{
++++ END PATCH

View File

@ -1,10 +1,11 @@
++++ REJECTED PATCH 1
--- ../src-base/minecraft/net/minecraft/item/ItemMap.java
+++ ../src-work/minecraft/net/minecraft/item/ItemMap.java
@@ -57,7 +57,7 @@
mapdata = new MapData(s);
mapdata.scale = 3;
mapdata.calculateMapCenter((double)worldIn.getWorldInfo().getSpawnX(), (double)worldIn.getWorldInfo().getSpawnZ(), mapdata.scale);
- mapdata.dimension = (byte)worldIn.provider.getDimensionId();
+ mapdata.dimension = worldIn.provider.getDimensionId();
- mapdata.dimension = (byte)worldIn.provider.func_186058_p().func_186068_a();
+ mapdata.dimension = worldIn.provider.func_186058_p().func_186068_a();
mapdata.markDirty();
worldIn.setItemData(s, mapdata);
}
++++ END PATCH

View File

@ -1,34 +1,11 @@
--- ../src-base/minecraft/net/minecraft/item/ItemMonsterPlacer.java
+++ ../src-work/minecraft/net/minecraft/item/ItemMonsterPlacer.java
@@ -193,8 +193,31 @@
return new ActionResult(EnumActionResult.PASS, itemStackIn);
}
}
+
+ for (String name : net.minecraftforge.fml.common.registry.EntityRegistry.getEggs().keySet())
+ {
+ ItemStack stack = new ItemStack(itemIn);
+ net.minecraft.nbt.NBTTagCompound nbt = new net.minecraft.nbt.NBTTagCompound();
+ nbt.setString("entity_name", name);
+ stack.setTagCompound(nbt);
+ subItems.add(stack);
+ }
}
@@ -88,7 +88,7 @@
pos = pos.offset(hitX);
double d0 = 0.0D;
+ public static String getEntityName(ItemStack stack)
+ {
+ if (stack.hasTagCompound() && stack.getTagCompound().hasKey("entity_name", 8))
+ return stack.getTagCompound().getString("entity_name");
+ return EntityList.getStringFromID(stack.getMetadata());
+ }
+
+ private static EntityList.EntityEggInfo getEggInfo(ItemStack stack)
+ {
+ if (stack.hasTagCompound() && stack.getTagCompound().hasKey("entity_name", 8))
+ return net.minecraftforge.fml.common.registry.EntityRegistry.getEggs().get(stack.getTagCompound().getString("entity_name"));
+ return (EntityList.EntityEggInfo)EntityList.entityEggs.get(stack.getMetadata());
+ }
+
public static Entity spawnCreature(World worldIn, String entityID, double x, double y, double z)
{
if (entityID != null && EntityList.entityEggs.containsKey(entityID))
- if (hitX == EnumFacing.UP && iblockstate instanceof BlockFence)
+ if (hitX == EnumFacing.UP && iblockstate.getBlock() instanceof BlockFence) //Forge: Fix Vanilla bug comparing state instead of block
{
d0 = 0.5D;
}

View File

@ -9,7 +9,17 @@
{
private Block crops;
private Block soilId;
@@ -33,4 +33,16 @@
@@ -22,7 +22,8 @@
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand side, EnumFacing hitX, float hitY, float hitZ, float p_180614_9_)
{
- if (hitX == EnumFacing.UP && playerIn.canPlayerEdit(pos.offset(hitX), hitX, stack) && worldIn.getBlockState(pos).getBlock() == this.soilId && worldIn.isAirBlock(pos.up()))
+ net.minecraft.block.state.IBlockState state = worldIn.getBlockState(pos);
+ if (hitX == EnumFacing.UP && playerIn.canPlayerEdit(pos.offset(hitX), hitX, stack) && state.getBlock().canSustainPlant(state, worldIn, pos, EnumFacing.UP, this) && worldIn.isAirBlock(pos.up()))
{
worldIn.setBlockState(pos.up(), this.crops.getDefaultState(), 11);
--stack.stackSize;
@@ -33,4 +34,16 @@
return EnumActionResult.FAIL;
}
}

View File

@ -9,7 +9,17 @@
{
private Block crops;
private Block soilBlockID;
@@ -34,4 +34,16 @@
@@ -23,7 +23,8 @@
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand side, EnumFacing hitX, float hitY, float hitZ, float p_180614_9_)
{
- if (hitX == EnumFacing.UP && playerIn.canPlayerEdit(pos.offset(hitX), hitX, stack) && worldIn.getBlockState(pos).getBlock() == this.soilBlockID && worldIn.isAirBlock(pos.up()))
+ net.minecraft.block.state.IBlockState state = worldIn.getBlockState(pos);
+ if (hitX == EnumFacing.UP && playerIn.canPlayerEdit(pos.offset(hitX), hitX, stack) && state.getBlock().canSustainPlant(state, worldIn, pos, EnumFacing.UP, this) && worldIn.isAirBlock(pos.up()))
{
worldIn.setBlockState(pos.up(), this.crops.getDefaultState());
--stack.stackSize;
@@ -34,4 +35,16 @@
return EnumActionResult.FAIL;
}
}

View File

@ -1,13 +1,30 @@
--- ../src-base/minecraft/net/minecraft/item/ItemShears.java
+++ ../src-work/minecraft/net/minecraft/item/ItemShears.java
@@ -36,4 +36,71 @@
@@ -6,6 +6,7 @@
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
+import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -22,7 +23,7 @@
{
stack.damageItem(1, playerIn);
Block block = blockIn.getBlock();
- return blockIn.func_185904_a() != Material.leaves && block != Blocks.web && block != Blocks.tallgrass && block != Blocks.vine && block != Blocks.tripwire && block != Blocks.wool ? super.onBlockDestroyed(stack, worldIn, blockIn, pos, playerIn) : true;
+ return blockIn.func_185904_a() != Material.leaves && block != Blocks.web && block != Blocks.tallgrass && block != Blocks.vine && block != Blocks.tripwire && block != Blocks.wool && !(blockIn instanceof net.minecraftforge.common.IShearable) ? super.onBlockDestroyed(stack, worldIn, blockIn, pos, playerIn) : true;
}
public boolean canHarvestBlock(IBlockState blockIn)
@@ -36,4 +37,71 @@
Block block = block.getBlock();
return block != Blocks.web && block.func_185904_a() != Material.leaves ? (block == Blocks.wool ? 5.0F : super.getStrVsBlock(stack, block)) : 15.0F;
}
+
+
+ @Override
+ public boolean itemInteractionForEntity(ItemStack itemstack, net.minecraft.entity.player.EntityPlayer player, EntityLivingBase entity)
+ public boolean itemInteractionForEntity(ItemStack itemstack, net.minecraft.entity.player.EntityPlayer player, EntityLivingBase entity, EnumHand hand)
+ {
+ if (entity.worldObj.isRemote)
+ {
@ -20,7 +37,7 @@
+ if (target.isShearable(itemstack, entity.worldObj, pos))
+ {
+ java.util.List<ItemStack> drops = target.onSheared(itemstack, entity.worldObj, pos,
+ net.minecraft.enchantment.EnchantmentHelper.getEnchantmentLevel(net.minecraft.enchantment.Enchantment.fortune.effectId, itemstack));
+ net.minecraft.enchantment.EnchantmentHelper.getEnchantmentLevel(net.minecraft.init.Enchantments.field_185308_t, itemstack));
+
+ java.util.Random rand = new java.util.Random();
+ for(ItemStack stack : drops)
@ -51,7 +68,7 @@
+ if (target.isShearable(itemstack, player.worldObj, pos))
+ {
+ java.util.List<ItemStack> drops = target.onSheared(itemstack, player.worldObj, pos,
+ net.minecraft.enchantment.EnchantmentHelper.getEnchantmentLevel(net.minecraft.enchantment.Enchantment.fortune.effectId, itemstack));
+ net.minecraft.enchantment.EnchantmentHelper.getEnchantmentLevel(net.minecraft.init.Enchantments.field_185308_t, itemstack));
+ java.util.Random rand = new java.util.Random();
+
+ for(ItemStack stack : drops)
@ -66,7 +83,7 @@
+ }
+
+ itemstack.damageItem(1, player);
+ player.addStat(net.minecraft.stats.StatList.mineBlockStatArray[Block.getIdFromBlock(block)], 1);
+ player.triggerAchievement(net.minecraft.stats.StatList.func_188055_a(block));
+ }
+ }
+ return false;

View File

@ -0,0 +1,22 @@
--- ../src-base/minecraft/net/minecraft/item/ItemSkull.java
+++ ../src-work/minecraft/net/minecraft/item/ItemSkull.java
@@ -42,13 +42,18 @@
}
else
{
+ if (worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos))
+ {
+ hitX = EnumFacing.UP;
+ pos = pos.down();
+ }
IBlockState iblockstate = worldIn.getBlockState(pos);
Block block = iblockstate.getBlock();
boolean flag = block.isReplaceable(worldIn, pos);
if (!flag)
{
- if (!worldIn.getBlockState(pos).func_185904_a().isSolid())
+ if (!worldIn.getBlockState(pos).func_185904_a().isSolid() && !worldIn.isSideSolid(pos, hitX, true))
{
return EnumActionResult.FAIL;
}

View File

@ -38,7 +38,48 @@
this.stackSize = amount;
this.itemDamage = meta;
@@ -196,7 +202,7 @@
@@ -114,7 +120,7 @@
public ItemStack splitStack(int amount)
{
amount = Math.min(amount, this.stackSize);
- ItemStack itemstack = new ItemStack(this.item, amount, this.itemDamage);
+ ItemStack itemstack = new ItemStack(this.item, amount, this.itemDamage, this.capabilities != null ? this.capabilities.serializeNBT() : null);
if (this.stackTagCompound != null)
{
@@ -127,11 +133,12 @@
public Item getItem()
{
- return this.item;
+ return this.delegate != null ? this.delegate.get() : null;
}
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand side, EnumFacing hitX, float hitY, float hitZ, float p_179546_8_)
{
+ if (!worldIn.isRemote) return net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(this, playerIn, worldIn, pos, hitX, hitY, hitZ, p_179546_8_, side);
EnumActionResult enumactionresult = this.getItem().onItemUse(this, playerIn, worldIn, pos, side, hitX, hitY, hitZ, p_179546_8_);
if (enumactionresult == EnumActionResult.SUCCESS)
@@ -169,12 +176,16 @@
nbt.setTag("tag", this.stackTagCompound);
}
+ if (this.capabilities != null) nbt.setTag("ForgeCaps", this.capabilities.serializeNBT());
+
return nbt;
}
public void readFromNBT(NBTTagCompound nbt)
{
- this.item = Item.getByNameOrId(nbt.getString("id"));
+ this.capNBT = nbt.hasKey("ForgeCaps") ? nbt.getCompoundTag("ForgeCaps") : null;
+ this.setItem(Item.getByNameOrId(nbt.getString("id")));
+ this.capNBT = null;
this.stackSize = nbt.getByte("Count");
this.itemDamage = nbt.getShort("Damage");
@@ -196,7 +207,7 @@
public int getMaxStackSize()
{
@ -47,7 +88,7 @@
}
public boolean isStackable()
@@ -206,7 +212,7 @@
@@ -206,7 +217,7 @@
public boolean isItemStackDamageable()
{
@ -56,6 +97,44 @@
}
public boolean getHasSubtypes()
@@ -216,32 +227,27 @@
public boolean isItemDamaged()
{
- return this.isItemStackDamageable() && this.itemDamage > 0;
+ return this.isItemStackDamageable() && getItem().isDamaged(this);
}
public int getItemDamage()
{
- return this.itemDamage;
+ return getItem().getDamage(this);
}
public int getMetadata()
{
- return this.itemDamage;
+ return getItem().getMetadata(this);
}
public void setItemDamage(int meta)
{
- this.itemDamage = meta;
-
- if (this.itemDamage < 0)
- {
- this.itemDamage = 0;
- }
+ getItem().setDamage(this, meta);
}
public int getMaxDamage()
{
- return this.item == null ? 0 : this.item.getMaxDamage();
+ return this.item == null ? 0 : this.item.getMaxDamage(this);
}
public boolean attemptDamageItem(int amount, Random rand)
@@ -273,8 +279,8 @@
}
}
@ -93,6 +172,15 @@
return list;
}
@@ -869,7 +876,7 @@
}
else
{
- multimap = this.getItem().getItemAttributeModifiers(p_111283_1_);
+ multimap = this.getItem().getAttributeModifiers(p_111283_1_, this);
}
return multimap;
@@ -901,6 +908,18 @@
public void setItem(Item newItem)

View File

@ -12,7 +12,18 @@
{
return;
}
@@ -689,6 +692,7 @@
@@ -670,7 +673,9 @@
if (blockpos.getY() < this.serverController.getBuildLimit() - 1 || enumfacing != EnumFacing.UP && blockpos.getY() < this.serverController.getBuildLimit())
{
- if (this.field_184362_y == null && this.playerEntity.getDistanceSq((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D) < 64.0D && !this.serverController.isBlockProtected(worldserver, blockpos, this.playerEntity) && worldserver.getWorldBorder().contains(blockpos))
+ double dist = playerEntity.theItemInWorldManager.getBlockReachDistance() + 3;
+ dist *= dist;
+ if (this.field_184362_y == null && this.playerEntity.getDistanceSq((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D) < dist && !this.serverController.isBlockProtected(worldserver, blockpos, this.playerEntity) && worldserver.getWorldBorder().contains(blockpos))
{
this.playerEntity.theItemInWorldManager.func_187251_a(this.playerEntity, worldserver, itemstack, enumhand, blockpos, enumfacing, p_184337_1_.func_187026_d(), p_184337_1_.func_187025_e(), p_184337_1_.func_187020_f());
}
@@ -689,6 +694,7 @@
if (itemstack != null && itemstack.stackSize == 0)
{
this.playerEntity.func_184611_a(enumhand, (ItemStack)null);
@ -20,3 +31,38 @@
itemstack = null;
}
}
@@ -703,12 +709,14 @@
if (itemstack != null)
{
+ //TODO: Hook interact event here... we don't know the type of itneration tho...
this.playerEntity.theItemInWorldManager.func_187250_a(this.playerEntity, worldserver, itemstack, enumhand);
itemstack = this.playerEntity.func_184586_b(enumhand);
if (itemstack != null && itemstack.stackSize == 0)
{
this.playerEntity.func_184611_a(enumhand, (ItemStack)null);
+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this.playerEntity, itemstack, enumhand);
itemstack = null;
}
}
@@ -888,7 +896,9 @@
}
else
{
- ITextComponent itextcomponent = new TextComponentTranslation("chat.type.text", new Object[] {this.playerEntity.getDisplayName(), s});
+ ITextComponent itextcomponent = new TextComponentTranslation("chat.type.text", this.playerEntity.getDisplayName(), net.minecraftforge.common.ForgeHooks.newChatWithLinks(s));
+ itextcomponent = net.minecraftforge.common.ForgeHooks.onServerChatEvent(this, s, itextcomponent);
+ if (itextcomponent == null) return;
this.serverController.func_184103_al().sendChatMsgImpl(itextcomponent, false);
}
@@ -1057,7 +1067,7 @@
return;
}
- this.playerEntity = this.serverController.func_184103_al().recreatePlayerEntity(this.playerEntity, 0, false);
+ this.playerEntity = this.serverController.func_184103_al().recreatePlayerEntity(this.playerEntity, playerEntity.dimension, false);
if (this.serverController.isHardcore())
{

View File

@ -1,5 +1,14 @@
--- ../src-base/minecraft/net/minecraft/world/storage/MapData.java
+++ ../src-work/minecraft/net/minecraft/world/storage/MapData.java
@@ -21,7 +21,7 @@
{
public int xCenter;
public int zCenter;
- public byte dimension;
+ public int dimension;
public boolean field_186210_e;
public byte scale;
public byte[] colors = new byte[16384];
@@ -45,7 +45,17 @@
public void readFromNBT(NBTTagCompound nbt)

View File

@ -1,735 +0,0 @@
++++ REJECTED PATCH 1
public class Item
{
- public static final RegistryNamespaced<ResourceLocation, Item> itemRegistry = new RegistryNamespaced();
- private static final Map<Block, Item> BLOCK_TO_ITEM = Maps.<Block, Item>newHashMap();
+ public static final RegistryNamespaced<ResourceLocation, Item> itemRegistry = net.minecraftforge.fml.common.registry.GameData.getItemRegistry();
+ private static final Map<Block, Item> BLOCK_TO_ITEM = net.minecraftforge.fml.common.registry.GameData.getBlockItemMap();
protected static final UUID itemModifierUUID = UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF");
private CreativeTabs tabToDisplayOn;
protected static Random itemRand = new Random();
++++ END PATCH
++++ REJECTED PATCH 6
float f6 = f3 * f4;
float f7 = f2 * f4;
double d3 = 5.0D;
+ if (playerIn instanceof net.minecraft.entity.player.EntityPlayerMP)
+ {
+ d3 = ((net.minecraft.entity.player.EntityPlayerMP)playerIn).theItemInWorldManager.getBlockReachDistance();
+ }
Vec3 vec31 = vec3.addVector((double)f6 * d3, (double)f5 * d3, (double)f7 * d3);
return worldIn.rayTraceBlocks(vec3, vec31, useLiquids, !useLiquids, false);
}
++++ END PATCH
++++ REJECTED PATCH 7
return false;
}
+ @Deprecated // Use ItemStack sensitive version below.
public Multimap<String, AttributeModifier> getItemAttributeModifiers()
{
return HashMultimap.<String, AttributeModifier>create();
}
+ /* ======================================== FORGE START =====================================*/
+ /**
+ * ItemStack sensitive version of getItemAttributeModifiers
+ */
+ public Multimap<String, AttributeModifier> getAttributeModifiers(ItemStack stack)
+ {
+ return this.getItemAttributeModifiers();
+ }
+
+ /**
+ * Called when a player drops the item into the world,
+ * returning false from this will prevent the item from
+ * being removed from the players inventory and spawning
+ * in the world
+ *
+ * @param player The player that dropped the item
+ * @param item The item stack, before the item is removed.
+ */
+ public boolean onDroppedByPlayer(ItemStack item, EntityPlayer player)
+ {
+ return true;
+ }
+
+ /**
+ * Allow the item one last chance to modify its name used for the
+ * tool highlight useful for adding something extra that can't be removed
+ * by a user in the displayed name, such as a mode of operation.
+ *
+ * @param item the ItemStack for the item.
+ * @param the name that will be displayed unless it is changed in this method.
+ */
+ public String getHighlightTip( ItemStack item, String displayName )
+ {
+ return displayName;
+ }
+
+ /**
+ * This is called when the item is used, before the block is activated.
+ * @param stack The Item Stack
+ * @param player The Player that used the item
+ * @param world The Current World
+ * @param pos Target position
+ * @param side The side of the target hit
+ * @return Return true to prevent any further processing.
+ */
+ public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
+ {
+ return false;
+ }
+
+ /**
+ * Metadata-sensitive version of getStrVsBlock
+ * @param itemstack The Item Stack
+ * @param state The block state
+ * @return The damage strength
+ */
+ public float getDigSpeed(ItemStack itemstack, net.minecraft.block.state.IBlockState state)
+ {
+ return getStrVsBlock(itemstack, state.getBlock());
+ }
+
+
+ protected boolean canRepair = true;
+ /**
+ * Called by CraftingManager to determine if an item is reparable.
+ * @return True if reparable
+ */
+ public boolean isRepairable()
+ {
+ return canRepair && isDamageable();
+ }
+
+ /**
+ * Call to disable repair recipes.
+ * @return The current Item instance
+ */
+ public Item setNoRepair()
+ {
+ canRepair = false;
+ return this;
+ }
+
+ /**
+ * Called before a block is broken. Return true to prevent default block harvesting.
+ *
+ * Note: In SMP, this is called on both client and server sides!
+ *
+ * @param itemstack The current ItemStack
+ * @param pos Block's position in world
+ * @param player The Player that is wielding the item
+ * @return True to prevent harvesting, false to continue as normal
+ */
+ public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, EntityPlayer player)
+ {
+ return false;
+ }
+
+ /**
+ * Called each tick while using an item.
+ * @param stack The Item being used
+ * @param player The Player using the item
+ * @param count The amount of time in tick the item has been used for continuously
+ */
+ public void onUsingTick(ItemStack stack, EntityPlayer player, int count)
+ {
+ }
+
+ /**
+ * Called when the player Left Clicks (attacks) an entity.
+ * Processed before damage is done, if return value is true further processing is canceled
+ * and the entity is not attacked.
+ *
+ * @param stack The Item being used
+ * @param player The player that is attacking
+ * @param entity The entity being attacked
+ * @return True to cancel the rest of the interaction.
+ */
+ public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
+ {
+ return false;
+ }
+
+ /**
+ * Player, Render pass, and item usage sensitive version of getIconIndex.
+ *
+ * @param stack The item stack to get the icon for.
+ * @param player The player holding the item
+ * @param useRemaining The ticks remaining for the active item.
+ * @return Null to use default model, or a custom ModelResourceLocation for the stage of use.
+ */
+ @SideOnly(Side.CLIENT)
+ public net.minecraft.client.resources.model.ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining)
+ {
+ return null;
+ }
+
+ /**
+ * ItemStack sensitive version of getContainerItem.
+ * Returns a full ItemStack instance of the result.
+ *
+ * @param itemStack The current ItemStack
+ * @return The resulting ItemStack
+ */
+ public ItemStack getContainerItem(ItemStack itemStack)
+ {
+ if (!hasContainerItem(itemStack))
+ {
+ return null;
+ }
+ return new ItemStack(getContainerItem());
+ }
+
+ /**
+ * ItemStack sensitive version of hasContainerItem
+ * @param stack The current item stack
+ * @return True if this item has a 'container'
+ */
+ public boolean hasContainerItem(ItemStack stack)
+ {
+ return hasContainerItem();
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * Determines if this Item has a special entity for when they are in the world.
+ * Is called when a EntityItem is spawned in the world, if true and Item#createCustomEntity
+ * returns non null, the EntityItem will be destroyed and the new Entity will be added to the world.
+ *
+ * @param stack The current item stack
+ * @return True of the item has a custom entity, If true, Item#createCustomEntity will be called
+ */
+ public boolean hasCustomEntity(ItemStack stack)
+ {
+ return false;
+ }
+
+ /**
+ * This function should return a new entity to replace the dropped item.
+ * Returning null here will not kill the EntityItem and will leave it to function normally.
+ * Called when the item it placed in a world.
+ *
+ * @param world The world object
+ * @param location The EntityItem object, useful for getting the position of the entity
+ * @param itemstack The current item stack
+ * @return A new Entity object to spawn or null
+ */
+ public Entity createEntity(World world, Entity location, ItemStack itemstack)
+ {
+ return null;
+ }
+
+ /**
+ * Called by the default implemetation of EntityItem's onUpdate method, allowing for cleaner
+ * control over the update of the item without having to write a subclass.
+ *
+ * @param entityItem The entity Item
+ * @return Return true to skip any further update code.
+ */
+ public boolean onEntityItemUpdate(net.minecraft.entity.item.EntityItem entityItem)
+ {
+ return false;
+ }
+
+ /**
+ * Gets a list of tabs that items belonging to this class can display on,
+ * combined properly with getSubItems allows for a single item to span
+ * many sub-items across many tabs.
+ *
+ * @return A list of all tabs that this item could possibly be one.
+ */
+ public CreativeTabs[] getCreativeTabs()
+ {
+ return new CreativeTabs[]{ getCreativeTab() };
+ }
+
+ /**
+ * Determines the base experience for a player when they remove this item from a furnace slot.
+ * This number must be between 0 and 1 for it to be valid.
+ * This number will be multiplied by the stack size to get the total experience.
+ *
+ * @param item The item stack the player is picking up.
+ * @return The amount to award for each item.
+ */
+ public float getSmeltingExperience(ItemStack item)
+ {
+ return -1; //-1 will default to the old lookups.
+ }
+
+ /**
+ * Return the correct icon for rendering based on the supplied ItemStack and render pass.
+ *
+ * Defers to {@link #getIconFromDamageForRenderPass(int, int)}
+ * @param stack to render for
+ * @param pass the multi-render pass
+ * @return the icon
+ * /
+ public IIcon getIcon(ItemStack stack, int pass)
+ {
+ return func_77618_c(stack.getMetadata(), pass);
+ }
+ */
+
+ /**
+ * Generates the base Random item for a specific instance of the chest gen,
+ * Enchanted books use this to pick a random enchantment.
+ *
+ * @param chest The chest category to generate for
+ * @param rnd World RNG
+ * @param original Original result registered with the chest gen hooks.
+ * @return New values to use as the random item, typically this will be original
+ */
+ public net.minecraft.util.WeightedRandomChestContent getChestGenBase(net.minecraftforge.common.ChestGenHooks chest, Random rnd, net.minecraft.util.WeightedRandomChestContent original)
+ {
+ if (this instanceof ItemEnchantedBook)
+ {
+ return ((ItemEnchantedBook)this).getRandom(rnd,
+ original.minStackSize,
+ original.maxStackSize, original.itemWeight);
+ }
+ return original;
+ }
+
+ /**
+ *
+ * Should this item, when held, allow sneak-clicks to pass through to the underlying block?
+ *
+ * @param world The world
+ * @param pos Block position in world
+ * @param player The Player that is wielding the item
+ * @return
+ */
+ public boolean doesSneakBypassUse(World world, BlockPos pos, EntityPlayer player)
+ {
+ return false;
+ }
+
+ /**
+ * Called to tick armor in the armor slot. Override to do something
+ */
+ public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack){}
+
+ /**
+ * Determines if the specific ItemStack can be placed in the specified armor slot.
+ *
+ * @param stack The ItemStack
+ * @param armorType Armor slot ID: 0: Helmet, 1: Chest, 2: Legs, 3: Boots
+ * @param entity The entity trying to equip the armor
+ * @return True if the given ItemStack can be inserted in the slot
+ */
+ public boolean isValidArmor(ItemStack stack, int armorType, Entity entity)
+ {
+ if (this instanceof ItemArmor)
+ {
+ return ((ItemArmor)this).armorType == armorType;
+ }
+
+ if (armorType == 0)
+ {
+ return this == Item.getItemFromBlock(Blocks.pumpkin) || this == Items.skull;
+ }
+
+ return false;
+ }
+
+ /**
+ * Allow or forbid the specific book/item combination as an anvil enchant
+ *
+ * @param stack The item
+ * @param book The book
+ * @return if the enchantment is allowed
+ */
+ public boolean isBookEnchantable(ItemStack stack, ItemStack book)
+ {
+ return true;
+ }
+
+ /**
+ * Called by RenderBiped and RenderPlayer to determine the armor texture that
+ * should be use for the currently equipped item.
+ * This will only be called on instances of ItemArmor.
+ *
+ * Returning null from this function will use the default value.
+ *
+ * @param stack ItemStack for the equipped armor
+ * @param entity The entity wearing the armor
+ * @param slot The slot the armor is in
+ * @param type The subtype, can be null or "overlay"
+ * @return Path of texture to bind, or null to use default
+ */
+ public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the font renderer used to render tooltips and overlays for this item.
+ * Returning null will use the standard font renderer.
+ *
+ * @param stack The current item stack
+ * @return A instance of FontRenderer or null to use default
+ */
+ @SideOnly(Side.CLIENT)
+ public net.minecraft.client.gui.FontRenderer getFontRenderer(ItemStack stack)
+ {
+ return null;
+ }
+
+ /**
+ * @deprecated Use 4-argument version.
+ */
+ // remove 1.9
+ @SideOnly(Side.CLIENT)
+ @Deprecated
+ public net.minecraft.client.model.ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot)
+ {
+ return null;
+ }
+
+ /**
+ * Override this method to have an item handle its own armor rendering.
+ *
+ * @param entityLiving The entity wearing the armor
+ * @param itemStack The itemStack to render the model of
+ * @param armorSlot 0=head, 1=torso, 2=legs, 3=feet
+ * @param _default Original armor model. Will have attributes set.
+ * @return A ModelBiped to render instead of the default
+ */
+ @SideOnly(Side.CLIENT)
+ public net.minecraft.client.model.ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot, net.minecraft.client.model.ModelBiped _default)
+ {
+ return getArmorModel(entityLiving, itemStack, armorSlot);
+ }
+
+ /**
+ * Called when a entity tries to play the 'swing' animation.
+ *
+ * @param entityLiving The entity swinging the item.
+ * @param stack The Item stack
+ * @return True to cancel any further processing by EntityLiving
+ */
+ public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack stack)
+ {
+ return false;
+ }
+
+ /**
+ * Called when the client starts rendering the HUD, for whatever item the player currently has as a helmet.
+ * This is where pumpkins would render there overlay.
+ *
+ * @param stack The ItemStack that is equipped
+ * @param player Reference to the current client entity
+ * @param resolution Resolution information about the current viewport and configured GUI Scale
+ * @param partialTicks Partial ticks for the renderer, useful for interpolation
+ */
+ @SideOnly(Side.CLIENT)
+ public void renderHelmetOverlay(ItemStack stack, EntityPlayer player, net.minecraft.client.gui.ScaledResolution resolution, float partialTicks){}
+
+ /**
+ * Return the itemDamage represented by this ItemStack. Defaults to the itemDamage field on ItemStack, but can be overridden here for other sources such as NBT.
+ *
+ * @param stack The itemstack that is damaged
+ * @return the damage value
+ */
+ public int getDamage(ItemStack stack)
+ {
+ return stack.itemDamage;
+ }
+
+ /**
+ * This used to be 'display damage' but its really just 'aux' data in the ItemStack, usually shares the same variable as damage.
+ * @param stack
+ * @return
+ */
+ public int getMetadata(ItemStack stack)
+ {
+ return stack.itemDamage;
+ }
+
+ /**
+ * Determines if the durability bar should be rendered for this item.
+ * Defaults to vanilla stack.isDamaged behavior.
+ * But modders can use this for any data they wish.
+ *
+ * @param stack The current Item Stack
+ * @return True if it should render the 'durability' bar.
+ */
+ public boolean showDurabilityBar(ItemStack stack)
+ {
+ return stack.isItemDamaged();
+ }
+
+ /**
+ * Queries the percentage of the 'Durability' bar that should be drawn.
+ *
+ * @param stack The current ItemStack
+ * @return 1.0 for 100% 0 for 0%
+ */
+ public double getDurabilityForDisplay(ItemStack stack)
+ {
+ return (double)stack.getItemDamage() / (double)stack.getMaxDamage();
+ }
+
+ /**
+ * Return the maxDamage for this ItemStack. Defaults to the maxDamage field in this item,
+ * but can be overridden here for other sources such as NBT.
+ *
+ * @param stack The itemstack that is damaged
+ * @return the damage value
+ */
+ public int getMaxDamage(ItemStack stack)
+ {
+ return getMaxDamage();
+ }
+
+ /**
+ * Return if this itemstack is damaged. Note only called if {@link #isDamageable()} is true.
+ * @param stack the stack
+ * @return if the stack is damaged
+ */
+ public boolean isDamaged(ItemStack stack)
+ {
+ return stack.itemDamage > 0;
+ }
+
+ /**
+ * Set the damage for this itemstack. Note, this method is responsible for zero checking.
+ * @param stack the stack
+ * @param damage the new damage value
+ */
+ public void setDamage(ItemStack stack, int damage)
+ {
+ stack.itemDamage = damage;
+
+ if (stack.itemDamage < 0)
+ {
+ stack.itemDamage = 0;
+ }
+ }
+
+ /**
+ * ItemStack sensitive version of {@link #canHarvestBlock(Block)}
+ * @param par1Block The block trying to harvest
+ * @param itemStack The itemstack used to harvest the block
+ * @return true if can harvest the block
+ */
+ public boolean canHarvestBlock(Block par1Block, ItemStack itemStack)
+ {
+ return canHarvestBlock(par1Block);
+ }
+
+ /**
+ * Gets the maximum number of items that this stack should be able to hold.
+ * This is a ItemStack (and thus NBT) sensitive version of Item.getItemStackLimit()
+ *
+ * @param stack The ItemStack
+ * @return THe maximum number this item can be stacked to
+ */
+ public int getItemStackLimit(ItemStack stack)
+ {
+ return this.getItemStackLimit();
+ }
+
+ private java.util.Map<String, Integer> toolClasses = new java.util.HashMap<String, Integer>();
+ /**
+ * Sets or removes the harvest level for the specified tool class.
+ *
+ * @param toolClass Class
+ * @param level Harvest level:
+ * Wood: 0
+ * Stone: 1
+ * Iron: 2
+ * Diamond: 3
+ * Gold: 0
+ */
+ public void setHarvestLevel(String toolClass, int level)
+ {
+ if (level < 0)
+ toolClasses.remove(toolClass);
+ else
+ toolClasses.put(toolClass, level);
+ }
+
+ public java.util.Set<String> getToolClasses(ItemStack stack)
+ {
+ return toolClasses.keySet();
+ }
+
+ /**
+ * Queries the harvest level of this item stack for the specifred tool class,
+ * Returns -1 if this tool is not of the specified type
+ *
+ * @param stack This item stack instance
+ * @param toolClass Tool Class
+ * @return Harvest level, or -1 if not the specified tool type.
+ */
+ public int getHarvestLevel(ItemStack stack, String toolClass)
+ {
+ Integer ret = toolClasses.get(toolClass);
+ return ret == null ? -1 : ret;
+ }
+
+ /**
+ * ItemStack sensitive version of getItemEnchantability
+ *
+ * @param stack The ItemStack
+ * @return the item echantability value
+ */
+ public int getItemEnchantability(ItemStack stack)
+ {
+ return getItemEnchantability();
+ }
+
+ /**
+ * Whether this Item can be used as a payment to activate the vanilla beacon.
+ * @param stack the ItemStack
+ * @return true if this Item can be used
+ */
+ public boolean isBeaconPayment(ItemStack stack)
+ {
+ return this == Items.emerald || this == Items.diamond || this == Items.gold_ingot || this == Items.iron_ingot;
+ }
+
+
+ /**
+ * Determine if the player switching between these two item stacks
+ * @param oldStack The old stack that was equipped
+ * @param newStack The new stack
+ * @param slotChanged If the current equipped slot was changed,
+ * Vanilla does not play the animation if you switch between two
+ * slots that hold the exact same item.
+ * @return True to play the item change animation
+ */
+ public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
+ {
+ return !ItemStack.areItemStacksEqual(oldStack, newStack);
+ }
+
+
+ private ResourceLocation registryName = null;
+ /**
+ * Sets a unique name for this Item. This should be used for uniquely identify the instance of the Item.
+ * This is the valid replacement for the atrocious 'getUnlocalizedName().substring(6)' stuff that everyone does.
+ * Unlocalized names have NOTHING to do with unique identifiers. As demonstrated by vanilla blocks and items.
+ *
+ * The supplied name will be prefixed with the currently active mod's modId.
+ * If the supplied name already has a prefix that is different, it will be used and a warning will be logged.
+ *
+ * If a name already exists, or this Item is already registered in a registry, then an IllegalStateException is thrown.
+ *
+ * Returns 'this' to allow for chaining.
+ *
+ * @param name Unique registry name
+ * @return This instance
+ */
+ public final Item setRegistryName(String name)
+ {
+ if (getRegistryName() != null)
+ throw new IllegalStateException("Attempted to set registry name on block with exisiting registry name! New: " + name + " Old: " + getRegistryName());
+ int index = name.lastIndexOf(':');
+ String oldPrefix = index == -1 ? "" : name.substring(0, index);
+ name = index == -1 ? name : name.substring(index + 1);
+ net.minecraftforge.fml.common.ModContainer mc = net.minecraftforge.fml.common.Loader.instance().activeModContainer();
+ String prefix = mc == null ? "minecraft" : mc.getModId();
+ if (!oldPrefix.equals(prefix) && oldPrefix.length() > 0)
+ {
+ net.minecraftforge.fml.common.FMLLog.bigWarning("Dangerous alternative prefix %s for name %s, invalid registry invocation/invalid name?", oldPrefix, name);
+ prefix = oldPrefix;
+ }
+ this.registryName = new ResourceLocation(prefix, name);
+ return this;
+ }
+ public final Item setRegistryName(ResourceLocation name){ return setRegistryName(name.toString()); }
+ public final Item setRegistryName(String modID, String name){ return setRegistryName(modID + ":" + name); }
+
+ /**
+ * A unique identifier for this block, if this block is registered in the game registry it will return that name.
+ * Otherwise it will return the name set in setRegistryName().
+ * If neither are valid null is returned.
+ *
+ * @return Unique identifier or null.
+ */
+ public final String getRegistryName()
+ {
+ if (delegate.getResourceName() != null) return delegate.getResourceName().toString();
+ return registryName != null ? registryName.toString() : null;
+ }
+
+ /**
+ * Called from ItemStack.setItem, will hold extra data for the life of this ItemStack.
+ * Can be retrieved from stack.getCapabilities()
+ * The NBT can be null if this is not called from readNBT or if the item the stack is
+ * changing FROM is different then this item, or the previous item had no capabilities.
+ *
+ * This is called BEFORE the stacks item is set so you can use stack.getItem() to see the OLD item.
+ * Remember that getItem CAN return null.
+ *
+ * @param stack The ItemStack
+ * @param nbt NBT of this item serialized, or null.
+ * @return A holder instance associated with this ItemStack where you can hold capabilities for the life of this item.
+ */
+ public net.minecraftforge.common.capabilities.ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt)
+ {
+ return null;
+ }
+ /* ======================================== FORGE END =====================================*/
+
public static void registerItems()
{
registerItemBlock(Blocks.stone, (new ItemMultiTexture(Blocks.stone, Blocks.stone, new Function<ItemStack, String>()
++++ END PATCH
++++ REJECTED PATCH 9
return this.enchantability;
}
+ @Deprecated // Use getRepairItemStack below
public Item getRepairItem()
{
- return this == WOOD ? Item.getItemFromBlock(Blocks.planks) : (this == STONE ? Item.getItemFromBlock(Blocks.cobblestone) : (this == GOLD ? Items.gold_ingot : (this == IRON ? Items.iron_ingot : (this == EMERALD ? Items.diamond : null))));
+ switch (this)
+ {
+ case WOOD: return Item.getItemFromBlock(Blocks.planks);
+ case STONE: return Item.getItemFromBlock(Blocks.cobblestone);
+ case GOLD: return Items.gold_ingot;
+ case IRON: return Items.iron_ingot;
+ case EMERALD: return Items.diamond;
+ default: return customCraftingMaterial;
+ }
}
+
+ public ToolMaterial setRepairItem(ItemStack stack)
+ {
+ if (this.repairMaterial != null || customCraftingMaterial != null) throw new RuntimeException("Can not change already set repair material");
+ if (this == WOOD || this == STONE || this == GOLD || this == IRON || this == EMERALD) throw new RuntimeException("Can not change vanilla tool repair materials");
+ this.repairMaterial = stack;
+ this.customCraftingMaterial = stack.getItem();
+ return this;
+ }
+
+ public ItemStack getRepairItemStack()
+ {
+ if (repairMaterial != null) return repairMaterial;
+ Item ret = this.getRepairItem();
+ if (ret == null) return null;
+ repairMaterial = new ItemStack(ret, 1, net.minecraftforge.oredict.OreDictionary.WILDCARD_VALUE);
+ return repairMaterial;
+ }
}
}
++++ END PATCH

View File

@ -1,31 +0,0 @@
++++ REJECTED PATCH 1
if (list.size() > 0)
{
EntityLivingBase entitylivingbase = (EntityLivingBase)list.get(0);
- int l = entitylivingbase instanceof EntityPlayer ? 1 : 0;
+ int l = 0;// Forge: We fix the indexes. Mojang Stop hard coding this!
int i1 = EntityLiving.getArmorPosition(stack);
ItemStack itemstack = stack.copy();
itemstack.stackSize = 1;
++++ END PATCH
++++ REJECTED PATCH 2
if (itemstack == null)
{
- playerIn.setCurrentItemOrArmor(i, itemStackIn.copy());
+ playerIn.setCurrentItemOrArmor(i + 1, itemStackIn.copy()); //Forge: Vanilla bug fix associated with fixed setCurrentItemOrArmor indexs for players.
itemStackIn.stackSize = 0;
}
++++ END PATCH
++++ REJECTED PATCH 3
private final int[] damageReductionAmountArray;
private final int enchantability;
+ //Added by forge for custom Armor materials.
+ public Item customCraftingMaterial = null;
+
private ArmorMaterial(String name, int maxDamage, int[] reductionAmounts, int enchantability)
{
this.name = name;
++++ END PATCH

View File

@ -1,19 +0,0 @@
++++ REJECTED PATCH 1
int i = this.getMetadata(stack.getMetadata());
IBlockState iblockstate1 = this.block.onBlockPlaced(worldIn, pos, side, hitX, hitY, hitZ, i, playerIn);
- if (worldIn.setBlockState(pos, iblockstate1, 3))
+ if (placeBlockAt(stack, playerIn, worldIn, pos, side, hitX, hitY, hitZ, iblockstate1))
{
- iblockstate1 = worldIn.getBlockState(pos);
-
- if (iblockstate1.getBlock() == this.block)
- {
- setTileEntityNBT(worldIn, playerIn, pos, stack);
- this.block.onBlockPlacedBy(worldIn, pos, iblockstate1, playerIn, stack);
- }
-
worldIn.playSoundEffect((double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), this.block.stepSound.getPlaceSound(), (this.block.stepSound.getVolume() + 1.0F) / 2.0F, this.block.stepSound.getFrequency() * 0.8F);
--stack.stackSize;
}
++++ END PATCH

View File

@ -1,22 +0,0 @@
++++ REJECTED PATCH 1
if (flag || playerIn.inventory.hasItem(Items.arrow))
{
int i = this.getMaxItemUseDuration(stack) - timeLeft;
+ net.minecraftforge.event.entity.player.ArrowLooseEvent event = new net.minecraftforge.event.entity.player.ArrowLooseEvent(playerIn, stack, i);
+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return;
+ i = event.charge;
float f = (float)i / 20.0F;
f = (f * f + f * 2.0F) / 3.0F;
++++ END PATCH
++++ REJECTED PATCH 2
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
+ net.minecraftforge.event.entity.player.ArrowNockEvent event = new net.minecraftforge.event.entity.player.ArrowNockEvent(playerIn, itemStackIn);
+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return event.result;
+
if (playerIn.capabilities.isCreativeMode || playerIn.inventory.hasItem(Items.arrow))
{
playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn));
++++ END PATCH

View File

@ -1,11 +0,0 @@
++++ REJECTED PATCH 1
}
else
{
+ ItemStack ret = net.minecraftforge.event.ForgeEventFactory.onBucketUse(playerIn, worldIn, itemStackIn, movingobjectposition);
+ if (ret != null) return ret;
+
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
{
BlockPos blockpos = movingobjectposition.getBlockPos();
++++ END PATCH

View File

@ -1,10 +0,0 @@
++++ REJECTED PATCH 3
Block block = worldIn.getBlockState(pos).getBlock();
- if (block.getMaterial() != Material.air)
+ if (block.isAir(worldIn, pos))
{
block.setBlockBoundsBasedOnState(worldIn, pos);
++++ END PATCH

View File

@ -1,10 +0,0 @@
++++ REJECTED PATCH 1
worldIn.setItemData(s, mapdata);
mapdata.scale = 0;
mapdata.calculateMapCenter(playerIn.posX, playerIn.posZ, mapdata.scale);
- mapdata.dimension = (byte)worldIn.provider.getDimensionId();
+ mapdata.dimension = worldIn.provider.getDimensionId();
mapdata.markDirty();
--itemStackIn.stackSize;
++++ END PATCH

View File

@ -1,10 +0,0 @@
++++ REJECTED PATCH 1
}
else
{
- if (worldIn.getBlockState(pos).getBlock().getMaterial() == Material.air)
+ if (worldIn.isAirBlock(pos))
{
worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F);
worldIn.setBlockState(pos, Blocks.fire.getDefaultState());
++++ END PATCH

View File

@ -1,16 +0,0 @@
++++ REJECTED PATCH 1
}
else
{
+ int hook = net.minecraftforge.event.ForgeEventFactory.onHoeUse(stack, playerIn, worldIn, pos);
+ if (hook != 0) return hook > 0;
+
IBlockState iblockstate = worldIn.getBlockState(pos);
Block block = iblockstate.getBlock();
- if (side != EnumFacing.DOWN && worldIn.getBlockState(pos.up()).getBlock().getMaterial() == Material.air)
+ if (side != EnumFacing.DOWN && worldIn.isAirBlock(pos.up()))
{
if (block == Blocks.grass)
{
++++ END PATCH

View File

@ -1,88 +0,0 @@
++++ REJECTED PATCH 1
public String getItemStackDisplayName(ItemStack stack)
{
String s = ("" + StatCollector.translateToLocal(this.getUnlocalizedName() + ".name")).trim();
- String s1 = EntityList.getStringFromID(stack.getMetadata());
+ String s1 = ItemMonsterPlacer.getEntityName(stack);
if (s1 != null)
{
++++ END PATCH
++++ REJECTED PATCH 2
@SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack stack, int renderPass)
{
- EntityList.EntityEggInfo entitylist$entityegginfo = (EntityList.EntityEggInfo)EntityList.entityEggs.get(Integer.valueOf(stack.getMetadata()));
+ EntityList.EntityEggInfo entitylist$entityegginfo = ItemMonsterPlacer.getEggInfo(stack);
return entitylist$entityegginfo != null ? (renderPass == 0 ? entitylist$entityegginfo.primaryColor : entitylist$entityegginfo.secondaryColor) : 16777215;
}
++++ END PATCH
++++ REJECTED PATCH 3
if (tileentity instanceof TileEntityMobSpawner)
{
MobSpawnerBaseLogic mobspawnerbaselogic = ((TileEntityMobSpawner)tileentity).getSpawnerBaseLogic();
- mobspawnerbaselogic.setEntityName(EntityList.getStringFromID(stack.getMetadata()));
+ mobspawnerbaselogic.setEntityName(ItemMonsterPlacer.getEntityName(stack));
tileentity.markDirty();
worldIn.markBlockForUpdate(pos);
++++ END PATCH
++++ REJECTED PATCH 4
pos = pos.offset(side);
double d0 = 0.0D;
- if (side == EnumFacing.UP && iblockstate instanceof BlockFence)
+ if (side == EnumFacing.UP && iblockstate.getBlock() instanceof BlockFence) //Forge: Fix Vanilla bug comparing state instead of block
{
d0 = 0.5D;
}
- Entity entity = spawnCreature(worldIn, stack.getMetadata(), (double)pos.getX() + 0.5D, (double)pos.getY() + d0, (double)pos.getZ() + 0.5D);
+ Entity entity = spawnCreature(worldIn, ItemMonsterPlacer.getEntityName(stack), (double)pos.getX() + 0.5D, (double)pos.getY() + d0, (double)pos.getZ() + 0.5D);
if (entity != null)
{
++++ END PATCH
++++ REJECTED PATCH 5
if (worldIn.getBlockState(blockpos).getBlock() instanceof BlockLiquid)
{
- Entity entity = spawnCreature(worldIn, itemStackIn.getMetadata(), (double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D);
+ Entity entity = spawnCreature(worldIn, ItemMonsterPlacer.getEntityName(itemStackIn), (double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D);
if (entity != null)
{
++++ END PATCH
++++ REJECTED PATCH 6
}
}
+ @Deprecated // Use string version below.
public static Entity spawnCreature(World worldIn, int entityID, double x, double y, double z)
{
if (!EntityList.entityEggs.containsKey(Integer.valueOf(entityID)))
{
return null;
}
+ return spawnCreature(worldIn, EntityList.getStringFromID(entityID), x, y, z);
+ }
+
+ public static Entity spawnCreature(World worldIn, String name, double x, double y, double z)
+ {
+ if (!EntityList.stringToClassMapping.containsKey(name))
+ {
+ return null;
+ }
else
{
Entity entity = null;
for (int i = 0; i < 1; ++i)
{
- entity = EntityList.createEntityByID(entityID, worldIn);
+ entity = EntityList.createEntityByName(name, worldIn);
if (entity instanceof EntityLivingBase)
{
++++ END PATCH

View File

@ -1,10 +0,0 @@
++++ REJECTED PATCH 2
{
return false;
}
- else if (worldIn.getBlockState(pos).getBlock() == this.soilId && worldIn.isAirBlock(pos.up()))
+ else if (worldIn.getBlockState(pos).getBlock().canSustainPlant(worldIn, pos, EnumFacing.UP, this) && worldIn.isAirBlock(pos.up()))
{
worldIn.setBlockState(pos.up(), this.crops.getDefaultState());
--stack.stackSize;
++++ END PATCH

View File

@ -1,10 +0,0 @@
++++ REJECTED PATCH 2
{
return false;
}
- else if (worldIn.getBlockState(pos).getBlock() == this.soilBlockID && worldIn.isAirBlock(pos.up()))
+ else if (worldIn.getBlockState(pos).getBlock().canSustainPlant(worldIn, pos, EnumFacing.UP, this) && worldIn.isAirBlock(pos.up()))
{
worldIn.setBlockState(pos.up(), this.crops.getDefaultState());
--stack.stackSize;
++++ END PATCH

View File

@ -1,16 +0,0 @@
++++ REJECTED PATCH 1
public boolean onBlockDestroyed(ItemStack stack, World worldIn, Block blockIn, BlockPos pos, EntityLivingBase playerIn)
{
- if (blockIn.getMaterial() != Material.leaves && blockIn != Blocks.web && blockIn != Blocks.tallgrass && blockIn != Blocks.vine && blockIn != Blocks.tripwire && blockIn != Blocks.wool)
+ if (blockIn.getMaterial() != Material.leaves && blockIn != Blocks.web && blockIn != Blocks.tallgrass && blockIn != Blocks.vine && blockIn != Blocks.tripwire && blockIn != Blocks.wool && !(blockIn instanceof net.minecraftforge.common.IShearable))
{
return super.onBlockDestroyed(stack, worldIn, blockIn, pos, playerIn);
}
else
{
- stack.damageItem(1, playerIn);
return true;
}
}
++++ END PATCH

View File

@ -1,32 +0,0 @@
++++ REJECTED PATCH 1
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
+ if (worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos) && side != EnumFacing.DOWN)
+ {
+ side = EnumFacing.UP;
+ pos = pos.down();
+ }
if (side == EnumFacing.DOWN)
{
return false;
++++ END PATCH
++++ REJECTED PATCH 2
if (!flag)
{
- if (!worldIn.getBlockState(pos).getBlock().getMaterial().isSolid())
+ if (!worldIn.getBlockState(pos).getBlock().getMaterial().isSolid() && !worldIn.isSideSolid(pos, side, true))
{
return false;
}
++++ END PATCH
++++ REJECTED PATCH 3
{
if (!worldIn.isRemote)
{
+ if (!Blocks.skull.canPlaceBlockOnSide(worldIn, pos, side)) return false;
worldIn.setBlockState(pos, Blocks.skull.getDefaultState().withProperty(BlockSkull.FACING, side), 3);
int i = 0;
++++ END PATCH

View File

@ -1,101 +0,0 @@
++++ REJECTED PATCH 4
public ItemStack splitStack(int amount)
{
- ItemStack itemstack = new ItemStack(this.item, amount, this.itemDamage);
+ ItemStack itemstack = new ItemStack(this.item, amount, this.itemDamage, this.capabilities != null ? this.capabilities.serializeNBT() : null);
if (this.stackTagCompound != null)
{
++++ END PATCH
++++ REJECTED PATCH 5
public Item getItem()
{
- return this.item;
+ return this.delegate != null ? this.delegate.get() : null;
}
public boolean onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
+ if (!worldIn.isRemote) return net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(this, playerIn, worldIn, pos, side, hitX, hitY, hitZ);
boolean flag = this.getItem().onItemUse(this, playerIn, worldIn, pos, side, hitX, hitY, hitZ);
if (flag)
++++ END PATCH
++++ REJECTED PATCH 6
nbt.setTag("tag", this.stackTagCompound);
}
+ if (this.capabilities != null) nbt.setTag("ForgeCaps", this.capabilities.serializeNBT());
+
return nbt;
}
public void readFromNBT(NBTTagCompound nbt)
{
+ this.capNBT = nbt.hasKey("ForgeCaps") ? nbt.getCompoundTag("ForgeCaps") : null;
if (nbt.hasKey("id", 8))
{
- this.item = Item.getByNameOrId(nbt.getString("id"));
+ this.setItem(Item.getByNameOrId(nbt.getString("id")));
}
else
{
- this.item = Item.getItemById(nbt.getShort("id"));
+ this.setItem(Item.getItemById(nbt.getShort("id")));
}
+ this.capNBT = null;
this.stackSize = nbt.getByte("Count");
this.itemDamage = nbt.getShort("Damage");
++++ END PATCH
++++ REJECTED PATCH 9
public boolean isItemDamaged()
{
- return this.isItemStackDamageable() && this.itemDamage > 0;
+ return this.isItemStackDamageable() && getItem().isDamaged(this);
}
public int getItemDamage()
{
- return this.itemDamage;
+ return getItem().getDamage(this);
}
public int getMetadata()
{
- return this.itemDamage;
+ return getItem().getMetadata(this);
}
public void setItemDamage(int meta)
{
- this.itemDamage = meta;
-
- if (this.itemDamage < 0)
- {
- this.itemDamage = 0;
- }
+ getItem().setDamage(this, meta);
}
public int getMaxDamage()
{
- return this.item.getMaxDamage();
+ return this.item.getMaxDamage(this);
}
public boolean attemptDamageItem(int amount, Random rand)
++++ END PATCH
++++ REJECTED PATCH 14
}
else
{
- multimap = this.getItem().getItemAttributeModifiers();
+ multimap = this.getItem().getAttributeModifiers(this);
}
return multimap;
++++ END PATCH

View File

@ -1,129 +0,0 @@
++++ REJECTED PATCH 1
this.playerEntity.ridingEntity.updateRiderPosition();
}
+ if (!this.hasMoved) return; //Fixes teleportation kick while riding entities
+
this.serverController.getConfigurationManager().serverUpdateMountedMovingPlayer(this.playerEntity);
if (this.playerEntity.ridingEntity != null)
++++ END PATCH
++++ REJECTED PATCH 2
this.playerEntity.jump();
}
+ if (!this.hasMoved) return; //Fixes "Moved Too Fast" kick when being teleported while moving
+
this.playerEntity.moveEntity(d11, d12, d13);
this.playerEntity.onGround = packetIn.isOnGround();
d11 = d8 - this.playerEntity.posX;
++++ END PATCH
++++ REJECTED PATCH 3
logger.warn(this.playerEntity.getName() + " moved wrongly!");
}
+ if (!this.hasMoved) return; //Fixes "Moved Too Fast" kick when being teleported while moving
+
this.playerEntity.setPositionAndRotation(d8, d9, d10, f1, f2);
this.playerEntity.addMovementStat(this.playerEntity.posX - d0, this.playerEntity.posY - d1, this.playerEntity.posZ - d2);
++++ END PATCH
++++ REJECTED PATCH 4
{
boolean flag2 = worldserver.getCollidingBoundingBoxes(this.playerEntity, this.playerEntity.getEntityBoundingBox().contract((double)f3, (double)f3, (double)f3)).isEmpty();
- if (flag && (flag1 || !flag2) && !this.playerEntity.isPlayerSleeping())
+ if (flag && (flag1 || !flag2) && !this.playerEntity.isPlayerSleeping() && !this.playerEntity.noClip)
{
this.setPlayerLocation(this.lastPosX, this.lastPosY, this.lastPosZ, f1, f2);
return;
++++ END PATCH
++++ REJECTED PATCH 5
this.floatingTickCount = 0;
}
+ if (!this.hasMoved) return; //Fixes "Moved Too Fast" kick when being teleported while moving
+
this.playerEntity.onGround = packetIn.isOnGround();
this.serverController.getConfigurationManager().serverUpdateMountedMovingPlayer(this.playerEntity);
this.playerEntity.handleFalling(this.playerEntity.posY - d7, packetIn.isOnGround());
++++ END PATCH
++++ REJECTED PATCH 7
WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension);
ItemStack itemstack = this.playerEntity.inventory.getCurrentItem();
boolean flag = false;
+ boolean placeResult = true;
BlockPos blockpos = packetIn.getPosition();
EnumFacing enumfacing = EnumFacing.getFront(packetIn.getPlacedBlockDirection());
this.playerEntity.markPlayerActive();
++++ END PATCH
++++ REJECTED PATCH 8
return;
}
+ net.minecraftforge.event.entity.player.PlayerInteractEvent event = net.minecraftforge.event.ForgeEventFactory.onPlayerInteract(playerEntity, net.minecraftforge.event.entity.player.PlayerInteractEvent.Action.RIGHT_CLICK_AIR, worldserver, new BlockPos(0, 0, 0), null, new net.minecraft.util.Vec3(packetIn.getPlacedBlockOffsetX(), packetIn.getPlacedBlockOffsetY(), packetIn.getPlacedBlockOffsetZ()));
+ if (event.useItem != net.minecraftforge.fml.common.eventhandler.Event.Result.DENY)
+ {
this.playerEntity.theItemInWorldManager.tryUseItem(this.playerEntity, worldserver, itemstack);
+ }
}
else if (blockpos.getY() < this.serverController.getBuildLimit() - 1 || enumfacing != EnumFacing.UP && blockpos.getY() < this.serverController.getBuildLimit())
{
- if (this.hasMoved && this.playerEntity.getDistanceSq((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D) < 64.0D && !this.serverController.isBlockProtected(worldserver, blockpos, this.playerEntity) && worldserver.getWorldBorder().contains(blockpos))
+ double dist = playerEntity.theItemInWorldManager.getBlockReachDistance() + 3;
+ dist *= dist;
+ if (this.hasMoved && this.playerEntity.getDistanceSq((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D) < dist && !this.serverController.isBlockProtected(worldserver, blockpos, this.playerEntity) && worldserver.getWorldBorder().contains(blockpos))
{
- this.playerEntity.theItemInWorldManager.activateBlockOrUseItem(this.playerEntity, worldserver, itemstack, blockpos, enumfacing, packetIn.getPlacedBlockOffsetX(), packetIn.getPlacedBlockOffsetY(), packetIn.getPlacedBlockOffsetZ());
+ // record block place result so we can update client itemstack size if place event was cancelled.
+ placeResult = this.playerEntity.theItemInWorldManager.activateBlockOrUseItem(this.playerEntity, worldserver, itemstack, blockpos, enumfacing, packetIn.getPlacedBlockOffsetX(), packetIn.getPlacedBlockOffsetY(), packetIn.getPlacedBlockOffsetZ());
}
flag = true;
++++ END PATCH
++++ REJECTED PATCH 9
this.playerEntity.isChangingQuantityOnly = true;
this.playerEntity.inventory.mainInventory[this.playerEntity.inventory.currentItem] = ItemStack.copyItemStack(this.playerEntity.inventory.mainInventory[this.playerEntity.inventory.currentItem]);
Slot slot = this.playerEntity.openContainer.getSlotFromInventory(this.playerEntity.inventory, this.playerEntity.inventory.currentItem);
+ int windowId = this.playerEntity.openContainer.windowId;
+ if (slot == null) // Forge: Fix 'slotless' inventories not selecting a valid slot to update
+ {
+ slot = this.playerEntity.inventoryContainer.getSlotFromInventory(this.playerEntity.inventory, this.playerEntity.inventory.currentItem);
+ windowId = this.playerEntity.inventoryContainer.windowId;
+ }
this.playerEntity.openContainer.detectAndSendChanges();
this.playerEntity.isChangingQuantityOnly = false;
- if (!ItemStack.areItemStacksEqual(this.playerEntity.inventory.getCurrentItem(), packetIn.getStack()))
+ if (!ItemStack.areItemStacksEqual(this.playerEntity.inventory.getCurrentItem(), packetIn.getStack()) || !placeResult) // force client itemstack update if place event was cancelled
{
- this.sendPacket(new S2FPacketSetSlot(this.playerEntity.openContainer.windowId, slot.slotNumber, this.playerEntity.inventory.getCurrentItem()));
+ this.sendPacket(new S2FPacketSetSlot(windowId, slot.slotNumber, this.playerEntity.inventory.getCurrentItem()));
}
}
}
++++ END PATCH
++++ REJECTED PATCH 10
}
else
{
- IChatComponent ichatcomponent = new ChatComponentTranslation("chat.type.text", new Object[] {this.playerEntity.getDisplayName(), s});
- this.serverController.getConfigurationManager().sendChatMsgImpl(ichatcomponent, false);
+ ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("chat.type.text", this.playerEntity.getDisplayName(), net.minecraftforge.common.ForgeHooks.newChatWithLinks(s));
+ IChatComponent chat = net.minecraftforge.common.ForgeHooks.onServerChatEvent(this, s, chatcomponenttranslation1);
+ if (chat == null) return;
+ this.serverController.getConfigurationManager().sendChatMsgImpl(chat, false);
}
this.chatSpamThresholdCount += 20;
++++ END PATCH
++++ REJECTED PATCH 11
return;
}
- this.playerEntity = this.serverController.getConfigurationManager().recreatePlayerEntity(this.playerEntity, 0, false);
+ this.playerEntity = this.serverController.getConfigurationManager().recreatePlayerEntity(this.playerEntity, playerEntity.dimension, false);
}
break;
++++ END PATCH

View File

@ -1,10 +0,0 @@
++++ REJECTED PATCH 1
public void writePacketData(PacketBuffer buf) throws IOException
{
- buf.writeString(GSON.toJson((Object)this.response));
+ buf.writeString(this.response.getJson());
}
public void processPacket(INetHandlerStatusClient handler)
++++ END PATCH

View File

@ -52,9 +52,15 @@ import net.minecraft.stats.StatList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityNote;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.WeightedRandom;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.event.ClickEvent;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.world.WorldSettings;
@ -540,14 +546,14 @@ public class ForgeHooks
}
@SuppressWarnings("deprecation")
public static ChatComponentTranslation onServerChatEvent(NetHandlerPlayServer net, String raw, ChatComponentTranslation comp)
public static ITextComponent onServerChatEvent(NetHandlerPlayServer net, String raw, ITextComponent comp)
{
ServerChatEvent event = new ServerChatEvent(net.playerEntity, raw, comp);
if (MinecraftForge.EVENT_BUS.post(event))
{
return null;
}
return event.component;
return event.getComponent();
}
@ -614,7 +620,7 @@ public class ForgeHooks
ClickEvent click = new ClickEvent(ClickEvent.Action.OPEN_URL, url);
link.getChatStyle().setChatClickEvent(click);
link.getChatStyle().setUnderlined(true);
link.getChatStyle().setColor(EnumChatFormatting.BLUE);
link.getChatStyle().setColor(TextFormatting.BLUE);
if (ichat == null)
ichat = link;
else
@ -691,7 +697,7 @@ public class ForgeHooks
return event.isCanceled() ? -1 : event.getExpToDrop();
}
public static boolean onPlaceItemIntoWorld(ItemStack itemstack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
public static EnumActionResult onPlaceItemIntoWorld(ItemStack itemstack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand)
{
// handle all placement events here
int meta = itemstack.getItemDamage();
@ -707,10 +713,10 @@ public class ForgeHooks
world.captureBlockSnapshots = true;
}
boolean flag = itemstack.getItem().onItemUse(itemstack, player, world, pos, side, hitX, hitY, hitZ);
EnumActionResult ret = itemstack.getItem().onItemUse(itemstack, player, world, pos, hand, side, hitX, hitY, hitZ);
world.captureBlockSnapshots = false;
if (flag)
if (ret == EnumActionResult.SUCCESS)
{
// save new item data
int newMeta = itemstack.getItemDamage();
@ -743,7 +749,7 @@ public class ForgeHooks
if (placeEvent != null && (placeEvent.isCanceled()))
{
flag = false; // cancel placement
ret = EnumActionResult.FAIL; // cancel placement
// revert back all captured blocks
for (net.minecraftforge.common.util.BlockSnapshot blocksnapshot : blockSnapshots)
{
@ -774,12 +780,12 @@ public class ForgeHooks
world.markAndNotifyBlock(snap.pos, null, oldBlock, newBlock, updateFlag);
}
player.addStat(StatList.objectUseStats[Item.getIdFromItem(itemstack.getItem())], 1);
player.triggerAchievement(StatList.func_188060_a(itemstack.getItem()));
}
}
world.capturedBlockSnapshots.clear();
return flag;
return ret;
}
public static boolean onAnvilChange(ContainerRepair container, ItemStack left, ItemStack right, IInventory outputSlot, String name, int baseCost)

View File

@ -16,10 +16,13 @@ import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayer.EnumStatus;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
@ -52,6 +55,8 @@ import net.minecraftforge.event.entity.living.LivingPackSizeEvent;
import net.minecraftforge.event.entity.living.LivingSpawnEvent;
import net.minecraftforge.event.entity.living.LivingSpawnEvent.AllowDespawn;
import net.minecraftforge.event.entity.living.ZombieEvent.SummonAidEvent;
import net.minecraftforge.event.entity.player.ArrowLooseEvent;
import net.minecraftforge.event.entity.player.ArrowNockEvent;
import net.minecraftforge.event.entity.player.BonemealEvent;
import net.minecraftforge.event.entity.player.EntityInteractEvent;
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
@ -297,23 +302,23 @@ public class ForgeEventFactory
return 0;
}
public static ItemStack onBucketUse(EntityPlayer player, World world, ItemStack stack, RayTraceResult target)
public static ActionResult<ItemStack> onBucketUse(EntityPlayer player, World world, ItemStack stack, RayTraceResult target)
{
FillBucketEvent event = new FillBucketEvent(player, stack, world, target);
if (MinecraftForge.EVENT_BUS.post(event)) return stack;
if (MinecraftForge.EVENT_BUS.post(event)) return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
if (event.getResult() == Result.ALLOW)
{
if (player.capabilities.isCreativeMode)
return stack;
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
if (--stack.stackSize <= 0)
return event.getFilledBucket();
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, event.getFilledBucket());
if (!player.inventory.addItemStackToInventory(event.getFilledBucket()))
player.dropPlayerItemWithRandomChoice(event.getFilledBucket(), false);
return stack;
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
}
return null;
}
@ -521,4 +526,20 @@ public class ForgeEventFactory
return canContinueSleep == Result.ALLOW;
}
public static ActionResult<ItemStack> onArrowNock(ItemStack item, World world, EntityPlayer player, EnumHand hand, boolean hasAmmo)
{
ArrowNockEvent event = new ArrowNockEvent(player, item, hand, world, hasAmmo);
if (MinecraftForge.EVENT_BUS.post(event))
return new ActionResult<ItemStack>(EnumActionResult.FAIL, item);
return event.getAction();
}
public static int onArrowLoose(ItemStack stack, World world, EntityPlayer player, int charge, boolean hasAmmo)
{
ArrowLooseEvent event = new ArrowLooseEvent(player, stack, world, charge, hasAmmo);
if (MinecraftForge.EVENT_BUS.post(event))
return -1;
return event.getCharge();
}
}

View File

@ -3,6 +3,7 @@ package net.minecraftforge.event.entity.player;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
/**
* ArrowLooseEvent is fired when a player stops using a bow.<br>
@ -22,13 +23,22 @@ import net.minecraft.item.ItemStack;
@Cancelable
public class ArrowLooseEvent extends PlayerEvent
{
public final ItemStack bow;
public int charge;
public ArrowLooseEvent(EntityPlayer player, ItemStack bow, int charge)
private final ItemStack bow;
private final World world;
private final boolean hasAmmo;
private int charge;
public ArrowLooseEvent(EntityPlayer player, ItemStack bow, World world, int charge, boolean hasAmmo)
{
super(player);
this.bow = bow;
this.world = world;
this.charge = charge;
this.hasAmmo = hasAmmo;
}
public ItemStack getBow() { return this.bow; }
public boolean hasAmmo() { return this.hasAmmo; }
public int getCharge() { return this.charge; }
public void setCharge(int charge) { this.charge = charge; }
}

View File

@ -1,31 +1,45 @@
package net.minecraftforge.event.entity.player;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;
/**
* ArrowNockEvent is fired when a player begins using a bow.<br>
* This event is fired whenever a player begins using a bow in
* ItemBow#onItemRightClick(ItemStack, World, EntityPlayer).<br>
* <br>
* {@link #result} contains the resulting ItemStack due to the use of the bow. <br>
* <br>
* This event is {@link Cancelable}.<br>
* If this event is canceled, the player does not begin using the bow.<br>
* <br>
* This event does not have a result. {@link HasResult}<br>
* <br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
**/
@Cancelable
public class ArrowNockEvent extends PlayerEvent
{
public ItemStack result;
public ArrowNockEvent(EntityPlayer player, ItemStack result)
private final ItemStack bow;
private final EnumHand hand;
private final World world;
private final boolean hasAmmo;
private ActionResult<ItemStack> action;
public ArrowNockEvent(EntityPlayer player, ItemStack item, EnumHand hand, World world, boolean hasAmmo)
{
super(player);
this.result = result;
this.bow = item;
this.hand = hand;
this.world = world;
this.hasAmmo = hasAmmo;
}
public ItemStack getBow() { return this.bow; }
public EnumHand getHand() { return this.hand; }
public boolean hasAmmo() { return this.hasAmmo; }
public ActionResult<ItemStack> getAction()
{
return this.action;
}
public void setAction(ActionResult<ItemStack> action)
{
this.action = action;
}
}