diff --git a/build.gradle b/build.gradle index a86ce441e..518575d36 100644 --- a/build.gradle +++ b/build.gradle @@ -54,7 +54,7 @@ launch4j { uploadArchives { repositories { - add project.repositories.mavenLocal() + add getProject().repositories.mavenLocal() } repositories.mavenDeployer { configuration = configurations.deployJars diff --git a/fml b/fml index 0098c57f9..0b419ac79 160000 --- a/fml +++ b/fml @@ -1 +1 @@ -Subproject commit 0098c57f94808751062ee45f2ee267324bb42089 +Subproject commit 0b419ac79c307579f162d47e0388a9d75bcd0a6e diff --git a/src/main/java/net/minecraftforge/client/event/ClientChatReceivedEvent.java b/src/main/java/net/minecraftforge/client/event/ClientChatReceivedEvent.java index 431261639..0711dd0fa 100644 --- a/src/main/java/net/minecraftforge/client/event/ClientChatReceivedEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ClientChatReceivedEvent.java @@ -1,7 +1,7 @@ package net.minecraftforge.client.event; -import net.minecraftforge.event.Cancelable; -import net.minecraftforge.event.Event; +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; @Cancelable public class ClientChatReceivedEvent extends Event diff --git a/src/main/java/net/minecraftforge/client/event/DrawBlockHighlightEvent.java b/src/main/java/net/minecraftforge/client/event/DrawBlockHighlightEvent.java index cfef7cee3..a7ce56958 100644 --- a/src/main/java/net/minecraftforge/client/event/DrawBlockHighlightEvent.java +++ b/src/main/java/net/minecraftforge/client/event/DrawBlockHighlightEvent.java @@ -1,11 +1,11 @@ package net.minecraftforge.client.event; +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.MovingObjectPosition; import net.minecraft.client.renderer.RenderGlobal; -import net.minecraftforge.event.Cancelable; -import net.minecraftforge.event.Event; @Cancelable public class DrawBlockHighlightEvent extends Event diff --git a/src/main/java/net/minecraftforge/client/event/FOVUpdateEvent.java b/src/main/java/net/minecraftforge/client/event/FOVUpdateEvent.java index 26cf84ad9..9754b2fad 100644 --- a/src/main/java/net/minecraftforge/client/event/FOVUpdateEvent.java +++ b/src/main/java/net/minecraftforge/client/event/FOVUpdateEvent.java @@ -1,8 +1,8 @@ package net.minecraftforge.client.event; +import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.renderer.EntityRenderer; -import net.minecraftforge.event.Event; /** * Author: MachineMuse (Claire Semple) diff --git a/src/main/java/net/minecraftforge/client/event/GuiOpenEvent.java b/src/main/java/net/minecraftforge/client/event/GuiOpenEvent.java index 67fdb29e9..80345f212 100644 --- a/src/main/java/net/minecraftforge/client/event/GuiOpenEvent.java +++ b/src/main/java/net/minecraftforge/client/event/GuiOpenEvent.java @@ -1,8 +1,8 @@ package net.minecraftforge.client.event; +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.client.gui.GuiScreen; -import net.minecraftforge.event.Cancelable; -import net.minecraftforge.event.Event; /** * This event is called before any Gui will open. diff --git a/src/main/java/net/minecraftforge/client/event/MouseEvent.java b/src/main/java/net/minecraftforge/client/event/MouseEvent.java index 473986ad5..4cedc34e7 100644 --- a/src/main/java/net/minecraftforge/client/event/MouseEvent.java +++ b/src/main/java/net/minecraftforge/client/event/MouseEvent.java @@ -1,9 +1,10 @@ package net.minecraftforge.client.event; -import net.minecraftforge.event.Cancelable; -import net.minecraftforge.event.Event; import org.lwjgl.input.Mouse; +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; + /** * Author: MachineMuse (Claire Semple) * Created: 2:46 PM, 9/4/13 diff --git a/src/main/java/net/minecraftforge/client/event/RenderGameOverlayEvent.java b/src/main/java/net/minecraftforge/client/event/RenderGameOverlayEvent.java index bf99acb4c..a6dd86554 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderGameOverlayEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderGameOverlayEvent.java @@ -2,9 +2,10 @@ package net.minecraftforge.client.event; import java.util.ArrayList; +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; + import net.minecraft.client.gui.ScaledResolution; -import net.minecraftforge.event.Cancelable; -import net.minecraftforge.event.Event; @Cancelable public class RenderGameOverlayEvent extends Event diff --git a/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java b/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java index 7b028e1f5..d20322f15 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java @@ -1,9 +1,9 @@ package net.minecraftforge.client.event; +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.client.renderer.entity.RendererLivingEntity; import net.minecraft.entity.EntityLivingBase; -import net.minecraftforge.event.Cancelable; -import net.minecraftforge.event.Event; public abstract class RenderLivingEvent extends Event { diff --git a/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java b/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java index dbe0259e6..dd4885d35 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java @@ -1,9 +1,9 @@ package net.minecraftforge.client.event; +import cpw.mods.fml.common.eventhandler.Cancelable; import net.minecraft.client.renderer.entity.RenderPlayer; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraftforge.event.Cancelable; import net.minecraftforge.event.entity.player.PlayerEvent; public abstract class RenderPlayerEvent extends PlayerEvent diff --git a/src/main/java/net/minecraftforge/client/event/RenderWorldLastEvent.java b/src/main/java/net/minecraftforge/client/event/RenderWorldLastEvent.java index 60adeca7c..ae5d596f6 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderWorldLastEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderWorldLastEvent.java @@ -1,7 +1,7 @@ package net.minecraftforge.client.event; +import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.client.renderer.RenderGlobal; -import net.minecraftforge.event.Event; public class RenderWorldLastEvent extends Event { diff --git a/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java b/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java index 0ab45394e..6b602e38b 100644 --- a/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java +++ b/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java @@ -1,7 +1,7 @@ package net.minecraftforge.client.event; +import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraftforge.event.Event; public class TextureStitchEvent extends Event diff --git a/src/main/java/net/minecraftforge/client/event/sound/SoundEvent.java b/src/main/java/net/minecraftforge/client/event/sound/SoundEvent.java index 6e3adf654..beee06e96 100644 --- a/src/main/java/net/minecraftforge/client/event/sound/SoundEvent.java +++ b/src/main/java/net/minecraftforge/client/event/sound/SoundEvent.java @@ -1,11 +1,11 @@ package net.minecraftforge.client.event.sound; +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.entity.Entity; import net.minecraft.client.audio.SoundManager; import net.minecraft.client.audio.SoundPoolEntry; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.Cancelable; -import net.minecraftforge.event.Event; public class SoundEvent extends Event { diff --git a/src/main/java/net/minecraftforge/common/ForgeChunkManager.java b/src/main/java/net/minecraftforge/common/ForgeChunkManager.java index 6e1bdce55..d4c48fb75 100644 --- a/src/main/java/net/minecraftforge/common/ForgeChunkManager.java +++ b/src/main/java/net/minecraftforge/common/ForgeChunkManager.java @@ -44,6 +44,7 @@ import com.google.common.collect.TreeMultiset; import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.server.MinecraftServer; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.ChunkCoordIntPair; @@ -60,7 +61,6 @@ import net.minecraftforge.common.ForgeChunkManager.Ticket; import net.minecraftforge.common.config.ConfigCategory; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; -import net.minecraftforge.event.Event; /** * Manages chunkloading for mods. diff --git a/src/main/java/net/minecraftforge/common/ForgeHooks.java b/src/main/java/net/minecraftforge/common/ForgeHooks.java index dea01c1bd..aad0af043 100644 --- a/src/main/java/net/minecraftforge/common/ForgeHooks.java +++ b/src/main/java/net/minecraftforge/common/ForgeHooks.java @@ -7,6 +7,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import cpw.mods.fml.common.eventhandler.Event; import cpw.mods.fml.relauncher.ReflectionHelper; import net.minecraft.block.Block; import net.minecraft.enchantment.EnchantmentHelper; @@ -33,7 +34,6 @@ import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.WeightedRandom; import net.minecraft.world.World; -import net.minecraftforge.event.Event; import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.event.ServerChatEvent; import net.minecraftforge.event.entity.item.ItemTossEvent; diff --git a/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java b/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java index 0a46ff07e..a4e60e415 100644 --- a/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java +++ b/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java @@ -3,6 +3,8 @@ package net.minecraftforge.common; import java.util.UUID; import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; @@ -14,7 +16,7 @@ import net.minecraftforge.event.world.WorldEvent; public class ForgeInternalHandler { - @ForgeSubscribe(priority = EventPriority.HIGHEST) + @SubscribeEvent(priority = EventPriority.HIGHEST) public void onEntityJoinWorld(EntityJoinWorldEvent event) { if (!event.world.isRemote) @@ -58,19 +60,19 @@ public class ForgeInternalHandler } } - @ForgeSubscribe(priority = EventPriority.HIGHEST) + @SubscribeEvent(priority = EventPriority.HIGHEST) public void onDimensionLoad(WorldEvent.Load event) { ForgeChunkManager.loadWorld(event.world); } - @ForgeSubscribe(priority = EventPriority.HIGHEST) + @SubscribeEvent(priority = EventPriority.HIGHEST) public void onDimensionSave(WorldEvent.Save event) { ForgeChunkManager.saveWorld(event.world); } - @ForgeSubscribe(priority = EventPriority.HIGHEST) + @SubscribeEvent(priority = EventPriority.HIGHEST) public void onDimensionUnload(WorldEvent.Unload event) { ForgeChunkManager.unloadWorld(event.world); diff --git a/src/main/java/net/minecraftforge/common/ForgeModContainer.java b/src/main/java/net/minecraftforge/common/ForgeModContainer.java index 9146aa3e5..f9a8d54b0 100644 --- a/src/main/java/net/minecraftforge/common/ForgeModContainer.java +++ b/src/main/java/net/minecraftforge/common/ForgeModContainer.java @@ -1,5 +1,11 @@ package net.minecraftforge.common; +import static net.minecraftforge.common.ForgeVersion.buildVersion; +import static net.minecraftforge.common.ForgeVersion.majorVersion; +import static net.minecraftforge.common.ForgeVersion.minorVersion; +import static net.minecraftforge.common.ForgeVersion.revisionVersion; +import static net.minecraftforge.common.config.Configuration.CATEGORY_GENERAL; + import java.io.File; import java.util.Arrays; import java.util.Map; @@ -7,16 +13,12 @@ import java.util.logging.Level; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.server.management.PlayerInstance; import net.minecraft.world.storage.SaveHandler; import net.minecraft.world.storage.WorldInfo; import net.minecraftforge.classloading.FMLForgePlugin; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; -import net.minecraftforge.common.network.ForgeConnectionHandler; import net.minecraftforge.common.network.ForgeNetworkHandler; -import net.minecraftforge.common.network.ForgePacketHandler; -import net.minecraftforge.common.network.ForgeTinyPacketHandler; import net.minecraftforge.oredict.RecipeSorter; import net.minecraftforge.server.command.ForgeCommand; @@ -36,17 +38,9 @@ import cpw.mods.fml.common.event.FMLLoadCompleteEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLServerStartingEvent; -import cpw.mods.fml.common.network.FMLNetworkHandler; -import cpw.mods.fml.common.network.NetworkMod; -import static net.minecraftforge.common.ForgeVersion.*; -import static net.minecraftforge.common.config.Configuration.*; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.network.internal.FMLNetworkHandler; -@NetworkMod( - channels = "FORGE", - connectionHandler = ForgeConnectionHandler.class, - packetHandler = ForgePacketHandler.class, - tinyPacketHandler = ForgeTinyPacketHandler.class - ) public class ForgeModContainer extends DummyModContainer implements WorldAccessContainer { public static int clumpingThreshold = 64; @@ -150,11 +144,11 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC prop = config.get(Configuration.CATEGORY_GENERAL, "biomeSkyBlendRange", new int[] { 20, 15, 10, 5 }); prop.comment = "Control the range of sky blending for colored skies in biomes."; blendRanges = prop.getIntList(); - + prop = config.get(Configuration.CATEGORY_GENERAL, "zombieBaseSummonChance", 0.1); prop.comment = "Base zombie summoning spawn chance. Allows changing the bonus zombie summoning mechanic."; zombieSummonBaseChance = prop.getDouble(0.1); - + prop = config.get(Configuration.CATEGORY_GENERAL, "zombieBabyChance", 0.05); prop.comment = "Chance that a zombie (or subclass) is a baby. Allows changing the zombie spawning mechanic."; zombieBabyChance = (float) prop.getDouble(0.05); @@ -179,16 +173,8 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC @Subscribe public void modConstruction(FMLConstructionEvent evt) { - FMLLog.info("Registering Forge Packet Handler"); - try - { - FMLNetworkHandler.instance().registerNetworkMod(new ForgeNetworkHandler(this)); - FMLLog.info("Succeeded registering Forge Packet Handler"); - } - catch (Exception e) - { - FMLLog.log(Level.SEVERE, e, "Failed to register packet handler for Forge"); - } + NetworkRegistry.INSTANCE.register(this, this.getClass(), null, evt.getASMHarvestedData()); + ForgeNetworkHandler.registerChannel(this, evt.getSide()); } @Subscribe diff --git a/src/main/java/net/minecraftforge/common/MinecraftForge.java b/src/main/java/net/minecraftforge/common/MinecraftForge.java index 1a0f579cb..f0c26077b 100644 --- a/src/main/java/net/minecraftforge/common/MinecraftForge.java +++ b/src/main/java/net/minecraftforge/common/MinecraftForge.java @@ -7,6 +7,8 @@ import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.eventhandler.EventBus; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; @@ -18,8 +20,6 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.common.ForgeHooks.GrassEntry; import net.minecraftforge.common.ForgeHooks.SeedEntry; import net.minecraftforge.common.util.IdentityMap; -import net.minecraftforge.event.EventBus; -import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.entity.EntityEvent; import net.minecraftforge.oredict.OreDictionary; diff --git a/src/main/java/net/minecraftforge/common/network/DimensionMessageHandler.java b/src/main/java/net/minecraftforge/common/network/DimensionMessageHandler.java new file mode 100644 index 000000000..ae6dc23d3 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/network/DimensionMessageHandler.java @@ -0,0 +1,19 @@ +package net.minecraftforge.common.network; + +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.common.network.ForgeMessage.DimensionRegisterMessage; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.SimpleChannelInboundHandler; + +public class DimensionMessageHandler extends SimpleChannelInboundHandler{ + @Override + protected void channelRead0(ChannelHandlerContext ctx, DimensionRegisterMessage msg) throws Exception + { + if (!DimensionManager.isDimensionRegistered(msg.dimensionId)) + { + DimensionManager.registerDimension(msg.dimensionId, msg.providerId); + } + } + +} diff --git a/src/main/java/net/minecraftforge/common/network/FluidIdRegistryMessageHandler.java b/src/main/java/net/minecraftforge/common/network/FluidIdRegistryMessageHandler.java new file mode 100644 index 000000000..7ba0825ca --- /dev/null +++ b/src/main/java/net/minecraftforge/common/network/FluidIdRegistryMessageHandler.java @@ -0,0 +1,12 @@ +package net.minecraftforge.common.network; + +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.SimpleChannelInboundHandler; + +public class FluidIdRegistryMessageHandler extends SimpleChannelInboundHandler { + @Override + protected void channelRead0(ChannelHandlerContext ctx, ForgeMessage.FluidIdMapMessage msg) throws Exception + { + // Do something with the message + } +} diff --git a/src/main/java/net/minecraftforge/common/network/ForgeConnectionHandler.java b/src/main/java/net/minecraftforge/common/network/ForgeConnectionHandler.java deleted file mode 100644 index 42ff849bb..000000000 --- a/src/main/java/net/minecraftforge/common/network/ForgeConnectionHandler.java +++ /dev/null @@ -1,55 +0,0 @@ -package net.minecraftforge.common.network; - -import net.minecraft.network.INetworkManager; -import net.minecraft.network.NetLoginHandler; -import net.minecraft.network.packet.NetHandler; -import net.minecraft.network.packet.Packet1Login; -import net.minecraft.network.packet.Packet250CustomPayload; -import net.minecraft.server.MinecraftServer; -import net.minecraftforge.fluids.FluidIdMapPacket; -import cpw.mods.fml.common.network.IConnectionHandler; -import cpw.mods.fml.common.network.PacketDispatcher; -import cpw.mods.fml.common.network.Player; - -public class ForgeConnectionHandler implements IConnectionHandler { - - @Override - public void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager) - { - Packet250CustomPayload[] fluidPackets = ForgePacket.makePacketSet(new FluidIdMapPacket()); - for (int i = 0; i < fluidPackets.length; i++) { - PacketDispatcher.sendPacketToPlayer(fluidPackets[i], player); - } - } - - @Override - public String connectionReceived(NetLoginHandler netHandler, INetworkManager manager) - { - return null; - } - - @Override - public void connectionOpened(NetHandler netClientHandler, String server, int port, INetworkManager manager) - { - - } - - @Override - public void connectionOpened(NetHandler netClientHandler, MinecraftServer server, INetworkManager manager) - { - - } - - @Override - public void connectionClosed(INetworkManager manager) - { - - } - - @Override - public void clientLoggedIn(NetHandler clientHandler, INetworkManager manager, Packet1Login login) - { - - } - -} diff --git a/src/main/java/net/minecraftforge/common/network/ForgeMessage.java b/src/main/java/net/minecraftforge/common/network/ForgeMessage.java new file mode 100644 index 000000000..8f0af9a9f --- /dev/null +++ b/src/main/java/net/minecraftforge/common/network/ForgeMessage.java @@ -0,0 +1,61 @@ +package net.minecraftforge.common.network; + +import java.util.Map; + +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; + +import cpw.mods.fml.common.network.ByteBufUtils; + +import net.minecraftforge.fluids.FluidRegistry; +import io.netty.buffer.ByteBuf; + +public abstract class ForgeMessage { + public static class DimensionRegisterMessage extends ForgeMessage { + /** The dimension ID to register on client */ + int dimensionId; + /** The provider ID to register with dimension on client */ + int providerId; + @Override + void toBytes(ByteBuf bytes) + { + bytes.writeInt(this.dimensionId); + bytes.writeInt(this.providerId); + } + + @Override + void fromBytes(ByteBuf bytes) + { + dimensionId = bytes.readInt(); + providerId = bytes.readInt(); + } + } + + public static class FluidIdMapMessage extends ForgeMessage { + BiMap fluidIds = HashBiMap.create(); + @Override + void toBytes(ByteBuf bytes) + { + bytes.writeInt(FluidRegistry.maxID); + for (Map.Entry entry : FluidRegistry.fluidIDs.entrySet()) + { + ByteBufUtils.writeUTF8String(bytes,entry.getKey()); + bytes.writeInt(entry.getValue()); + } + } + + @Override + void fromBytes(ByteBuf bytes) + { + int listSize = bytes.readInt(); + for (int i = 0; i < listSize; i++) { + String fluidName = ByteBufUtils.readUTF8String(bytes); + int fluidId = bytes.readInt(); + fluidIds.put(fluidName, fluidId); + } + } + } + + abstract void toBytes(ByteBuf bytes); + abstract void fromBytes(ByteBuf bytes); +} diff --git a/src/main/java/net/minecraftforge/common/network/ForgeNetworkHandler.java b/src/main/java/net/minecraftforge/common/network/ForgeNetworkHandler.java index 160b49954..6ca2f79f3 100644 --- a/src/main/java/net/minecraftforge/common/network/ForgeNetworkHandler.java +++ b/src/main/java/net/minecraftforge/common/network/ForgeNetworkHandler.java @@ -1,20 +1,39 @@ package net.minecraftforge.common.network; -import net.minecraftforge.common.ForgeModContainer; -import cpw.mods.fml.common.network.NetworkMod; -import cpw.mods.fml.common.network.NetworkModHandler; +import io.netty.channel.embedded.EmbeddedChannel; -public class ForgeNetworkHandler extends NetworkModHandler +import java.util.EnumMap; + +import net.minecraftforge.common.ForgeModContainer; +import cpw.mods.fml.common.network.FMLOutboundHandler; +import cpw.mods.fml.common.network.FMLOutboundHandler.OutboundTarget; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.network.internal.FMLRuntimeCodec; +import cpw.mods.fml.common.network.internal.HandshakeCompletionHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ForgeNetworkHandler { - public ForgeNetworkHandler(ForgeModContainer container) + private static EnumMap channelPair; + + public static void registerChannel(ForgeModContainer forgeModContainer, Side side) { - super(container,container.getClass().getAnnotation(NetworkMod.class)); - configureNetworkMod(container); + channelPair = NetworkRegistry.INSTANCE.newChannel(forgeModContainer, "FML", new FMLRuntimeCodec(), new HandshakeCompletionHandler()); + EmbeddedChannel embeddedChannel = channelPair.get(Side.SERVER); + embeddedChannel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.NOWHERE); + + if (side == Side.CLIENT) + { + addClientHandlers(); + } + channelPair.get(Side.SERVER).pipeline().addAfter("ForgeRuntimeCodec#0", "ServerToClientConnection", new ServerToClientConnectionEstablishedHandler()); } - @Override - public boolean acceptVersion(String version) + @SideOnly(Side.CLIENT) + private static void addClientHandlers() { - return true; + channelPair.get(Side.CLIENT).pipeline().addAfter("ForgeRuntimeCodec#0", "DimensionHandler", new DimensionMessageHandler()); + channelPair.get(Side.CLIENT).pipeline().addAfter("ForgeRuntimeCodec#0", "FluidIdRegistryHandler", new FluidIdRegistryMessageHandler()); } } diff --git a/src/main/java/net/minecraftforge/common/network/ForgePacket.java b/src/main/java/net/minecraftforge/common/network/ForgePacket.java deleted file mode 100644 index 16ba87f54..000000000 --- a/src/main/java/net/minecraftforge/common/network/ForgePacket.java +++ /dev/null @@ -1,189 +0,0 @@ -package net.minecraftforge.common.network; - -import java.util.Arrays; -import java.util.concurrent.ConcurrentMap; -import java.util.logging.Level; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraftforge.common.network.packet.DimensionRegisterPacket; -import net.minecraftforge.fluids.FluidIdMapPacket; - -import com.google.common.base.Throwables; -import com.google.common.collect.MapMaker; -import com.google.common.io.ByteArrayDataInput; -import com.google.common.io.ByteStreams; -import com.google.common.primitives.Bytes; -import com.google.common.primitives.Ints; -import com.google.common.primitives.UnsignedBytes; - -import cpw.mods.fml.common.FMLLog; -import cpw.mods.fml.common.network.FMLNetworkException; - -public abstract class ForgePacket -{ - public static final String CHANNEL_ID = "FORGE"; - enum Type - { - /** - * Registers a dimension for a provider on client - */ - REGISTERDIMENSION(DimensionRegisterPacket.class), - /** - * The Fluid ID map to send to the client - */ - FLUID_IDMAP(FluidIdMapPacket.class); - - private Class packetType; - private ConcurrentMap partTracker; - - private Type(Class clazz) - { - this.packetType = clazz; - } - - ForgePacket make() - { - try - { - return this.packetType.newInstance(); - } - catch (Exception e) - { - Throwables.propagateIfPossible(e); - FMLLog.log(Level.SEVERE, e, "A bizarre critical error occured during packet encoding"); - throw new FMLNetworkException(e); - } - } - - private ForgePacket consumePart(INetworkManager network, byte[] data) - { - if (partTracker == null) - { - partTracker = new MapMaker().weakKeys().weakValues().makeMap(); - } - if (!partTracker.containsKey(network)) - { - partTracker.put(network, make()); - } - - ForgePacket pkt = partTracker.get(network); - - ByteArrayDataInput bdi = ByteStreams.newDataInput(data); - int chunkIdx = UnsignedBytes.toInt(bdi.readByte()); - int chunkTotal = UnsignedBytes.toInt(bdi.readByte()); - int chunkLength = bdi.readInt(); - - if (pkt.partials == null) - { - pkt.partials = new byte[chunkTotal][]; - } - - pkt.partials[chunkIdx] = new byte[chunkLength]; - bdi.readFully(pkt.partials[chunkIdx]); - for (int i = 0; i < pkt.partials.length; i++) - { - if (pkt.partials[i] == null) - { - return null; - } - } - - return pkt; - } - } - - private Type type; - private byte[][] partials; - - public static Packet250CustomPayload[] makePacketSet(ForgePacket packet) - { - byte[] packetData = packet.generatePacket(); - - if (packetData.length < 32000) - { - return new Packet250CustomPayload[] - { - new Packet250CustomPayload(CHANNEL_ID, - Bytes.concat(new byte[] - { - UnsignedBytes.checkedCast(0), //IsMultipart: False - UnsignedBytes.checkedCast(packet.getID()) - }, - packetData)) - }; - } - else - { - byte[][] chunks = new byte[packetData.length / 32000 + 1][]; - for (int i = 0; i < packetData.length / 32000 + 1; i++) - { - int len = Math.min(32000, packetData.length - i* 32000); - chunks[i] = Bytes.concat(new byte[] - { - UnsignedBytes.checkedCast(1), //IsMultipart: True - UnsignedBytes.checkedCast(packet.getID()), //Packet ID - UnsignedBytes.checkedCast(i), //Part Number - UnsignedBytes.checkedCast(chunks.length), //Total Parts - }, - Ints.toByteArray(len), //Length - Arrays.copyOfRange(packetData, i * 32000, len + i * 32000)); - } - - Packet250CustomPayload[] ret = new Packet250CustomPayload[chunks.length]; - for (int i = 0; i < chunks.length; i++) - { - ret[i] = new Packet250CustomPayload(CHANNEL_ID, chunks[i]); - } - return ret; - } - } - - public static ForgePacket readPacket(INetworkManager network, byte[] payload) - { - boolean multipart = UnsignedBytes.toInt(payload[0]) == 1; - int type = UnsignedBytes.toInt(payload[1]); - Type eType = Type.values()[type]; - byte[] data = Arrays.copyOfRange(payload, 2, payload.length); - - if (multipart) - { - ForgePacket pkt = eType.consumePart(network, data); - if (pkt != null) - { - return pkt.consumePacket(Bytes.concat(pkt.partials)); - } - return null; - } - else - { - return eType.make().consumePacket(data); - } - } - - public ForgePacket() - { - for (Type t : Type.values()) - { - if (t.packetType == getClass()) - { - type = t; - continue; - } - } - if (type == null) - { - throw new RuntimeException("ForgePacket constructor called on ungregistered type."); - } - } - - public byte getID() - { - return UnsignedBytes.checkedCast(type.ordinal()); - } - - public abstract byte[] generatePacket(); - - public abstract ForgePacket consumePacket(byte[] data); - - public abstract void execute(INetworkManager network, EntityPlayer player); -} diff --git a/src/main/java/net/minecraftforge/common/network/ForgePacketHandler.java b/src/main/java/net/minecraftforge/common/network/ForgePacketHandler.java deleted file mode 100644 index 854405b7e..000000000 --- a/src/main/java/net/minecraftforge/common/network/ForgePacketHandler.java +++ /dev/null @@ -1,26 +0,0 @@ -package net.minecraftforge.common.network; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.network.INetworkManager; -import net.minecraft.network.NetLoginHandler; -import net.minecraft.network.packet.Packet250CustomPayload; -import cpw.mods.fml.common.network.FMLPacket; -import cpw.mods.fml.common.network.IPacketHandler; -import cpw.mods.fml.common.network.Player; - -public class ForgePacketHandler implements IPacketHandler { - - @Override - public void onPacketData(INetworkManager network, Packet250CustomPayload packet, Player player) - { - ForgePacket pkt = ForgePacket.readPacket(network, packet.data); - // Part of an incomplete multipart packet - if (pkt == null) - { - return; - } - - pkt.execute(network, (EntityPlayer)player); - } - -} diff --git a/src/main/java/net/minecraftforge/common/network/ForgeRuntimeCodec.java b/src/main/java/net/minecraftforge/common/network/ForgeRuntimeCodec.java new file mode 100644 index 000000000..e46000da9 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/network/ForgeRuntimeCodec.java @@ -0,0 +1,23 @@ +package net.minecraftforge.common.network; + +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; +import cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec; + +public class ForgeRuntimeCodec extends FMLIndexedMessageToMessageCodec { + public ForgeRuntimeCodec() + { + addDiscriminator(1, ForgeMessage.DimensionRegisterMessage.class); + } + @Override + public void encodeInto(ChannelHandlerContext ctx, ForgeMessage msg, ByteBuf target) throws Exception + { + msg.toBytes(target); + } + + @Override + public void decodeInto(ChannelHandlerContext ctx, ByteBuf source, ForgeMessage msg) + { + msg.fromBytes(source); + } +} diff --git a/src/main/java/net/minecraftforge/common/network/ServerToClientConnectionEstablishedHandler.java b/src/main/java/net/minecraftforge/common/network/ServerToClientConnectionEstablishedHandler.java new file mode 100644 index 000000000..d7bd3033f --- /dev/null +++ b/src/main/java/net/minecraftforge/common/network/ServerToClientConnectionEstablishedHandler.java @@ -0,0 +1,19 @@ +package net.minecraftforge.common.network; + +import cpw.mods.fml.common.network.NetworkHandshakeEstablished; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInboundHandlerAdapter; + +public class ServerToClientConnectionEstablishedHandler extends ChannelInboundHandlerAdapter { + @Override + public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception + { + if (evt instanceof NetworkHandshakeEstablished) + { + ctx.writeAndFlush(new ForgeMessage.FluidIdMapMessage()); + return; + } + // pass it forward + ctx.fireUserEventTriggered(evt); + } +} diff --git a/src/main/java/net/minecraftforge/common/network/packet/DimensionRegisterPacket.java b/src/main/java/net/minecraftforge/common/network/packet/DimensionRegisterPacket.java deleted file mode 100644 index 140c6219c..000000000 --- a/src/main/java/net/minecraftforge/common/network/packet/DimensionRegisterPacket.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * This software is provided under the terms of the Minecraft Forge Public - * License v1.0. - */ - -package net.minecraftforge.common.network.packet; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.network.INetworkManager; -import net.minecraft.network.packet.NetHandler; -import net.minecraftforge.common.DimensionManager; -import net.minecraftforge.common.network.ForgePacket; - -import com.google.common.io.ByteArrayDataInput; -import com.google.common.io.ByteArrayDataOutput; -import com.google.common.io.ByteStreams; - -/** - * This class offers the ability for servers to register dimensions on client. - */ -public class DimensionRegisterPacket extends ForgePacket -{ - - /** The dimension ID to register on client */ - public int dimensionId; - /** The provider ID to register with dimension on client */ - public int providerId; - - // nullary constructor required by ForgePacket.make() - public DimensionRegisterPacket() {} - - public DimensionRegisterPacket(int dimensionId, int providerId) - { - this.dimensionId = dimensionId; - this.providerId = providerId; - } - - @Override - public byte[] generatePacket() - { - ByteArrayDataOutput dat = ByteStreams.newDataOutput(); - dat.writeInt(this.dimensionId); - dat.writeInt(this.providerId); - return dat.toByteArray(); - } - - @Override - public ForgePacket consumePacket(byte[] data) - { - ByteArrayDataInput dat = ByteStreams.newDataInput(data); - dimensionId = dat.readInt(); - providerId = dat.readInt(); - return this; - } - - @Override - public void execute(INetworkManager network, EntityPlayer player) - { - if (!(player instanceof EntityPlayerMP)) - { - if (!DimensionManager.isDimensionRegistered(dimensionId)) - { - DimensionManager.registerDimension(dimensionId, providerId); - } - } - } - -} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/event/ASMEventHandler.java b/src/main/java/net/minecraftforge/event/ASMEventHandler.java deleted file mode 100644 index a9af9d329..000000000 --- a/src/main/java/net/minecraftforge/event/ASMEventHandler.java +++ /dev/null @@ -1,130 +0,0 @@ -package net.minecraftforge.event; - -import static org.objectweb.asm.Opcodes.*; - -import java.lang.reflect.Method; -import java.util.HashMap; - - -import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Type; - -import com.google.common.collect.Maps; - - -public class ASMEventHandler implements IEventListener -{ - private static int IDs = 0; - private static final String HANDLER_DESC = Type.getInternalName(IEventListener.class); - private static final String HANDLER_FUNC_DESC = Type.getMethodDescriptor(IEventListener.class.getDeclaredMethods()[0]); - private static final ASMClassLoader LOADER = new ASMClassLoader(); - private static final HashMap> cache = Maps.newHashMap(); - - private final IEventListener handler; - private final ForgeSubscribe subInfo; - public ASMEventHandler(Object target, Method method) throws Exception - { - handler = (IEventListener)createWrapper(method).getConstructor(Object.class).newInstance(target); - subInfo = method.getAnnotation(ForgeSubscribe.class); - } - - @Override - public void invoke(Event event) - { - if (handler != null) - { - if (!event.isCancelable() || !event.isCanceled() || subInfo.receiveCanceled()) - { - handler.invoke(event); - } - } - } - - public EventPriority getPriority() - { - return subInfo.priority(); - } - - public Class createWrapper(Method callback) - { - if (cache.containsKey(callback)) - { - return cache.get(callback); - } - - ClassWriter cw = new ClassWriter(0); - MethodVisitor mv; - - String name = getUniqueName(callback); - String desc = name.replace('.', '/'); - String instType = Type.getInternalName(callback.getDeclaringClass()); - String eventType = Type.getInternalName(callback.getParameterTypes()[0]); - - /* - System.out.println("Name: " + name); - System.out.println("Desc: " + desc); - System.out.println("InstType: " + instType); - System.out.println("Callback: " + callback.getName() + Type.getMethodDescriptor(callback)); - System.out.println("Event: " + eventType); - */ - - cw.visit(V1_6, ACC_PUBLIC | ACC_SUPER, desc, null, "java/lang/Object", new String[]{ HANDLER_DESC }); - - cw.visitSource(".dynamic", null); - { - cw.visitField(ACC_PUBLIC, "instance", "Ljava/lang/Object;", null, null).visitEnd(); - } - { - mv = cw.visitMethod(ACC_PUBLIC, "", "(Ljava/lang/Object;)V", null, null); - mv.visitCode(); - mv.visitVarInsn(ALOAD, 0); - mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "", "()V"); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ALOAD, 1); - mv.visitFieldInsn(PUTFIELD, desc, "instance", "Ljava/lang/Object;"); - mv.visitInsn(RETURN); - mv.visitMaxs(2, 2); - mv.visitEnd(); - } - { - mv = cw.visitMethod(ACC_PUBLIC, "invoke", HANDLER_FUNC_DESC, null, null); - mv.visitCode(); - mv.visitVarInsn(ALOAD, 0); - mv.visitFieldInsn(GETFIELD, desc, "instance", "Ljava/lang/Object;"); - mv.visitTypeInsn(CHECKCAST, instType); - mv.visitVarInsn(ALOAD, 1); - mv.visitTypeInsn(CHECKCAST, eventType); - mv.visitMethodInsn(INVOKEVIRTUAL, instType, callback.getName(), Type.getMethodDescriptor(callback)); - mv.visitInsn(RETURN); - mv.visitMaxs(2, 2); - mv.visitEnd(); - } - cw.visitEnd(); - Class ret = LOADER.define(name, cw.toByteArray()); - cache.put(callback, ret); - return ret; - } - - private String getUniqueName(Method callback) - { - return String.format("%s_%d_%s_%s_%s", getClass().getName(), IDs++, - callback.getDeclaringClass().getSimpleName(), - callback.getName(), - callback.getParameterTypes()[0].getSimpleName()); - } - - private static class ASMClassLoader extends ClassLoader - { - private ASMClassLoader() - { - super(ASMClassLoader.class.getClassLoader()); - } - - public Class define(String name, byte[] data) - { - return defineClass(name, data, 0, data.length); - } - } - -} diff --git a/src/main/java/net/minecraftforge/event/Cancelable.java b/src/main/java/net/minecraftforge/event/Cancelable.java deleted file mode 100644 index 2d30ca9a7..000000000 --- a/src/main/java/net/minecraftforge/event/Cancelable.java +++ /dev/null @@ -1,11 +0,0 @@ -package net.minecraftforge.event; - -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -@Retention(value = RUNTIME) -@Target(value = TYPE) -public @interface Cancelable{} diff --git a/src/main/java/net/minecraftforge/event/CommandEvent.java b/src/main/java/net/minecraftforge/event/CommandEvent.java index fc8f8bd93..9559a38b1 100644 --- a/src/main/java/net/minecraftforge/event/CommandEvent.java +++ b/src/main/java/net/minecraftforge/event/CommandEvent.java @@ -1,5 +1,7 @@ package net.minecraftforge.event; +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; diff --git a/src/main/java/net/minecraftforge/event/Event.java b/src/main/java/net/minecraftforge/event/Event.java deleted file mode 100644 index 1e1ef0b1d..000000000 --- a/src/main/java/net/minecraftforge/event/Event.java +++ /dev/null @@ -1,155 +0,0 @@ -package net.minecraftforge.event; - -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - - -/** - * Base Event class that all other events are derived from - */ -public class Event -{ - @Retention(value = RUNTIME) - @Target(value = TYPE) - public @interface HasResult{} - - public enum Result - { - DENY, - DEFAULT, - ALLOW - } - - private boolean isCanceled = false; - private final boolean isCancelable; - private Result result = Result.DEFAULT; - private final boolean hasResult; - private static ListenerList listeners = new ListenerList(); - - private static final Map> annotationMap = new ConcurrentHashMap>(); - - public Event() - { - setup(); - isCancelable = hasAnnotation(Cancelable.class); - hasResult = hasAnnotation(HasResult.class); - } - - private boolean hasAnnotation(Class annotation) - { - Class me = this.getClass(); - Map list = annotationMap.get(me); - if (list == null) - { - list = new ConcurrentHashMap(); - annotationMap.put(me, list); - } - - Boolean cached = list.get(annotation); - if (cached != null) - { - return cached; - } - - Class cls = me; - while (cls != Event.class) - { - if (cls.isAnnotationPresent(annotation)) - { - list.put(annotation, true); - return true; - } - cls = cls.getSuperclass(); - } - - list.put(annotation, false); - return false; - } - - /** - * Determine if this function is cancelable at all. - * @return If access to setCanceled should be allowed - */ - public boolean isCancelable() - { - return isCancelable; - } - - /** - * Determine if this event is canceled and should stop executing. - * @return The current canceled state - */ - public boolean isCanceled() - { - return isCanceled; - } - - /** - * Sets the state of this event, not all events are cancelable, and any attempt to - * cancel a event that can't be will result in a IllegalArgumentException. - * - * The functionality of setting the canceled state is defined on a per-event bases. - * - * @param cancel The new canceled value - */ - public void setCanceled(boolean cancel) - { - if (!isCancelable()) - { - throw new IllegalArgumentException("Attempted to cancel a uncancelable event"); - } - isCanceled = cancel; - } - - /** - * Determines if this event expects a significant result value. - */ - public boolean hasResult() - { - return hasResult; - } - - /** - * Returns the value set as the result of this event - */ - public Result getResult() - { - return result; - } - - /** - * Sets the result value for this event, not all events can have a result set, and any attempt to - * set a result for a event that isn't expecting it will result in a IllegalArgumentException. - * - * The functionality of setting the result is defined on a per-event bases. - * - * @param value The new result - */ - public void setResult(Result value) - { - result = value; - } - /** - * Called by the base constructor, this is used by ASM generated - * event classes to setup various functionality such as the listener's list. - */ - protected void setup() - { - } - - /** - * Returns a ListenerList object that contains all listeners - * that are registered to this event. - * - * @return Listener List - */ - public ListenerList getListenerList() - { - return listeners; - } -} diff --git a/src/main/java/net/minecraftforge/event/EventBus.java b/src/main/java/net/minecraftforge/event/EventBus.java deleted file mode 100644 index 3fe149c44..000000000 --- a/src/main/java/net/minecraftforge/event/EventBus.java +++ /dev/null @@ -1,112 +0,0 @@ -package net.minecraftforge.event; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - - - -import com.google.common.reflect.TypeToken; - -public class EventBus -{ - private static int maxID = 0; - - private ConcurrentHashMap> listeners = new ConcurrentHashMap>(); - private final int busID = maxID++; - - public EventBus() - { - ListenerList.resize(busID + 1); - } - - public void register(Object target) - { - if (listeners.containsKey(target)) - { - return; - } - - Set> supers = TypeToken.of(target.getClass()).getTypes().rawTypes(); - for (Method method : target.getClass().getMethods()) - { - for (Class cls : supers) - { - try - { - Method real = cls.getDeclaredMethod(method.getName(), method.getParameterTypes()); - if (real.isAnnotationPresent(ForgeSubscribe.class)) - { - Class[] parameterTypes = method.getParameterTypes(); - if (parameterTypes.length != 1) - { - throw new IllegalArgumentException( - "Method " + method + " has @ForgeSubscribe annotation, but requires " + parameterTypes.length + - " arguments. Event handler methods must require a single argument." - ); - } - - Class eventType = parameterTypes[0]; - - if (!Event.class.isAssignableFrom(eventType)) - { - throw new IllegalArgumentException("Method " + method + " has @ForgeSubscribe annotation, but takes a argument that is not a Event " + eventType); - } - - register(eventType, target, method); - break; - } - } - catch (NoSuchMethodException e) - { - ; - } - } - } - } - - private void register(Class eventType, Object target, Method method) - { - try - { - Constructor ctr = eventType.getConstructor(); - ctr.setAccessible(true); - Event event = (Event)ctr.newInstance(); - ASMEventHandler listener = new ASMEventHandler(target, method); - event.getListenerList().register(busID, listener.getPriority(), listener); - - ArrayList others = listeners.get(target); - if (others == null) - { - others = new ArrayList(); - listeners.put(target, others); - } - others.add(listener); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - public void unregister(Object object) - { - ArrayList list = listeners.remove(object); - for (IEventListener listener : list) - { - ListenerList.unregiterAll(busID, listener); - } - } - - public boolean post(Event event) - { - IEventListener[] listeners = event.getListenerList().getListeners(busID); - for (IEventListener listener : listeners) - { - listener.invoke(event); - } - return (event.isCancelable() ? event.isCanceled() : false); - } -} diff --git a/src/main/java/net/minecraftforge/event/EventPriority.java b/src/main/java/net/minecraftforge/event/EventPriority.java deleted file mode 100644 index 74302900c..000000000 --- a/src/main/java/net/minecraftforge/event/EventPriority.java +++ /dev/null @@ -1,16 +0,0 @@ -package net.minecraftforge.event; - -public enum EventPriority -{ - /*Priority of event listeners, listeners will be sorted with respect to this priority level. - * - * Note: - * Due to using a ArrayList in the ListenerList, - * these need to stay in a contiguous index starting at 0. {Default ordinal} - */ - HIGHEST, //First to execute - HIGH, - NORMAL, - LOW, - LOWEST //Last to execute -} diff --git a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java index 2773defd7..07d35ea30 100644 --- a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java +++ b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java @@ -3,6 +3,8 @@ package net.minecraftforge.event; import java.util.ArrayList; import java.util.List; +import cpw.mods.fml.common.eventhandler.Event.Result; + import net.minecraft.block.Block; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; @@ -13,7 +15,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.Event.Result; import net.minecraftforge.event.entity.living.LivingPackSizeEvent; import net.minecraftforge.event.entity.living.LivingSpawnEvent; import net.minecraftforge.event.entity.living.LivingSpawnEvent.AllowDespawn; diff --git a/src/main/java/net/minecraftforge/event/ForgeSubscribe.java b/src/main/java/net/minecraftforge/event/ForgeSubscribe.java deleted file mode 100644 index 0a5ffd8c5..000000000 --- a/src/main/java/net/minecraftforge/event/ForgeSubscribe.java +++ /dev/null @@ -1,15 +0,0 @@ -package net.minecraftforge.event; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.RetentionPolicy.*; -import static java.lang.annotation.ElementType.*; - -@Retention(value = RUNTIME) -@Target(value = METHOD) -public @interface ForgeSubscribe -{ - public EventPriority priority() default EventPriority.NORMAL; - public boolean receiveCanceled() default false; -} diff --git a/src/main/java/net/minecraftforge/event/IEventListener.java b/src/main/java/net/minecraftforge/event/IEventListener.java deleted file mode 100644 index 9fdd7f481..000000000 --- a/src/main/java/net/minecraftforge/event/IEventListener.java +++ /dev/null @@ -1,8 +0,0 @@ -package net.minecraftforge.event; - - - -public interface IEventListener -{ - public void invoke(Event event); -} diff --git a/src/main/java/net/minecraftforge/event/ListenerList.java b/src/main/java/net/minecraftforge/event/ListenerList.java deleted file mode 100644 index b1694b3bb..000000000 --- a/src/main/java/net/minecraftforge/event/ListenerList.java +++ /dev/null @@ -1,219 +0,0 @@ -package net.minecraftforge.event; - -import java.util.*; - - -public class ListenerList -{ - private static ArrayList allLists = new ArrayList(); - private static int maxSize = 0; - - private ListenerList parent; - private ListenerListInst[] lists = new ListenerListInst[0]; - - public ListenerList() - { - allLists.add(this); - resizeLists(maxSize); - } - - public ListenerList(ListenerList parent) - { - allLists.add(this); - this.parent = parent; - resizeLists(maxSize); - } - - public static void resize(int max) - { - if (max <= maxSize) - { - return; - } - for (ListenerList list : allLists) - { - list.resizeLists(max); - } - maxSize = max; - } - - public void resizeLists(int max) - { - if (parent != null) - { - parent.resizeLists(max); - } - - if (lists.length >= max) - { - return; - } - - ListenerListInst[] newList = new ListenerListInst[max]; - int x = 0; - for (; x < lists.length; x++) - { - newList[x] = lists[x]; - } - for(; x < max; x++) - { - if (parent != null) - { - newList[x] = new ListenerListInst(parent.getInstance(x)); - } - else - { - newList[x] = new ListenerListInst(); - } - } - lists = newList; - } - - public static void clearBusID(int id) - { - for (ListenerList list : allLists) - { - list.lists[id].dispose(); - } - } - - protected ListenerListInst getInstance(int id) - { - return lists[id]; - } - - public IEventListener[] getListeners(int id) - { - return lists[id].getListeners(); - } - - public void register(int id, EventPriority priority, IEventListener listener) - { - lists[id].register(priority, listener); - } - - public void unregister(int id, IEventListener listener) - { - lists[id].unregister(listener); - } - - public static void unregiterAll(int id, IEventListener listener) - { - for (ListenerList list : allLists) - { - list.unregister(id, listener); - } - } - - private class ListenerListInst - { - private boolean rebuild = true; - private IEventListener[] listeners; - private ArrayList> priorities; - private ListenerListInst parent; - - private ListenerListInst() - { - int count = EventPriority.values().length; - priorities = new ArrayList>(count); - - for (int x = 0; x < count; x++) - { - priorities.add(new ArrayList()); - } - } - - public void dispose() - { - for (ArrayList listeners : priorities) - { - listeners.clear(); - } - priorities.clear(); - parent = null; - listeners = null; - } - - private ListenerListInst(ListenerListInst parent) - { - this(); - this.parent = parent; - } - - /** - * Returns a ArrayList containing all listeners for this event, - * and all parent events for the specified priority. - * - * The list is returned with the listeners for the children events first. - * - * @param priority The Priority to get - * @return ArrayList containing listeners - */ - public ArrayList getListeners(EventPriority priority) - { - ArrayList ret = new ArrayList(priorities.get(priority.ordinal())); - if (parent != null) - { - ret.addAll(parent.getListeners(priority)); - } - return ret; - } - - /** - * Returns a full list of all listeners for all priority levels. - * Including all parent listeners. - * - * List is returned in proper priority order. - * - * Automatically rebuilds the internal Array cache if its information is out of date. - * - * @return Array containing listeners - */ - public IEventListener[] getListeners() - { - if (shouldRebuild()) buildCache(); - return listeners; - } - - protected boolean shouldRebuild() - { - return rebuild || (parent != null && parent.shouldRebuild()); - } - - /** - * Rebuild the local Array of listeners, returns early if there is no work to do. - */ - private void buildCache() - { - if(parent != null && parent.shouldRebuild()) - { - parent.buildCache(); - } - - ArrayList ret = new ArrayList(); - for (EventPriority value : EventPriority.values()) - { - ret.addAll(getListeners(value)); - } - listeners = ret.toArray(new IEventListener[ret.size()]); - rebuild = false; - } - - public void register(EventPriority priority, IEventListener listener) - { - priorities.get(priority.ordinal()).add(listener); - rebuild = true; - } - - public void unregister(IEventListener listener) - { - for(ArrayList list : priorities) - { - if (list.remove(listener)) - { - rebuild = true; - } - } - } - } -} diff --git a/src/main/java/net/minecraftforge/event/ServerChatEvent.java b/src/main/java/net/minecraftforge/event/ServerChatEvent.java index bde018fbb..f9f6c8b6b 100644 --- a/src/main/java/net/minecraftforge/event/ServerChatEvent.java +++ b/src/main/java/net/minecraftforge/event/ServerChatEvent.java @@ -1,5 +1,7 @@ package net.minecraftforge.event; +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.util.ChatMessageComponent; diff --git a/src/main/java/net/minecraftforge/event/brewing/PotionBrewedEvent.java b/src/main/java/net/minecraftforge/event/brewing/PotionBrewedEvent.java index 5c4af348d..1864a220b 100644 --- a/src/main/java/net/minecraftforge/event/brewing/PotionBrewedEvent.java +++ b/src/main/java/net/minecraftforge/event/brewing/PotionBrewedEvent.java @@ -1,7 +1,7 @@ package net.minecraftforge.event.brewing; +import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.item.ItemStack; -import net.minecraftforge.event.Event; public class PotionBrewedEvent extends Event { diff --git a/src/main/java/net/minecraftforge/event/entity/EntityEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityEvent.java index 648fd2570..c859f01bf 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityEvent.java @@ -1,8 +1,8 @@ package net.minecraftforge.event.entity; +import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.entity.Entity; import net.minecraft.world.World; -import net.minecraftforge.event.Event; public class EntityEvent extends Event { diff --git a/src/main/java/net/minecraftforge/event/entity/EntityJoinWorldEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityJoinWorldEvent.java index f852b6c15..7a317a6b7 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityJoinWorldEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityJoinWorldEvent.java @@ -1,8 +1,8 @@ package net.minecraftforge.event.entity; +import cpw.mods.fml.common.eventhandler.Cancelable; import net.minecraft.entity.Entity; import net.minecraft.world.World; -import net.minecraftforge.event.Cancelable; @Cancelable public class EntityJoinWorldEvent extends EntityEvent diff --git a/src/main/java/net/minecraftforge/event/entity/EntityStruckByLightningEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityStruckByLightningEvent.java index c55cc4fdb..f6898c6bf 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityStruckByLightningEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityStruckByLightningEvent.java @@ -1,8 +1,8 @@ package net.minecraftforge.event.entity; +import cpw.mods.fml.common.eventhandler.Cancelable; import net.minecraft.entity.Entity; import net.minecraft.entity.effect.EntityLightningBolt; -import net.minecraftforge.event.Cancelable; @Cancelable public class EntityStruckByLightningEvent extends EntityEvent diff --git a/src/main/java/net/minecraftforge/event/entity/PlaySoundAtEntityEvent.java b/src/main/java/net/minecraftforge/event/entity/PlaySoundAtEntityEvent.java index 859debd1f..8e0ce19db 100644 --- a/src/main/java/net/minecraftforge/event/entity/PlaySoundAtEntityEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/PlaySoundAtEntityEvent.java @@ -1,7 +1,7 @@ package net.minecraftforge.event.entity; +import cpw.mods.fml.common.eventhandler.Cancelable; import net.minecraft.entity.Entity; -import net.minecraftforge.event.Cancelable; @Cancelable public class PlaySoundAtEntityEvent extends EntityEvent diff --git a/src/main/java/net/minecraftforge/event/entity/item/ItemExpireEvent.java b/src/main/java/net/minecraftforge/event/entity/item/ItemExpireEvent.java index 3f21a9d4d..f52ffd1bf 100644 --- a/src/main/java/net/minecraftforge/event/entity/item/ItemExpireEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/item/ItemExpireEvent.java @@ -1,7 +1,7 @@ package net.minecraftforge.event.entity.item; +import cpw.mods.fml.common.eventhandler.Cancelable; import net.minecraft.entity.item.EntityItem; -import net.minecraftforge.event.Cancelable; import net.minecraftforge.event.entity.EntityEvent; /** diff --git a/src/main/java/net/minecraftforge/event/entity/item/ItemTossEvent.java b/src/main/java/net/minecraftforge/event/entity/item/ItemTossEvent.java index 033fc6f20..dd8dc3446 100644 --- a/src/main/java/net/minecraftforge/event/entity/item/ItemTossEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/item/ItemTossEvent.java @@ -1,8 +1,8 @@ package net.minecraftforge.event.entity.item; +import cpw.mods.fml.common.eventhandler.Cancelable; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; -import net.minecraftforge.event.Cancelable; import net.minecraftforge.event.entity.EntityEvent; /** diff --git a/src/main/java/net/minecraftforge/event/entity/living/EnderTeleportEvent.java b/src/main/java/net/minecraftforge/event/entity/living/EnderTeleportEvent.java index b90725e0d..9e907ca82 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/EnderTeleportEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/EnderTeleportEvent.java @@ -1,9 +1,9 @@ package net.minecraftforge.event.entity.living; +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; -import net.minecraftforge.event.Cancelable; -import net.minecraftforge.event.Event; /** * Event for when an Enderman teleports or an ender pearl is used. Can be used to either modify the target position, or cancel the teleport outright. diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingAttackEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingAttackEvent.java index 2b1567b32..ad4537178 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingAttackEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingAttackEvent.java @@ -1,8 +1,8 @@ package net.minecraftforge.event.entity.living; +import cpw.mods.fml.common.eventhandler.Cancelable; import net.minecraft.util.DamageSource; import net.minecraft.entity.EntityLivingBase; -import net.minecraftforge.event.Cancelable; @Cancelable public class LivingAttackEvent extends LivingEvent diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingDeathEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingDeathEvent.java index 709380c46..4adb0330f 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingDeathEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingDeathEvent.java @@ -1,8 +1,8 @@ package net.minecraftforge.event.entity.living; +import cpw.mods.fml.common.eventhandler.Cancelable; import net.minecraft.util.DamageSource; import net.minecraft.entity.EntityLivingBase; -import net.minecraftforge.event.Cancelable; @Cancelable public class LivingDeathEvent extends LivingEvent diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingDropsEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingDropsEvent.java index 0de2175e3..9ad66eb84 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingDropsEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingDropsEvent.java @@ -2,10 +2,11 @@ package net.minecraftforge.event.entity.living; import java.util.ArrayList; +import cpw.mods.fml.common.eventhandler.Cancelable; + import net.minecraft.util.DamageSource; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.EntityLivingBase; -import net.minecraftforge.event.Cancelable; @Cancelable public class LivingDropsEvent extends LivingEvent diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingEvent.java index 971cd0642..056ba57fb 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingEvent.java @@ -1,7 +1,7 @@ package net.minecraftforge.event.entity.living; +import cpw.mods.fml.common.eventhandler.Cancelable; import net.minecraft.entity.EntityLivingBase; -import net.minecraftforge.event.Cancelable; import net.minecraftforge.event.entity.EntityEvent; public class LivingEvent extends EntityEvent diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingFallEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingFallEvent.java index 4c32b7acf..b4d03b9dc 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingFallEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingFallEvent.java @@ -1,7 +1,7 @@ package net.minecraftforge.event.entity.living; +import cpw.mods.fml.common.eventhandler.Cancelable; import net.minecraft.entity.EntityLivingBase; -import net.minecraftforge.event.Cancelable; @Cancelable public class LivingFallEvent extends LivingEvent diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingHurtEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingHurtEvent.java index 243723115..d7850483a 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingHurtEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingHurtEvent.java @@ -1,8 +1,8 @@ package net.minecraftforge.event.entity.living; +import cpw.mods.fml.common.eventhandler.Cancelable; import net.minecraft.util.DamageSource; import net.minecraft.entity.EntityLivingBase; -import net.minecraftforge.event.Cancelable; @Cancelable public class LivingHurtEvent extends LivingEvent diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingPackSizeEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingPackSizeEvent.java index 01affa682..af962c8d9 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingPackSizeEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingPackSizeEvent.java @@ -1,7 +1,7 @@ package net.minecraftforge.event.entity.living; +import cpw.mods.fml.common.eventhandler.Event.HasResult; import net.minecraft.entity.EntityLiving; -import net.minecraftforge.event.Event.HasResult; @HasResult public class LivingPackSizeEvent extends LivingEvent diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingSpawnEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingSpawnEvent.java index cd1cfb7c0..d864a174a 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingSpawnEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingSpawnEvent.java @@ -1,9 +1,9 @@ package net.minecraftforge.event.entity.living; +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event.HasResult; import net.minecraft.entity.EntityLiving; import net.minecraft.world.World; -import net.minecraftforge.event.Cancelable; -import net.minecraftforge.event.Event.HasResult; public class LivingSpawnEvent extends LivingEvent { diff --git a/src/main/java/net/minecraftforge/event/entity/living/ZombieEvent.java b/src/main/java/net/minecraftforge/event/entity/living/ZombieEvent.java index 19277383c..69f721f55 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/ZombieEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/ZombieEvent.java @@ -1,10 +1,10 @@ package net.minecraftforge.event.entity.living; +import cpw.mods.fml.common.eventhandler.Cancelable; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.EntityZombie; import net.minecraft.world.World; -import net.minecraftforge.event.Cancelable; import net.minecraftforge.event.entity.EntityEvent; public class ZombieEvent extends EntityEvent { diff --git a/src/main/java/net/minecraftforge/event/entity/minecart/MinecartInteractEvent.java b/src/main/java/net/minecraftforge/event/entity/minecart/MinecartInteractEvent.java index 76ace4046..8d31e3f2d 100644 --- a/src/main/java/net/minecraftforge/event/entity/minecart/MinecartInteractEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/minecart/MinecartInteractEvent.java @@ -1,8 +1,8 @@ package net.minecraftforge.event.entity.minecart; +import cpw.mods.fml.common.eventhandler.Cancelable; import net.minecraft.entity.item.EntityMinecart; import net.minecraft.entity.player.EntityPlayer; -import net.minecraftforge.event.Cancelable; @Cancelable public class MinecartInteractEvent extends MinecartEvent diff --git a/src/main/java/net/minecraftforge/event/entity/player/ArrowLooseEvent.java b/src/main/java/net/minecraftforge/event/entity/player/ArrowLooseEvent.java index c1ed1260a..3dee68af0 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/ArrowLooseEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/ArrowLooseEvent.java @@ -1,8 +1,8 @@ package net.minecraftforge.event.entity.player; +import cpw.mods.fml.common.eventhandler.Cancelable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraftforge.event.Cancelable; @Cancelable public class ArrowLooseEvent extends PlayerEvent diff --git a/src/main/java/net/minecraftforge/event/entity/player/ArrowNockEvent.java b/src/main/java/net/minecraftforge/event/entity/player/ArrowNockEvent.java index 67537e516..771d7423f 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/ArrowNockEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/ArrowNockEvent.java @@ -1,8 +1,8 @@ package net.minecraftforge.event.entity.player; +import cpw.mods.fml.common.eventhandler.Cancelable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraftforge.event.Cancelable; @Cancelable public class ArrowNockEvent extends PlayerEvent diff --git a/src/main/java/net/minecraftforge/event/entity/player/AttackEntityEvent.java b/src/main/java/net/minecraftforge/event/entity/player/AttackEntityEvent.java index 00235f280..f49171103 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/AttackEntityEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/AttackEntityEvent.java @@ -1,8 +1,8 @@ package net.minecraftforge.event.entity.player; +import cpw.mods.fml.common.eventhandler.Cancelable; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; -import net.minecraftforge.event.Cancelable; @Cancelable public class AttackEntityEvent extends PlayerEvent 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 e34b59dc9..1c1f9353a 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/BonemealEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/BonemealEvent.java @@ -1,9 +1,9 @@ package net.minecraftforge.event.entity.player; +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; -import net.minecraftforge.event.Cancelable; -import net.minecraftforge.event.Event; @Cancelable @Event.HasResult diff --git a/src/main/java/net/minecraftforge/event/entity/player/EntityInteractEvent.java b/src/main/java/net/minecraftforge/event/entity/player/EntityInteractEvent.java index 845584576..0c750f9c5 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/EntityInteractEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/EntityInteractEvent.java @@ -1,8 +1,8 @@ package net.minecraftforge.event.entity.player; +import cpw.mods.fml.common.eventhandler.Cancelable; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; -import net.minecraftforge.event.Cancelable; @Cancelable public class EntityInteractEvent extends PlayerEvent diff --git a/src/main/java/net/minecraftforge/event/entity/player/EntityItemPickupEvent.java b/src/main/java/net/minecraftforge/event/entity/player/EntityItemPickupEvent.java index e9004f5bd..a14e7a0be 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/EntityItemPickupEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/EntityItemPickupEvent.java @@ -1,10 +1,10 @@ package net.minecraftforge.event.entity.player; +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; -import net.minecraftforge.event.Cancelable; -import net.minecraftforge.event.Event; @Cancelable @Event.HasResult diff --git a/src/main/java/net/minecraftforge/event/entity/player/FillBucketEvent.java b/src/main/java/net/minecraftforge/event/entity/player/FillBucketEvent.java index 260353197..50dc45902 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/FillBucketEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/FillBucketEvent.java @@ -1,11 +1,11 @@ package net.minecraftforge.event.entity.player; +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; -import net.minecraftforge.event.Cancelable; -import net.minecraftforge.event.Event; @Cancelable @Event.HasResult diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerDropsEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerDropsEvent.java index 395c1b3ba..6181b70d4 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerDropsEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerDropsEvent.java @@ -2,11 +2,12 @@ package net.minecraftforge.event.entity.player; import java.util.ArrayList; +import cpw.mods.fml.common.eventhandler.Cancelable; + import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.DamageSource; -import net.minecraftforge.event.Cancelable; import net.minecraftforge.event.entity.living.LivingDropsEvent; /** diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerEvent.java index 8100318de..8a06fdb69 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerEvent.java @@ -1,9 +1,9 @@ package net.minecraftforge.event.entity.player; +import cpw.mods.fml.common.eventhandler.Cancelable; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; -import net.minecraftforge.event.Cancelable; import net.minecraftforge.event.entity.living.LivingEvent; public class PlayerEvent extends LivingEvent diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerFlyableFallEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerFlyableFallEvent.java index c250c077d..517471bc4 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerFlyableFallEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerFlyableFallEvent.java @@ -1,7 +1,7 @@ package net.minecraftforge.event.entity.player; +import cpw.mods.fml.common.eventhandler.Cancelable; import net.minecraft.entity.player.EntityPlayer; -import net.minecraftforge.event.Cancelable; /** * Occurs when a player falls, but is able to fly. Doesn't need to be cancelable, this is mainly for notification purposes. 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 31c1102df..465ae4637 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java @@ -1,11 +1,11 @@ package net.minecraftforge.event.entity.player; +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; -import net.minecraftforge.event.Cancelable; -import net.minecraftforge.event.Event; -import static net.minecraftforge.event.Event.Result; -import static net.minecraftforge.event.Event.Result.*; +import static cpw.mods.fml.common.eventhandler.Event.Result; +import static cpw.mods.fml.common.eventhandler.Event.Result.*; @Cancelable public class PlayerInteractEvent extends PlayerEvent diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerOpenContainerEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerOpenContainerEvent.java index 6ea781c1c..dde290ea5 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerOpenContainerEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerOpenContainerEvent.java @@ -1,8 +1,8 @@ package net.minecraftforge.event.entity.player; +import cpw.mods.fml.common.eventhandler.Event.HasResult; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; -import net.minecraftforge.event.Event.HasResult; @HasResult public class PlayerOpenContainerEvent extends PlayerEvent diff --git a/src/main/java/net/minecraftforge/event/entity/player/UseHoeEvent.java b/src/main/java/net/minecraftforge/event/entity/player/UseHoeEvent.java index 9a16da635..79a6f47c1 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/UseHoeEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/UseHoeEvent.java @@ -1,10 +1,10 @@ package net.minecraftforge.event.entity.player; +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import net.minecraftforge.event.Cancelable; -import net.minecraftforge.event.Event; @Cancelable @Event.HasResult diff --git a/src/main/java/net/minecraftforge/event/terraingen/BiomeEvent.java b/src/main/java/net/minecraftforge/event/terraingen/BiomeEvent.java index d5eb6eea4..8487dfbb9 100644 --- a/src/main/java/net/minecraftforge/event/terraingen/BiomeEvent.java +++ b/src/main/java/net/minecraftforge/event/terraingen/BiomeEvent.java @@ -1,6 +1,7 @@ package net.minecraftforge.event.terraingen; import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.eventhandler.Event; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.world.biome.BiomeDecorator; diff --git a/src/main/java/net/minecraftforge/event/terraingen/ChunkProviderEvent.java b/src/main/java/net/minecraftforge/event/terraingen/ChunkProviderEvent.java index 52b31baeb..98dcdc967 100644 --- a/src/main/java/net/minecraftforge/event/terraingen/ChunkProviderEvent.java +++ b/src/main/java/net/minecraftforge/event/terraingen/ChunkProviderEvent.java @@ -1,5 +1,6 @@ package net.minecraftforge.event.terraingen; +import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.chunk.IChunkProvider; import net.minecraftforge.event.*; diff --git a/src/main/java/net/minecraftforge/event/terraingen/DecorateBiomeEvent.java b/src/main/java/net/minecraftforge/event/terraingen/DecorateBiomeEvent.java index af9d6cfed..5e0c4a864 100644 --- a/src/main/java/net/minecraftforge/event/terraingen/DecorateBiomeEvent.java +++ b/src/main/java/net/minecraftforge/event/terraingen/DecorateBiomeEvent.java @@ -2,6 +2,8 @@ package net.minecraftforge.event.terraingen; import java.util.Random; +import cpw.mods.fml.common.eventhandler.Event; + import net.minecraft.world.World; import net.minecraftforge.event.*; diff --git a/src/main/java/net/minecraftforge/event/terraingen/InitMapGenEvent.java b/src/main/java/net/minecraftforge/event/terraingen/InitMapGenEvent.java index 2aab3eae4..30c350f70 100644 --- a/src/main/java/net/minecraftforge/event/terraingen/InitMapGenEvent.java +++ b/src/main/java/net/minecraftforge/event/terraingen/InitMapGenEvent.java @@ -1,5 +1,6 @@ package net.minecraftforge.event.terraingen; +import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.world.gen.MapGenBase; import net.minecraftforge.event.*; diff --git a/src/main/java/net/minecraftforge/event/terraingen/OreGenEvent.java b/src/main/java/net/minecraftforge/event/terraingen/OreGenEvent.java index 7d9835180..a22580571 100644 --- a/src/main/java/net/minecraftforge/event/terraingen/OreGenEvent.java +++ b/src/main/java/net/minecraftforge/event/terraingen/OreGenEvent.java @@ -2,6 +2,8 @@ package net.minecraftforge.event.terraingen; import java.util.Random; +import cpw.mods.fml.common.eventhandler.Event; + import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; import net.minecraftforge.event.*; diff --git a/src/main/java/net/minecraftforge/event/terraingen/SaplingGrowTreeEvent.java b/src/main/java/net/minecraftforge/event/terraingen/SaplingGrowTreeEvent.java index 668fc2968..b054981c1 100644 --- a/src/main/java/net/minecraftforge/event/terraingen/SaplingGrowTreeEvent.java +++ b/src/main/java/net/minecraftforge/event/terraingen/SaplingGrowTreeEvent.java @@ -2,8 +2,9 @@ package net.minecraftforge.event.terraingen; import java.util.Random; +import cpw.mods.fml.common.eventhandler.Event.HasResult; + import net.minecraft.world.World; -import net.minecraftforge.event.Event.HasResult; import net.minecraftforge.event.world.WorldEvent; /** diff --git a/src/main/java/net/minecraftforge/event/terraingen/TerrainGen.java b/src/main/java/net/minecraftforge/event/terraingen/TerrainGen.java index 8b86d01a8..8924f9b6a 100644 --- a/src/main/java/net/minecraftforge/event/terraingen/TerrainGen.java +++ b/src/main/java/net/minecraftforge/event/terraingen/TerrainGen.java @@ -2,13 +2,14 @@ package net.minecraftforge.event.terraingen; import java.util.Random; +import cpw.mods.fml.common.eventhandler.Event.*; + import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.MapGenBase; import net.minecraft.world.gen.NoiseGeneratorOctaves; import net.minecraft.world.gen.feature.WorldGenerator; import net.minecraftforge.common.*; -import net.minecraftforge.event.Event.*; import net.minecraftforge.event.terraingen.DecorateBiomeEvent.*; import net.minecraftforge.event.terraingen.OreGenEvent.*; import net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.*; diff --git a/src/main/java/net/minecraftforge/event/terraingen/WorldTypeEvent.java b/src/main/java/net/minecraftforge/event/terraingen/WorldTypeEvent.java index 9f2fe1a96..3c22fd62c 100644 --- a/src/main/java/net/minecraftforge/event/terraingen/WorldTypeEvent.java +++ b/src/main/java/net/minecraftforge/event/terraingen/WorldTypeEvent.java @@ -1,8 +1,8 @@ package net.minecraftforge.event.terraingen; +import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.world.gen.layer.GenLayer; import net.minecraft.world.WorldType; -import net.minecraftforge.event.Event; public class WorldTypeEvent extends Event { diff --git a/src/main/java/net/minecraftforge/event/world/BlockEvent.java b/src/main/java/net/minecraftforge/event/world/BlockEvent.java index f94c7c75e..42a4fab15 100644 --- a/src/main/java/net/minecraftforge/event/world/BlockEvent.java +++ b/src/main/java/net/minecraftforge/event/world/BlockEvent.java @@ -2,13 +2,14 @@ package net.minecraftforge.event.world; import java.util.ArrayList; +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; + import net.minecraft.block.Block; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import net.minecraftforge.event.Cancelable; -import net.minecraftforge.event.Event; public class BlockEvent extends Event { public final int x; diff --git a/src/main/java/net/minecraftforge/event/world/ChunkWatchEvent.java b/src/main/java/net/minecraftforge/event/world/ChunkWatchEvent.java index f912975f5..0e9bfd1cb 100644 --- a/src/main/java/net/minecraftforge/event/world/ChunkWatchEvent.java +++ b/src/main/java/net/minecraftforge/event/world/ChunkWatchEvent.java @@ -1,10 +1,10 @@ package net.minecraftforge.event.world; +import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.server.management.PlayerInstance; import net.minecraft.world.WorldServer; -import net.minecraftforge.event.Event; public class ChunkWatchEvent extends Event { diff --git a/src/main/java/net/minecraftforge/event/world/WorldEvent.java b/src/main/java/net/minecraftforge/event/world/WorldEvent.java index 6ebbffbdd..f46c3f4dd 100644 --- a/src/main/java/net/minecraftforge/event/world/WorldEvent.java +++ b/src/main/java/net/minecraftforge/event/world/WorldEvent.java @@ -3,11 +3,12 @@ package net.minecraftforge.event.world; import java.util.ArrayList; import java.util.List; +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; + import net.minecraft.entity.EnumCreatureType; import net.minecraft.world.World; import net.minecraft.world.biome.SpawnListEntry; -import net.minecraftforge.event.Cancelable; -import net.minecraftforge.event.Event; public class WorldEvent extends Event { diff --git a/src/main/java/net/minecraftforge/fluids/FluidContainerRegistry.java b/src/main/java/net/minecraftforge/fluids/FluidContainerRegistry.java index 42835cfa6..99ed07456 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidContainerRegistry.java +++ b/src/main/java/net/minecraftforge/fluids/FluidContainerRegistry.java @@ -8,11 +8,12 @@ import java.util.List; import java.util.Map; import java.util.Set; +import cpw.mods.fml.common.eventhandler.Event; + import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.Event; /** * Register simple items that contain fluids here. Useful for buckets, bottles, and things that have diff --git a/src/main/java/net/minecraftforge/fluids/FluidEvent.java b/src/main/java/net/minecraftforge/fluids/FluidEvent.java index c9cff4ff5..ec8b91514 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidEvent.java +++ b/src/main/java/net/minecraftforge/fluids/FluidEvent.java @@ -1,9 +1,9 @@ package net.minecraftforge.fluids; +import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.Event; public class FluidEvent extends Event { diff --git a/src/main/java/net/minecraftforge/fluids/FluidRegistry.java b/src/main/java/net/minecraftforge/fluids/FluidRegistry.java index c6e24cc74..26fe20b47 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidRegistry.java +++ b/src/main/java/net/minecraftforge/fluids/FluidRegistry.java @@ -6,12 +6,13 @@ import java.util.Map; import net.minecraft.block.Block; import net.minecraft.util.StatCollector; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.Event; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import com.google.common.collect.ImmutableMap; +import cpw.mods.fml.common.eventhandler.Event; + /** * Handles Fluid registrations. Fluids MUST be registered in order to function. * diff --git a/src/main/java/net/minecraftforge/oredict/OreDictionary.java b/src/main/java/net/minecraftforge/oredict/OreDictionary.java index cf2d7cb9b..2424c4cde 100644 --- a/src/main/java/net/minecraftforge/oredict/OreDictionary.java +++ b/src/main/java/net/minecraftforge/oredict/OreDictionary.java @@ -7,6 +7,8 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import cpw.mods.fml.common.eventhandler.Event; + import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -17,7 +19,6 @@ import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.ShapedRecipes; import net.minecraft.item.crafting.ShapelessRecipes; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.Event; public class OreDictionary { diff --git a/src/main/java/net/minecraftforge/transformers/EventTransformer.java b/src/main/java/net/minecraftforge/transformers/EventTransformer.java deleted file mode 100644 index d3f8b34b1..000000000 --- a/src/main/java/net/minecraftforge/transformers/EventTransformer.java +++ /dev/null @@ -1,164 +0,0 @@ -package net.minecraftforge.transformers; - -import java.util.List; - -import net.minecraft.launchwrapper.IClassTransformer; -import net.minecraftforge.event.Event; -import net.minecraftforge.event.ListenerList; - -import org.objectweb.asm.*; -import org.objectweb.asm.tree.*; -import static org.objectweb.asm.Opcodes.*; -import static org.objectweb.asm.Type.*; -import static org.objectweb.asm.ClassWriter.*; - -public class EventTransformer implements IClassTransformer -{ - public EventTransformer() - { - } - - @Override - public byte[] transform(String name, String transformedName, byte[] bytes) - { - if (bytes == null || name.equals("net.minecraftforge.event.Event") || name.startsWith("net.minecraft.") || name.indexOf('.') == -1) - { - return bytes; - } - ClassReader cr = new ClassReader(bytes); - ClassNode classNode = new ClassNode(); - cr.accept(classNode, 0); - - try - { - if (buildEvents(classNode)) - { - ClassWriter cw = new ClassWriter(COMPUTE_MAXS | COMPUTE_FRAMES); - classNode.accept(cw); - return cw.toByteArray(); - } - return bytes; - } - catch (ClassNotFoundException ex) - { - // Discard silently- it's just noise - } - catch (Exception e) - { - e.printStackTrace(); - } - - return bytes; - } - - @SuppressWarnings("unchecked") - private boolean buildEvents(ClassNode classNode) throws Exception - { - Class parent = this.getClass().getClassLoader().loadClass(classNode.superName.replace('/', '.')); - if (!Event.class.isAssignableFrom(parent)) - { - return false; - } - - boolean hasSetup = false; - boolean hasGetListenerList = false; - boolean hasDefaultCtr = false; - - Class listenerListClazz = Class.forName("net.minecraftforge.event.ListenerList", false, getClass().getClassLoader()); - Type tList = Type.getType(listenerListClazz); - - for (MethodNode method : (List)classNode.methods) - { - if (method.name.equals("setup") && - method.desc.equals(Type.getMethodDescriptor(VOID_TYPE)) && - (method.access & ACC_PROTECTED) == ACC_PROTECTED) - { - hasSetup = true; - } - if (method.name.equals("getListenerList") && - method.desc.equals(Type.getMethodDescriptor(tList)) && - (method.access & ACC_PUBLIC) == ACC_PUBLIC) - { - hasGetListenerList = true; - } - if (method.name.equals("") && - method.desc.equals(Type.getMethodDescriptor(VOID_TYPE))) - { - hasDefaultCtr = true; - } - } - - if (hasSetup) - { - if (!hasGetListenerList) - { - throw new RuntimeException("Event class defines setup() but does not define getListenerList! " + classNode.name); - } - else - { - return false; - } - } - - Type tSuper = Type.getType(classNode.superName); - - //Add private static ListenerList LISTENER_LIST - classNode.fields.add(new FieldNode(ACC_PRIVATE | ACC_STATIC, "LISTENER_LIST", tList.getDescriptor(), null, null)); - - /*Add: - * public () - * { - * super(); - * } - */ - MethodNode method = new MethodNode(ASM4, ACC_PUBLIC, "", getMethodDescriptor(VOID_TYPE), null, null); - method.instructions.add(new VarInsnNode(ALOAD, 0)); - method.instructions.add(new MethodInsnNode(INVOKESPECIAL, tSuper.getInternalName(), "", getMethodDescriptor(VOID_TYPE))); - method.instructions.add(new InsnNode(RETURN)); - if (!hasDefaultCtr) - { - classNode.methods.add(method); - } - - /*Add: - * protected void setup() - * { - * super.setup(); - * if (LISTENER_LIST != NULL) - * { - * return; - * } - * LISTENER_LIST = new ListenerList(super.getListenerList()); - * } - */ - method = new MethodNode(ASM4, ACC_PROTECTED, "setup", getMethodDescriptor(VOID_TYPE), null, null); - method.instructions.add(new VarInsnNode(ALOAD, 0)); - method.instructions.add(new MethodInsnNode(INVOKESPECIAL, tSuper.getInternalName(), "setup", getMethodDescriptor(VOID_TYPE))); - method.instructions.add(new FieldInsnNode(GETSTATIC, classNode.name, "LISTENER_LIST", tList.getDescriptor())); - LabelNode initLisitener = new LabelNode(); - method.instructions.add(new JumpInsnNode(IFNULL, initLisitener)); - method.instructions.add(new InsnNode(RETURN)); - method.instructions.add(initLisitener); - method.instructions.add(new FrameNode(F_SAME, 0, null, 0, null)); - method.instructions.add(new TypeInsnNode(NEW, tList.getInternalName())); - method.instructions.add(new InsnNode(DUP)); - method.instructions.add(new VarInsnNode(ALOAD, 0)); - method.instructions.add(new MethodInsnNode(INVOKESPECIAL, tSuper.getInternalName(), "getListenerList", getMethodDescriptor(tList))); - method.instructions.add(new MethodInsnNode(INVOKESPECIAL, tList.getInternalName(), "", getMethodDescriptor(VOID_TYPE, tList))); - method.instructions.add(new FieldInsnNode(PUTSTATIC, classNode.name, "LISTENER_LIST", tList.getDescriptor())); - method.instructions.add(new InsnNode(RETURN)); - classNode.methods.add(method); - - /*Add: - * public ListenerList getListenerList() - * { - * return this.LISTENER_LIST; - * } - */ - method = new MethodNode(ASM4, ACC_PUBLIC, "getListenerList", getMethodDescriptor(tList), null, null); - method.instructions.add(new FieldInsnNode(GETSTATIC, classNode.name, "LISTENER_LIST", tList.getDescriptor())); - method.instructions.add(new InsnNode(ARETURN)); - classNode.methods.add(method); - return true; - } -}