From 9a09ff68aac457d4297355bd9cb30286af92ec05 Mon Sep 17 00:00:00 2001 From: Ben Staddon Date: Thu, 15 Jun 2017 19:26:14 +0100 Subject: [PATCH] Remove some deprecated methods and clean up --- .../multiplayer/PlayerControllerMP.java.patch | 4 +- .../entity/item/EntityItem.java.patch | 2 +- .../entity/player/EntityPlayer.java.patch | 2 +- .../net/minecraft/item/ItemDye.java.patch | 13 +-- .../net/minecraft/item/ItemStack.java.patch | 2 +- .../network/NetHandlerPlayServer.java.patch | 2 +- .../PlayerInteractionManager.java.patch | 2 +- .../client/gui/ForgeGuiFactory.java | 6 -- .../client/model/pipeline/BlockInfo.java | 2 - .../minecraftforge/common/DungeonHooks.java | 8 -- .../net/minecraftforge/common/ForgeHooks.java | 51 ++---------- .../common/util/Java6Utils.java | 49 ----------- .../event/AttachCapabilitiesEvent.java | 31 +------ .../event/ForgeEventFactory.java | 21 ++--- .../event/LootTableLoadEvent.java | 8 -- .../event/entity/player/BonemealEvent.java | 9 -- .../entity/player/PlayerInteractEvent.java | 8 -- .../event/world/BlockEvent.java | 15 ---- .../minecraftforge/fluids/BlockFluidBase.java | 27 ------ .../fml/client/DefaultGuiFactory.java | 32 ++++--- .../fml/client/FMLConfigGuiFactory.java | 40 --------- .../minecraftforge/fml/client/GuiModList.java | 19 +---- .../fml/client/IModGuiFactory.java | 83 ------------------- .../fml/common/asm/FMLSanityChecker.java | 3 +- .../fml/common/discovery/JarDiscoverer.java | 3 +- .../fml/relauncher/ReflectionHelper.java | 23 ----- .../fml/server/FMLServerHandler.java | 3 +- .../debug/TestCapabilityMod.java | 21 ----- 28 files changed, 45 insertions(+), 444 deletions(-) delete mode 100644 src/main/java/net/minecraftforge/common/util/Java6Utils.java diff --git a/patches/minecraft/net/minecraft/client/multiplayer/PlayerControllerMP.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/PlayerControllerMP.java.patch index f83e117ab..d1c5e7d04 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/PlayerControllerMP.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/PlayerControllerMP.java.patch @@ -171,7 +171,7 @@ } else { -+ EnumActionResult cancelResult = net.minecraftforge.common.ForgeHooks.onItemRightClickAction(p_187101_1_, p_187101_3_); ++ EnumActionResult cancelResult = net.minecraftforge.common.ForgeHooks.onItemRightClick(p_187101_1_, p_187101_3_); + if (cancelResult != null) return cancelResult; int i = itemstack.func_190916_E(); ActionResult actionresult = itemstack.func_77957_a(p_187101_2_, p_187101_1_, p_187101_3_); @@ -192,7 +192,7 @@ Vec3d vec3d = new Vec3d(p_187102_3_.field_72307_f.field_72450_a - p_187102_2_.field_70165_t, p_187102_3_.field_72307_f.field_72448_b - p_187102_2_.field_70163_u, p_187102_3_.field_72307_f.field_72449_c - p_187102_2_.field_70161_v); this.field_78774_b.func_147297_a(new CPacketUseEntity(p_187102_2_, p_187102_4_, vec3d)); + if (this.field_78779_k == GameType.SPECTATOR) return EnumActionResult.PASS; // don't fire for spectators to match non-specific EntityInteract -+ EnumActionResult cancelResult = net.minecraftforge.common.ForgeHooks.onInteractEntityAtAction(p_187102_1_, p_187102_2_, p_187102_3_, p_187102_4_); ++ EnumActionResult cancelResult = net.minecraftforge.common.ForgeHooks.onInteractEntityAt(p_187102_1_, p_187102_2_, p_187102_3_, p_187102_4_); + if(cancelResult != null) return cancelResult; return this.field_78779_k == GameType.SPECTATOR ? EnumActionResult.PASS : p_187102_2_.func_184199_a(p_187102_1_, vec3d, p_187102_4_); } diff --git a/patches/minecraft/net/minecraft/entity/item/EntityItem.java.patch b/patches/minecraft/net/minecraft/entity/item/EntityItem.java.patch index f39f20e30..75fa7b08e 100644 --- a/patches/minecraft/net/minecraft/entity/item/EntityItem.java.patch +++ b/patches/minecraft/net/minecraft/entity/item/EntityItem.java.patch @@ -90,7 +90,7 @@ int i = itemstack.func_190916_E(); - if (this.field_145804_b == 0 && (this.field_145802_g == null || 6000 - this.field_70292_b <= 200 || this.field_145802_g.equals(p_70100_1_.func_70005_c_())) && p_70100_1_.field_71071_by.func_70441_a(itemstack)) -+ int hook = net.minecraftforge.event.ForgeEventFactory.onItemPickup(this, p_70100_1_, itemstack); ++ int hook = net.minecraftforge.event.ForgeEventFactory.onItemPickup(this, p_70100_1_); + if (hook < 0) return; + + if (this.field_145804_b <= 0 && (this.field_145802_g == null || lifespan - this.field_70292_b <= 200 || this.field_145802_g.equals(p_70100_1_.func_70005_c_())) && (hook == 1 || i <= 0 || p_70100_1_.field_71071_by.func_70441_a(itemstack))) diff --git a/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch b/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch index c517a7a41..267c037be 100644 --- a/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch +++ b/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch @@ -228,7 +228,7 @@ } else { -+ EnumActionResult cancelResult = net.minecraftforge.common.ForgeHooks.onInteractEntityAction(this, p_190775_1_, p_190775_2_); ++ EnumActionResult cancelResult = net.minecraftforge.common.ForgeHooks.onInteractEntity(this, p_190775_1_, p_190775_2_); + if (cancelResult != null) return cancelResult; ItemStack itemstack = this.func_184586_b(p_190775_2_); ItemStack itemstack1 = itemstack.func_190926_b() ? ItemStack.field_190927_a : itemstack.func_77946_l(); diff --git a/patches/minecraft/net/minecraft/item/ItemDye.java.patch b/patches/minecraft/net/minecraft/item/ItemDye.java.patch index bb12aee52..d663936c7 100644 --- a/patches/minecraft/net/minecraft/item/ItemDye.java.patch +++ b/patches/minecraft/net/minecraft/item/ItemDye.java.patch @@ -18,7 +18,7 @@ p_180614_2_.func_180501_a(p_180614_3_, iblockstate1, 10); if (!p_180614_1_.field_71075_bZ.field_75098_d) -@@ -99,8 +99,27 @@ +@@ -99,8 +99,18 @@ public static boolean func_179234_a(ItemStack p_179234_0_, World p_179234_1_, BlockPos p_179234_2_) { @@ -27,15 +27,6 @@ + return false; + } + -+ /** -+ * @deprecated Use {@link #applyBonemeal(ItemStack, World, BlockPos, EntityPlayer, EnumHand)} instead. -+ */ -+ @Deprecated -+ public static boolean applyBonemeal(ItemStack p_179234_0_, World p_179234_1_, BlockPos p_179234_2_, EntityPlayer player) -+ { -+ return applyBonemeal(p_179234_0_, p_179234_1_, p_179234_2_, player, null); -+ } -+ + public static boolean applyBonemeal(ItemStack p_179234_0_, World p_179234_1_, BlockPos p_179234_2_, EntityPlayer player, @javax.annotation.Nullable EnumHand hand) + { IBlockState iblockstate = p_179234_1_.func_180495_p(p_179234_2_); @@ -46,7 +37,7 @@ if (iblockstate.func_177230_c() instanceof IGrowable) { IGrowable igrowable = (IGrowable)iblockstate.func_177230_c(); -@@ -144,6 +163,16 @@ +@@ -144,6 +154,16 @@ p_180617_0_.func_175688_a(EnumParticleTypes.VILLAGER_HAPPY, (double)((float)p_180617_1_.func_177958_n() + field_77697_d.nextFloat()), (double)p_180617_1_.func_177956_o() + (double)field_77697_d.nextFloat() * iblockstate.func_185900_c(p_180617_0_, p_180617_1_).field_72337_e, (double)((float)p_180617_1_.func_177952_p() + field_77697_d.nextFloat()), d0, d1, d2); } } diff --git a/patches/minecraft/net/minecraft/item/ItemStack.java.patch b/patches/minecraft/net/minecraft/item/ItemStack.java.patch index 933386e65..73744eaf7 100644 --- a/patches/minecraft/net/minecraft/item/ItemStack.java.patch +++ b/patches/minecraft/net/minecraft/item/ItemStack.java.patch @@ -294,7 +294,7 @@ + { + this.delegate = item.delegate; + net.minecraftforge.common.capabilities.ICapabilityProvider provider = item.initCapabilities(this, this.capNBT); -+ this.capabilities = net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(item, this, provider); ++ this.capabilities = net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(this, provider); + if (this.capNBT != null && this.capabilities != null) this.capabilities.deserializeNBT(this.capNBT); + } + } diff --git a/patches/minecraft/net/minecraft/network/NetHandlerPlayServer.java.patch b/patches/minecraft/net/minecraft/network/NetHandlerPlayServer.java.patch index 0ed9546f8..6874b7ab6 100644 --- a/patches/minecraft/net/minecraft/network/NetHandlerPlayServer.java.patch +++ b/patches/minecraft/net/minecraft/network/NetHandlerPlayServer.java.patch @@ -38,7 +38,7 @@ else if (p_147340_1_.func_149565_c() == CPacketUseEntity.Action.INTERACT_AT) { EnumHand enumhand1 = p_147340_1_.func_186994_b(); -+ if(net.minecraftforge.common.ForgeHooks.onInteractEntityAtAction(field_147369_b, entity, p_147340_1_.func_179712_b(), enumhand1) != null) return; ++ if(net.minecraftforge.common.ForgeHooks.onInteractEntityAt(field_147369_b, entity, p_147340_1_.func_179712_b(), enumhand1) != null) return; entity.func_184199_a(this.field_147369_b, p_147340_1_.func_179712_b(), enumhand1); } else if (p_147340_1_.func_149565_c() == CPacketUseEntity.Action.ATTACK) diff --git a/patches/minecraft/net/minecraft/server/management/PlayerInteractionManager.java.patch b/patches/minecraft/net/minecraft/server/management/PlayerInteractionManager.java.patch index dfafa7ecc..27b55ee59 100644 --- a/patches/minecraft/net/minecraft/server/management/PlayerInteractionManager.java.patch +++ b/patches/minecraft/net/minecraft/server/management/PlayerInteractionManager.java.patch @@ -204,7 +204,7 @@ } else { -+ EnumActionResult cancelResult = net.minecraftforge.common.ForgeHooks.onItemRightClickAction(p_187250_1_, p_187250_4_); ++ EnumActionResult cancelResult = net.minecraftforge.common.ForgeHooks.onItemRightClick(p_187250_1_, p_187250_4_); + if (cancelResult != null) return cancelResult; int i = p_187250_3_.func_190916_E(); int j = p_187250_3_.func_77960_j(); diff --git a/src/main/java/net/minecraftforge/client/gui/ForgeGuiFactory.java b/src/main/java/net/minecraftforge/client/gui/ForgeGuiFactory.java index 99782cb04..aa6a7a576 100644 --- a/src/main/java/net/minecraftforge/client/gui/ForgeGuiFactory.java +++ b/src/main/java/net/minecraftforge/client/gui/ForgeGuiFactory.java @@ -104,16 +104,10 @@ public class ForgeGuiFactory implements IModGuiFactory @Override public GuiScreen createConfigGui(GuiScreen parent) { return new ForgeConfigGui(parent); } - - @Override - public Class mainConfigGuiClass() { return null; } @Override public Set runtimeGuiCategories() { return null; } - @Override - public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) { return null; } - public static class ForgeConfigGui extends GuiConfig { public ForgeConfigGui(GuiScreen parentScreen) diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/BlockInfo.java b/src/main/java/net/minecraftforge/client/model/pipeline/BlockInfo.java index cb44ff78b..1c713956d 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/BlockInfo.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/BlockInfo.java @@ -19,12 +19,10 @@ package net.minecraftforge.client.model.pipeline; -import net.minecraft.block.Block.EnumOffsetType; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.color.BlockColors; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.IBlockAccess; diff --git a/src/main/java/net/minecraftforge/common/DungeonHooks.java b/src/main/java/net/minecraftforge/common/DungeonHooks.java index 6ebdc8578..4e3de27ec 100644 --- a/src/main/java/net/minecraftforge/common/DungeonHooks.java +++ b/src/main/java/net/minecraftforge/common/DungeonHooks.java @@ -62,14 +62,6 @@ public class DungeonHooks return rarity; } - // TODO: remove - /** @deprecated use {@link #removeDungeonMob(ResourceLocation)} */ - @Deprecated - public static int removeDungeonMob(String name) - { - return removeDungeonMob(new ResourceLocation(name)); - } - /** * Will completely remove a Mob from the dungeon spawn list. * diff --git a/src/main/java/net/minecraftforge/common/ForgeHooks.java b/src/main/java/net/minecraftforge/common/ForgeHooks.java index 9f011b550..d066108ec 100644 --- a/src/main/java/net/minecraftforge/common/ForgeHooks.java +++ b/src/main/java/net/minecraftforge/common/ForgeHooks.java @@ -1032,52 +1032,27 @@ public class ForgeHooks return git == null ? null : git.hitVec; } - // TODO 1.12 remove these three - @Deprecated - public static boolean onInteractEntityAt(EntityPlayer player, Entity entity, RayTraceResult ray, EnumHand hand) - { - return onInteractEntityAtAction(player, entity, ray, hand) != null; - } - - @Deprecated - public static boolean onInteractEntityAt(EntityPlayer player, Entity entity, Vec3d vec3d, EnumHand hand) - { - return onInteractEntityAtAction(player, entity, vec3d, hand) != null; - } - - @Deprecated - public static boolean onInteractEntity(EntityPlayer player, Entity entity, EnumHand hand) - { - return onInteractEntityAction(player, entity, hand) != null; - } - - public static EnumActionResult onInteractEntityAtAction(EntityPlayer player, Entity entity, RayTraceResult ray, EnumHand hand) + public static EnumActionResult onInteractEntityAt(EntityPlayer player, Entity entity, RayTraceResult ray, EnumHand hand) { Vec3d vec3d = new Vec3d(ray.hitVec.x - entity.posX, ray.hitVec.y - entity.posY, ray.hitVec.z - entity.posZ); - return onInteractEntityAtAction(player, entity, vec3d, hand); + return onInteractEntityAt(player, entity, vec3d, hand); } - public static EnumActionResult onInteractEntityAtAction(EntityPlayer player, Entity entity, Vec3d vec3d, EnumHand hand) + public static EnumActionResult onInteractEntityAt(EntityPlayer player, Entity entity, Vec3d vec3d, EnumHand hand) { PlayerInteractEvent.EntityInteractSpecific evt = new PlayerInteractEvent.EntityInteractSpecific(player, hand, entity, vec3d); MinecraftForge.EVENT_BUS.post(evt); return evt.isCanceled() ? evt.getCancellationResult() : null; } - public static EnumActionResult onInteractEntityAction(EntityPlayer player, Entity entity, EnumHand hand) + public static EnumActionResult onInteractEntity(EntityPlayer player, Entity entity, EnumHand hand) { PlayerInteractEvent.EntityInteract evt = new PlayerInteractEvent.EntityInteract(player, hand, entity); MinecraftForge.EVENT_BUS.post(evt); return evt.isCanceled() ? evt.getCancellationResult() : null; } - @Deprecated // TODO 1.12 remove - public static boolean onItemRightClick(EntityPlayer player, EnumHand hand) - { - return onItemRightClickAction(player, hand) != null; - } - - public static EnumActionResult onItemRightClickAction(EntityPlayer player, EnumHand hand) + public static EnumActionResult onItemRightClick(EntityPlayer player, EnumHand hand) { PlayerInteractEvent.RightClickItem evt = new PlayerInteractEvent.RightClickItem(player, hand); MinecraftForge.EVENT_BUS.post(evt); @@ -1108,14 +1083,6 @@ public class ForgeHooks MinecraftForge.EVENT_BUS.post(new PlayerInteractEvent.LeftClickEmpty(player)); } - // TODO: remove - /** @deprecated use {@link ForgeHooks#onEmptyLeftClick(EntityPlayer)} */ - @Deprecated - public static void onEmptyLeftClick(EntityPlayer player, @Nonnull ItemStack stack) - { - onEmptyLeftClick(player); - } - private static ThreadLocal> lootContext = new ThreadLocal>(); private static LootTableContext getLootTableContext() { @@ -1127,14 +1094,6 @@ public class ForgeHooks return ctx; } - // TODO: remove - /** @deprecated use {@link ForgeHooks#loadLootTable(Gson, ResourceLocation, String, boolean, LootTableManager)} */ - @Deprecated - public static LootTable loadLootTable(Gson gson, ResourceLocation name, String data, boolean custom) - { - return loadLootTable(gson, name, data, custom, null); - } - @Nullable public static LootTable loadLootTable(Gson gson, ResourceLocation name, String data, boolean custom, LootTableManager lootTableManager) { diff --git a/src/main/java/net/minecraftforge/common/util/Java6Utils.java b/src/main/java/net/minecraftforge/common/util/Java6Utils.java deleted file mode 100644 index 4038052d4..000000000 --- a/src/main/java/net/minecraftforge/common/util/Java6Utils.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.common.util; - -import org.apache.commons.io.IOUtils; - -import javax.annotation.Nullable; -import java.io.Closeable; -import java.io.IOException; -import java.util.zip.ZipFile; - -public class Java6Utils -{ - /** - * {@link ZipFile} does not implement {@link Closeable} on Java 6. - * This method is the same as {@link IOUtils#closeQuietly(Closeable)} but works on {@link ZipFile} on Java 6. - */ - public static void closeZipQuietly(@Nullable ZipFile file) - { - try - { - if (file != null) - { - file.close(); - } - } - catch (IOException ioe) - { - // ignore - } - } -} diff --git a/src/main/java/net/minecraftforge/event/AttachCapabilitiesEvent.java b/src/main/java/net/minecraftforge/event/AttachCapabilitiesEvent.java index 49a5a226c..c9e034e06 100644 --- a/src/main/java/net/minecraftforge/event/AttachCapabilitiesEvent.java +++ b/src/main/java/net/minecraftforge/event/AttachCapabilitiesEvent.java @@ -28,8 +28,6 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.fml.common.eventhandler.GenericEvent; -import javax.annotation.Nonnull; - /** * Fired whenever an object with Capabilities support {currently TileEntity/Item/Entity) * is created. Allowing for the attachment of arbitrary capability providers. @@ -40,20 +38,13 @@ import javax.annotation.Nonnull; public class AttachCapabilitiesEvent extends GenericEvent { private final T obj; - final Map caps;// package-private for ForgeEventFactory - private final Map view; + private final Map caps = Maps.newLinkedHashMap(); + private final Map view = Collections.unmodifiableMap(caps); public AttachCapabilitiesEvent(Class type, T obj) - { - this(type, obj, Maps.newLinkedHashMap()); - } - // package-private for ForgeEventFactory - AttachCapabilitiesEvent(Class type, T obj, Map caps) { super(type); this.obj = obj; - this.caps = caps; - this.view = Collections.unmodifiableMap(caps); } /** @@ -86,22 +77,4 @@ public class AttachCapabilitiesEvent extends GenericEvent { return view; } - - /** - * A version of the parent event which is only fired for ItemStacks. - */ - public static class Item extends AttachCapabilitiesEvent - { - private final net.minecraft.item.ItemStack stack; - public Item(net.minecraft.item.Item item, @Nonnull net.minecraft.item.ItemStack stack) - { - super(net.minecraft.item.Item.class, item); - this.stack = stack; - } - @Nonnull - public net.minecraft.item.ItemStack getItemStack() - { - return this.stack; - } - } } diff --git a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java index e9a785463..a882482a4 100644 --- a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java +++ b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java @@ -22,13 +22,10 @@ package net.minecraftforge.event; import java.io.File; import java.util.EnumSet; import java.util.List; -import java.util.Map; import java.util.Random; -import com.google.common.base.Predicate; import net.minecraft.block.state.IBlockState; import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.command.ICommandSender; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; @@ -40,7 +37,6 @@ import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer.SleepResult; import net.minecraft.init.Blocks; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ActionResult; @@ -54,7 +50,6 @@ import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvent; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.Vec3d; import net.minecraft.util.text.ChatType; import net.minecraft.util.text.ITextComponent; import net.minecraft.village.Village; @@ -127,7 +122,7 @@ import javax.annotation.Nullable; public class ForgeEventFactory { - public static MultiPlaceEvent onPlayerMultiBlockPlace(EntityPlayer player, List blockSnapshots, EnumFacing direction, @Nullable EnumHand hand) + public static MultiPlaceEvent onPlayerMultiBlockPlace(EntityPlayer player, List blockSnapshots, EnumFacing direction, EnumHand hand) { BlockSnapshot snap = blockSnapshots.get(0); IBlockState placedAgainst = snap.getWorld().getBlockState(snap.getPos().offset(direction.getOpposite())); @@ -400,9 +395,9 @@ public class ForgeEventFactory return event.getExtraLife(); } - public static int onItemPickup(EntityItem entityItem, EntityPlayer entityIn, ItemStack itemstack) + public static int onItemPickup(EntityItem entityItem, EntityPlayer player) { - Event event = new EntityItemPickupEvent(entityIn, entityItem); + Event event = new EntityItemPickupEvent(player, entityItem); if (MinecraftForge.EVENT_BUS.post(event)) return -1; return event.getResult() == Result.ALLOW ? 1 : 0; } @@ -561,15 +556,9 @@ public class ForgeEventFactory } @Nullable - public static CapabilityDispatcher gatherCapabilities(Item item, ItemStack stack, ICapabilityProvider parent) + public static CapabilityDispatcher gatherCapabilities(ItemStack stack, ICapabilityProvider parent) { - // first fire the legacy event - AttachCapabilitiesEvent.Item legacyEvent = new AttachCapabilitiesEvent.Item(item, stack); - MinecraftForge.EVENT_BUS.post(legacyEvent); - - // fire new event with the caps that were already registered on the legacy event - AttachCapabilitiesEvent event = new AttachCapabilitiesEvent(ItemStack.class, stack, legacyEvent.caps); - return gatherCapabilities(event, parent); + return gatherCapabilities(new AttachCapabilitiesEvent(ItemStack.class, stack), parent); } @Nullable diff --git a/src/main/java/net/minecraftforge/event/LootTableLoadEvent.java b/src/main/java/net/minecraftforge/event/LootTableLoadEvent.java index 0f6dc1b4a..78a87ee14 100644 --- a/src/main/java/net/minecraftforge/event/LootTableLoadEvent.java +++ b/src/main/java/net/minecraftforge/event/LootTableLoadEvent.java @@ -41,14 +41,6 @@ public class LootTableLoadEvent extends Event private LootTable table; private LootTableManager lootTableManager; - /** - * @deprecated Use {@link #LootTableLoadEvent(ResourceLocation, LootTable, LootTableManager)}
- */ - @Deprecated - public LootTableLoadEvent(ResourceLocation name, LootTable table) { - this(name, table, null); - } - public LootTableLoadEvent(ResourceLocation name, LootTable table, LootTableManager lootTableManager) { this.name = name; diff --git a/src/main/java/net/minecraftforge/event/entity/player/BonemealEvent.java b/src/main/java/net/minecraftforge/event/entity/player/BonemealEvent.java index 4ab4e730f..d34062105 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/BonemealEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/BonemealEvent.java @@ -51,15 +51,6 @@ public class BonemealEvent extends PlayerEvent private final EnumHand hand; private final ItemStack stack; - /** - * @deprecated Use {@link #BonemealEvent(EntityPlayer, World, BlockPos, IBlockState, EnumHand, ItemStack)} instead. - */ - @Deprecated - public BonemealEvent(EntityPlayer player, World world, BlockPos pos, IBlockState block) - { - this(player, world, pos, block, null, ItemStack.EMPTY); - } - public BonemealEvent(@Nonnull EntityPlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState block, @Nullable EnumHand hand, @Nonnull ItemStack stack) { diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java index fb256b965..c3ef28c31 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java @@ -318,14 +318,6 @@ public class PlayerInteractEvent extends PlayerEvent { super(player, EnumHand.MAIN_HAND, new BlockPos(player), null); } - - // TODO: remove - /** @deprecated use {@link LeftClickEmpty(EntityPlayer)} */ - @Deprecated - public LeftClickEmpty(EntityPlayer player, @Nonnull ItemStack stack) - { - this(player); - } } /** diff --git a/src/main/java/net/minecraftforge/event/world/BlockEvent.java b/src/main/java/net/minecraftforge/event/world/BlockEvent.java index b0de106e9..d9a740542 100644 --- a/src/main/java/net/minecraftforge/event/world/BlockEvent.java +++ b/src/main/java/net/minecraftforge/event/world/BlockEvent.java @@ -35,13 +35,10 @@ import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.util.BlockSnapshot; import net.minecraftforge.fml.common.eventhandler.Cancelable; import net.minecraftforge.fml.common.eventhandler.Event; -import net.minecraftforge.fml.common.eventhandler.Event.HasResult; -import net.minecraftforge.fml.common.eventhandler.Event.Result; import com.google.common.collect.ImmutableList; import javax.annotation.Nonnull; -import javax.annotation.Nullable; public class BlockEvent extends Event { @@ -177,12 +174,6 @@ public class BlockEvent extends Event private final IBlockState placedAgainst; private final EnumHand hand; - @Deprecated - public PlaceEvent(BlockSnapshot blockSnapshot, IBlockState placedAgainst, EntityPlayer player) - { - this(blockSnapshot, placedAgainst, player, EnumHand.MAIN_HAND); - } - public PlaceEvent(@Nonnull BlockSnapshot blockSnapshot, @Nonnull IBlockState placedAgainst, @Nonnull EntityPlayer player, @Nonnull EnumHand hand) { super(blockSnapshot.getWorld(), blockSnapshot.getPos(), blockSnapshot.getCurrentBlock()); this.player = player; @@ -218,12 +209,6 @@ public class BlockEvent extends Event { private final List blockSnapshots; - @Deprecated - public MultiPlaceEvent(List blockSnapshots, IBlockState placedAgainst, EntityPlayer player) - { - this(blockSnapshots, placedAgainst, player, EnumHand.MAIN_HAND); - } - public MultiPlaceEvent(@Nonnull List blockSnapshots, @Nonnull IBlockState placedAgainst, @Nonnull EntityPlayer player, @Nonnull EnumHand hand) { super(blockSnapshots.get(0), placedAgainst, player, hand); this.blockSnapshots = ImmutableList.copyOf(blockSnapshots); diff --git a/src/main/java/net/minecraftforge/fluids/BlockFluidBase.java b/src/main/java/net/minecraftforge/fluids/BlockFluidBase.java index 1169f7b60..00c2bb064 100644 --- a/src/main/java/net/minecraftforge/fluids/BlockFluidBase.java +++ b/src/main/java/net/minecraftforge/fluids/BlockFluidBase.java @@ -642,33 +642,6 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock return !here.getMaterial().isSolid() && up.getBlock() == this ? 1 : this.getQuantaPercentage(world, pos) * 0.875F; } - /** - * @deprecated we now pass along up from getExtendedState - */ - @Deprecated - public float getFluidHeightForRender(IBlockAccess world, BlockPos pos) - { - IBlockState here = world.getBlockState(pos); - IBlockState up = world.getBlockState(pos.down(densityDir)); - if (here.getBlock() == this) - { - if (up.getMaterial().isLiquid() || up.getBlock() instanceof IFluidBlock) - { - return 1; - } - - if (getMetaFromState(here) == getMaxRenderHeightMeta()) - { - return 0.875F; - } - } - if (here.getBlock() instanceof BlockLiquid) - { - return Math.min(1 - BlockLiquid.getLiquidHeightPercent(here.getValue(BlockLiquid.LEVEL)), 14f / 16); - } - return !here.getMaterial().isSolid() && up.getBlock() == this ? 1 : this.getQuantaPercentage(world, pos) * 0.875F; - } - public Vec3d getFlowVector(IBlockAccess world, BlockPos pos) { Vec3d vec = new Vec3d(0.0D, 0.0D, 0.0D); diff --git a/src/main/java/net/minecraftforge/fml/client/DefaultGuiFactory.java b/src/main/java/net/minecraftforge/fml/client/DefaultGuiFactory.java index a5b7f0468..f6c3f511b 100644 --- a/src/main/java/net/minecraftforge/fml/client/DefaultGuiFactory.java +++ b/src/main/java/net/minecraftforge/fml/client/DefaultGuiFactory.java @@ -1,3 +1,22 @@ +/* + * Minecraft Forge + * Copyright (c) 2016. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + package net.minecraftforge.fml.client; import java.util.Set; @@ -37,25 +56,12 @@ public class DefaultGuiFactory implements IModGuiFactory return new GuiConfig(parentScreen, modid, title); } - @Deprecated - @Override - public Class mainConfigGuiClass() - { - return null; - } - @Override public Set runtimeGuiCategories() { return null; } - @Override - public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) - { - return null; - } - public static IModGuiFactory forMod(ModContainer mod) { return new DefaultGuiFactory(mod.getModId(), mod.getName()); diff --git a/src/main/java/net/minecraftforge/fml/client/FMLConfigGuiFactory.java b/src/main/java/net/minecraftforge/fml/client/FMLConfigGuiFactory.java index 418491409..6f8ea24f7 100644 --- a/src/main/java/net/minecraftforge/fml/client/FMLConfigGuiFactory.java +++ b/src/main/java/net/minecraftforge/fml/client/FMLConfigGuiFactory.java @@ -27,8 +27,6 @@ import java.util.regex.Pattern; import com.google.common.collect.ImmutableSet; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.resources.I18n; import net.minecraftforge.fml.client.config.ConfigGuiType; @@ -141,12 +139,6 @@ public class FMLConfigGuiFactory implements IModGuiFactory return new FMLConfigGuiScreen(parentScreen); } - @Override - public Class mainConfigGuiClass() - { - return null; - } - private static final Set fmlCategories = ImmutableSet.of(new RuntimeOptionCategoryElement("HELP", "FML")); @Override @@ -154,36 +146,4 @@ public class FMLConfigGuiFactory implements IModGuiFactory { return fmlCategories; } - - @Override - public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) - { - return new RuntimeOptionGuiHandler() { - @Override - public void paint(int x, int y, int w, int h) - { - // TODO Auto-generated method stub - - } - - @Override - public void close() - { - } - - @Override - public void addWidgets(List widgets, int x, int y, int w, int h) - { - widgets.add(new GuiButton(100, x+10, y+10, "HELLO")); - } - - @Override - public void actionCallback(int actionId) - { - // TODO Auto-generated method stub - - } - }; - } - } diff --git a/src/main/java/net/minecraftforge/fml/client/GuiModList.java b/src/main/java/net/minecraftforge/fml/client/GuiModList.java index afaca2ae8..4af9cd51d 100644 --- a/src/main/java/net/minecraftforge/fml/client/GuiModList.java +++ b/src/main/java/net/minecraftforge/fml/client/GuiModList.java @@ -281,15 +281,7 @@ public class GuiModList extends GuiScreen try { IModGuiFactory guiFactory = FMLClientHandler.instance().getGuiFactoryFor(selectedMod); - GuiScreen newScreen = null; - try - { - newScreen = guiFactory.createConfigGui(this); - } - catch (AbstractMethodError error) - { - newScreen = guiFactory.mainConfigGuiClass().getConstructor(GuiScreen.class).newInstance(this); - } + GuiScreen newScreen = guiFactory.createConfigGui(this); this.mc.displayGuiScreen(newScreen); } catch (Exception e) @@ -425,14 +417,7 @@ public class GuiModList extends GuiScreen configModButton.enabled = false; if (guiFactory != null) { - try - { - configModButton.enabled = guiFactory.hasConfigGui(); - } - catch(AbstractMethodError error) - { - configModButton.enabled = guiFactory.mainConfigGuiClass() != null; - } + configModButton.enabled = guiFactory.hasConfigGui(); } lines.add(selectedMod.getMetadata().name); lines.add(String.format("Version: %s (%s)", selectedMod.getDisplayVersion(), selectedMod.getVersion())); diff --git a/src/main/java/net/minecraftforge/fml/client/IModGuiFactory.java b/src/main/java/net/minecraftforge/fml/client/IModGuiFactory.java index a7d16b667..a127d86a3 100644 --- a/src/main/java/net/minecraftforge/fml/client/IModGuiFactory.java +++ b/src/main/java/net/minecraftforge/fml/client/IModGuiFactory.java @@ -19,14 +19,10 @@ package net.minecraftforge.fml.client; -import java.util.List; import java.util.Set; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiScreen; -import javax.annotation.Nullable; - /** * This is the interface you need to implement if you want to provide a customized config screen. * {@link DefaultGuiFactory} provides a default implementation of this interface and will be used @@ -67,31 +63,6 @@ public interface IModGuiFactory { * or null if no GUI is desired. */ public GuiScreen createConfigGui(GuiScreen parentScreen); - - /** - * Return the name of a class extending {@link GuiScreen}. This class will - * be instantiated when the "config" button is pressed in the mod list. It will - * have a single argument constructor - the "parent" screen, the same as all - * Minecraft GUIs. The expected behaviour is that this screen will replace the - * "mod list" screen completely, and will return to the mod list screen through - * the parent link, once the appropriate action is taken from the config screen. - * - * A null from this method indicates that the mod does not provide a "config" - * button GUI screen, and the config button will be hidden/disabled. - * - * This config GUI is anticipated to provide configuration to the mod in a friendly - * visual way. It should not be abused to set internals such as IDs (they're gonna - * keep disappearing anyway), but rather, interesting behaviours. This config GUI - * is never run when a server game is running, and should be used to configure - * desired behaviours that affect server state. Costs, mod game modes, stuff like that - * can be changed here. - * - * @deprecated The method {@link IModGuiFactory.maingConfigGui(GuiScreen} is the recommended method. - * @return A class that will be instantiated on clicks on the config button - * or null if no GUI is desired. - */ - @Deprecated - public Class mainConfigGuiClass(); /** * Return a list of the "runtime" categories this mod wishes to populate with @@ -115,16 +86,6 @@ public interface IModGuiFactory { */ public Set runtimeGuiCategories(); - /** - * Return an instance of a {@link RuntimeOptionGuiHandler} that handles painting the - * right hand side option screen for the specified {@link RuntimeOptionCategoryElement}. - * - * @param element The element we wish to paint for - * @return The Handler for painting it - */ - @Nullable - public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element); - /** * Represents an option category and entry in the runtime gui options list. * @@ -141,48 +102,4 @@ public interface IModGuiFactory { this.child = child; } } - - /** - * Responsible for painting the mod specific section of runtime options GUI for a particular category - * - * @author cpw - * - * TODO remove in 1.11 - this was never fully implemented and will be removed - */ - @Deprecated - public interface RuntimeOptionGuiHandler { - /** - * Called to add widgets to the screen, such as buttons. - * GUI identifier numbers should start at 100 and increase. - * The callback will be through {@link #actionCallback(int)} - * - * @param x X - * @param y Y - * @param w width - * @param h height - */ - public void addWidgets(List widgetList, int x, int y, int w, int h); - - /** - * Called to paint the rectangle specified. - * @param x X - * @param y Y - * @param w width - * @param h height - */ - public void paint(int x, int y, int w, int h); - - /** - * Called if a widget with id >= 100 is fired. - * - * @param actionId the actionId of the firing widget - */ - public void actionCallback(int actionId); - - /** - * Called when this handler is about to go away (probably replaced by another one, or closing the - * option screen) - */ - public void close(); - } } diff --git a/src/main/java/net/minecraftforge/fml/common/asm/FMLSanityChecker.java b/src/main/java/net/minecraftforge/fml/common/asm/FMLSanityChecker.java index e6bd19956..ec7c65bc2 100644 --- a/src/main/java/net/minecraftforge/fml/common/asm/FMLSanityChecker.java +++ b/src/main/java/net/minecraftforge/fml/common/asm/FMLSanityChecker.java @@ -28,7 +28,6 @@ import java.util.Map; import java.util.jar.JarEntry; import java.util.jar.JarFile; -import net.minecraftforge.common.util.Java6Utils; import org.apache.commons.io.IOUtils; import net.minecraft.launchwrapper.LaunchClassLoader; @@ -146,7 +145,7 @@ public class FMLSanityChecker implements IFMLCallHook } finally { - Java6Utils.closeZipQuietly(mcJarFile); + IOUtils.closeQuietly(mcJarFile); } } else diff --git a/src/main/java/net/minecraftforge/fml/common/discovery/JarDiscoverer.java b/src/main/java/net/minecraftforge/fml/common/discovery/JarDiscoverer.java index 51b9b468a..4f67497de 100644 --- a/src/main/java/net/minecraftforge/fml/common/discovery/JarDiscoverer.java +++ b/src/main/java/net/minecraftforge/fml/common/discovery/JarDiscoverer.java @@ -24,7 +24,6 @@ import java.util.Collections; import java.util.List; import java.util.jar.JarFile; -import net.minecraftforge.common.util.Java6Utils; import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.LoaderException; import net.minecraftforge.fml.common.MetadataCollection; @@ -120,7 +119,7 @@ public class JarDiscoverer implements ITypeDiscoverer } finally { - Java6Utils.closeZipQuietly(jar); + IOUtils.closeQuietly(jar); } return foundMods; } diff --git a/src/main/java/net/minecraftforge/fml/relauncher/ReflectionHelper.java b/src/main/java/net/minecraftforge/fml/relauncher/ReflectionHelper.java index 008562537..434d56bfe 100644 --- a/src/main/java/net/minecraftforge/fml/relauncher/ReflectionHelper.java +++ b/src/main/java/net/minecraftforge/fml/relauncher/ReflectionHelper.java @@ -180,29 +180,6 @@ public class ReflectionHelper throw new UnableToFindClassException(classNames, err); } - /** - * @deprecated use {@link #findMethod(Class, String, String, Class[])} - */ - @Deprecated - public static Method findMethod(Class clazz, E instance, String[] methodNames, Class... methodTypes) - { - Throwable failed = null; - for (String methodName : methodNames) - { - try - { - Method m = clazz.getDeclaredMethod(methodName, methodTypes); - m.setAccessible(true); - return m; - } - catch (Exception e) - { - failed = e; - } - } - throw new UnableToFindMethodException(failed); - } - /** * Finds a method with the specified name and parameters in the given class and makes it accessible. * Note: for performance, store the returned value and avoid calling this repeatedly. diff --git a/src/main/java/net/minecraftforge/fml/server/FMLServerHandler.java b/src/main/java/net/minecraftforge/fml/server/FMLServerHandler.java index bb047cb0f..7bcf694b8 100644 --- a/src/main/java/net/minecraftforge/fml/server/FMLServerHandler.java +++ b/src/main/java/net/minecraftforge/fml/server/FMLServerHandler.java @@ -36,7 +36,6 @@ import net.minecraft.util.IThreadListener; import net.minecraft.util.text.translation.LanguageMap; import net.minecraft.world.storage.SaveFormatOld; import net.minecraftforge.common.util.CompoundDataFixer; -import net.minecraftforge.common.util.Java6Utils; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.IFMLSidedHandler; @@ -277,7 +276,7 @@ public class FMLServerHandler implements IFMLSidedHandler finally { IOUtils.closeQuietly(stream); - Java6Utils.closeZipQuietly(zip); + IOUtils.closeQuietly(zip); } } diff --git a/src/test/java/net/minecraftforge/debug/TestCapabilityMod.java b/src/test/java/net/minecraftforge/debug/TestCapabilityMod.java index 3c4755775..205ea89a8 100644 --- a/src/test/java/net/minecraftforge/debug/TestCapabilityMod.java +++ b/src/test/java/net/minecraftforge/debug/TestCapabilityMod.java @@ -3,7 +3,6 @@ package net.minecraftforge.debug; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; @@ -189,26 +188,6 @@ public class TestCapabilityMod } } - // these can be removed if we remove these legacy events - @SubscribeEvent - public void onItemLoadLegacy(AttachCapabilitiesEvent event) - { - if (event.getObject() == Items.APPLE) - { - event.addCapability(new ResourceLocation("forge.testcapmod:dummy_cap"), new Provider(event.getObject())); - } - } - - @SubscribeEvent - public void onItemLoadLegacy(AttachCapabilitiesEvent.Item event) - { - if (event.getObject() == Items.ARROW) - { - event.addCapability(new ResourceLocation("forge.testcapmod:dummy_cap"), new Provider(event.getObject())); - } - } - - @SuppressWarnings("rawtypes") @SubscribeEvent public void attachEvent(AttachCapabilitiesEvent event) //Test Raw type gets everything still.