Remove some deprecated methods and clean up

This commit is contained in:
Ben Staddon authored and mezz committed 2017-06-25 22:30:18 -07:00
1 parent 7892ca922c
commit 9a09ff68aa
28 files changed
+45 -444

No files matched your search

@@ -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<T> extends GenericEvent<T>
{
private final T obj;
final Map<ResourceLocation, ICapabilityProvider> caps;// package-private for ForgeEventFactory
private final Map<ResourceLocation, ICapabilityProvider> view;
private final Map<ResourceLocation, ICapabilityProvider> caps = Maps.newLinkedHashMap();
private final Map<ResourceLocation, ICapabilityProvider> view = Collections.unmodifiableMap(caps);
public AttachCapabilitiesEvent(Class<T> type, T obj)
{
this(type, obj, Maps.<ResourceLocation, ICapabilityProvider>newLinkedHashMap());
}
// package-private for ForgeEventFactory
AttachCapabilitiesEvent(Class<T> type, T obj, Map<ResourceLocation, ICapabilityProvider> caps)
{
super(type);
this.obj = obj;
this.caps = caps;
this.view = Collections.unmodifiableMap(caps);
}
/**
@@ -86,22 +77,4 @@ public class AttachCapabilitiesEvent<T> extends GenericEvent<T>
{
return view;
}
/**
* A version of the parent event which is only fired for ItemStacks.
*/
public static class Item extends AttachCapabilitiesEvent<net.minecraft.item.Item>
{
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;
}
}
}
@@ -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<BlockSnapshot> blockSnapshots, EnumFacing direction, @Nullable EnumHand hand)
public static MultiPlaceEvent onPlayerMultiBlockPlace(EntityPlayer player, List<BlockSnapshot> 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<ItemStack> event = new AttachCapabilitiesEvent<ItemStack>(ItemStack.class, stack, legacyEvent.caps);
return gatherCapabilities(event, parent);
return gatherCapabilities(new AttachCapabilitiesEvent<ItemStack>(ItemStack.class, stack), parent);
}
@Nullable
@@ -41,14 +41,6 @@ public class LootTableLoadEvent extends Event
private LootTable table;
private LootTableManager lootTableManager;
/**
* @deprecated Use {@link #LootTableLoadEvent(ResourceLocation, LootTable, LootTableManager)}<br>
*/
@Deprecated
public LootTableLoadEvent(ResourceLocation name, LootTable table) {
this(name, table, null);
}
public LootTableLoadEvent(ResourceLocation name, LootTable table, LootTableManager lootTableManager)
{
this.name = name;
@@ -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)
{
@@ -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);
}
}
/**
@@ -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<BlockSnapshot> blockSnapshots;
@Deprecated
public MultiPlaceEvent(List<BlockSnapshot> blockSnapshots, IBlockState placedAgainst, EntityPlayer player)
{
this(blockSnapshots, placedAgainst, player, EnumHand.MAIN_HAND);
}
public MultiPlaceEvent(@Nonnull List<BlockSnapshot> blockSnapshots, @Nonnull IBlockState placedAgainst, @Nonnull EntityPlayer player, @Nonnull EnumHand hand) {
super(blockSnapshots.get(0), placedAgainst, player, hand);
this.blockSnapshots = ImmutableList.copyOf(blockSnapshots);