diff --git a/.gitignore b/.gitignore index 429a832e0..cc81d5d54 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ changelog.txt /patches_old_bak/ *.py *.7z +/logs/ diff --git a/src/main/java/net/minecraftforge/client/ForgeHooksClient.java b/src/main/java/net/minecraftforge/client/ForgeHooksClient.java index 0a24c5ed5..60db7b275 100644 --- a/src/main/java/net/minecraftforge/client/ForgeHooksClient.java +++ b/src/main/java/net/minecraftforge/client/ForgeHooksClient.java @@ -20,8 +20,10 @@ package net.minecraftforge.client; import static net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType.BOSSINFO; -import static net.minecraftforge.common.ForgeVersion.Status.BETA; -import static net.minecraftforge.common.ForgeVersion.Status.BETA_OUTDATED; +import static net.minecraftforge.fml.VersionChecker.Status.BETA; +import static net.minecraftforge.fml.VersionChecker.Status.BETA_OUTDATED; +import static org.lwjgl.opengl.GL11.*; +import static org.lwjgl.opengl.GL20.*; import java.awt.image.BufferedImage; import java.io.File; @@ -125,22 +127,19 @@ import net.minecraftforge.client.resource.SelectiveReloadStateHandler; import net.minecraftforge.client.resource.VanillaResourceType; import net.minecraftforge.common.ForgeModContainer; import net.minecraftforge.common.ForgeVersion; -import net.minecraftforge.common.ForgeVersion.Status; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.model.IModelPart; import net.minecraftforge.common.model.ITransformation; import net.minecraftforge.common.model.TRSRTransformation; +import net.minecraftforge.fml.VersionChecker; import net.minecraftforge.fml.client.FMLClientHandler; import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.common.FMLLog; import org.apache.commons.lang3.tuple.Pair; import org.lwjgl.BufferUtils; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL20; - -import java.util.function.Predicate; +import java.util.Optional; import com.google.common.collect.Maps; public class ForgeHooksClient @@ -167,7 +166,7 @@ public class ForgeHooksClient if (block != null && block.isBed(state, world, pos, entity)) { - GL11.glRotatef((float)(block.getBedDirection(state, world, pos).getHorizontalIndex() * 90), 0.0F, 1.0F, 0.0F); + glRotatef((float)(block.getBedDirection(state, world, pos).getHorizontalIndex() * 90), 0.0F, 1.0F, 0.0F); } } @@ -330,7 +329,7 @@ public class ForgeHooksClient private static int updatescrollcounter = 0; public static String renderMainMenu(GuiMainMenu gui, FontRenderer font, int width, int height, String splashText) { - Status status = ForgeVersion.getStatus(); + VersionChecker.Status status = ForgeVersion.getStatus(); if (status == BETA || status == BETA_OUTDATED) { // render a warning at the top of the screen, @@ -400,6 +399,29 @@ public class ForgeHooksClient modelLoader.onPostBakeEvent(modelRegistry); } + @SuppressWarnings("deprecation") + public static Matrix4f getMatrix(net.minecraft.client.renderer.block.model.ItemTransformVec3f transform) + { + javax.vecmath.Matrix4f m = new javax.vecmath.Matrix4f(), t = new javax.vecmath.Matrix4f(); + m.setIdentity(); + m.setTranslation(TRSRTransformation.toVecmath(transform.translation)); + t.setIdentity(); + t.rotY(transform.rotation.y); + m.mul(t); + t.setIdentity(); + t.rotX(transform.rotation.x); + m.mul(t); + t.setIdentity(); + t.rotZ(transform.rotation.z); + m.mul(t); + t.setIdentity(); + t.m00 = transform.scale.x; + t.m11 = transform.scale.y; + t.m22 = transform.scale.z; + m.mul(t); + return m; + } + private static final Matrix4f flipX; static { flipX = new Matrix4f(); @@ -436,7 +458,7 @@ public class ForgeHooksClient matrixBuf.put(t); } matrixBuf.flip(); - GL11.glMultMatrix(matrixBuf); + glMultMatrix(matrixBuf); } // moved and expanded from WorldVertexBufferUploader.draw @@ -450,32 +472,32 @@ public class ForgeHooksClient switch(attrType) { case POSITION: - GlStateManager.glVertexPointer(count, constant, stride, buffer); - GlStateManager.glEnableClientState(GL11.GL_VERTEX_ARRAY); + glVertexPointer(count, constant, stride, buffer); + glEnableClientState(GL_VERTEX_ARRAY); break; case NORMAL: if(count != 3) { throw new IllegalArgumentException("Normal attribute should have the size 3: " + attr); } - GlStateManager.glNormalPointer(constant, stride, buffer); - GlStateManager.glEnableClientState(GL11.GL_NORMAL_ARRAY); + glNormalPointer(constant, stride, buffer); + glEnableClientState(GL_NORMAL_ARRAY); break; case COLOR: - GlStateManager.glColorPointer(count, constant, stride, buffer); - GlStateManager.glEnableClientState(GL11.GL_COLOR_ARRAY); + glColorPointer(count, constant, stride, buffer); + glEnableClientState(GL_COLOR_ARRAY); break; case UV: OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit + attr.getIndex()); - GlStateManager.glTexCoordPointer(count, constant, stride, buffer); - GlStateManager.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); + glTexCoordPointer(count, constant, stride, buffer); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit); break; case PADDING: break; case GENERIC: - GL20.glEnableVertexAttribArray(attr.getIndex()); - GL20.glVertexAttribPointer(attr.getIndex(), count, constant, false, stride, buffer); + glEnableVertexAttribArray(attr.getIndex()); + glVertexAttribPointer(attr.getIndex(), count, constant, false, stride, buffer); default: FMLLog.log.fatal("Unimplemented vanilla attribute upload: {}", attrType.getDisplayName()); } @@ -487,25 +509,25 @@ public class ForgeHooksClient switch(attrType) { case POSITION: - GlStateManager.glDisableClientState(GL11.GL_VERTEX_ARRAY); + glDisableClientState(GL_VERTEX_ARRAY); break; case NORMAL: - GlStateManager.glDisableClientState(GL11.GL_NORMAL_ARRAY); + glDisableClientState(GL_NORMAL_ARRAY); break; case COLOR: - GlStateManager.glDisableClientState(GL11.GL_COLOR_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); // is this really needed? GlStateManager.resetColor(); break; case UV: OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit + attr.getIndex()); - GlStateManager.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit); break; case PADDING: break; case GENERIC: - GL20.glDisableVertexAttribArray(attr.getIndex()); + glDisableVertexAttribArray(attr.getIndex()); default: FMLLog.log.fatal("Unimplemented vanilla attribute upload: {}", attrType.getDisplayName()); } @@ -570,15 +592,6 @@ public class ForgeHooksClient } } - /** - * @deprecated Will be removed as soon as possible. See {@link Item#getTileEntityItemStackRenderer()}. - */ - @Deprecated - public static void registerTESRItemStack(Item item, int metadata, Class TileClass) - { - tileItemMap.put(Pair.of(item, metadata), TileClass); - } - /** * internal, relies on fixed format of FaceBakery */ @@ -742,9 +755,9 @@ public class ForgeHooksClient @SuppressWarnings("deprecation") public static Pair handlePerspective(IBakedModel model, ItemCameraTransforms.TransformType type) { - TRSRTransformation tr = TRSRTransformation.from(model.getItemCameraTransforms().getTransform(type)); + TRSRTransformation tr = new TRSRTransformation(model.getItemCameraTransforms().getTransform(type)); Matrix4f mat = null; - if (!tr.isIdentity()) mat = tr.getMatrix(); + if(!tr.equals(TRSRTransformation.identity())) mat = tr.getMatrix(); return Pair.of(model, mat); } diff --git a/src/main/java/net/minecraftforge/client/event/ClientChatEvent.java b/src/main/java/net/minecraftforge/client/event/ClientChatEvent.java index 3bced1328..715f24ff7 100644 --- a/src/main/java/net/minecraftforge/client/event/ClientChatEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ClientChatEvent.java @@ -20,8 +20,8 @@ package net.minecraftforge.client.event; import com.google.common.base.Strings; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.common.MinecraftForge; import net.minecraft.client.gui.GuiScreen; diff --git a/src/main/java/net/minecraftforge/client/event/ClientChatReceivedEvent.java b/src/main/java/net/minecraftforge/client/event/ClientChatReceivedEvent.java index cbb3928d7..7bda8e0dc 100644 --- a/src/main/java/net/minecraftforge/client/event/ClientChatReceivedEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ClientChatReceivedEvent.java @@ -21,11 +21,11 @@ package net.minecraftforge.client.event; import net.minecraft.util.text.ChatType; import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; -@Cancelable -public class ClientChatReceivedEvent extends Event +@net.minecraftforge.eventbus.api.Cancelable +public class ClientChatReceivedEvent extends net.minecraftforge.eventbus.api.Event { private ITextComponent message; private final ChatType type; diff --git a/src/main/java/net/minecraftforge/client/event/ColorHandlerEvent.java b/src/main/java/net/minecraftforge/client/event/ColorHandlerEvent.java index 412779d1a..d7a4abb4a 100644 --- a/src/main/java/net/minecraftforge/client/event/ColorHandlerEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ColorHandlerEvent.java @@ -21,7 +21,7 @@ package net.minecraftforge.client.event; import net.minecraft.client.renderer.color.BlockColors; import net.minecraft.client.renderer.color.ItemColors; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Event; /** * Use these events to register block/item diff --git a/src/main/java/net/minecraftforge/client/event/DrawBlockHighlightEvent.java b/src/main/java/net/minecraftforge/client/event/DrawBlockHighlightEvent.java index 3682402b4..f508b16f7 100644 --- a/src/main/java/net/minecraftforge/client/event/DrawBlockHighlightEvent.java +++ b/src/main/java/net/minecraftforge/client/event/DrawBlockHighlightEvent.java @@ -19,8 +19,8 @@ package net.minecraftforge.client.event; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.math.RayTraceResult; import net.minecraft.client.renderer.RenderGlobal; diff --git a/src/main/java/net/minecraftforge/client/event/EntityViewRenderEvent.java b/src/main/java/net/minecraftforge/client/event/EntityViewRenderEvent.java index df3f5dfe2..4a1d2faa2 100644 --- a/src/main/java/net/minecraftforge/client/event/EntityViewRenderEvent.java +++ b/src/main/java/net/minecraftforge/client/event/EntityViewRenderEvent.java @@ -22,14 +22,14 @@ package net.minecraftforge.client.event; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.entity.Entity; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; /** * Event that hooks into EntityRenderer, allowing any feature to customize visual attributes * the player sees. */ -public abstract class EntityViewRenderEvent extends Event +public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.api.Event { private final EntityRenderer renderer; private final Entity entity; diff --git a/src/main/java/net/minecraftforge/client/event/FOVUpdateEvent.java b/src/main/java/net/minecraftforge/client/event/FOVUpdateEvent.java index 9c1f98862..bf1c86893 100644 --- a/src/main/java/net/minecraftforge/client/event/FOVUpdateEvent.java +++ b/src/main/java/net/minecraftforge/client/event/FOVUpdateEvent.java @@ -20,7 +20,7 @@ package net.minecraftforge.client.event; import net.minecraft.entity.player.EntityPlayer; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Event; /** * Author: MachineMuse (Claire Semple) diff --git a/src/main/java/net/minecraftforge/client/event/GuiContainerEvent.java b/src/main/java/net/minecraftforge/client/event/GuiContainerEvent.java index 036736170..0298ecf4c 100644 --- a/src/main/java/net/minecraftforge/client/event/GuiContainerEvent.java +++ b/src/main/java/net/minecraftforge/client/event/GuiContainerEvent.java @@ -20,7 +20,7 @@ package net.minecraftforge.client.event; import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Event; /** * Event class for handling GuiContainer specific events. diff --git a/src/main/java/net/minecraftforge/client/event/GuiOpenEvent.java b/src/main/java/net/minecraftforge/client/event/GuiOpenEvent.java index c8f9263a8..5139ed7af 100644 --- a/src/main/java/net/minecraftforge/client/event/GuiOpenEvent.java +++ b/src/main/java/net/minecraftforge/client/event/GuiOpenEvent.java @@ -19,8 +19,8 @@ package net.minecraftforge.client.event; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; import net.minecraft.client.gui.GuiScreen; /** @@ -30,8 +30,8 @@ import net.minecraft.client.gui.GuiScreen; * * @author jk-5 */ -@Cancelable -public class GuiOpenEvent extends Event +@net.minecraftforge.eventbus.api.Cancelable +public class GuiOpenEvent extends net.minecraftforge.eventbus.api.Event { private GuiScreen gui; public GuiOpenEvent(GuiScreen gui) diff --git a/src/main/java/net/minecraftforge/client/event/GuiScreenEvent.java b/src/main/java/net/minecraftforge/client/event/GuiScreenEvent.java index 4e75bd4e0..14daae971 100644 --- a/src/main/java/net/minecraftforge/client/event/GuiScreenEvent.java +++ b/src/main/java/net/minecraftforge/client/event/GuiScreenEvent.java @@ -30,8 +30,8 @@ import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; diff --git a/src/main/java/net/minecraftforge/client/event/ModelBakeEvent.java b/src/main/java/net/minecraftforge/client/event/ModelBakeEvent.java index 22201eccb..15ca47c21 100644 --- a/src/main/java/net/minecraftforge/client/event/ModelBakeEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ModelBakeEvent.java @@ -24,14 +24,14 @@ import net.minecraft.client.renderer.block.model.ModelManager; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.util.registry.IRegistry; import net.minecraftforge.client.model.ModelLoader; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Event; /** * Fired when the ModelManager is notified of the resource manager reloading. * Called after model registry is setup, but before it's passed to BlockModelShapes. */ // TODO: try to merge with ICustomModelLoader -public class ModelBakeEvent extends Event +public class ModelBakeEvent extends net.minecraftforge.eventbus.api.Event { private final ModelManager modelManager; private final IRegistry modelRegistry; diff --git a/src/main/java/net/minecraftforge/client/event/ModelRegistryEvent.java b/src/main/java/net/minecraftforge/client/event/ModelRegistryEvent.java index 03dd5fa4f..2563dda6d 100644 --- a/src/main/java/net/minecraftforge/client/event/ModelRegistryEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ModelRegistryEvent.java @@ -19,7 +19,7 @@ package net.minecraftforge.client.event; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fml.common.eventhandler.IContextSetter; /** diff --git a/src/main/java/net/minecraftforge/client/event/MouseEvent.java b/src/main/java/net/minecraftforge/client/event/MouseEvent.java index 8ce64d8a5..ed23487b9 100644 --- a/src/main/java/net/minecraftforge/client/event/MouseEvent.java +++ b/src/main/java/net/minecraftforge/client/event/MouseEvent.java @@ -21,15 +21,15 @@ package net.minecraftforge.client.event; import org.lwjgl.input.Mouse; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; /** * Author: MachineMuse (Claire Semple) * Created: 2:46 PM, 9/4/13 */ -@Cancelable -public class MouseEvent extends Event +@net.minecraftforge.eventbus.api.Cancelable +public class MouseEvent extends net.minecraftforge.eventbus.api.Event { private final int x; private final int y; diff --git a/src/main/java/net/minecraftforge/client/event/PlayerSPPushOutOfBlocksEvent.java b/src/main/java/net/minecraftforge/client/event/PlayerSPPushOutOfBlocksEvent.java index b29222846..4c42d135c 100644 --- a/src/main/java/net/minecraftforge/client/event/PlayerSPPushOutOfBlocksEvent.java +++ b/src/main/java/net/minecraftforge/client/event/PlayerSPPushOutOfBlocksEvent.java @@ -22,7 +22,7 @@ package net.minecraftforge.client.event; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.event.entity.player.PlayerEvent; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; import javax.annotation.Nonnull; @@ -31,7 +31,7 @@ import javax.annotation.Nonnull; * * Cancelling the event will prevent pushOutOfBlocks from being called. */ -@Cancelable +@net.minecraftforge.eventbus.api.Cancelable public class PlayerSPPushOutOfBlocksEvent extends PlayerEvent { private AxisAlignedBB entityBoundingBox; diff --git a/src/main/java/net/minecraftforge/client/event/RenderBlockOverlayEvent.java b/src/main/java/net/minecraftforge/client/event/RenderBlockOverlayEvent.java index e05897678..9a4b22594 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderBlockOverlayEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderBlockOverlayEvent.java @@ -23,14 +23,15 @@ import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.math.BlockPos; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; /** * Called when a block's texture is going to be overlaid on the player's HUD. Cancel this event to prevent the overlay. */ -@Cancelable -public class RenderBlockOverlayEvent extends Event { +@net.minecraftforge.eventbus.api.Cancelable +public class RenderBlockOverlayEvent extends net.minecraftforge.eventbus.api.Event +{ public static enum OverlayType { FIRE, BLOCK, WATER diff --git a/src/main/java/net/minecraftforge/client/event/RenderGameOverlayEvent.java b/src/main/java/net/minecraftforge/client/event/RenderGameOverlayEvent.java index 5bd05b712..cfea6b78c 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderGameOverlayEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderGameOverlayEvent.java @@ -21,12 +21,12 @@ package net.minecraftforge.client.event; import java.util.ArrayList; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; import net.minecraft.client.gui.BossInfoClient; import net.minecraft.client.gui.ScaledResolution; -@Cancelable +@net.minecraftforge.eventbus.api.Cancelable public class RenderGameOverlayEvent extends Event { public float getPartialTicks() diff --git a/src/main/java/net/minecraftforge/client/event/RenderHandEvent.java b/src/main/java/net/minecraftforge/client/event/RenderHandEvent.java index 0905b908d..df36de9a5 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderHandEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderHandEvent.java @@ -19,8 +19,8 @@ package net.minecraftforge.client.event; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; import net.minecraft.client.renderer.RenderGlobal; /** @@ -30,8 +30,8 @@ import net.minecraft.client.renderer.RenderGlobal; * and prevents {@link RenderSpecificHandEvent} from firing. * TODO This may get merged in 11 with RenderSpecificHandEvent to make a generic hand rendering */ -@Cancelable -public class RenderHandEvent extends Event +@net.minecraftforge.eventbus.api.Cancelable +public class RenderHandEvent extends net.minecraftforge.eventbus.api.Event { private final RenderGlobal context; private final float partialTicks; diff --git a/src/main/java/net/minecraftforge/client/event/RenderItemInFrameEvent.java b/src/main/java/net/minecraftforge/client/event/RenderItemInFrameEvent.java index 8c11c7c9f..b3927260b 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderItemInFrameEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderItemInFrameEvent.java @@ -22,8 +22,8 @@ package net.minecraftforge.client.event; import net.minecraft.client.renderer.entity.RenderItemFrame; import net.minecraft.entity.item.EntityItemFrame; import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; import javax.annotation.Nonnull; @@ -33,7 +33,7 @@ import javax.annotation.Nonnull; * You can set canceled to do no further vanilla processing. */ @Cancelable -public class RenderItemInFrameEvent extends Event +public class RenderItemInFrameEvent extends net.minecraftforge.eventbus.api.Event { private final ItemStack item; private final EntityItemFrame entityItemFrame; diff --git a/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java b/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java index 8642e6527..b06ac1d95 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java @@ -19,12 +19,12 @@ package net.minecraftforge.client.event; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; import net.minecraft.client.renderer.entity.RenderLivingBase; import net.minecraft.entity.EntityLivingBase; -public abstract class RenderLivingEvent extends Event +public abstract class RenderLivingEvent extends net.minecraftforge.eventbus.api.Event { private final EntityLivingBase entity; private final RenderLivingBase renderer; @@ -56,7 +56,7 @@ public abstract class RenderLivingEvent extends Even public double getY() { return y; } public double getZ() { return z; } - @Cancelable + @net.minecraftforge.eventbus.api.Cancelable public static class Pre extends RenderLivingEvent { @Deprecated @@ -74,7 +74,7 @@ public abstract class RenderLivingEvent extends Even { public Specials(EntityLivingBase entity, RenderLivingBase renderer, double x, double y, double z){ super(entity, renderer, 0, x, y, z); } - @Cancelable + @net.minecraftforge.eventbus.api.Cancelable public static class Pre extends Specials { public Pre(EntityLivingBase entity, RenderLivingBase renderer, double x, double y, double z){ super(entity, renderer, x, y, z); } diff --git a/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java b/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java index d88396852..e571c3895 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java @@ -19,7 +19,7 @@ package net.minecraftforge.client.event; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; import net.minecraft.client.renderer.entity.RenderPlayer; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -51,7 +51,7 @@ public abstract class RenderPlayerEvent extends PlayerEvent public double getY() { return y; } public double getZ() { return z; } - @Cancelable + @net.minecraftforge.eventbus.api.Cancelable public static class Pre extends RenderPlayerEvent { public Pre(EntityPlayer player, RenderPlayer renderer, float tick, double x, double y, double z){ super(player, renderer, tick, x, y, z); } @@ -74,7 +74,7 @@ public abstract class RenderPlayerEvent extends PlayerEvent super(player, renderer, partialTicks, 0D, 0D, 0D); } - @Cancelable + @net.minecraftforge.eventbus.api.Cancelable public static class Pre extends Specials { private boolean renderHelmet = true; diff --git a/src/main/java/net/minecraftforge/client/event/RenderSpecificHandEvent.java b/src/main/java/net/minecraftforge/client/event/RenderSpecificHandEvent.java index 217940118..c31140d5a 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderSpecificHandEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderSpecificHandEvent.java @@ -21,8 +21,8 @@ package net.minecraftforge.client.event; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumHand; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; import javax.annotation.Nonnull; diff --git a/src/main/java/net/minecraftforge/client/event/RenderTooltipEvent.java b/src/main/java/net/minecraftforge/client/event/RenderTooltipEvent.java index 1d19b8e96..dce4aa8bf 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderTooltipEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderTooltipEvent.java @@ -27,8 +27,8 @@ import javax.annotation.Nonnull; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.ItemStack; import net.minecraftforge.event.entity.player.ItemTooltipEvent; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; /** * A set of events which are fired at various points during tooltip rendering. @@ -42,7 +42,7 @@ import net.minecraftforge.fml.common.eventhandler.Event; *
  • {@link RenderTooltipEvent.PostText}
  • * */ -public abstract class RenderTooltipEvent extends Event +public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api.Event { @Nonnull protected final ItemStack stack; @@ -110,7 +110,7 @@ public abstract class RenderTooltipEvent extends Event *

    * This event is {@link Cancelable}. */ - @Cancelable + @net.minecraftforge.eventbus.api.Cancelable public static class Pre extends RenderTooltipEvent { private int screenWidth; diff --git a/src/main/java/net/minecraftforge/client/event/RenderWorldLastEvent.java b/src/main/java/net/minecraftforge/client/event/RenderWorldLastEvent.java index 6d940bbd2..e4d2d4cf2 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderWorldLastEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderWorldLastEvent.java @@ -19,10 +19,10 @@ package net.minecraftforge.client.event; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Event; import net.minecraft.client.renderer.RenderGlobal; -public class RenderWorldLastEvent extends Event +public class RenderWorldLastEvent extends net.minecraftforge.eventbus.api.Event { private final RenderGlobal context; private final float partialTicks; diff --git a/src/main/java/net/minecraftforge/client/event/ScreenshotEvent.java b/src/main/java/net/minecraftforge/client/event/ScreenshotEvent.java index 99c0105be..26e360051 100644 --- a/src/main/java/net/minecraftforge/client/event/ScreenshotEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ScreenshotEvent.java @@ -21,8 +21,8 @@ package net.minecraftforge.client.event; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentString; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; import java.awt.image.BufferedImage; import java.io.File; @@ -37,7 +37,7 @@ import java.io.File; * {@link #resultMessage} contains the {@link ITextComponent} to be returned. If {@code null}, the default vanilla message will be used instead */ @Cancelable -public class ScreenshotEvent extends Event +public class ScreenshotEvent extends net.minecraftforge.eventbus.api.Event { public static final ITextComponent DEFAULT_CANCEL_REASON = new TextComponentString("Screenshot canceled"); diff --git a/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java b/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java index 7958ec08f..ab6907c59 100644 --- a/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java +++ b/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java @@ -19,7 +19,7 @@ package net.minecraftforge.client.event; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Event; import net.minecraft.client.renderer.texture.TextureMap; 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 b3971c429..85b928a9c 100644 --- a/src/main/java/net/minecraftforge/client/event/sound/SoundEvent.java +++ b/src/main/java/net/minecraftforge/client/event/sound/SoundEvent.java @@ -19,11 +19,11 @@ package net.minecraftforge.client.event.sound; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Event; import net.minecraft.client.audio.ISound; import net.minecraft.client.audio.SoundManager; -public class SoundEvent extends Event +public class SoundEvent extends net.minecraftforge.eventbus.api.Event { private final SoundManager manager; public SoundEvent(SoundManager manager) diff --git a/src/main/java/net/minecraftforge/client/gui/NotificationModUpdateScreen.java b/src/main/java/net/minecraftforge/client/gui/NotificationModUpdateScreen.java index 4fad1dc0e..9d2c6d6ae 100644 --- a/src/main/java/net/minecraftforge/client/gui/NotificationModUpdateScreen.java +++ b/src/main/java/net/minecraftforge/client/gui/NotificationModUpdateScreen.java @@ -28,6 +28,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.ForgeModContainer; import net.minecraftforge.common.ForgeVersion; import net.minecraftforge.common.ForgeVersion.Status; +import net.minecraftforge.fml.VersionChecker; import net.minecraftforge.fml.client.ClientModLoader; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.ModContainer; @@ -41,7 +42,7 @@ public class NotificationModUpdateScreen extends GuiScreen private static final ResourceLocation VERSION_CHECK_ICONS = new ResourceLocation(ForgeVersion.MOD_ID, "textures/gui/version_check_icons.png"); private final GuiButton modButton; - private Status showNotification = null; + private VersionChecker.Status showNotification = null; private boolean hasCheckedForUpdates = false; public NotificationModUpdateScreen(GuiButton modButton) diff --git a/src/main/java/net/minecraftforge/client/model/ModelLoader.java b/src/main/java/net/minecraftforge/client/model/ModelLoader.java index e4eb2b871..bc0b88a6e 100644 --- a/src/main/java/net/minecraftforge/client/model/ModelLoader.java +++ b/src/main/java/net/minecraftforge/client/model/ModelLoader.java @@ -80,6 +80,7 @@ import net.minecraftforge.common.model.animation.IClip; import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.common.property.Properties; import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fml.client.ClientModLoader; import net.minecraftforge.fml.client.FMLClientHandler; import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.ProgressManager; @@ -143,7 +144,7 @@ public final class ModelLoader extends ModelBakery @Override public IRegistry setupModelRegistry() { - if (FMLClientHandler.instance().hasError()) // skip loading models if we're just going to show a fatal error screen + if (ClientModLoader.isErrored()) // skip loading models if we're just going to show a fatal error screen return bakedRegistry; isLoading = true; diff --git a/src/main/java/net/minecraftforge/common/ForgeChunkManager.java b/src/main/java/net/minecraftforge/common/ForgeChunkManager.java index d0a917d6f..792e34e39 100644 --- a/src/main/java/net/minecraftforge/common/ForgeChunkManager.java +++ b/src/main/java/net/minecraftforge/common/ForgeChunkManager.java @@ -53,7 +53,7 @@ import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.ModContainer; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Event; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; @@ -390,7 +390,8 @@ public class ForgeChunkManager } } - public static class ForceChunkEvent extends Event { + public static class ForceChunkEvent extends net.minecraftforge.eventbus.api.Event + { private final Ticket ticket; private final ChunkPos location; @@ -411,7 +412,8 @@ public class ForgeChunkManager } } - public static class UnforceChunkEvent extends Event { + public static class UnforceChunkEvent extends net.minecraftforge.eventbus.api.Event + { private final Ticket ticket; private final ChunkPos location; diff --git a/src/main/java/net/minecraftforge/common/ForgeHooks.java b/src/main/java/net/minecraftforge/common/ForgeHooks.java index 76121b989..dcd8a6239 100644 --- a/src/main/java/net/minecraftforge/common/ForgeHooks.java +++ b/src/main/java/net/minecraftforge/common/ForgeHooks.java @@ -146,7 +146,7 @@ import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.LoaderState; import net.minecraftforge.fml.common.ModContainer; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher; import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.ConnectionType; import net.minecraftforge.fml.common.registry.ForgeRegistries; @@ -1279,7 +1279,7 @@ public class ForgeHooks { BlockEvent ev = new BlockEvent.CropGrowEvent.Pre(worldIn,pos,state); MinecraftForge.EVENT_BUS.post(ev); - return (ev.getResult() == Event.Result.ALLOW || (ev.getResult() == Event.Result.DEFAULT && def)); + return (ev.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || (ev.getResult() == net.minecraftforge.eventbus.api.Event.Result.DEFAULT && def)); } public static void onCropsGrowPost(World worldIn, BlockPos pos, IBlockState state, IBlockState blockState) @@ -1320,7 +1320,7 @@ public class ForgeHooks { CriticalHitEvent hitResult = new CriticalHitEvent(player, target, damageModifier, vanillaCritical); MinecraftForge.EVENT_BUS.post(hitResult); - if (hitResult.getResult() == Event.Result.ALLOW || (vanillaCritical && hitResult.getResult() == Event.Result.DEFAULT)) + if (hitResult.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || (vanillaCritical && hitResult.getResult() == net.minecraftforge.eventbus.api.Event.Result.DEFAULT)) { return hitResult; } diff --git a/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java b/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java index 9a01aa256..f02e20021 100644 --- a/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java +++ b/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java @@ -28,9 +28,8 @@ import net.minecraftforge.common.util.FakePlayerFactory; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.client.FMLClientHandler; -import net.minecraftforge.fml.common.FMLLog; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.EventPriority; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; @@ -64,7 +63,7 @@ public class ForgeInternalHandler } } - @SubscribeEvent(priority = EventPriority.HIGHEST) + @net.minecraftforge.eventbus.api.SubscribeEvent(priority = net.minecraftforge.eventbus.api.EventPriority.HIGHEST) public void onDimensionLoad(WorldEvent.Load event) { ForgeChunkManager.loadWorld(event.getWorld()); @@ -76,7 +75,7 @@ public class ForgeInternalHandler ForgeChunkManager.saveWorld(event.getWorld()); } - @SubscribeEvent(priority = EventPriority.HIGHEST) + @net.minecraftforge.eventbus.api.SubscribeEvent(priority = EventPriority.HIGHEST) public void onDimensionUnload(WorldEvent.Unload event) { ForgeChunkManager.unloadWorld(event.getWorld()); diff --git a/src/main/java/net/minecraftforge/common/ForgeModContainer.java b/src/main/java/net/minecraftforge/common/ForgeModContainer.java index 3a6d0915c..b2750bdba 100644 --- a/src/main/java/net/minecraftforge/common/ForgeModContainer.java +++ b/src/main/java/net/minecraftforge/common/ForgeModContainer.java @@ -94,7 +94,7 @@ import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.event.FMLServerStartingEvent; import net.minecraftforge.fml.common.event.FMLServerStoppingEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.PlayerEvent; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.relauncher.Side; @@ -415,7 +415,7 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC } } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public void playerLogin(PlayerEvent.PlayerLoggedInEvent event) { UsernameCache.setUsername(event.player.getPersistentID(), event.player.getGameProfile().getName()); @@ -491,7 +491,7 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC } } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public void registrItems(RegistryEvent.Register event) { // Add and register the forge universal bucket, if it's enabled diff --git a/src/main/java/net/minecraftforge/common/ForgeVersion.java b/src/main/java/net/minecraftforge/common/ForgeVersion.java index a0ded6e82..c1b332b86 100644 --- a/src/main/java/net/minecraftforge/common/ForgeVersion.java +++ b/src/main/java/net/minecraftforge/common/ForgeVersion.java @@ -21,12 +21,9 @@ package net.minecraftforge.common; import static net.minecraftforge.common.ForgeVersion.Status.*; -import java.io.IOException; import java.io.InputStream; import java.net.URISyntaxException; -import java.net.HttpURLConnection; import java.net.URL; -import java.net.URLConnection; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; @@ -43,6 +40,7 @@ import java.util.concurrent.ConcurrentHashMap; import com.electronwill.nightconfig.core.Config; import com.electronwill.nightconfig.core.UnmodifiableConfig; import com.electronwill.nightconfig.core.path.PathConfig; +import net.minecraftforge.fml.VersionChecker; import net.minecraftforge.fml.common.versioning.DefaultArtifactVersion; import net.minecraftforge.fml.loading.moddiscovery.ModInfo; import org.apache.logging.log4j.Level; @@ -52,6 +50,7 @@ import org.apache.logging.log4j.Logger; import com.google.common.io.ByteStreams; import com.google.gson.Gson; +import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.InjectedModContainer; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.ModContainer; @@ -75,15 +74,9 @@ public class ForgeVersion public static final String mcVersion = "1.12.2"; // This is the MCP data version we're using public static final String mcpVersion = "9.42"; - @SuppressWarnings("unused") - private static Status status = PENDING; - @SuppressWarnings("unused") - private static String target = null; private static final Logger log = LogManager.getLogger("ForgeVersionCheck"); - private static final int MAX_HTTP_REDIRECTS = Integer.getInteger("http.maxRedirects", 20); - public static int getMajorVersion() { return majorVersion; @@ -104,299 +97,20 @@ public class ForgeVersion return buildVersion; } - public static Status getStatus() - { - return getResult(ForgeModContainer.getInstance()).status; - } - - @Nullable - public static String getTarget() - { - CheckResult res = getResult(ForgeModContainer.getInstance()); - return res.target != null ? res.target.toString() : null; - } - public static String getVersion() { return String.format("%d.%d.%d.%d", majorVersion, minorVersion, revisionVersion, buildVersion); } - public static List getModInfos() + public static VersionChecker.Status getStatus() { - PathConfig minecraftmod; - PathConfig forgemod; - try - { - minecraftmod = PathConfig.of(Paths.get(ForgeVersion.class.getClassLoader().getResource("minecraftmod.toml").toURI())); - forgemod = PathConfig.of(Paths.get(ForgeVersion.class.getClassLoader().getResource("forgemod.toml").toURI())); - minecraftmod.load(); - forgemod.load(); - } - catch (URISyntaxException | NullPointerException e) - { - throw new RuntimeException("Missing toml configs for minecraft and forge!", e); - } - return Arrays.asList( - new ModInfo(null, minecraftmod), - new ModInfo(null, forgemod) - ); + return VersionChecker.Status.PENDING; } - public static enum Status + @Nullable + public static String getTarget() { - PENDING(), - FAILED(), - UP_TO_DATE(), - OUTDATED(3, true), - AHEAD(), - BETA(), - BETA_OUTDATED(6, true); - - final int sheetOffset; - final boolean draw, animated; - - Status() - { - this(0, false, false); - } - - Status(int sheetOffset) - { - this(sheetOffset, true, false); - } - - Status(int sheetOffset, boolean animated) - { - this(sheetOffset, true, animated); - } - - Status(int sheetOffset, boolean draw, boolean animated) - { - this.sheetOffset = sheetOffset; - this.draw = draw; - this.animated = animated; - } - - public int getSheetOffset() - { - return sheetOffset; - } - - public boolean shouldDraw() - { - return draw; - } - - public boolean isAnimated() - { - return animated; - } - - } - - public static class CheckResult - { - public final Status status; - @Nullable - public final ComparableVersion target; - public final Map changes; - @Nullable - public final String url; - - private CheckResult(Status status, @Nullable ComparableVersion target, @Nullable Map changes, @Nullable String url) - { - this.status = status; - this.target = target; - this.changes = changes == null ? Collections.emptyMap() : Collections.unmodifiableMap(changes); - this.url = url; - } - } - - public static void startVersionCheck() - { - new Thread("Forge Version Check") - { - @Override - public void run() - { - if (!ForgeModContainer.getConfig().get(ForgeModContainer.VERSION_CHECK_CAT, "Global", true).getBoolean()) - { - log.info("Global Forge version check system disabled, no further processing."); - return; - } - - for (Entry entry : gatherMods().entrySet()) - { - ModContainer mod = entry.getKey(); - if (ForgeModContainer.getConfig().get(ForgeModContainer.VERSION_CHECK_CAT, mod.getModId(), true).getBoolean()) - { - process(mod, entry.getValue()); - } - else - { - log.info("[{}] Skipped version check", mod.getModId()); - } - } - } - - /** - * Opens stream for given URL while following redirects - */ - private InputStream openUrlStream(URL url) throws IOException - { - URL currentUrl = url; - for (int redirects = 0; redirects < MAX_HTTP_REDIRECTS; redirects++) - { - URLConnection c = currentUrl.openConnection(); - if (c instanceof HttpURLConnection) - { - HttpURLConnection huc = (HttpURLConnection) c; - huc.setInstanceFollowRedirects(false); - int responseCode = huc.getResponseCode(); - if (responseCode >= 300 && responseCode <= 399) - { - try - { - String loc = huc.getHeaderField("Location"); - currentUrl = new URL(currentUrl, loc); - continue; - } - finally - { - huc.disconnect(); - } - } - } - - return c.getInputStream(); - } - throw new IOException("Too many redirects while trying to fetch " + url); - } - - private void process(ModContainer mod, URL url) - { - try - { - log.info("[{}] Starting version check at {}", mod.getModId(), url.toString()); - Status status = PENDING; - ComparableVersion target = null; - - InputStream con = openUrlStream(url); - String data = new String(ByteStreams.toByteArray(con), "UTF-8"); - con.close(); - - log.debug("[{}] Received version check data:\n{}", mod.getModId(), data); - - - @SuppressWarnings("unchecked") - Map json = new Gson().fromJson(data, Map.class); - @SuppressWarnings("unchecked") - Map promos = (Map)json.get("promos"); - String display_url = (String)json.get("homepage"); - - String rec = promos.get(MinecraftForge.MC_VERSION + "-recommended"); - String lat = promos.get(MinecraftForge.MC_VERSION + "-latest"); - ComparableVersion current = new ComparableVersion(mod.getVersion()); - - if (rec != null) - { - ComparableVersion recommended = new ComparableVersion(rec); - int diff = recommended.compareTo(current); - - if (diff == 0) - status = UP_TO_DATE; - else if (diff < 0) - { - status = AHEAD; - if (lat != null) - { - ComparableVersion latest = new ComparableVersion(lat); - if (current.compareTo(latest) < 0) - { - status = OUTDATED; - target = latest; - } - } - } - else - { - status = OUTDATED; - target = recommended; - } - } - else if (lat != null) - { - ComparableVersion latest = new ComparableVersion(lat); - if (current.compareTo(latest) < 0) - { - status = BETA_OUTDATED; - target = latest; - } - else - status = BETA; - } - else - status = BETA; - - log.info("[{}] Found status: {} Target: {}", mod.getModId(), status, target); - - Map changes = new LinkedHashMap(); - @SuppressWarnings("unchecked") - Map tmp = (Map)json.get(MinecraftForge.MC_VERSION); - if (tmp != null) - { - List ordered = new ArrayList(); - for (String key : tmp.keySet()) - { - ComparableVersion ver = new ComparableVersion(key); - if (ver.compareTo(current) > 0 && (target == null || ver.compareTo(target) < 1)) - { - ordered.add(ver); - } - } - Collections.sort(ordered); - - for (ComparableVersion ver : ordered) - { - changes.put(ver, tmp.get(ver.toString())); - } - } - if (mod instanceof InjectedModContainer) - mod = ((InjectedModContainer)mod).wrappedContainer; - results.put(mod, new CheckResult(status, target, changes, display_url)); - } - catch (Exception e) - { - log.debug("Failed to process update information", e); - status = FAILED; - } - } - }.start(); - } - - // Gather a list of mods that have opted in to this update system by providing a URL. - public static Map gatherMods() - { - Map ret = new HashMap(); - for (ModContainer mod : Loader.instance().getActiveModList()) - { - URL url = mod.getUpdateUrl(); - if (url != null) - ret.put(mod, url); - } - return ret; - } - - private static Map results = new ConcurrentHashMap(); - private static final CheckResult PENDING_CHECK = new CheckResult(PENDING, null, null, null); - - public static CheckResult getResult(ModContainer mod) - { - if (mod == null) return PENDING_CHECK; - if (mod instanceof InjectedModContainer) - mod = ((InjectedModContainer)mod).wrappedContainer; - CheckResult ret = results.get(mod); - return ret == null ? PENDING_CHECK : ret; + return ""; } } diff --git a/src/main/java/net/minecraftforge/common/MinecraftForge.java b/src/main/java/net/minecraftforge/common/MinecraftForge.java index b0cde896d..7f748105a 100644 --- a/src/main/java/net/minecraftforge/common/MinecraftForge.java +++ b/src/main/java/net/minecraftforge/common/MinecraftForge.java @@ -24,14 +24,12 @@ import net.minecraftforge.fml.common.ICrashCallable; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.discovery.ASMDataTable; import net.minecraftforge.fml.common.discovery.ASMDataTable.ASMData; -import net.minecraftforge.fml.common.eventhandler.EventBus; +import net.minecraftforge.eventbus.api.IEventBus; import java.util.Collections; import java.util.List; import java.util.Set; -import org.apache.logging.log4j.Level; - import com.google.common.collect.Lists; import net.minecraft.crash.CrashReport; @@ -53,9 +51,9 @@ public class MinecraftForge * ORE_GEN_BUS for ore gen events * EVENT_BUS for everything else */ - public static final EventBus EVENT_BUS = new EventBus(); - public static final EventBus TERRAIN_GEN_BUS = new EventBus(); - public static final EventBus ORE_GEN_BUS = new EventBus(); + public static final IEventBus EVENT_BUS = IEventBus.create(); + public static final IEventBus TERRAIN_GEN_BUS = IEventBus.create(); + public static final IEventBus ORE_GEN_BUS = IEventBus.create(); public static final String MC_VERSION = Loader.MC_VERSION; static final ForgeInternalHandler INTERNAL_HANDLER = new ForgeInternalHandler(); diff --git a/src/main/java/net/minecraftforge/event/AnvilUpdateEvent.java b/src/main/java/net/minecraftforge/event/AnvilUpdateEvent.java index 99a8bcb93..8ad6117d5 100644 --- a/src/main/java/net/minecraftforge/event/AnvilUpdateEvent.java +++ b/src/main/java/net/minecraftforge/event/AnvilUpdateEvent.java @@ -19,8 +19,8 @@ package net.minecraftforge.event; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; import net.minecraft.item.ItemStack; import javax.annotation.Nonnull; diff --git a/src/main/java/net/minecraftforge/event/AttachCapabilitiesEvent.java b/src/main/java/net/minecraftforge/event/AttachCapabilitiesEvent.java index 72bdc1448..5c6144335 100644 --- a/src/main/java/net/minecraftforge/event/AttachCapabilitiesEvent.java +++ b/src/main/java/net/minecraftforge/event/AttachCapabilitiesEvent.java @@ -26,7 +26,7 @@ import com.google.common.collect.Maps; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.capabilities.ICapabilityProvider; -import net.minecraftforge.fml.common.eventhandler.GenericEvent; +import net.minecraftforge.eventbus.api.GenericEvent; /** * Fired whenever an object with Capabilities support {currently TileEntity/Item/Entity) diff --git a/src/main/java/net/minecraftforge/event/CommandEvent.java b/src/main/java/net/minecraftforge/event/CommandEvent.java index 1cf5427c3..a93bd2833 100644 --- a/src/main/java/net/minecraftforge/event/CommandEvent.java +++ b/src/main/java/net/minecraftforge/event/CommandEvent.java @@ -22,8 +22,8 @@ package net.minecraftforge.event; import net.minecraft.command.CommandHandler; import net.minecraftforge.client.ClientCommandHandler; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; @@ -45,7 +45,7 @@ import net.minecraft.command.ICommandSender; * This event is fired on the {@link MinecraftForge#EVENT_BUS}.
    **/ @Cancelable -public class CommandEvent extends Event +public class CommandEvent extends net.minecraftforge.eventbus.api.Event { private final ICommand command; diff --git a/src/main/java/net/minecraftforge/event/DifficultyChangeEvent.java b/src/main/java/net/minecraftforge/event/DifficultyChangeEvent.java index 8d050210c..ab2158e30 100644 --- a/src/main/java/net/minecraftforge/event/DifficultyChangeEvent.java +++ b/src/main/java/net/minecraftforge/event/DifficultyChangeEvent.java @@ -19,27 +19,25 @@ package net.minecraftforge.event; -import javax.annotation.Nonnull; - import net.minecraft.world.EnumDifficulty; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.MinecraftForge; -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.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; +import net.minecraftforge.eventbus.api.Event.HasResult; /** * DifficultyChangeEvent is fired when difficulty is changing.
    *
    * This event is fired via the {@link ForgeHooks#onDifficultyChange(EnumDifficulty, EnumDifficulty)}.
    *
    - * This event is not {@link Cancelable}.
    + * This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.
    *
    * This event does not have a result. {@link HasResult}
    *
    * This event is fired on the {@link MinecraftForge#EVENT_BUS}. **/ -public class DifficultyChangeEvent extends Event +public class DifficultyChangeEvent extends net.minecraftforge.eventbus.api.Event { private final EnumDifficulty difficulty; private final EnumDifficulty oldDifficulty; diff --git a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java index a92837432..93d808a0c 100644 --- a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java +++ b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java @@ -128,8 +128,8 @@ import net.minecraftforge.event.world.ExplosionEvent; import net.minecraftforge.event.world.GetCollisionBoxesEvent; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; -import net.minecraftforge.fml.common.eventhandler.Event; -import net.minecraftforge.fml.common.eventhandler.Event.Result; +import net.minecraftforge.eventbus.api.Event; +import net.minecraftforge.eventbus.api.Event.Result; import net.minecraftforge.fml.common.registry.GameRegistry; import javax.annotation.Nonnull; @@ -737,7 +737,7 @@ public class ForgeEventFactory { ChunkGeneratorEvent.ReplaceBiomeBlocks event = new ChunkGeneratorEvent.ReplaceBiomeBlocks(gen, x, z, primer, world); net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); - return event.getResult() != net.minecraftforge.fml.common.eventhandler.Event.Result.DENY; + return event.getResult() != net.minecraftforge.eventbus.api.Event.Result.DENY; } public static void onChunkPopulate(boolean pre, IChunkGenerator gen, World world, Random rand, int x, int z, boolean hasVillageGenerated) diff --git a/src/main/java/net/minecraftforge/event/LootTableLoadEvent.java b/src/main/java/net/minecraftforge/event/LootTableLoadEvent.java index 4698c0562..ac8038bc4 100644 --- a/src/main/java/net/minecraftforge/event/LootTableLoadEvent.java +++ b/src/main/java/net/minecraftforge/event/LootTableLoadEvent.java @@ -22,8 +22,8 @@ package net.minecraftforge.event; import net.minecraft.util.ResourceLocation; import net.minecraft.world.storage.loot.LootTable; import net.minecraft.world.storage.loot.LootTableManager; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; /** * Event fired when a LootTable json is loaded from json. diff --git a/src/main/java/net/minecraftforge/event/RegistryEvent.java b/src/main/java/net/minecraftforge/event/RegistryEvent.java index f3964fa01..f67e9477c 100644 --- a/src/main/java/net/minecraftforge/event/RegistryEvent.java +++ b/src/main/java/net/minecraftforge/event/RegistryEvent.java @@ -27,9 +27,7 @@ import org.apache.commons.lang3.Validate; import com.google.common.collect.ImmutableList; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.ModContainer; -import net.minecraftforge.fml.common.eventhandler.Event; -import net.minecraftforge.fml.common.eventhandler.GenericEvent; -import net.minecraftforge.fml.common.eventhandler.IContextSetter; +import net.minecraftforge.eventbus.api.GenericEvent; import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.IForgeRegistryEntry; @@ -37,7 +35,7 @@ import net.minecraftforge.registries.IForgeRegistryEntry; /** * RegistryEvent supertype. */ -public class RegistryEvent> extends GenericEvent implements IContextSetter +public class RegistryEvent> extends GenericEvent { RegistryEvent(Class clazz) { super(clazz); @@ -45,7 +43,7 @@ public class RegistryEvent> extends GenericEven /** * Register new registries when you receive this event, through the {@link RecipeBuilder} */ - public static class NewRegistry extends Event + public static class NewRegistry extends net.minecraftforge.eventbus.api.Event { } diff --git a/src/main/java/net/minecraftforge/event/ServerChatEvent.java b/src/main/java/net/minecraftforge/event/ServerChatEvent.java index 338a26556..cb9f2462a 100644 --- a/src/main/java/net/minecraftforge/event/ServerChatEvent.java +++ b/src/main/java/net/minecraftforge/event/ServerChatEvent.java @@ -22,8 +22,8 @@ package net.minecraftforge.event; import net.minecraft.network.NetHandlerPlayServer; import net.minecraft.network.play.client.CPacketChatMessage; import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.util.text.ITextComponent; @@ -45,7 +45,7 @@ import net.minecraft.util.text.ITextComponent; * This event is fired on the {@link MinecraftForge#EVENT_BUS}. **/ @Cancelable -public class ServerChatEvent extends Event +public class ServerChatEvent extends net.minecraftforge.eventbus.api.Event { private final String message, username; private final EntityPlayerMP player; diff --git a/src/main/java/net/minecraftforge/event/brewing/PotionBrewEvent.java b/src/main/java/net/minecraftforge/event/brewing/PotionBrewEvent.java index 7402341d8..c688aa33d 100644 --- a/src/main/java/net/minecraftforge/event/brewing/PotionBrewEvent.java +++ b/src/main/java/net/minecraftforge/event/brewing/PotionBrewEvent.java @@ -23,9 +23,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntityBrewingStand; import net.minecraft.util.NonNullList; import net.minecraftforge.common.MinecraftForge; -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.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; +import net.minecraftforge.eventbus.api.Event.HasResult; import javax.annotation.Nonnull; @@ -67,7 +67,7 @@ public class PotionBrewEvent extends Event *
    * {@link #stacks} contains the itemstack array from the TileEntityBrewer holding all items in Brewer.
    *
    - * This event is {@link Cancelable}.
    + * This event is {@link net.minecraftforge.eventbus.api.Cancelable}.
    * If the event is not canceled, the vanilla brewing will take place instead of modded brewing. *
    * This event does not have a result. {@link HasResult}
    @@ -76,7 +76,7 @@ public class PotionBrewEvent extends Event *
    * If this event is canceled, and items have been modified, PotionBrewEvent.Post will automatically be fired. **/ - @Cancelable + @net.minecraftforge.eventbus.api.Cancelable public static class Pre extends PotionBrewEvent { public Pre(NonNullList stacks) @@ -92,7 +92,7 @@ public class PotionBrewEvent extends Event *
    * {@link #stacks} contains the itemstack array from the TileEntityBrewer holding all items in Brewer.
    *
    - * This event is not {@link Cancelable}.
    + * This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.
    *
    * This event does not have a result. {@link HasResult}
    *
    diff --git a/src/main/java/net/minecraftforge/event/enchanting/EnchantmentLevelSetEvent.java b/src/main/java/net/minecraftforge/event/enchanting/EnchantmentLevelSetEvent.java index 33f809c21..67e45e005 100644 --- a/src/main/java/net/minecraftforge/event/enchanting/EnchantmentLevelSetEvent.java +++ b/src/main/java/net/minecraftforge/event/enchanting/EnchantmentLevelSetEvent.java @@ -22,7 +22,7 @@ package net.minecraftforge.event.enchanting; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Event; import javax.annotation.Nonnull; @@ -34,7 +34,7 @@ import javax.annotation.Nonnull; * from 0-15 and indicates how many bookshelves surround the enchanting table. The {@link #itemStack} representing the item being * enchanted is also available. */ -public class EnchantmentLevelSetEvent extends Event +public class EnchantmentLevelSetEvent extends net.minecraftforge.eventbus.api.Event { private final World world; private final BlockPos pos; diff --git a/src/main/java/net/minecraftforge/event/entity/EntityEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityEvent.java index 15dd6918e..18552c6c1 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityEvent.java @@ -22,13 +22,13 @@ package net.minecraftforge.event.entity; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; import net.minecraft.entity.Entity; /** * EntityEvent is fired when an event involving any Entity occurs.
    - * If a method utilizes this {@link Event} as its parameter, the method will + * If a method utilizes this {@link net.minecraftforge.eventbus.api.Event} as its parameter, the method will * receive every child event of this class.
    *
    * {@link #entity} contains the entity that caused this event to occur.
    @@ -53,7 +53,7 @@ public class EntityEvent extends Event * EntityConstructing is fired when an Entity is being created.
    * This event is fired within the constructor of the Entity.
    *
    - * This event is not {@link Cancelable}.
    + * This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.
    *
    * This event does not have a result. {@link HasResult}
    *
    diff --git a/src/main/java/net/minecraftforge/event/entity/EntityJoinWorldEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityJoinWorldEvent.java index 47fb90999..00690d26f 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityJoinWorldEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityJoinWorldEvent.java @@ -21,7 +21,7 @@ package net.minecraftforge.event.entity; import net.minecraft.world.WorldServer; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; import net.minecraft.entity.Entity; import net.minecraft.world.World; @@ -41,7 +41,7 @@ import java.util.Collection; *
    * This event is fired on the {@link MinecraftForge#EVENT_BUS}. **/ -@Cancelable +@net.minecraftforge.eventbus.api.Cancelable public class EntityJoinWorldEvent extends EntityEvent { diff --git a/src/main/java/net/minecraftforge/event/entity/EntityMountEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityMountEvent.java index 969726c5a..dfad1013a 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityMountEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityMountEvent.java @@ -22,15 +22,15 @@ package net.minecraftforge.event.entity; import net.minecraft.entity.Entity; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event.HasResult; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event.HasResult; /** * This event gets fired whenever a entity mounts/dismounts another entity.
    * entityBeingMounted can be null, be sure to check for that. *
    *
    - * This event is {@link Cancelable}.
    + * This event is {@link net.minecraftforge.eventbus.api.Cancelable}.
    * If this event is canceled, the entity does not mount/dismount the other entity.
    *
    * This event does not have a result. {@link HasResult}
    @@ -39,7 +39,7 @@ import net.minecraftforge.fml.common.eventhandler.Event.HasResult; * */ -@Cancelable +@net.minecraftforge.eventbus.api.Cancelable public class EntityMountEvent 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 715125f82..713307f11 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityStruckByLightningEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityStruckByLightningEvent.java @@ -21,7 +21,7 @@ package net.minecraftforge.event.entity; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ForgeEventFactory; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; import net.minecraft.entity.Entity; import net.minecraft.entity.effect.EntityLightningBolt; @@ -39,7 +39,7 @@ import net.minecraft.entity.effect.EntityLightningBolt; *
    * This event is fired on the {@link MinecraftForge#EVENT_BUS}.
    **/ -@Cancelable +@net.minecraftforge.eventbus.api.Cancelable public class EntityStruckByLightningEvent extends EntityEvent { private final EntityLightningBolt lightning; diff --git a/src/main/java/net/minecraftforge/event/entity/EntityTravelToDimensionEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityTravelToDimensionEvent.java index 68a797ee1..9919d61ec 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityTravelToDimensionEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityTravelToDimensionEvent.java @@ -21,15 +21,15 @@ package net.minecraftforge.event.entity; import net.minecraft.entity.Entity; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event.HasResult; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event.HasResult; /** * EntityTravelToDimensionEvent is fired before an Entity travels to a dimension.
    *
    * {@link #dimension} contains the id of the dimension the entity is traveling to.
    *
    - * This event is {@link Cancelable}.
    + * This event is {@link net.minecraftforge.eventbus.api.Cancelable}.
    * If this event is canceled, the Entity does not travel to the dimension.
    *
    * This event does not have a result. {@link HasResult}
    diff --git a/src/main/java/net/minecraftforge/event/entity/PlaySoundAtEntityEvent.java b/src/main/java/net/minecraftforge/event/entity/PlaySoundAtEntityEvent.java index 246ddd66a..849742a45 100644 --- a/src/main/java/net/minecraftforge/event/entity/PlaySoundAtEntityEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/PlaySoundAtEntityEvent.java @@ -21,10 +21,9 @@ package net.minecraftforge.event.entity; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; import net.minecraft.entity.Entity; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvent; @@ -48,7 +47,7 @@ import net.minecraft.util.SoundEvent; *
    * This event is fired on the {@link MinecraftForge#EVENT_BUS}.
    **/ -@Cancelable +@net.minecraftforge.eventbus.api.Cancelable public class PlaySoundAtEntityEvent extends EntityEvent { private SoundEvent name; diff --git a/src/main/java/net/minecraftforge/event/entity/ProjectileImpactEvent.java b/src/main/java/net/minecraftforge/event/entity/ProjectileImpactEvent.java index d089edb83..c4103bf19 100644 --- a/src/main/java/net/minecraftforge/event/entity/ProjectileImpactEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/ProjectileImpactEvent.java @@ -26,7 +26,7 @@ import net.minecraft.entity.projectile.EntityThrowable; import net.minecraft.util.math.RayTraceResult; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ForgeEventFactory; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; /** * This event is fired when a projectile entity impacts something. diff --git a/src/main/java/net/minecraftforge/event/entity/ThrowableImpactEvent.java b/src/main/java/net/minecraftforge/event/entity/ThrowableImpactEvent.java index b601b673a..71aba12bb 100644 --- a/src/main/java/net/minecraftforge/event/entity/ThrowableImpactEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/ThrowableImpactEvent.java @@ -21,7 +21,7 @@ package net.minecraftforge.event.entity; import net.minecraft.entity.projectile.EntityThrowable; import net.minecraft.util.math.RayTraceResult; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; /** * This event is fired before an {@link EntityThrowable} calls its {@link EntityThrowable#onImpact} method. @@ -33,7 +33,7 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable; * @deprecated use {@link ProjectileImpactEvent.Throwable} */ @Deprecated // TODO: remove (1.13) -@Cancelable +@net.minecraftforge.eventbus.api.Cancelable public class ThrowableImpactEvent extends EntityEvent { private final EntityThrowable throwable; 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 d32c1db34..8937028e4 100644 --- a/src/main/java/net/minecraftforge/event/entity/item/ItemExpireEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/item/ItemExpireEvent.java @@ -19,7 +19,7 @@ package net.minecraftforge.event.entity.item; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; import net.minecraft.entity.item.EntityItem; /** 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 c23955c14..d7737dde5 100644 --- a/src/main/java/net/minecraftforge/event/entity/item/ItemTossEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/item/ItemTossEvent.java @@ -19,7 +19,7 @@ package net.minecraftforge.event.entity.item; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; diff --git a/src/main/java/net/minecraftforge/event/entity/living/AnimalTameEvent.java b/src/main/java/net/minecraftforge/event/entity/living/AnimalTameEvent.java index a1587ccd4..45f55a2ae 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/AnimalTameEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/AnimalTameEvent.java @@ -23,16 +23,16 @@ import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ForgeEventFactory; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; /** * This event is fired when an {@link EntityAnimal} is tamed.
    * It is fired via {@link ForgeEventFactory#onAnimalTame(EntityAnimal, EntityPlayer)}. * Forge fires this event for applicable vanilla animals, mods need to fire it themselves. - * This event is {@link Cancelable}. If canceled, taming the animal will fail. + * This event is {@link net.minecraftforge.eventbus.api.Cancelable}. If canceled, taming the animal will fail. * This event is fired on the {@link MinecraftForge#EVENT_BUS}. */ -@Cancelable +@net.minecraftforge.eventbus.api.Cancelable public class AnimalTameEvent extends LivingEvent { private final EntityAnimal animal; diff --git a/src/main/java/net/minecraftforge/event/entity/living/BabyEntitySpawnEvent.java b/src/main/java/net/minecraftforge/event/entity/living/BabyEntitySpawnEvent.java index 82a52a7c0..4bc574a6a 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/BabyEntitySpawnEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/BabyEntitySpawnEvent.java @@ -26,8 +26,8 @@ import net.minecraft.entity.ai.EntityAIVillagerMate; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; import javax.annotation.Nullable; /** @@ -50,7 +50,7 @@ import javax.annotation.Nullable; * This event is fired on the {@link MinecraftForge#EVENT_BUS}. **/ @Cancelable -public class BabyEntitySpawnEvent extends Event +public class BabyEntitySpawnEvent extends net.minecraftforge.eventbus.api.Event { private final EntityLiving parentA; private final EntityLiving parentB; 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 8b66963ae..0c460e624 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/EnderTeleportEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/EnderTeleportEvent.java @@ -19,7 +19,7 @@ package net.minecraftforge.event.entity.living; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; import net.minecraft.entity.EntityLivingBase; /** 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 8e44f41c4..896951c2b 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingAttackEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingAttackEvent.java @@ -22,7 +22,7 @@ package net.minecraftforge.event.entity.living; import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; import net.minecraft.util.DamageSource; import net.minecraft.entity.EntityLivingBase; @@ -37,14 +37,14 @@ import net.minecraft.entity.EntityLivingBase; * {@link #source} contains the DamageSource of the attack.
    * {@link #amount} contains the amount of damage dealt to the entity.
    *
    - * This event is {@link Cancelable}.
    + * This event is {@link net.minecraftforge.eventbus.api.Cancelable}.
    * If this event is canceled, the Entity does not take attack damage.
    *
    * This event does not have a result. {@link HasResult}
    *
    * This event is fired on the {@link MinecraftForge#EVENT_BUS}. **/ -@Cancelable +@net.minecraftforge.eventbus.api.Cancelable public class LivingAttackEvent extends LivingEvent { private final DamageSource source; diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingDamageEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingDamageEvent.java index 735efe95d..768cdcc1a 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingDamageEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingDamageEvent.java @@ -21,7 +21,7 @@ package net.minecraftforge.event.entity.living; import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; import net.minecraft.util.DamageSource; import net.minecraft.entity.EntityLivingBase; @@ -38,7 +38,7 @@ import net.minecraft.entity.EntityLivingBase; * {@link #source} contains the DamageSource that caused this Entity to be hurt.
    * {@link #amount} contains the final amount of damage that will be dealt to entity.
    *
    - * This event is {@link Cancelable}.
    + * This event is {@link net.minecraftforge.eventbus.api.Cancelable}.
    * If this event is canceled, the Entity is not hurt. Used resources WILL NOT be restored.
    *
    * This event does not have a result. {@link HasResult}
    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 a5ab47499..d0e8f675c 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingDeathEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingDeathEvent.java @@ -23,7 +23,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; import net.minecraft.util.DamageSource; import net.minecraft.entity.EntityLivingBase; diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingDestroyBlockEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingDestroyBlockEvent.java index 7e6af5a7e..4c658de8e 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingDestroyBlockEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingDestroyBlockEvent.java @@ -26,19 +26,19 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; /** * Fired when the ender dragon or wither attempts to destroy a block and when ever a zombie attempts to break a door. Basically a event version of {@link Block#canEntityDestroy(IBlockState, IBlockAccess, BlockPos, Entity)}
    *
    - * This event is {@link Cancelable}.
    + * This event is {@link net.minecraftforge.eventbus.api.Cancelable}.
    * If this event is canceled, the block will not be destroyed.
    *
    * This event does not have a result. {@link HasResult}
    *
    * This event is fired on the {@link MinecraftForge#EVENT_BUS}. **/ -@Cancelable +@net.minecraftforge.eventbus.api.Cancelable public class LivingDestroyBlockEvent extends LivingEvent { private final BlockPos pos; 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 3185ac005..270cd7fea 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingDropsEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingDropsEvent.java @@ -24,7 +24,7 @@ import java.util.List; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; import net.minecraft.util.DamageSource; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.EntityLivingBase; @@ -48,7 +48,7 @@ import net.minecraft.entity.EntityLivingBase; *
    * This event is fired on the {@link MinecraftForge#EVENT_BUS}. **/ -@Cancelable +@net.minecraftforge.eventbus.api.Cancelable public class LivingDropsEvent extends LivingEvent { private final DamageSource source; diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingEntityUseItemEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingEntityUseItemEvent.java index dc6b0498f..b73fe60b4 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingEntityUseItemEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingEntityUseItemEvent.java @@ -21,7 +21,7 @@ package net.minecraftforge.event.entity.living; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; import javax.annotation.Nonnull; diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingEquipmentChangeEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingEquipmentChangeEvent.java index 67c192fca..be2c18ce6 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingEquipmentChangeEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingEquipmentChangeEvent.java @@ -23,7 +23,7 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; import javax.annotation.Nonnull; 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 644f1ce36..9e6f1bcc6 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingEvent.java @@ -19,8 +19,8 @@ package net.minecraftforge.event.entity.living; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.EntityMagmaCube; import net.minecraft.entity.passive.EntityHorse; @@ -30,7 +30,7 @@ import net.minecraftforge.event.entity.EntityEvent; /** * LivingEvent is fired whenever an event involving Living entities occurs.
    - * If a method utilizes this {@link Event} as its parameter, the method will + * If a method utilizes this {@link net.minecraftforge.eventbus.api.Event} as its parameter, the method will * receive every child event of this class.
    *
    * All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.
    diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingExperienceDropEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingExperienceDropEvent.java index 175aaabbd..5b69667fa 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingExperienceDropEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingExperienceDropEvent.java @@ -21,14 +21,14 @@ package net.minecraftforge.event.entity.living; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; /** * Event for when an entity drops experience on its death, can be used to change * the amount of experience points dropped or completely prevent dropping of experience * by canceling the event. */ -@Cancelable +@net.minecraftforge.eventbus.api.Cancelable public class LivingExperienceDropEvent extends LivingEvent { private final EntityPlayer attackingPlayer; 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 fa200591f..81093d27a 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingFallEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingFallEvent.java @@ -21,7 +21,7 @@ package net.minecraftforge.event.entity.living; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; import net.minecraft.entity.EntityLivingBase; /** @@ -33,14 +33,14 @@ import net.minecraft.entity.EntityLivingBase; *
    * {@link #distance} contains the distance the Entity is to fall. If this event is canceled, this value is set to 0.0F. *
    - * This event is {@link Cancelable}.
    + * This event is {@link net.minecraftforge.eventbus.api.Cancelable}.
    * If this event is canceled, the Entity does not fall.
    *
    * This event does not have a result. {@link HasResult}
    *
    * This event is fired on the {@link MinecraftForge#EVENT_BUS}. **/ -@Cancelable +@net.minecraftforge.eventbus.api.Cancelable public class LivingFallEvent extends LivingEvent { private float distance; diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingHealEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingHealEvent.java index de023da3f..6548317f3 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingHealEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingHealEvent.java @@ -21,7 +21,7 @@ package net.minecraftforge.event.entity.living; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ForgeEventFactory; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; import net.minecraft.entity.EntityLivingBase; /** @@ -32,14 +32,14 @@ import net.minecraft.entity.EntityLivingBase; *
    * {@link #amount} contains the amount of healing done to the Entity that was healed.
    *
    - * This event is {@link Cancelable}.
    + * This event is {@link net.minecraftforge.eventbus.api.Cancelable}.
    * If this event is canceled, the Entity is not healed.
    *
    * This event does not have a result. {@link HasResult}
    *
    * This event is fired on the {@link MinecraftForge#EVENT_BUS}. **/ -@Cancelable +@net.minecraftforge.eventbus.api.Cancelable public class LivingHealEvent extends LivingEvent { private float amount; 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 a11f18a1f..6737d18d0 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingHurtEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingHurtEvent.java @@ -22,7 +22,7 @@ package net.minecraftforge.event.entity.living; import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; import net.minecraft.util.DamageSource; import net.minecraft.entity.EntityLivingBase; @@ -45,7 +45,7 @@ import net.minecraft.entity.EntityLivingBase; * This event is fired on the {@link MinecraftForge#EVENT_BUS}. * @see LivingDamageEvent **/ -@Cancelable +@net.minecraftforge.eventbus.api.Cancelable public class LivingHurtEvent extends LivingEvent { private final DamageSource source; diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingKnockBackEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingKnockBackEvent.java index 6d6f07d05..9ba79f283 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingKnockBackEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingKnockBackEvent.java @@ -26,7 +26,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.DamageSource; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; /** * LivingKnockBackEvent is fired when a living entity is about to be knocked back.
    @@ -43,7 +43,7 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable; * {@link #ratioX} contains the x ratio of the knock back.
    * {@link #ratioZ} contains the z ratio of the knock back.
    *
    - * This event is {@link Cancelable}.
    + * This event is {@link net.minecraftforge.eventbus.api.Cancelable}.
    * If this event is canceled, the entity is not knocked back.
    *
    * This event does not have a result. {@link HasResult}
    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 d833d749f..d72d20328 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingPackSizeEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingPackSizeEvent.java @@ -19,7 +19,7 @@ package net.minecraftforge.event.entity.living; -import net.minecraftforge.fml.common.eventhandler.Event.HasResult; +import net.minecraftforge.eventbus.api.Event.HasResult; import net.minecraft.entity.EntityLiving; @HasResult diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingSetAttackTargetEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingSetAttackTargetEvent.java index 4db7148d1..f610969bf 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingSetAttackTargetEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingSetAttackTargetEvent.java @@ -23,7 +23,7 @@ import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; /** * LivingSetAttackTargetEvent is fired when an Entity sets a target to attack.
    @@ -35,7 +35,7 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable; *
    * {@link #target} contains the newly targeted Entity.
    *
    - * This event is not {@link Cancelable}.
    + * This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.
    *
    * This event does not have a result. {@link HasResult}
    *
    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 6f19cc217..a83924935 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingSpawnEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingSpawnEvent.java @@ -21,11 +21,10 @@ package net.minecraftforge.event.entity.living; import javax.annotation.Nullable; import net.minecraft.tileentity.MobSpawnerBaseLogic; -import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ForgeEventFactory; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; import net.minecraft.entity.EntityLiving; import net.minecraft.world.World; @@ -142,14 +141,14 @@ public class LivingSpawnEvent extends LivingEvent *
    * This event is fired via the {@link ForgeEventFactory#doSpecialSpawn(EntityLiving, World, float, float, float)}.
    *
    - * This event is {@link Cancelable}.
    + * This event is {@link net.minecraftforge.eventbus.api.Cancelable}.
    * If this event is canceled, the Entity is not spawned.
    *
    * This event does not have a result. {@link HasResult}
    *
    * This event is fired on the {@link MinecraftForge#EVENT_BUS}. **/ - @Cancelable + @net.minecraftforge.eventbus.api.Cancelable public static class SpecialSpawn extends LivingSpawnEvent { @Nullable 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 c9c4bb0d8..ce9e4d056 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/ZombieEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/ZombieEvent.java @@ -23,16 +23,15 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.EntityZombie; import net.minecraft.util.DamageSource; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.event.entity.EntityEvent; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; /** * ZombieEvent is fired whenever a zombie is spawned for aid. - * If a method utilizes this {@link Event} as its parameter, the method will + * If a method utilizes this {@link Event} as its parameter, the method will * receive every child event of this class. * * All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}. @@ -64,7 +63,7 @@ public class ZombieEvent extends EntityEvent { * {@link #attacker} contains the living Entity that attacked and caused this event to fire. * {@link #summonChance} contains the likelihood that a Zombie would successfully be summoned. * - * This event is not {@link Cancelable}. + * This event is not {@link net.minecraftforge.eventbus.api.Cancelable}. * * This event has a result. {@link HasResult} * {@link Result#ALLOW} Zombie is summoned. diff --git a/src/main/java/net/minecraftforge/event/entity/minecart/MinecartCollisionEvent.java b/src/main/java/net/minecraftforge/event/entity/minecart/MinecartCollisionEvent.java index 8bdaab074..e7bd43cfb 100644 --- a/src/main/java/net/minecraftforge/event/entity/minecart/MinecartCollisionEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/minecart/MinecartCollisionEvent.java @@ -22,7 +22,7 @@ package net.minecraftforge.event.entity.minecart; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityMinecart; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; /** * MinecartCollisionEvent is fired when a minecart collides with an Entity. diff --git a/src/main/java/net/minecraftforge/event/entity/minecart/MinecartEvent.java b/src/main/java/net/minecraftforge/event/entity/minecart/MinecartEvent.java index 26721d32e..44a282d02 100644 --- a/src/main/java/net/minecraftforge/event/entity/minecart/MinecartEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/minecart/MinecartEvent.java @@ -22,11 +22,11 @@ package net.minecraftforge.event.entity.minecart; import net.minecraft.entity.item.EntityMinecart; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.EntityEvent; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Event; /** * MinecartEvent is fired whenever an event involving minecart entities occurs.
    - * If a method utilizes this {@link Event} as its parameter, the method will
    + * If a method utilizes this {@link net.minecraftforge.eventbus.api.Event} as its parameter, the method will
    * receive every child event of this class.
    *
    * {@link #minecart} contains the minecart entity involved with this event.
    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 e033f85e6..1d5c558a5 100644 --- a/src/main/java/net/minecraftforge/event/entity/minecart/MinecartInteractEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/minecart/MinecartInteractEvent.java @@ -19,12 +19,8 @@ package net.minecraftforge.event.entity.minecart; -import net.minecraft.entity.item.EntityMinecartContainer; -import net.minecraft.entity.item.EntityMinecartEmpty; -import net.minecraft.entity.item.EntityMinecartFurnace; -import net.minecraft.entity.item.EntityMinecartHopper; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; import net.minecraft.entity.item.EntityMinecart; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -40,14 +36,14 @@ import javax.annotation.Nonnull; *
    * {@link #player} contains the EntityPlayer that is involved with this minecart interaction.
    *
    - * This event is {@link Cancelable}.
    + * This event is {@link net.minecraftforge.eventbus.api.Cancelable}.
    * If this event is canceled, the player does not interact with the minecart.
    *
    * This event does not have a result. {@link HasResult}
    *
    * This event is fired on the {@link MinecraftForge#EVENT_BUS}. **/ -@Cancelable +@net.minecraftforge.eventbus.api.Cancelable public class MinecartInteractEvent extends MinecartEvent { private final EntityPlayer player; diff --git a/src/main/java/net/minecraftforge/event/entity/minecart/MinecartUpdateEvent.java b/src/main/java/net/minecraftforge/event/entity/minecart/MinecartUpdateEvent.java index 86910f73c..575991840 100644 --- a/src/main/java/net/minecraftforge/event/entity/minecart/MinecartUpdateEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/minecart/MinecartUpdateEvent.java @@ -22,7 +22,7 @@ package net.minecraftforge.event.entity.minecart; import net.minecraft.entity.item.EntityMinecart; import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; /** * MinecartUpdateEvent is fired when a minecart is updated.
    @@ -31,7 +31,7 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable; *
    * {@link #pos} contains the coordinate of the track the entity is on {if applicable}.
    *
    - * This event is not {@link Cancelable}.
    + * This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.
    *
    * This event does not have a result. {@link HasResult}
    *
    diff --git a/src/main/java/net/minecraftforge/event/entity/player/AdvancementEvent.java b/src/main/java/net/minecraftforge/event/entity/player/AdvancementEvent.java index 355099aba..6bf018f80 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/AdvancementEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/AdvancementEvent.java @@ -22,12 +22,12 @@ package net.minecraftforge.event.entity.player; import net.minecraft.advancements.Advancement; import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; /** * This event is fired when a player gets an advancement. *
    - * This event is not {@link Cancelable}.
    + * This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.
    *
    * This event does not have a result. {@link HasResult}
    *
    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 722d0486e..8c4869734 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/ArrowLooseEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/ArrowLooseEvent.java @@ -22,7 +22,7 @@ package net.minecraftforge.event.entity.player; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemBow; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; @@ -37,14 +37,14 @@ import javax.annotation.Nonnull; * {@link #bow} contains the ItemBow ItemStack that was used in this event.
    * {@link #charge} contains the value for how much the player had charged before stopping the shot.
    *
    - * This event is {@link Cancelable}.
    + * This event is {@link net.minecraftforge.eventbus.api.Cancelable}.
    * If this event is canceled, the player does not stop using the bow.
    *
    * This event does not have a result. {@link HasResult}
    *
    * This event is fired on the {@link MinecraftForge#EVENT_BUS}. **/ -@Cancelable +@net.minecraftforge.eventbus.api.Cancelable public class ArrowLooseEvent extends PlayerEvent { private final ItemStack bow; 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 ec97697de..bf2a0f898 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/AttackEntityEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/AttackEntityEvent.java @@ -20,7 +20,7 @@ package net.minecraftforge.event.entity.player; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; 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 333de636c..3f20cd143 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/BonemealEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/BonemealEvent.java @@ -19,8 +19,8 @@ package net.minecraftforge.event.entity.player; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -41,7 +41,7 @@ import javax.annotation.Nullable; * setResult(ALLOW) is the same as the old setHandled() */ @Cancelable -@Event.HasResult +@net.minecraftforge.eventbus.api.Event.HasResult public class BonemealEvent extends PlayerEvent { diff --git a/src/main/java/net/minecraftforge/event/entity/player/CriticalHitEvent.java b/src/main/java/net/minecraftforge/event/entity/player/CriticalHitEvent.java index b492ef7b7..852539ef8 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/CriticalHitEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/CriticalHitEvent.java @@ -19,8 +19,8 @@ package net.minecraftforge.event.entity.player; -import net.minecraftforge.fml.common.eventhandler.Event.HasResult; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Event.HasResult; +import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.common.MinecraftForge; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; 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 8d95f5033..823ff152a 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/EntityItemPickupEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/EntityItemPickupEvent.java @@ -19,8 +19,8 @@ package net.minecraftforge.event.entity.player; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; 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 4c1081a98..74bf6c69f 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/FillBucketEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/FillBucketEvent.java @@ -19,8 +19,8 @@ package net.minecraftforge.event.entity.player; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.math.RayTraceResult; @@ -38,7 +38,7 @@ import javax.annotation.Nullable; * ItemStack to your inventory and reducing the stack size to process. * setResult(ALLOW) is the same as the old setHandled(); */ -@Cancelable +@net.minecraftforge.eventbus.api.Cancelable @Event.HasResult public class FillBucketEvent extends PlayerEvent { diff --git a/src/main/java/net/minecraftforge/event/entity/player/ItemFishedEvent.java b/src/main/java/net/minecraftforge/event/entity/player/ItemFishedEvent.java index daebb89ef..ee0ff731d 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/ItemFishedEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/ItemFishedEvent.java @@ -23,7 +23,7 @@ import com.google.common.base.Preconditions; import net.minecraft.entity.projectile.EntityFishHook; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; import javax.annotation.Nonnegative; import java.util.List; @@ -31,11 +31,11 @@ import java.util.List; /** * This event is called when a player fishes an item. * - * This event is {@link net.minecraftforge.fml.common.eventhandler.Cancelable} + * This event is {@link net.minecraftforge.eventbus.api.Cancelable} * Canceling the event will cause the player to receive no items at all. * The hook will still take the damage specified */ -@Cancelable +@net.minecraftforge.eventbus.api.Cancelable public class ItemFishedEvent extends PlayerEvent { private final NonNullList stacks = NonNullList.create(); diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerDestroyItemEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerDestroyItemEvent.java index 6816434b7..752ebe0be 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerDestroyItemEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerDestroyItemEvent.java @@ -31,7 +31,7 @@ import net.minecraft.world.World; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ForgeEventFactory; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumHand; 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 a227553dd..c99bcb00f 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerDropsEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerDropsEvent.java @@ -22,7 +22,7 @@ package net.minecraftforge.event.entity.player; import java.util.List; import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -34,7 +34,7 @@ import net.minecraftforge.event.entity.living.LivingDropsEvent; * player dies. Canceling the event will prevent ALL drops from entering the * world. */ -@Cancelable +@net.minecraftforge.eventbus.api.Cancelable public class PlayerDropsEvent extends LivingDropsEvent { private final EntityPlayer entityPlayer; 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 b9709725f..ff3dd85e2 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerEvent.java @@ -23,18 +23,17 @@ import java.io.File; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ForgeEventFactory; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraft.block.Block; +import net.minecraftforge.eventbus.api.Cancelable; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.math.BlockPos; import net.minecraftforge.event.entity.living.LivingEvent; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Event; /** * PlayerEvent is fired whenever an event involving Living entities occurs.
    - * If a method utilizes this {@link Event} as its parameter, the method will + * If a method utilizes this {@link net.minecraftforge.eventbus.api.Event} as its parameter, the method will * receive every child event of this class.
    *
    * All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}. @@ -63,7 +62,7 @@ public class PlayerEvent extends LivingEvent * {@link #state} contains the {@link IBlockState} that is being checked for harvesting.
    * {@link #success} contains the boolean value for whether the Block will be successfully harvested.
    *
    - * This event is not {@link Cancelable}.
    + * This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.
    *
    * This event does not have a result. {@link HasResult}
    *
    @@ -98,7 +97,7 @@ public class PlayerEvent extends LivingEvent * {@link #newSpeed} contains the newSpeed at which the player will break the block.
    * {@link #pos} contains the coordinates at which this event is occurring. Y value -1 means location is unknown.
    *
    - * This event is {@link Cancelable}.
    + * This event is {@link net.minecraftforge.eventbus.api.Cancelable}.
    * If it is canceled, the player is unable to break the block.
    *
    * This event does not have a result. {@link HasResult}
    @@ -139,7 +138,7 @@ public class PlayerEvent extends LivingEvent * {@link #username} contains the username of the player. * {@link #displayname} contains the display name of the player. *
    - * This event is not {@link Cancelable}. + * This event is not {@link net.minecraftforge.eventbus.api.Cancelable}. *
    * This event does not have a result. {@link HasResult} *
    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 76c8f3ab9..205489e41 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java @@ -30,14 +30,14 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.fml.relauncher.Side; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import static net.minecraftforge.fml.common.eventhandler.Event.Result.DEFAULT; -import static net.minecraftforge.fml.common.eventhandler.Event.Result.DENY; +import static net.minecraftforge.eventbus.api.Event.Result.DEFAULT; +import static net.minecraftforge.eventbus.api.Event.Result.DENY; /** * PlayerInteractEvent is fired when a player interacts in some way. @@ -69,7 +69,7 @@ public class PlayerInteractEvent extends PlayerEvent * Let result be the return value of {@link Entity#applyPlayerInteraction}, or {@link #cancellationResult} if the event is cancelled. * If we are on the client and result is not {@link EnumActionResult#SUCCESS}, the client will then try {@link EntityInteract}. */ - @Cancelable + @net.minecraftforge.eventbus.api.Cancelable public static class EntityInteractSpecific extends PlayerInteractEvent { private final Vec3d localPos; @@ -110,7 +110,7 @@ public class PlayerInteractEvent extends PlayerEvent * or {@link #cancellationResult} if the event is cancelled. * If we are on the client and result is not {@link EnumActionResult#SUCCESS}, the client will then try {@link RightClickItem}. */ - @Cancelable + @net.minecraftforge.eventbus.api.Cancelable public static class EntityInteract extends PlayerInteractEvent { private final Entity target; @@ -248,7 +248,7 @@ public class PlayerInteractEvent extends PlayerEvent * Also note that creative mode directly breaks the block without running any other logic. * Therefore, in creative mode, {@link #setUseBlock} and {@link #setUseItem} have no effect. */ - @Cancelable + @net.minecraftforge.eventbus.api.Cancelable public static class LeftClickBlock extends PlayerInteractEvent { private Result useBlock = DEFAULT; diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerPickupXpEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerPickupXpEvent.java index 138bb442e..ca317e095 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerPickupXpEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerPickupXpEvent.java @@ -19,7 +19,7 @@ package net.minecraftforge.event.entity.player; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; import net.minecraft.entity.item.EntityXPOrb; import net.minecraft.entity.player.EntityPlayer; diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerSetSpawnEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerSetSpawnEvent.java index a86803b19..49e11d5b5 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerSetSpawnEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerSetSpawnEvent.java @@ -19,11 +19,11 @@ package net.minecraftforge.event.entity.player; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.math.BlockPos; -@Cancelable +@net.minecraftforge.eventbus.api.Cancelable public class PlayerSetSpawnEvent extends PlayerEvent { private final boolean forced; diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerSleepInBedEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerSleepInBedEvent.java index cc2590cd4..f5482fd22 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerSleepInBedEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerSleepInBedEvent.java @@ -23,7 +23,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer.SleepResult; import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; /** * PlayerSleepInBedEvent is fired when a player sleeps in a bed. @@ -33,7 +33,7 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable; *
    * {@link #result} contains whether the player is able to sleep.
    *
    - * This event is not {@link Cancelable}. + * This event is not {@link net.minecraftforge.eventbus.api.Cancelable}. *
    * This event does not have a result. {@link HasResult} *
    diff --git a/src/main/java/net/minecraftforge/event/entity/player/SleepingLocationCheckEvent.java b/src/main/java/net/minecraftforge/event/entity/player/SleepingLocationCheckEvent.java index 0b267b2eb..e1765d706 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/SleepingLocationCheckEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/SleepingLocationCheckEvent.java @@ -25,7 +25,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; -import net.minecraftforge.fml.common.eventhandler.Event.HasResult; +import net.minecraftforge.eventbus.api.Event.HasResult; /** * This event is fired when game checks, if sleeping player should be still considered "in bed".
    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 6534218ab..3ace99550 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/UseHoeEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/UseHoeEvent.java @@ -23,8 +23,8 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; import javax.annotation.Nonnull; @@ -38,7 +38,7 @@ import javax.annotation.Nonnull; * setResult(ALLOW) is the same as the old setHandled(); */ @Cancelable -@Event.HasResult +@net.minecraftforge.eventbus.api.Event.HasResult public class UseHoeEvent extends PlayerEvent { diff --git a/src/main/java/net/minecraftforge/event/furnace/FurnaceFuelBurnTimeEvent.java b/src/main/java/net/minecraftforge/event/furnace/FurnaceFuelBurnTimeEvent.java index 974697df0..53fbec13c 100644 --- a/src/main/java/net/minecraftforge/event/furnace/FurnaceFuelBurnTimeEvent.java +++ b/src/main/java/net/minecraftforge/event/furnace/FurnaceFuelBurnTimeEvent.java @@ -25,8 +25,8 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ForgeEventFactory; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; /** * {@link FurnaceFuelBurnTimeEvent} is fired when determining the fuel value for an ItemStack.
    diff --git a/src/main/java/net/minecraftforge/event/terraingen/BiomeEvent.java b/src/main/java/net/minecraftforge/event/terraingen/BiomeEvent.java index 5cf406bf3..fff94f663 100644 --- a/src/main/java/net/minecraftforge/event/terraingen/BiomeEvent.java +++ b/src/main/java/net/minecraftforge/event/terraingen/BiomeEvent.java @@ -20,8 +20,8 @@ package net.minecraftforge.event.terraingen; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; import net.minecraft.block.state.IBlockState; import net.minecraft.world.biome.BiomeDecorator; import net.minecraft.world.biome.Biome; @@ -34,7 +34,7 @@ import net.minecraft.world.biome.Biome; * All children of this event are fired on the {@link MinecraftForge#TERRAIN_GEN_BUS} * unless stated otherwise in their Javadocs. **/ -public class BiomeEvent extends Event +public class BiomeEvent extends net.minecraftforge.eventbus.api.Event { private final Biome biome; @@ -56,7 +56,7 @@ public class BiomeEvent extends Event * {@link #originalBiomeDecorator} contains the original BiomeDecorator that would be used in vanilla. * {@link #newBiomeDecorator} contains the new BiomeDecoration to be used by Minecraft. *
    - * This event is not {@link Cancelable}. + * This event is not {@link net.minecraftforge.eventbus.api.Cancelable}. *
    * This event does not have a result. {@link HasResult} *
    @@ -92,7 +92,7 @@ public class BiomeEvent extends Event /** * BiomeColor is fired whenever an event involving biome colors occurs.
    - * If a method utilizes this {@link Event} as its parameter, the method will + * If a method utilizes this {@link net.minecraftforge.eventbus.api.Event} as its parameter, the method will * receive every child event of this class.
    *
    * All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}. diff --git a/src/main/java/net/minecraftforge/event/terraingen/ChunkGeneratorEvent.java b/src/main/java/net/minecraftforge/event/terraingen/ChunkGeneratorEvent.java index d76662050..98a7f5977 100644 --- a/src/main/java/net/minecraftforge/event/terraingen/ChunkGeneratorEvent.java +++ b/src/main/java/net/minecraftforge/event/terraingen/ChunkGeneratorEvent.java @@ -19,12 +19,12 @@ package net.minecraftforge.event.terraingen; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Event; import net.minecraft.world.World; import net.minecraft.world.chunk.ChunkPrimer; import net.minecraft.world.gen.IChunkGenerator; -public class ChunkGeneratorEvent extends Event +public class ChunkGeneratorEvent extends net.minecraftforge.eventbus.api.Event { private final IChunkGenerator gen; diff --git a/src/main/java/net/minecraftforge/event/terraingen/DecorateBiomeEvent.java b/src/main/java/net/minecraftforge/event/terraingen/DecorateBiomeEvent.java index fa2c75d8e..12d024631 100644 --- a/src/main/java/net/minecraftforge/event/terraingen/DecorateBiomeEvent.java +++ b/src/main/java/net/minecraftforge/event/terraingen/DecorateBiomeEvent.java @@ -28,8 +28,11 @@ import net.minecraft.util.math.ChunkPos; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; +import net.minecraftforge.eventbus.api.Event.HasResult; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; /** * DecorateBiomeEvent is fired when a BiomeDecorator is created. @@ -41,7 +44,7 @@ import net.minecraftforge.fml.common.eventhandler.Event; * {@link #rand} contains an instance of Random to be used.
    * {@link #chunkPos} contains the original chunk for the decorator.
    *
    - * This event is not {@link Cancelable}. + * This event is not {@link net.minecraftforge.eventbus.api.Cancelable}. *
    * This event does not have a result. {@link HasResult} *
    @@ -51,28 +54,15 @@ public class DecorateBiomeEvent extends Event { private final World world; private final Random rand; - /** @deprecated use {@link #chunkPos} */ - @Deprecated // TODO remove in 1.13 - private final BlockPos pos; private final ChunkPos chunkPos; public DecorateBiomeEvent(World world, Random rand, ChunkPos chunkPos) { this.world = world; this.rand = rand; - this.pos = chunkPos.getBlock(0, 0, 0); this.chunkPos = chunkPos; } - @Deprecated // TODO: remove in 1.13 - public DecorateBiomeEvent(World world, Random rand, BlockPos pos) - { - this.world = world; - this.rand = rand; - this.pos = pos; - this.chunkPos = new ChunkPos(pos); - } - public World getWorld() { return world; @@ -83,15 +73,6 @@ public class DecorateBiomeEvent extends Event return rand; } - /** - * @deprecated use {@link #getChunkPos()} or {@link Decorate#getPlacementPos} instead. - */ - @Deprecated - public BlockPos getPos() - { - return pos; - } - public ChunkPos getChunkPos() { return chunkPos; @@ -106,12 +87,6 @@ public class DecorateBiomeEvent extends Event { super(world, rand, chunkPos); } - - @Deprecated // TODO: remove in 1.13 - public Pre(World world, Random rand, BlockPos pos) - { - this(world, rand, new ChunkPos(pos)); - } } /** @@ -123,12 +98,6 @@ public class DecorateBiomeEvent extends Event { super(world, rand, chunkPos); } - - @Deprecated //TODO: remove in 1.13 - public Post(World world, Random rand, BlockPos pos) - { - this(world, rand, new ChunkPos(pos)); - } } /** @@ -158,14 +127,6 @@ public class DecorateBiomeEvent extends Event this.placementPos = placementPos; } - @Deprecated // TODO: remove in 1.13 - public Decorate(World world, Random rand, BlockPos pos, EventType type) - { - super(world, rand, pos); - this.type = type; - this.placementPos = null; - } - public EventType getType() { return type; diff --git a/src/main/java/net/minecraftforge/event/terraingen/InitMapGenEvent.java b/src/main/java/net/minecraftforge/event/terraingen/InitMapGenEvent.java index 7970543af..b0b62712f 100644 --- a/src/main/java/net/minecraftforge/event/terraingen/InitMapGenEvent.java +++ b/src/main/java/net/minecraftforge/event/terraingen/InitMapGenEvent.java @@ -19,7 +19,7 @@ package net.minecraftforge.event.terraingen; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Event; import net.minecraft.world.gen.MapGenBase; public class InitMapGenEvent extends Event diff --git a/src/main/java/net/minecraftforge/event/terraingen/OreGenEvent.java b/src/main/java/net/minecraftforge/event/terraingen/OreGenEvent.java index f13646f53..2e5529e2e 100644 --- a/src/main/java/net/minecraftforge/event/terraingen/OreGenEvent.java +++ b/src/main/java/net/minecraftforge/event/terraingen/OreGenEvent.java @@ -23,16 +23,16 @@ import java.util.Random; import net.minecraft.world.biome.BiomeDecorator; import net.minecraftforge.common.MinecraftForge; -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.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; +import net.minecraftforge.eventbus.api.Event.HasResult; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; /** * OreGenEvent is fired when an event involving ore generation occurs.
    - * If a method utilizes this {@link Event} as its parameter, the method will + * If a method utilizes this {@link net.minecraftforge.eventbus.api.Event} as its parameter, the method will * receive every child event of this class.
    *
    * {@link #world} contains the world this event is occurring in.
    @@ -74,7 +74,7 @@ public class OreGenEvent extends Event * This event is fired just before ore generation in * {@link BiomeDecorator#generateOres(World, Random)}.
    *
    - * This event is not {@link Cancelable}.
    + * This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.
    *
    * This event does not have a result. {@link HasResult}
    *
    @@ -93,7 +93,7 @@ public class OreGenEvent extends Event * This event is fired just after ore generation in * {@link BiomeDecorator#generateOres(World, Random)}.
    *
    - * This event is not {@link Cancelable}.
    + * This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.
    *
    * This event does not have a result. {@link HasResult}
    *
    @@ -115,7 +115,7 @@ public class OreGenEvent extends Event * {@link #type} contains the enum value for the Ore attempting to be generated.
    * {@link #generator} contains the WorldGenerator generating this ore.
    *
    - * This event is not {@link Cancelable}.
    + * This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.
    *
    * This event has a result. {@link HasResult}
    * This result determines whether the ore is allowed to be generated.
    diff --git a/src/main/java/net/minecraftforge/event/terraingen/PopulateChunkEvent.java b/src/main/java/net/minecraftforge/event/terraingen/PopulateChunkEvent.java index 9b501990f..b6c0d7742 100644 --- a/src/main/java/net/minecraftforge/event/terraingen/PopulateChunkEvent.java +++ b/src/main/java/net/minecraftforge/event/terraingen/PopulateChunkEvent.java @@ -24,12 +24,12 @@ import java.util.Random; import net.minecraft.world.World; import net.minecraft.world.gen.IChunkGenerator; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; /** * PopulateChunkEvent is fired when an event involving chunk terrain feature population occurs.
    - * If a method utilizes this {@link Event} as its parameter, the method will + * If a method utilizes this {@link net.minecraftforge.eventbus.api.Event} as its parameter, the method will * receive every child event of this class.
    *
    * {@link #world} contains the world this event is occurring in.
    diff --git a/src/main/java/net/minecraftforge/event/terraingen/SaplingGrowTreeEvent.java b/src/main/java/net/minecraftforge/event/terraingen/SaplingGrowTreeEvent.java index a42fcf247..3ee6dc40e 100644 --- a/src/main/java/net/minecraftforge/event/terraingen/SaplingGrowTreeEvent.java +++ b/src/main/java/net/minecraftforge/event/terraingen/SaplingGrowTreeEvent.java @@ -24,8 +24,8 @@ import java.util.Random; import net.minecraft.block.BlockSapling; import net.minecraft.block.state.IBlockState; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event.HasResult; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event.HasResult; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.event.world.WorldEvent; @@ -38,7 +38,7 @@ import net.minecraftforge.event.world.WorldEvent; * {@link #pos} contains the coordinates of the growing sapling.
    * {@link #rand} contains an instance of Random for use.
    *
    - * This event is not {@link Cancelable}.
    + * This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.
    *
    * This event has a result. {@link HasResult}
    * This result determines if the sapling is allowed to grow.
    diff --git a/src/main/java/net/minecraftforge/event/terraingen/TerrainGen.java b/src/main/java/net/minecraftforge/event/terraingen/TerrainGen.java index df465b1c4..ca94ec949 100644 --- a/src/main/java/net/minecraftforge/event/terraingen/TerrainGen.java +++ b/src/main/java/net/minecraftforge/event/terraingen/TerrainGen.java @@ -31,7 +31,7 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate; import net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable; import net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate; -import net.minecraftforge.fml.common.eventhandler.Event.Result; +import net.minecraftforge.eventbus.api.Event.Result; public abstract class TerrainGen { diff --git a/src/main/java/net/minecraftforge/event/terraingen/WorldTypeEvent.java b/src/main/java/net/minecraftforge/event/terraingen/WorldTypeEvent.java index 78c9e5adc..341a47bba 100644 --- a/src/main/java/net/minecraftforge/event/terraingen/WorldTypeEvent.java +++ b/src/main/java/net/minecraftforge/event/terraingen/WorldTypeEvent.java @@ -21,8 +21,8 @@ package net.minecraftforge.event.terraingen; import net.minecraft.world.biome.BiomeProvider; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; import net.minecraft.world.gen.layer.GenLayer; import net.minecraft.world.WorldType; @@ -35,7 +35,7 @@ import net.minecraft.world.WorldType; *
    * All children of this event are fired on the {@link MinecraftForge#TERRAIN_GEN_BUS}.
    **/ -public class WorldTypeEvent extends Event +public class WorldTypeEvent extends net.minecraftforge.eventbus.api.Event { private final WorldType worldType; diff --git a/src/main/java/net/minecraftforge/event/world/BlockEvent.java b/src/main/java/net/minecraftforge/event/world/BlockEvent.java index 2fe035919..d529777d0 100644 --- a/src/main/java/net/minecraftforge/event/world/BlockEvent.java +++ b/src/main/java/net/minecraftforge/event/world/BlockEvent.java @@ -38,8 +38,8 @@ import net.minecraft.util.EnumFacing; import net.minecraft.world.World; 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.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; import com.google.common.collect.ImmutableList; diff --git a/src/main/java/net/minecraftforge/event/world/ChunkDataEvent.java b/src/main/java/net/minecraftforge/event/world/ChunkDataEvent.java index 3087ac367..30a7d024f 100644 --- a/src/main/java/net/minecraftforge/event/world/ChunkDataEvent.java +++ b/src/main/java/net/minecraftforge/event/world/ChunkDataEvent.java @@ -24,8 +24,8 @@ import net.minecraft.world.chunk.Chunk; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.chunk.storage.AnvilChunkLoader; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; /** * ChunkDataEvent is fired when an event involving chunk data occurs.
    @@ -75,7 +75,7 @@ public class ChunkDataEvent extends ChunkEvent * This event is fired during chunk saving in * {@link AnvilChunkLoader#saveChunk(World, Chunk)}.
    *
    - * This event is not {@link Cancelable}.
    + * This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.
    *
    * This event does not have a result. {@link HasResult}
    *
    diff --git a/src/main/java/net/minecraftforge/event/world/ChunkEvent.java b/src/main/java/net/minecraftforge/event/world/ChunkEvent.java index b870a892e..5ca1566f0 100644 --- a/src/main/java/net/minecraftforge/event/world/ChunkEvent.java +++ b/src/main/java/net/minecraftforge/event/world/ChunkEvent.java @@ -22,12 +22,12 @@ package net.minecraftforge.event.world; import net.minecraft.client.multiplayer.ChunkProviderClient; import net.minecraft.world.chunk.Chunk; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; /** * ChunkEvent is fired when an event involving a chunk occurs.
    - * If a method utilizes this {@link Event} as its parameter, the method will + * If a method utilizes this {@link net.minecraftforge.eventbus.api.Event} as its parameter, the method will * receive every child event of this class.
    *
    * {@link #chunk} contains the Chunk this event is affecting.
    @@ -55,7 +55,7 @@ public class ChunkEvent extends WorldEvent * {@link ChunkProviderClient#loadChunk(int, int)},
    * Chunk.onChunkLoad().
    *
    - * This event is not {@link Cancelable}.
    + * This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.
    *
    * This event does not have a result. {@link HasResult}
    *
    @@ -74,7 +74,7 @@ public class ChunkEvent extends WorldEvent * This event is fired during chunk unloading in
    * Chunk.onChunkUnload().
    *
    - * This event is not {@link Cancelable}.
    + * This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.
    *
    * This event does not have a result. {@link HasResult}
    *
    diff --git a/src/main/java/net/minecraftforge/event/world/ChunkWatchEvent.java b/src/main/java/net/minecraftforge/event/world/ChunkWatchEvent.java index 469301705..e14f4c5b7 100644 --- a/src/main/java/net/minecraftforge/event/world/ChunkWatchEvent.java +++ b/src/main/java/net/minecraftforge/event/world/ChunkWatchEvent.java @@ -21,8 +21,8 @@ package net.minecraftforge.event.world; import net.minecraft.server.management.PlayerChunkMapEntry; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; import javax.annotation.Nullable; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.util.math.ChunkPos; @@ -45,19 +45,9 @@ import net.minecraft.world.chunk.Chunk; **/ public class ChunkWatchEvent extends Event //TODO: extend ChunkEvent in 1.13 { - @Deprecated //TODO: Remove in 1.13 - private final ChunkPos chunk; private final EntityPlayerMP player; private final Chunk chunkInstance; - @Deprecated //TODO: Remove in 1.13 - public ChunkWatchEvent(ChunkPos chunk, EntityPlayerMP player) - { - this.chunk = chunk; - this.player = player; - this.chunkInstance = null; - } - public ChunkWatchEvent(Chunk chunk, EntityPlayerMP player) { this.chunk = chunk.getPos(); @@ -65,12 +55,6 @@ public class ChunkWatchEvent extends Event //TODO: extend ChunkEvent in 1.13 this.chunkInstance = chunk; } - @Deprecated //TODO: Remove in 1.13 - public ChunkPos getChunk() - { - return chunk; - } - public EntityPlayerMP getPlayer() { return player; @@ -91,7 +75,7 @@ public class ChunkWatchEvent extends Event //TODO: extend ChunkEvent in 1.13 * This event is fired when a chunk is added to the watched chunks of an EntityPlayer in * {@link PlayerChunkMapEntry#addPlayer(EntityPlayerMP)} and {@link PlayerChunkMapEntry#sendToPlayers()}.
    *
    - * This event is not {@link Cancelable}.
    + * This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.
    *
    * This event does not have a result. {@link HasResult}
    *
    @@ -99,9 +83,6 @@ public class ChunkWatchEvent extends Event //TODO: extend ChunkEvent in 1.13 **/ public static class Watch extends ChunkWatchEvent { - @Deprecated //TODO: Remove in 1.13 - public Watch(ChunkPos chunk, EntityPlayerMP player) { super(chunk, player); } - public Watch(Chunk chunk, EntityPlayerMP player) { super(chunk, player); } } @@ -110,7 +91,7 @@ public class ChunkWatchEvent extends Event //TODO: extend ChunkEvent in 1.13 * This event is fired when a chunk is removed from the watched chunks of an EntityPlayer in * {@link PlayerChunkMapEntry#removePlayer(EntityPlayerMP)}.
    *
    - * This event is not {@link Cancelable}.
    + * This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.
    *
    * This event does not have a result. {@link HasResult}
    *
    @@ -118,9 +99,6 @@ public class ChunkWatchEvent extends Event //TODO: extend ChunkEvent in 1.13 **/ public static class UnWatch extends ChunkWatchEvent { - @Deprecated //TODO: Remove in 1.13 - public UnWatch(ChunkPos chunkLocation, EntityPlayerMP player) { super(chunkLocation, player); } - public UnWatch(Chunk chunk, EntityPlayerMP player) { super(chunk, player); } } } diff --git a/src/main/java/net/minecraftforge/event/world/ExplosionEvent.java b/src/main/java/net/minecraftforge/event/world/ExplosionEvent.java index 4c015a033..0f426c102 100644 --- a/src/main/java/net/minecraftforge/event/world/ExplosionEvent.java +++ b/src/main/java/net/minecraftforge/event/world/ExplosionEvent.java @@ -22,8 +22,8 @@ package net.minecraftforge.event.world; import java.util.List; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; import net.minecraft.entity.Entity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.Explosion; @@ -62,7 +62,7 @@ public class ExplosionEvent extends Event /** ExplosionEvent.Start is fired before the explosion actually occurs. Canceling this event will stop the explosion.
    *
    - * This event is {@link Cancelable}.
    + * This event is {@link net.minecraftforge.eventbus.api.Cancelable}.
    * This event does not use {@link HasResult}.
    * This event is fired on the {@link MinecraftForge#EVENT_BUS}.
    */ diff --git a/src/main/java/net/minecraftforge/event/world/GetCollisionBoxesEvent.java b/src/main/java/net/minecraftforge/event/world/GetCollisionBoxesEvent.java index bba71567b..4e33b64fb 100644 --- a/src/main/java/net/minecraftforge/event/world/GetCollisionBoxesEvent.java +++ b/src/main/java/net/minecraftforge/event/world/GetCollisionBoxesEvent.java @@ -23,7 +23,7 @@ import net.minecraft.entity.Entity; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; import javax.annotation.Nullable; import java.util.List; diff --git a/src/main/java/net/minecraftforge/event/world/NoteBlockEvent.java b/src/main/java/net/minecraftforge/event/world/NoteBlockEvent.java index 04909e3a9..97162e396 100644 --- a/src/main/java/net/minecraftforge/event/world/NoteBlockEvent.java +++ b/src/main/java/net/minecraftforge/event/world/NoteBlockEvent.java @@ -22,7 +22,7 @@ package net.minecraftforge.event.world; import net.minecraft.block.state.IBlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.eventbus.api.Cancelable; import com.google.common.base.Preconditions; diff --git a/src/main/java/net/minecraftforge/event/world/WorldEvent.java b/src/main/java/net/minecraftforge/event/world/WorldEvent.java index 99f020549..ed00fc6d7 100644 --- a/src/main/java/net/minecraftforge/event/world/WorldEvent.java +++ b/src/main/java/net/minecraftforge/event/world/WorldEvent.java @@ -37,8 +37,8 @@ import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraft.world.WorldSettings; import net.minecraft.world.biome.Biome.SpawnListEntry; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; /** * WorldEvent is fired when an event involving the world occurs.
    @@ -127,7 +127,7 @@ public class WorldEvent extends Event * where the latter checks for identity, meaning both events must add the same instance. * Canceling the event will result in a empty list, meaning no entity will be spawned. */ - @Cancelable + @net.minecraftforge.eventbus.api.Cancelable public static class PotentialSpawns extends WorldEvent { private final EnumCreatureType type; @@ -169,7 +169,7 @@ public class WorldEvent extends Event * Called by WorldServer when it attempts to create a spawnpoint for a dimension. * Canceling the event will prevent the vanilla code from running. */ - @Cancelable + @net.minecraftforge.eventbus.api.Cancelable public static class CreateSpawnPosition extends WorldEvent { private final WorldSettings settings; diff --git a/src/main/java/net/minecraftforge/fluids/FluidEvent.java b/src/main/java/net/minecraftforge/fluids/FluidEvent.java index f81d0c025..db6ff9154 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidEvent.java +++ b/src/main/java/net/minecraftforge/fluids/FluidEvent.java @@ -22,9 +22,9 @@ package net.minecraftforge.fluids; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Event; -public class FluidEvent extends Event +public class FluidEvent extends net.minecraftforge.eventbus.api.Event { private final FluidStack fluid; private final World world; diff --git a/src/main/java/net/minecraftforge/fluids/FluidRegistry.java b/src/main/java/net/minecraftforge/fluids/FluidRegistry.java index 632500b83..471bc8916 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidRegistry.java +++ b/src/main/java/net/minecraftforge/fluids/FluidRegistry.java @@ -26,7 +26,6 @@ import java.util.Set; import net.minecraftforge.fml.ModThreadContext; import net.minecraftforge.fml.common.LoaderState; -import org.apache.logging.log4j.Level; import net.minecraft.block.Block; import net.minecraft.init.Blocks; @@ -48,7 +47,7 @@ import com.google.common.collect.Sets; import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.ModContainer; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.registries.IRegistryDelegate; import javax.annotation.Nullable; diff --git a/src/main/java/net/minecraftforge/fluids/UniversalBucket.java b/src/main/java/net/minecraftforge/fluids/UniversalBucket.java index 42dafc851..851aacd20 100644 --- a/src/main/java/net/minecraftforge/fluids/UniversalBucket.java +++ b/src/main/java/net/minecraftforge/fluids/UniversalBucket.java @@ -40,9 +40,9 @@ import net.minecraftforge.event.entity.player.FillBucketEvent; import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.fluids.capability.IFluidHandlerItem; import net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper; -import net.minecraftforge.fml.common.eventhandler.Event; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.Event; +import net.minecraftforge.eventbus.api.EventPriority; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.items.ItemHandlerHelper; import javax.annotation.Nonnull; @@ -212,7 +212,7 @@ public class UniversalBucket extends Item @SubscribeEvent(priority = EventPriority.LOW) // low priority so other mods can handle their stuff first public void onFillBucket(FillBucketEvent event) { - if (event.getResult() != Event.Result.DEFAULT) + if (event.getResult() != net.minecraftforge.eventbus.api.Event.Result.DEFAULT) { // event was already handled return; @@ -243,7 +243,7 @@ public class UniversalBucket extends Item FluidActionResult filledResult = FluidUtil.tryPickUpFluid(singleBucket, event.getEntityPlayer(), world, pos, target.sideHit); if (filledResult.isSuccess()) { - event.setResult(Event.Result.ALLOW); + event.setResult(net.minecraftforge.eventbus.api.Event.Result.ALLOW); event.setFilledBucket(filledResult.getResult()); } else diff --git a/src/main/java/net/minecraftforge/fml/DefaultModContainers.java b/src/main/java/net/minecraftforge/fml/DefaultModContainers.java index b909469a8..df08d1926 100644 --- a/src/main/java/net/minecraftforge/fml/DefaultModContainers.java +++ b/src/main/java/net/minecraftforge/fml/DefaultModContainers.java @@ -19,14 +19,61 @@ package net.minecraftforge.fml; -import net.minecraftforge.common.ForgeVersion; -import net.minecraftforge.fml.common.MinecraftDummyContainer; +import com.electronwill.nightconfig.core.path.PathConfig; import net.minecraftforge.fml.common.ModContainer; +import net.minecraftforge.fml.loading.moddiscovery.IModInfo; +import net.minecraftforge.fml.loading.moddiscovery.ModInfo; + +import java.net.URISyntaxException; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; public class DefaultModContainers { + static { + PathConfig minecraftmod; + PathConfig forgemod; + try + { + minecraftmod = PathConfig.of(Paths.get(DefaultModContainers.class.getClassLoader().getResource("minecraftmod.toml").toURI())); + forgemod = PathConfig.of(Paths.get(DefaultModContainers.class.getClassLoader().getResource("forgemod.toml").toURI())); + minecraftmod.load(); + forgemod.load(); + } + catch (URISyntaxException | NullPointerException e) + { + throw new RuntimeException("Missing toml configs for minecraft and forge!", e); + } + minecraftModInfo = new ModInfo(null, minecraftmod); + forgeModInfo = new ModInfo(null, forgemod); + + } + + private static final IModInfo minecraftModInfo; + private static final IModInfo forgeModInfo; + // no construction private DefaultModContainers() {} - public static final ModContainer MINECRAFT = new MinecraftDummyContainer(ForgeVersion.mcVersion); -} + public static List getModInfos() + { + return Arrays.asList(minecraftModInfo, forgeModInfo); + } + + + public static final ModContainer MINECRAFT = new ModContainer(minecraftModInfo) + { + @Override + public boolean matches(Object mod) + { + return mod == this; + } + + @Override + public Object getMod() + { + return this; + } + }; +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/fml/LaunchTesting.java b/src/main/java/net/minecraftforge/fml/LaunchTesting.java index dba8dd0b3..66c9147a6 100644 --- a/src/main/java/net/minecraftforge/fml/LaunchTesting.java +++ b/src/main/java/net/minecraftforge/fml/LaunchTesting.java @@ -51,9 +51,13 @@ public class LaunchTesting Configurator.setRootLevel(Level.DEBUG); final MarkerFilter classloadingFilter = MarkerFilter.createFilter("CLASSLOADING", Filter.Result.DENY, Filter.Result.NEUTRAL); final MarkerFilter launchpluginFilter = MarkerFilter.createFilter("LAUNCHPLUGIN", Filter.Result.DENY, Filter.Result.NEUTRAL); + final MarkerFilter axformFilter= MarkerFilter.createFilter("AXFORM", Filter.Result.DENY, Filter.Result.NEUTRAL); + final MarkerFilter eventbusFilter = MarkerFilter.createFilter("EVENTBUS", Filter.Result.DENY, Filter.Result.NEUTRAL); final LoggerContext logcontext = LoggerContext.getContext(false); -// logcontext.getConfiguration().addFilter(classloadingFilter); + logcontext.getConfiguration().addFilter(classloadingFilter); logcontext.getConfiguration().addFilter(launchpluginFilter); + logcontext.getConfiguration().addFilter(axformFilter); + logcontext.getConfiguration().addFilter(eventbusFilter); logcontext.updateLoggers(); hackNatives(); Launcher.main("--launchTarget", "devfmlclient","--gameDir", "projects/run", diff --git a/src/main/java/net/minecraftforge/fml/LifecycleEventProvider.java b/src/main/java/net/minecraftforge/fml/LifecycleEventProvider.java new file mode 100644 index 000000000..7da75f2ba --- /dev/null +++ b/src/main/java/net/minecraftforge/fml/LifecycleEventProvider.java @@ -0,0 +1,62 @@ +/* + * Minecraft Forge + * Copyright (c) 2018. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml; + +import net.minecraftforge.eventbus.api.Event; +import net.minecraftforge.fml.loading.ModList; + +import java.util.function.Supplier; + +public enum LifecycleEventProvider +{ + LOAD(()->new LifecycleEvent(ModLoadingStage.BEGIN)), + PREINIT(()->new LifecycleEvent(ModLoadingStage.PREINIT)); + + public void dispatch(final ModList target) { + target.dispatchLifeCycleEvent(this.event.get()); + } + private final Supplier event; + + LifecycleEventProvider(Supplier e) + { + event = e; + } + + + public static class LifecycleEvent extends Event { + private final ModLoadingStage stage; + + public LifecycleEvent(ModLoadingStage stage) + { + this.stage = stage; + } + + public ModLoadingStage fromStage() + { + return this.stage; + } + + public ModLoadingStage toStage() + { + return ModLoadingStage.values()[this.stage.ordinal()+1]; + } + + } +} diff --git a/src/main/java/net/minecraftforge/fml/common/eventhandler/IEventListener.java b/src/main/java/net/minecraftforge/fml/ModLoadingStage.java similarity index 86% rename from src/main/java/net/minecraftforge/fml/common/eventhandler/IEventListener.java rename to src/main/java/net/minecraftforge/fml/ModLoadingStage.java index ca25a9e53..2b8a6f9eb 100644 --- a/src/main/java/net/minecraftforge/fml/common/eventhandler/IEventListener.java +++ b/src/main/java/net/minecraftforge/fml/ModLoadingStage.java @@ -17,11 +17,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.common.eventhandler; +package net.minecraftforge.fml; - - -public interface IEventListener +public enum ModLoadingStage { - void invoke(Event event); + ERROR, BEGIN, CONSTRUCT, PREINIT, INIT, POSTINIT, COMPLETE } diff --git a/src/main/java/net/minecraftforge/fml/SidedProvider.java b/src/main/java/net/minecraftforge/fml/SidedProvider.java new file mode 100644 index 000000000..ab78ba7e1 --- /dev/null +++ b/src/main/java/net/minecraftforge/fml/SidedProvider.java @@ -0,0 +1,68 @@ +/* + * Minecraft Forge + * Copyright (c) 2018. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml; + +import net.minecraft.client.Minecraft; +import net.minecraft.server.dedicated.DedicatedServer; +import net.minecraftforge.api.Side; +import net.minecraftforge.fml.loading.FMLEnvironment; + +import java.util.function.Function; +import java.util.function.Supplier; + +public enum SidedProvider +{ + DATAFIXER(c->c.get().getDataFixer(), s->s.get().getDataFixer()); + + private static Supplier client; + private static Supplier server; + + public static void setClient(Supplier client) + { + SidedProvider.client = client; + } + public static void setServer(Supplier server) + { + SidedProvider.server = server; + } + + private final Function, ?> clientSide; + private final Function, ?> serverSide; + + + SidedProvider(Function,?> clientSide, Function,?> serverSide) + { + this.clientSide = clientSide; + this.serverSide = serverSide; + } + + @SuppressWarnings("unchecked") + public T get() { + if (FMLEnvironment.side == Side.CLIENT) { + return (T)this.clientSide.apply(client); + } + else if (FMLEnvironment.side == Side.SERVER) { + return (T)this.serverSide.apply(server); + } + else { + throw new IllegalArgumentException("THREE SIDES? WUT?"); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/fml/TomlConverters.java b/src/main/java/net/minecraftforge/fml/TomlConverters.java deleted file mode 100644 index 99f6c5940..000000000 --- a/src/main/java/net/minecraftforge/fml/TomlConverters.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml; - -import com.electronwill.nightconfig.core.conversion.Converter; - -import java.net.MalformedURLException; -import java.net.URL; - -public final class TomlConverters -{ - public static class StringToURL implements Converter { - - @Override - public URL convertToField(String value) - { - try - { - return new URL(value); - } - catch (MalformedURLException e) - { - throw new RuntimeException("Invalid URL specified", e); - } - } - - @Override - public String convertFromField(URL value) - { - return value.toString(); - } - } -} diff --git a/src/main/java/net/minecraftforge/fml/VersionChecker.java b/src/main/java/net/minecraftforge/fml/VersionChecker.java new file mode 100644 index 000000000..fbeb55a94 --- /dev/null +++ b/src/main/java/net/minecraftforge/fml/VersionChecker.java @@ -0,0 +1,122 @@ +/* + * Minecraft Forge + * Copyright (c) 2018. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml; + +import net.minecraftforge.fml.common.ModContainer; +import net.minecraftforge.fml.common.versioning.ComparableVersion; + +import javax.annotation.Nullable; +import java.net.URL; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +public class VersionChecker +{ + public enum Status + { + PENDING(), + FAILED(), + UP_TO_DATE(), + OUTDATED(3, true), + AHEAD(), + BETA(), + BETA_OUTDATED(6, true); + + final int sheetOffset; + final boolean draw, animated; + + Status() + { + this(0, false, false); + } + + Status(int sheetOffset) + { + this(sheetOffset, true, false); + } + + Status(int sheetOffset, boolean animated) + { + this(sheetOffset, true, animated); + } + + Status(int sheetOffset, boolean draw, boolean animated) + { + this.sheetOffset = sheetOffset; + this.draw = draw; + this.animated = animated; + } + + public int getSheetOffset() + { + return sheetOffset; + } + + public boolean shouldDraw() + { + return draw; + } + + public boolean isAnimated() + { + return animated; + } + + } + + public static class CheckResult + { + public final Status status; + @Nullable + public final ComparableVersion target; + public final Map changes; + @Nullable + public final String url; + + private CheckResult(Status status, @Nullable ComparableVersion target, @Nullable Map changes, @Nullable String url) + { + this.status = status; + this.target = target; + this.changes = changes == null ? Collections.emptyMap() : Collections.unmodifiableMap(changes); + this.url = url; + } + } + + public static void startVersionCheck() + { + } + + // Gather a list of mods that have opted in to this update system by providing a URL. + public static Map gatherMods() + { + Map ret = new HashMap<>(); + return ret; + } + + private static Map results = new ConcurrentHashMap<>(); + + public static CheckResult getResult(ModContainer mod) + { + return new CheckResult(Status.PENDING, null, null, null); + } + +} diff --git a/src/main/java/net/minecraftforge/fml/client/ClientModLoader.java b/src/main/java/net/minecraftforge/fml/client/ClientModLoader.java index 72d423444..b6240e915 100644 --- a/src/main/java/net/minecraftforge/fml/client/ClientModLoader.java +++ b/src/main/java/net/minecraftforge/fml/client/ClientModLoader.java @@ -20,15 +20,21 @@ package net.minecraftforge.fml.client; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.resources.IReloadableResourceManager; import net.minecraft.client.resources.IResourcePack; import net.minecraft.client.resources.data.MetadataSerializer; import net.minecraftforge.common.ForgeVersion; +import net.minecraftforge.fml.LifecycleEventProvider; +import net.minecraftforge.fml.SidedProvider; +import net.minecraftforge.fml.VersionChecker; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.ModContainer; import net.minecraftforge.fml.loading.FMLLoader; +import org.lwjgl.input.Mouse; +import java.io.IOException; import java.util.List; public class ClientModLoader @@ -40,8 +46,9 @@ public class ClientModLoader * @param mcResourceManager * @param metadataSerializer_ */ - public static void begin(Minecraft minecraft, List defaultResourcePacks, IReloadableResourceManager mcResourceManager, MetadataSerializer metadataSerializer_) + public static void begin(final Minecraft minecraft, final List defaultResourcePacks, final IReloadableResourceManager mcResourceManager, MetadataSerializer metadataSerializer_) { + SidedProvider.setClient(()->minecraft); SplashProgress.start(); FMLLoader.getModLoader().loadMods(); minecraft.refreshResources(); @@ -52,9 +59,9 @@ public class ClientModLoader SplashProgress.finish(); } - public static ForgeVersion.Status checkForUpdates() + public static VersionChecker.Status checkForUpdates() { - return ForgeVersion.Status.UP_TO_DATE; + return VersionChecker.Status.UP_TO_DATE; } public static void complete() @@ -62,4 +69,30 @@ public class ClientModLoader GlStateManager.disableTexture2D(); GlStateManager.enableTexture2D(); } + + // If the startup screen has a notification on it, render that instead of the loading screen + public static boolean drawNotificationOverProgressScreen(final Minecraft client, final ScaledResolution scaledResolution) throws IOException + { + if (client.currentScreen instanceof GuiNotification) + { + int width = scaledResolution.getScaledWidth(); + int height = scaledResolution.getScaledHeight(); + int mouseX = Mouse.getX() * width / client.displayWidth; + int mouseZ = height - Mouse.getY() * height / client.displayHeight - 1; + + client.currentScreen.drawScreen(mouseX, mouseZ, 0); + client.currentScreen.handleInput(); + + return true; + } + else + { + return false; + } + } + + public static boolean isErrored() + { + return false; + } } diff --git a/src/main/java/net/minecraftforge/fml/client/FMLClientHandler.java b/src/main/java/net/minecraftforge/fml/client/FMLClientHandler.java index 99654098f..255006f5d 100644 --- a/src/main/java/net/minecraftforge/fml/client/FMLClientHandler.java +++ b/src/main/java/net/minecraftforge/fml/client/FMLClientHandler.java @@ -109,7 +109,7 @@ import net.minecraftforge.fml.common.ModMetadata; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import net.minecraftforge.fml.common.StartupQuery; import net.minecraftforge.fml.common.WrongMinecraftVersionException; -import net.minecraftforge.fml.common.eventhandler.EventBus; +import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.common.network.FMLNetworkEvent; import net.minecraftforge.fml.common.network.internal.FMLNetworkHandler; import net.minecraftforge.fml.common.toposort.ModSortingException; @@ -118,8 +118,6 @@ import net.minecraftforge.registries.GameData; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.message.FormattedMessage; -import org.lwjgl.LWJGLUtil; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.Display; @@ -179,9 +177,6 @@ public class FMLClientHandler implements IFMLSidedHandler private DummyModContainer optifineContainer; - @Deprecated // TODO remove in 1.13. mods are referencing this to get around client-only dependencies in old Forge versions - private MissingModsException modsMissing; - private boolean loading = true; @Nullable @@ -583,15 +578,6 @@ public class FMLClientHandler implements IFMLSidedHandler return client.getIntegratedServer(); } - /** - * TODO remove in 1.13 - */ - @Deprecated - public void displayMissingMods(Object modMissingPacket) - { -// showGuiScreen(new GuiModsMissingForServer(modMissingPacket)); - } - /** * If the client is in the midst of loading, we disable saving so that custom settings aren't wiped out */ @@ -894,7 +880,7 @@ public class FMLClientHandler implements IFMLSidedHandler } @Override - public void fireNetRegistrationEvent(EventBus bus, NetworkManager manager, Set channelSet, String channel, Side side) + public void fireNetRegistrationEvent(IEventBus bus, NetworkManager manager, Set channelSet, String channel, Side side) { if (side == Side.CLIENT) { @@ -930,7 +916,6 @@ public class FMLClientHandler implements IFMLSidedHandler throw new RuntimeException("Unknown INetHandler: " + net); } - private SetMultimap missingTextures = HashMultimap.create(); private Set badTextureDomains = Sets.newHashSet(); private Table> brokenTextures = HashBasedTable.create(); @@ -1043,6 +1028,7 @@ public class FMLClientHandler implements IFMLSidedHandler return DISALLOWED_CHAR_MATCHER.removeFrom(StringUtils.stripControlCodes(message)); } + public void logMissingTextureErrors() {} @Override public void reloadRenderers() { diff --git a/src/main/java/net/minecraftforge/fml/client/TextureTracker.java b/src/main/java/net/minecraftforge/fml/client/TextureTracker.java new file mode 100644 index 000000000..e07b79afb --- /dev/null +++ b/src/main/java/net/minecraftforge/fml/client/TextureTracker.java @@ -0,0 +1,147 @@ +/* + * Minecraft Forge + * Copyright (c) 2018. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml.client; + +import com.google.common.base.MoreObjects; +import com.google.common.base.Strings; +import com.google.common.collect.HashBasedTable; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.SetMultimap; +import com.google.common.collect.Sets; +import com.google.common.collect.Table; +import net.minecraft.client.Minecraft; +import net.minecraft.client.resources.AbstractResourcePack; +import net.minecraft.client.resources.FallbackResourceManager; +import net.minecraft.client.resources.IResourcePack; +import net.minecraft.client.resources.SimpleReloadableResourceManager; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.common.FMLContainerHolder; +import net.minecraftforge.fml.common.ModContainer; +import net.minecraftforge.fml.common.ObfuscationReflectionHelper; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.io.File; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class TextureTracker +{ + private static final SetMultimap missingTextures = HashMultimap.create(); + private static final Set badTextureDomains = Sets.newHashSet(); + private static final Table> brokenTextures = HashBasedTable.create(); + + public static void trackMissingTexture(ResourceLocation resourceLocation) + { + badTextureDomains.add(resourceLocation.getResourceDomain()); + missingTextures.put(resourceLocation.getResourceDomain(),resourceLocation); + } + + public static void trackBrokenTexture(ResourceLocation resourceLocation, String error) + { + badTextureDomains.add(resourceLocation.getResourceDomain()); + Set badType = brokenTextures.get(resourceLocation.getResourceDomain(), error); + if (badType == null) + { + badType = Sets.newHashSet(); + brokenTextures.put(resourceLocation.getResourceDomain(), MoreObjects.firstNonNull(error, "Unknown error"), badType); + } + badType.add(resourceLocation); + } + + public static void logMissingTextureErrors() + { + if (missingTextures.isEmpty() && brokenTextures.isEmpty()) + { + return; + } + Logger logger = LogManager.getLogger("TEXTURE ERRORS"); + logger.error(Strings.repeat("+=", 25)); + logger.error("The following texture errors were found."); + Map resManagers = ObfuscationReflectionHelper.getPrivateValue(SimpleReloadableResourceManager.class, (SimpleReloadableResourceManager)Minecraft.getMinecraft().getResourceManager(), "domainResourceManagers", "field_110548"+"_a"); + for (String resourceDomain : badTextureDomains) + { + Set missing = missingTextures.get(resourceDomain); + logger.error(Strings.repeat("=", 50)); + logger.error(" DOMAIN {}", resourceDomain); + logger.error(Strings.repeat("-", 50)); + logger.error(" domain {} is missing {} texture{}",resourceDomain, missing.size(),missing.size()!=1 ? "s" : ""); + FallbackResourceManager fallbackResourceManager = resManagers.get(resourceDomain); + if (fallbackResourceManager == null) + { + logger.error(" domain {} is missing a resource manager - it is probably a side-effect of automatic texture processing", resourceDomain); + } + else + { + List resPacks = ObfuscationReflectionHelper.getPrivateValue(FallbackResourceManager.class, fallbackResourceManager, "resourcePacks","field_110540"+"_a"); + logger.error(" domain {} has {} location{}:",resourceDomain, resPacks.size(), resPacks.size() != 1 ? "s" :""); + for (IResourcePack resPack : resPacks) + { + if (resPack instanceof FMLContainerHolder) { + FMLContainerHolder containerHolder = (FMLContainerHolder) resPack; + ModContainer fmlContainer = containerHolder.getFMLContainer(); + logger.error(" mod {} resources at {}", fmlContainer.getModId(), fmlContainer.getSource().getPath()); + } + else if (resPack instanceof AbstractResourcePack) + { + AbstractResourcePack resourcePack = (AbstractResourcePack) resPack; + File resPath = ObfuscationReflectionHelper.getPrivateValue(AbstractResourcePack.class, resourcePack, "resourcePackFile","field_110597"+"_b"); + logger.error(" resource pack at path {}",resPath.getPath()); + } + else + { + logger.error(" unknown resourcepack type {} : {}", resPack.getClass().getName(), resPack.getPackName()); + } + } + } + logger.error(Strings.repeat("-", 25)); + if (missingTextures.containsKey(resourceDomain)) { + logger.error(" The missing resources for domain {} are:", resourceDomain); + for (ResourceLocation rl : missing) { + logger.error(" {}", rl.getResourcePath()); + } + logger.error(Strings.repeat("-", 25)); + } + if (!brokenTextures.containsRow(resourceDomain)) + { + logger.error(" No other errors exist for domain {}", resourceDomain); + } + else + { + logger.error(" The following other errors were reported for domain {}:",resourceDomain); + Map> resourceErrs = brokenTextures.row(resourceDomain); + for (String error: resourceErrs.keySet()) + { + logger.error(Strings.repeat("-", 25)); + logger.error(" Problem: {}", error); + for (ResourceLocation rl : resourceErrs.get(error)) + { + logger.error(" {}",rl.getResourcePath()); + } + } + } + logger.error(Strings.repeat("=", 50)); + } + logger.error(Strings.repeat("+=", 25)); + } + + +} diff --git a/src/main/java/net/minecraftforge/fml/client/config/GuiConfig.java b/src/main/java/net/minecraftforge/fml/client/config/GuiConfig.java index 0f8d58a95..b8243de7e 100644 --- a/src/main/java/net/minecraftforge/fml/client/config/GuiConfig.java +++ b/src/main/java/net/minecraftforge/fml/client/config/GuiConfig.java @@ -25,7 +25,6 @@ import static net.minecraftforge.fml.client.config.GuiUtils.UNDO_CHAR; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.Comparator; import java.util.List; @@ -43,7 +42,7 @@ import net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEve import net.minecraftforge.fml.client.event.ConfigChangedEvent.PostConfigChangedEvent; import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.eventhandler.Event.Result; +import net.minecraftforge.eventbus.api.Event.Result; import org.lwjgl.input.Keyboard; diff --git a/src/main/java/net/minecraftforge/fml/client/event/ConfigChangedEvent.java b/src/main/java/net/minecraftforge/fml/client/event/ConfigChangedEvent.java index 37677eabf..1d3aa8a1a 100644 --- a/src/main/java/net/minecraftforge/fml/client/event/ConfigChangedEvent.java +++ b/src/main/java/net/minecraftforge/fml/client/event/ConfigChangedEvent.java @@ -19,8 +19,8 @@ package net.minecraftforge.fml.client.event; -import net.minecraftforge.fml.common.eventhandler.Event; -import net.minecraftforge.fml.common.eventhandler.Event.HasResult; +import net.minecraftforge.eventbus.api.Event; +import net.minecraftforge.eventbus.api.Event.HasResult; import javax.annotation.Nullable; @@ -36,7 +36,7 @@ import javax.annotation.Nullable; * @author bspkrs */ @HasResult -public class ConfigChangedEvent extends Event +public class ConfigChangedEvent extends net.minecraftforge.eventbus.api.Event { private final String modID; private final boolean isWorldRunning; diff --git a/src/main/java/net/minecraftforge/fml/common/DummyModContainer.java b/src/main/java/net/minecraftforge/fml/common/DummyModContainer.java deleted file mode 100644 index a30ac203a..000000000 --- a/src/main/java/net/minecraftforge/fml/common/DummyModContainer.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.common; - -import java.io.File; -import java.net.URL; -import java.security.cert.Certificate; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import net.minecraftforge.fml.StringUtils; -import net.minecraftforge.fml.common.versioning.ArtifactVersion; -import net.minecraftforge.fml.common.versioning.DefaultArtifactVersion; -import net.minecraftforge.fml.common.versioning.VersionRange; - -import com.google.common.collect.ImmutableList; -import com.google.common.eventbus.EventBus; - -import javax.annotation.Nullable; - -public class DummyModContainer implements ModContainer -{ - private ModMetadata md; - private ArtifactVersion processedVersion; - private String label; - private int classVersion; - - public DummyModContainer(ModMetadata md) - { - this.md = md; - } - - public DummyModContainer(String label) - { - this.label = label; - } - public DummyModContainer() - { - } - - @Override - public void bindMetadata(MetadataCollection mc) - { - } - - @Override - public List getDependants() - { - return Collections.emptyList(); - } - - @Override - public List getDependencies() - { - return Collections.emptyList(); - } - - @Override - public Set getRequirements() - { - return Collections.emptySet(); - } - - @Override - public ModMetadata getMetadata() - { - return md; - } - - @Override - public Object getMod() - { - return null; - } - - @Override - public String getModId() - { - return md.modId; - } - - @Override - public String getPrefix() - { - return StringUtils.toLowerCase(getModId()); - } - - @Override - public String getName() - { - return md.name; - } - - @Override - public String getSortingRules() - { - return ""; - } - - @Override - public File getSource() - { - return null; - } - - @Override - public String getVersion() - { - return md.version; - } - - @Override - public boolean matches(Object mod) - { - return false; - } - - @Override - public void setEnabledState(boolean enabled) - { - } - - @Override - public boolean registerBus(EventBus bus, LoadController controller) - { - return false; - } - - @Override - public ArtifactVersion getProcessedVersion() - { - if (processedVersion == null) - { - processedVersion = new DefaultArtifactVersion(getModId(), getVersion()); - } - return processedVersion; - } - - @Override - public boolean isImmutable() - { - return false; - } - - @Override - public String getDisplayVersion() - { - return md.version; - } - @Override - public VersionRange acceptableMinecraftVersionRange() - { - return Loader.instance().getMinecraftModContainer().getStaticVersionRange(); - } - - @Override - @Nullable - public Certificate getSigningCertificate() - { - return null; - } - - @Override - public String toString() - { - return md != null ? getModId() : "Dummy Container ("+label+") @" + System.identityHashCode(this); - } - - @Override - public Map getCustomModProperties() - { - return EMPTY_PROPERTIES; - } - @Override - public Class getCustomResourcePackClass() - { - return null; - } - - @Override - public Map getSharedModDescriptor() - { - return null; - } - - @Override - public Disableable canBeDisabled() - { - return Disableable.NEVER; - } - - @Override - public String getGuiClassName() - { - return null; - } - - @Override - public List getOwnedPackages() - { - return ImmutableList.of(); - } - - @Override - public boolean shouldLoadInEnvironment() - { - return true; - } - - @Override - public URL getUpdateUrl() - { - return null; - } - - @Override - public void setClassVersion(int classVersion) - { - this.classVersion = classVersion; - } - - @Override - public int getClassVersion() - { - return this.classVersion; - } -} diff --git a/src/main/java/net/minecraftforge/fml/common/FMLCommonHandler.java b/src/main/java/net/minecraftforge/fml/common/FMLCommonHandler.java index 30842428b..7ec06ed05 100644 --- a/src/main/java/net/minecraftforge/fml/common/FMLCommonHandler.java +++ b/src/main/java/net/minecraftforge/fml/common/FMLCommonHandler.java @@ -54,7 +54,7 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.CompoundDataFixer; import net.minecraftforge.fml.client.BrandingControl; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.EventBus; +import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.common.gameevent.InputEvent; import net.minecraftforge.fml.common.gameevent.PlayerEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; @@ -102,7 +102,7 @@ public class FMLCommonHandler private List brandingsNoMC; private Set handlerSet = Collections.newSetFromMap(new MapMaker().weakKeys().makeMap()); private WeakReference handlerToCheck; - private EventBus eventBus = MinecraftForge.EVENT_BUS; + private IEventBus eventBus = MinecraftForge.EVENT_BUS; private volatile CountDownLatch exitLatch = null; private FMLCommonHandler() @@ -115,7 +115,7 @@ public class FMLCommonHandler * @return the event bus */ @Deprecated - public EventBus bus() + public IEventBus bus() { return eventBus; } diff --git a/src/main/java/net/minecraftforge/fml/common/FMLModContainer.java b/src/main/java/net/minecraftforge/fml/common/FMLModContainer.java deleted file mode 100644 index 870015ded..000000000 --- a/src/main/java/net/minecraftforge/fml/common/FMLModContainer.java +++ /dev/null @@ -1,776 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.common; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.net.MalformedURLException; -import java.net.URL; -import java.security.cert.Certificate; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Properties; -import java.util.Set; - -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.config.Config; -import net.minecraftforge.common.config.ConfigManager; -import net.minecraftforge.fml.common.Mod.Instance; -import net.minecraftforge.fml.common.Mod.Metadata; -import net.minecraftforge.fml.common.discovery.ASMDataTable; -import net.minecraftforge.fml.common.discovery.ModCandidate; -import net.minecraftforge.fml.common.discovery.ASMDataTable.ASMData; -import net.minecraftforge.fml.common.event.FMLConstructionEvent; -import net.minecraftforge.fml.common.event.FMLEvent; -import net.minecraftforge.fml.common.event.FMLFingerprintViolationEvent; -import net.minecraftforge.fml.common.network.NetworkRegistry; -import net.minecraftforge.fml.common.versioning.ArtifactVersion; -import net.minecraftforge.fml.common.versioning.DefaultArtifactVersion; -import net.minecraftforge.fml.common.versioning.DependencyParser; -import net.minecraftforge.fml.common.versioning.VersionParser; -import net.minecraftforge.fml.common.versioning.VersionRange; -import net.minecraftforge.fml.loading.moddiscovery.ModInfo; -import net.minecraftforge.fml.relauncher.Side; - -import org.apache.commons.io.IOUtils; -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import java.util.function.Function; -import com.google.common.base.Strings; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ListMultimap; -import com.google.common.collect.Maps; -import com.google.common.collect.SetMultimap; -import com.google.common.eventbus.EventBus; -import com.google.common.eventbus.Subscribe; - -import javax.annotation.Nullable; - -import static net.minecraftforge.fml.Logging.CORE; - -public class FMLModContainer implements ModContainer -{ - private Object modInstance; - private File source; - private ModMetadata modMetadata; - private String className; - private Map descriptor; - private boolean enabled = true; - private String internalVersion; - private boolean overridesMetadata; - private EventBus eventBus; - private LoadController controller; - private DefaultArtifactVersion processedVersion; - - private String annotationDependencies; - private VersionRange minecraftAccepted; - private boolean fingerprintNotPresent; - private Set sourceFingerprints; - private Certificate certificate; - private String modLanguage; - private ILanguageAdapter languageAdapter; - private Disableable disableability; - private ListMultimap, Method> eventMethods; - private Map customModProperties; - private ModCandidate candidate; - private URL updateJSONUrl; - private int classVersion; - - private Logger modLog; - - public FMLModContainer(String className, ModCandidate container, Map modDescriptor) - { - this.className = className; - this.source = container.getModContainer(); - this.candidate = container; - this.descriptor = modDescriptor; - this.eventMethods = ArrayListMultimap.create(); - - this.modLanguage = (String)modDescriptor.get("modLanguage"); - String languageAdapterType = (String)modDescriptor.get("modLanguageAdapter"); - if (Strings.isNullOrEmpty(languageAdapterType)) - { - this.languageAdapter = "scala".equals(modLanguage) ? new ILanguageAdapter.ScalaAdapter() : new ILanguageAdapter.JavaAdapter(); - } - else - { - // Delay loading of the adapter until the mod is on the classpath, in case the mod itself contains it. - this.languageAdapter = null; - FMLLog.log.trace("Using custom language adapter {} for {} (modid: {})", languageAdapterType, this.className, getModId()); - } - sanityCheckModId(); - - modLog = LogManager.getLogger(getModId()); - } - - public FMLModContainer(ModInfo info, String className, ClassLoader modClassLoader) - { - try - { - final Class aClass = Class.forName(className, true, modClassLoader); - LogManager.getLogger("FML").error("Loaded {} with {}", aClass, aClass.getClassLoader()); - } - catch (ClassNotFoundException e) - { - LogManager.getLogger("FML").error(CORE, "Failed to load class {}", className, e); - throw new RuntimeException(e); - } - } - - private void sanityCheckModId() - { - String modid = (String)this.descriptor.get("modid"); - if (Strings.isNullOrEmpty(modid)) - { - throw new IllegalArgumentException("The modId is null or empty"); - } - if (modid.length() > 64) - { - throw new IllegalArgumentException(String.format("The modId %s is longer than the maximum of 64 characters.", modid)); - } - if (!modid.equals(modid.toLowerCase(Locale.ENGLISH))) - { - throw new IllegalArgumentException(String.format("The modId %s must be all lowercase.", modid)); - } - } - - private ILanguageAdapter getLanguageAdapter() - { - if (languageAdapter == null) - { - try - { - languageAdapter = (ILanguageAdapter)Class.forName((String)descriptor.get("modLanguageAdapter"), true, Loader.instance().getModClassLoader()).newInstance(); - } - catch (Exception ex) - { - FMLLog.log.error("Error constructing custom mod language adapter referenced by {} (modid: {})", getModId(), ex); - throw new RuntimeException(ex); - } - } - return languageAdapter; - } - - @Override - public String getModId() - { - return (String)descriptor.get("modid"); - } - - @Override - public String getName() - { - return modMetadata.name; - } - - @Override - public String getVersion() - { - return internalVersion; - } - - @Override - public File getSource() - { - return source; - } - - @Override - public ModMetadata getMetadata() - { - return modMetadata; - } - - @Override - public void bindMetadata(MetadataCollection mc) - { - modMetadata = mc.getMetadataForId(getModId(), descriptor); - - if (descriptor.containsKey("useMetadata")) - { - overridesMetadata = !((Boolean)descriptor.get("useMetadata")); - } - - if (overridesMetadata || !modMetadata.useDependencyInformation) - { - annotationDependencies = (String)descriptor.get("dependencies"); - DependencyParser dependencyParser = new DependencyParser(getModId(), FMLCommonHandler.instance().getSide()); - DependencyParser.DependencyInfo info = dependencyParser.parseDependencies(annotationDependencies); - info.dependants.addAll(Loader.instance().getInjectedBefore(getModId())); - info.dependencies.addAll(Loader.instance().getInjectedAfter(getModId())); - modMetadata.requiredMods = info.requirements; - modMetadata.dependencies = info.dependencies; - modMetadata.dependants = info.dependants; - modLog.trace("Parsed dependency info : Requirements: {} After:{} Before:{}", info.requirements, info.dependencies, info.dependants); - } - else - { - modLog.trace("Using mcmod dependency info : {} {} {}", modMetadata.requiredMods, modMetadata.dependencies, modMetadata.dependants); - } - if (Strings.isNullOrEmpty(modMetadata.name)) - { - modLog.info("Mod {} is missing the required element 'name'. Substituting {}", getModId(), getModId()); - modMetadata.name = getModId(); - } - internalVersion = (String)descriptor.get("version"); - if (Strings.isNullOrEmpty(internalVersion)) - { - Properties versionProps = searchForVersionProperties(); - if (versionProps != null) - { - internalVersion = versionProps.getProperty(getModId() + ".version"); - modLog.debug("Found version {} for mod {} in version.properties, using", internalVersion, getModId()); - } - - } - if (Strings.isNullOrEmpty(internalVersion) && !Strings.isNullOrEmpty(modMetadata.version)) - { - modLog.warn("Mod {} is missing the required element 'version' and a version.properties file could not be found. Falling back to metadata version {}", getModId(), modMetadata.version); - internalVersion = modMetadata.version; - } - if (Strings.isNullOrEmpty(internalVersion)) - { - modLog.warn("Mod {} is missing the required element 'version' and no fallback can be found. Substituting '1.0'.", getModId()); - modMetadata.version = internalVersion = "1.0"; - } - - String mcVersionString = (String)descriptor.get("acceptedMinecraftVersions"); - if ("[1.12]".equals(mcVersionString)) - mcVersionString = "[1.12,1.12.2]"; - if ("[1.12.1]".equals(mcVersionString) || "[1.12,1.12.1]".equals(mcVersionString)) - mcVersionString = "[1.12,1.12.2]"; - - if (!Strings.isNullOrEmpty(mcVersionString)) - { - minecraftAccepted = VersionParser.parseRange(mcVersionString); - } - else - { - minecraftAccepted = Loader.instance().getMinecraftModContainer().getStaticVersionRange(); - } - - String jsonURL = (String)descriptor.get("updateJSON"); - if (!Strings.isNullOrEmpty(jsonURL)) - { - try - { - this.updateJSONUrl = new URL(jsonURL); - } - catch (MalformedURLException e) - { - modLog.debug("Specified json URL invalid: {}", jsonURL); - } - } - } - - @Nullable - public Properties searchForVersionProperties() - { - try - { - modLog.debug("Attempting to load the file version.properties from {} to locate a version number for {}", getSource().getName(), getModId()); - Properties version = null; - if (getSource().isFile()) - { - ZipFile source = new ZipFile(getSource()); - ZipEntry versionFile = source.getEntry("version.properties"); - if (versionFile != null) - { - version = new Properties(); - InputStream sourceInputStream = source.getInputStream(versionFile); - try - { - version.load(sourceInputStream); - } - finally - { - IOUtils.closeQuietly(sourceInputStream); - } - } - source.close(); - } - else if (getSource().isDirectory()) - { - File propsFile = new File(getSource(), "version.properties"); - if (propsFile.exists() && propsFile.isFile()) - { - version = new Properties(); - try (FileInputStream fis = new FileInputStream(propsFile)) - { - version.load(fis); - } - } - } - return version; - } - catch (IOException e) - { - modLog.trace("Failed to find a usable version.properties file"); - return null; - } - } - - @Override - public void setEnabledState(boolean enabled) - { - this.enabled = enabled; - } - - @Override - public Set getRequirements() - { - return modMetadata.requiredMods; - } - - @Override - public List getDependencies() - { - return modMetadata.dependencies; - } - - @Override - public List getDependants() - { - return modMetadata.dependants; - } - - @Override - public String getSortingRules() - { - return ((overridesMetadata || !modMetadata.useDependencyInformation) ? Strings.nullToEmpty(annotationDependencies) : modMetadata.printableSortingRules()); - } - - @Override - public boolean matches(Object mod) - { - return mod == modInstance; - } - - @Override - public Object getMod() - { - return modInstance; - } - - @Override - public boolean registerBus(EventBus bus, LoadController controller) - { - if (this.enabled) - { - modLog.debug("Enabling mod {}", getModId()); - this.eventBus = bus; - this.controller = controller; - eventBus.register(this); - return true; - } - else - { - return false; - } - } - - @Nullable - @SuppressWarnings("unchecked") - private Method gatherAnnotations(Class clazz) throws Exception - { - Method factoryMethod = null; - for (Method m : clazz.getDeclaredMethods()) - { - for (Annotation a : m.getAnnotations()) - { - if (a.annotationType().equals(Mod.EventHandler.class)) - { - if (m.getParameterTypes().length == 1 && FMLEvent.class.isAssignableFrom(m.getParameterTypes()[0])) - { - m.setAccessible(true); - eventMethods.put((Class)m.getParameterTypes()[0], m); - } - else - { - modLog.error("The mod {} appears to have an invalid event annotation {}. This annotation can only apply to methods with recognized event arguments - it will not be called", getModId(), a.annotationType().getSimpleName()); - } - } - else if (a.annotationType().equals(Mod.InstanceFactory.class)) - { - if (Modifier.isStatic(m.getModifiers()) && m.getParameterTypes().length == 0 && factoryMethod == null) - { - m.setAccessible(true); - factoryMethod = m; - } - else if (!(Modifier.isStatic(m.getModifiers()) && m.getParameterTypes().length == 0)) - { - modLog.error("The InstanceFactory annotation can only apply to a static method, taking zero arguments - it will be ignored on {}({})", m.getName(), Arrays.asList(m.getParameterTypes())); - } - else if (factoryMethod != null) - { - modLog.error("The InstanceFactory annotation can only be used once, the application to {}({}) will be ignored", m.getName(), Arrays.asList(m.getParameterTypes())); - } - } - } - } - return factoryMethod; - } - - private void processFieldAnnotations(ASMDataTable asmDataTable) throws Exception - { - SetMultimap annotations = asmDataTable.getAnnotationsFor(this); - - parseSimpleFieldAnnotation(annotations, Instance.class.getName(), ModContainer::getMod); - parseSimpleFieldAnnotation(annotations, Metadata.class.getName(), ModContainer::getMetadata); - } - - private void parseSimpleFieldAnnotation(SetMultimap annotations, String annotationClassName, Function retriever) throws IllegalAccessException - { - Set mods = annotations.get(Mod.class.getName()); - String[] annName = annotationClassName.split("\\."); - String annotationName = annName[annName.length - 1]; - for (ASMData targets : annotations.get(annotationClassName)) - { - String targetMod = (String)targets.getAnnotationInfo().get("value"); - String owner = (String)targets.getAnnotationInfo().get("owner"); - if (Strings.isNullOrEmpty(owner)) - { - owner = ASMDataTable.getOwnerModID(mods, targets); - if (Strings.isNullOrEmpty(owner)) - { - FMLLog.bigWarning("Could not determine owning mod for @{} on {} for mod {}", annotationClassName, targets.getClassName(), this.getModId()); - continue; - } - } - if (!this.getModId().equals(owner)) - { - FMLLog.log.debug("Skipping @{} injection for {}.{} since it is not for mod {}", annotationClassName, targets.getClassName(), targets.getObjectName(), this.getModId()); - continue; - } - Field f = null; - Object injectedMod = null; - ModContainer mc = this; - boolean isStatic = false; - Class clz = modInstance.getClass(); - if (!Strings.isNullOrEmpty(targetMod)) - { - if (Loader.isModLoaded(targetMod)) - { - mc = Loader.instance().getIndexedModList().get(targetMod); - } - else - { - mc = null; - } - } - if (mc != null) - { - try - { - clz = Class.forName(targets.getClassName(), true, Loader.instance().getModClassLoader()); - f = clz.getDeclaredField(targets.getObjectName()); - f.setAccessible(true); - isStatic = Modifier.isStatic(f.getModifiers()); - injectedMod = retriever.apply(mc); - } - catch (ReflectiveOperationException e) - { - modLog.warn("Attempting to load @{} in class {} for {} and failing", annotationName, targets.getClassName(), mc.getModId(), e); - } - } - if (f != null) - { - Object target = null; - if (!isStatic) - { - target = modInstance; - if (!modInstance.getClass().equals(clz)) - { - modLog.warn("Unable to inject @{} in non-static field {}.{} for {} as it is NOT the primary mod instance", annotationName, targets.getClassName(), targets.getObjectName(), mc.getModId()); - continue; - } - } - f.set(target, injectedMod); - } - } - } - - @Subscribe - public void constructMod(FMLConstructionEvent event) - { - try - { - ModClassLoader modClassLoader = event.getModClassLoader(); - modClassLoader.addFile(source); - modClassLoader.clearNegativeCacheFor(candidate.getClassList()); - - //Only place I could think to add this... - MinecraftForge.preloadCrashClasses(event.getASMHarvestedData(), getModId(), candidate.getClassList()); - - Class clazz = Class.forName(className, true, modClassLoader); - - Certificate[] certificates = clazz.getProtectionDomain().getCodeSource().getCertificates(); - ImmutableList certList = CertificateHelper.getFingerprints(certificates); - sourceFingerprints = ImmutableSet.copyOf(certList); - - String expectedFingerprint = (String)descriptor.get("certificateFingerprint"); - - fingerprintNotPresent = true; - - if (expectedFingerprint != null && !expectedFingerprint.isEmpty()) - { - if (!sourceFingerprints.contains(expectedFingerprint)) - { - Level warnLevel = Level.ERROR; - if (source.isDirectory()) - { - warnLevel = Level.TRACE; - } - modLog.log(warnLevel, "The mod {} is expecting signature {} for source {}, however there is no signature matching that description", getModId(), expectedFingerprint, source.getName()); - } - else - { - certificate = certificates[certList.indexOf(expectedFingerprint)]; - fingerprintNotPresent = false; - } - } - - @SuppressWarnings("unchecked") - List> props = (List>)descriptor.get("customProperties"); - if (props != null) - { - com.google.common.collect.ImmutableMap.Builder builder = ImmutableMap.builder(); - for (Map p : props) - { - builder.put((String)p.get("k"), (String)p.get("v")); - } - customModProperties = builder.build(); - } - else - { - customModProperties = EMPTY_PROPERTIES; - } - - Boolean hasDisableableFlag = (Boolean)descriptor.get("canBeDeactivated"); - boolean hasReverseDepends = !event.getReverseDependencies().get(getModId()).isEmpty(); - if (hasDisableableFlag != null && hasDisableableFlag) - { - disableability = hasReverseDepends ? Disableable.DEPENDENCIES : Disableable.YES; - } - else - { - disableability = hasReverseDepends ? Disableable.DEPENDENCIES : Disableable.RESTART; - } - Method factoryMethod = gatherAnnotations(clazz); - modInstance = getLanguageAdapter().getNewInstance(this, clazz, modClassLoader, factoryMethod); - NetworkRegistry.INSTANCE.register(this, clazz, (String)(descriptor.containsKey("acceptableRemoteVersions") ? descriptor.get("acceptableRemoteVersions") : null), event.getASMHarvestedData()); - if (fingerprintNotPresent) - { - eventBus.post(new FMLFingerprintViolationEvent(source.isDirectory(), source, ImmutableSet.copyOf(this.sourceFingerprints), expectedFingerprint)); - } - ProxyInjector.inject(this, event.getASMHarvestedData(), FMLCommonHandler.instance().getSide(), getLanguageAdapter()); - AutomaticEventSubscriber.inject(this, event.getASMHarvestedData(), FMLCommonHandler.instance().getSide()); - ConfigManager.sync(this.getModId(), Config.Type.INSTANCE); - - processFieldAnnotations(event.getASMHarvestedData()); - } - catch (Throwable e) - { - controller.errorOccurred(this, e); - } - } - - @Subscribe - public void handleModStateEvent(FMLEvent event) - { - if (!eventMethods.containsKey(event.getClass())) - { - return; - } - try - { - for (Method m : eventMethods.get(event.getClass())) - { - m.invoke(modInstance, event); - } - } - catch (Throwable t) - { - controller.errorOccurred(this, t); - } - } - - @Override - public ArtifactVersion getProcessedVersion() - { - if (processedVersion == null) - { - processedVersion = new DefaultArtifactVersion(getModId(), getVersion()); - } - return processedVersion; - } - - @Override - public boolean isImmutable() - { - return false; - } - - @Override - public String getDisplayVersion() - { - return modMetadata.version; - } - - @Override - public VersionRange acceptableMinecraftVersionRange() - { - return minecraftAccepted; - } - - @Override - public Certificate getSigningCertificate() - { - return certificate; - } - - @Override - public String toString() - { - return "FMLMod:" + getModId() + "{" + getVersion() + "}"; - } - - @Override - public Map getCustomModProperties() - { - return customModProperties; - } - - @Override - public Class getCustomResourcePackClass() - { - try - { - return getSource().isDirectory() ? Class.forName("net.minecraftforge.fml.client.FMLFolderResourcePack", true, getClass().getClassLoader()) : Class.forName("net.minecraftforge.fml.client.FMLFileResourcePack", true, getClass().getClassLoader()); - } - catch (ClassNotFoundException e) - { - return null; - } - } - - @Override - public Map getSharedModDescriptor() - { - Map descriptor = Maps.newHashMap(); - descriptor.put("modsystem", "FML"); - descriptor.put("id", getModId()); - descriptor.put("version", getDisplayVersion()); - descriptor.put("name", getName()); - descriptor.put("url", modMetadata.url); - descriptor.put("authors", modMetadata.getAuthorList()); - descriptor.put("description", modMetadata.description); - return descriptor; - } - - @Override - public Disableable canBeDisabled() - { - return disableability; - } - - @Override - public String getGuiClassName() - { - return (String)descriptor.get("guiFactory"); - } - - @Override - public List getOwnedPackages() - { - return candidate.getContainedPackages(); - } - - private boolean isTrue(Boolean value) - { - if (value == null) - { - return false; - } - return value; - } - - @Override - public boolean shouldLoadInEnvironment() - { - boolean clientSideOnly = isTrue((Boolean)descriptor.get("clientSideOnly")); - boolean serverSideOnly = isTrue((Boolean)descriptor.get("serverSideOnly")); - - if (clientSideOnly && serverSideOnly) - { - throw new RuntimeException("Mod annotation claims to be both client and server side only!"); - } - - Side side = FMLCommonHandler.instance().getSide(); - - if (clientSideOnly && side != Side.CLIENT) - { - FMLLog.log.info("Disabling mod {} it is client side only.", getModId()); - return false; - } - - if (serverSideOnly && side != Side.SERVER) - { - FMLLog.log.info("Disabling mod {} it is server side only.", getModId()); - return false; - } - - return true; - } - - @Override - public URL getUpdateUrl() - { - return updateJSONUrl; - } - - @Override - public void setClassVersion(int classVersion) - { - this.classVersion = classVersion; - } - - @Override - public int getClassVersion() - { - return this.classVersion; - } -} diff --git a/src/main/java/net/minecraftforge/fml/common/IFMLSidedHandler.java b/src/main/java/net/minecraftforge/fml/common/IFMLSidedHandler.java index 781d617c9..a637eee85 100644 --- a/src/main/java/net/minecraftforge/fml/common/IFMLSidedHandler.java +++ b/src/main/java/net/minecraftforge/fml/common/IFMLSidedHandler.java @@ -28,7 +28,7 @@ import net.minecraft.network.NetworkManager; import net.minecraft.server.MinecraftServer; import net.minecraft.util.IThreadListener; import net.minecraftforge.common.util.CompoundDataFixer; -import net.minecraftforge.fml.common.eventhandler.EventBus; +import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.relauncher.Side; public interface IFMLSidedHandler @@ -65,7 +65,7 @@ public interface IFMLSidedHandler INetHandler getClientPlayHandler(); - void fireNetRegistrationEvent(EventBus bus, NetworkManager manager, Set channelSet, String channel, Side side); + void fireNetRegistrationEvent(IEventBus bus, NetworkManager manager, Set channelSet, String channel, Side side); boolean shouldAllowPlayerLogins(); diff --git a/src/main/java/net/minecraftforge/fml/common/ILanguageAdapter.java b/src/main/java/net/minecraftforge/fml/common/ILanguageAdapter.java index 76372a467..863db19c7 100644 --- a/src/main/java/net/minecraftforge/fml/common/ILanguageAdapter.java +++ b/src/main/java/net/minecraftforge/fml/common/ILanguageAdapter.java @@ -23,10 +23,9 @@ import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import net.minecraftforge.fml.javafmlmod.FMLModContainer; import net.minecraftforge.fml.relauncher.Side; -import org.apache.logging.log4j.Level; - public interface ILanguageAdapter { Object getNewInstance(FMLModContainer container, Class objectClass, ClassLoader classLoader, Method factoryMarkedAnnotation) throws Exception; boolean supportsStatics(); diff --git a/src/main/java/net/minecraftforge/fml/common/InjectedModContainer.java b/src/main/java/net/minecraftforge/fml/common/InjectedModContainer.java deleted file mode 100644 index bc38f56de..000000000 --- a/src/main/java/net/minecraftforge/fml/common/InjectedModContainer.java +++ /dev/null @@ -1,240 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.common; - -import java.io.File; -import java.net.URL; -import java.security.cert.Certificate; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import net.minecraftforge.fml.common.versioning.ArtifactVersion; -import net.minecraftforge.fml.common.versioning.VersionRange; - -import com.google.common.eventbus.EventBus; - -import javax.annotation.Nullable; - -public class InjectedModContainer implements ModContainer -{ - private File source; - public final ModContainer wrappedContainer; - - public InjectedModContainer(ModContainer mc, File source) - { - this.source = source != null ? source : new File("minecraft.jar"); - this.wrappedContainer = mc; - } - - @Override - public String getModId() - { - return wrappedContainer.getModId(); - } - - @Override - public String getName() - { - return wrappedContainer.getName(); - } - - @Override - public String getVersion() - { - return wrappedContainer.getVersion(); - } - - @Override - public File getSource() - { - return source; - } - - @Override - public ModMetadata getMetadata() - { - return wrappedContainer.getMetadata(); - } - - @Override - public void bindMetadata(MetadataCollection mc) - { - wrappedContainer.bindMetadata(mc); - } - - @Override - public void setEnabledState(boolean enabled) - { - wrappedContainer.setEnabledState(enabled); - } - - @Override - public Set getRequirements() - { - return wrappedContainer.getRequirements(); - } - - @Override - public List getDependencies() - { - return wrappedContainer.getDependencies(); - } - - @Override - public List getDependants() - { - return wrappedContainer.getDependants(); - } - - @Override - public String getSortingRules() - { - return wrappedContainer.getSortingRules(); - } - - @Override - public boolean registerBus(EventBus bus, LoadController controller) - { - return wrappedContainer.registerBus(bus, controller); - } - - @Override - public boolean matches(Object mod) - { - return wrappedContainer.matches(mod); - } - - @Override - public Object getMod() - { - return wrappedContainer.getMod(); - } - - @Override - public ArtifactVersion getProcessedVersion() - { - return wrappedContainer.getProcessedVersion(); - } - - @Override - public boolean isImmutable() - { - return true; - } - - @Override - public String getDisplayVersion() - { - return wrappedContainer.getDisplayVersion(); - } - - @Override - public VersionRange acceptableMinecraftVersionRange() - { - return wrappedContainer.acceptableMinecraftVersionRange(); - } - - @Nullable - public WorldAccessContainer getWrappedWorldAccessContainer() - { - if (wrappedContainer instanceof WorldAccessContainer) - { - return (WorldAccessContainer) wrappedContainer; - } - else - { - return null; - } - } - - @Override - @Nullable - public Certificate getSigningCertificate() - { - return wrappedContainer.getSigningCertificate(); - } - - @Override - public String toString() - { - return "Wrapped{"+wrappedContainer.toString()+"}"; - } - - @Override - public Map getCustomModProperties() - { - return wrappedContainer.getCustomModProperties(); - } - - @Override - public Class getCustomResourcePackClass() - { - return wrappedContainer.getCustomResourcePackClass(); - } - - @Override - public Map getSharedModDescriptor() - { - return wrappedContainer.getSharedModDescriptor(); - } - - @Override - public Disableable canBeDisabled() - { - return wrappedContainer.canBeDisabled(); - } - - @Override - public String getGuiClassName() - { - return wrappedContainer.getGuiClassName(); - } - - @Override - public List getOwnedPackages() - { - return wrappedContainer.getOwnedPackages(); - } - - @Override - public boolean shouldLoadInEnvironment() - { - return true; - } - - @Override - public URL getUpdateUrl() - { - return wrappedContainer.getUpdateUrl(); - } - - @Override - public void setClassVersion(int classVersion) - { - wrappedContainer.setClassVersion(classVersion); - } - - @Override - public int getClassVersion() - { - return wrappedContainer.getClassVersion(); - } -} diff --git a/src/main/java/net/minecraftforge/fml/common/MCPDummyContainer.java b/src/main/java/net/minecraftforge/fml/common/MCPDummyContainer.java deleted file mode 100644 index a958649cb..000000000 --- a/src/main/java/net/minecraftforge/fml/common/MCPDummyContainer.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.common; - -import com.google.common.eventbus.EventBus; - -public class MCPDummyContainer extends DummyModContainer { - public MCPDummyContainer(ModMetadata metadata) { - super(metadata); - } - - @Override - public boolean registerBus(EventBus bus, LoadController controller) { - return true; - } - - @Override - public Disableable canBeDisabled() - { - return Disableable.YES; - } -} diff --git a/src/main/java/net/minecraftforge/fml/common/MinecraftDummyContainer.java b/src/main/java/net/minecraftforge/fml/common/MinecraftDummyContainer.java deleted file mode 100644 index d66597090..000000000 --- a/src/main/java/net/minecraftforge/fml/common/MinecraftDummyContainer.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.common; - -import java.io.File; -import java.security.cert.Certificate; - -import com.google.common.eventbus.EventBus; -import net.minecraftforge.fml.common.versioning.VersionParser; -import net.minecraftforge.fml.common.versioning.VersionRange; -import net.minecraftforge.fml.relauncher.FMLLaunchHandler; -import net.minecraftforge.fml.relauncher.Side; - -import javax.annotation.Nullable; - -public class MinecraftDummyContainer extends DummyModContainer -{ - - private VersionRange staticRange; - public MinecraftDummyContainer(String actualMCVersion) - { - super(new ModMetadata()); - getMetadata().modId = "minecraft"; - getMetadata().name = "Minecraft"; - getMetadata().version = actualMCVersion; - staticRange = VersionParser.parseRange("["+actualMCVersion+"]"); - } - - @Override - public boolean isImmutable() - { - return true; - } - - @Override - public File getSource() - { - return new File("minecraft.jar"); - } - - @Override - public boolean registerBus(EventBus bus, LoadController controller) - { - return true; - } - - public VersionRange getStaticVersionRange() - { - return staticRange; - } - - @Override - @Nullable - public Certificate getSigningCertificate() - { - if (FMLLaunchHandler.side() != Side.CLIENT) - return null; - - try - { - Class cbr = Class.forName("net.minecraft.client.ClientBrandRetriever", false, getClass().getClassLoader()); - Certificate[] certificates = cbr.getProtectionDomain().getCodeSource().getCertificates(); - return certificates != null ? certificates[0] : null; - } - catch (Exception ignored){} // Errors don't matter just return null. - return null; - } -} diff --git a/src/main/java/net/minecraftforge/fml/common/ModAPIManager.java b/src/main/java/net/minecraftforge/fml/common/ModAPIManager.java deleted file mode 100644 index 2597b2ed4..000000000 --- a/src/main/java/net/minecraftforge/fml/common/ModAPIManager.java +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.common; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -import net.minecraftforge.fml.common.asm.transformers.ModAPITransformer; -import net.minecraftforge.fml.common.discovery.ASMDataTable; -import net.minecraftforge.fml.common.discovery.ModCandidate; -import net.minecraftforge.fml.common.discovery.ModDiscoverer; -import net.minecraftforge.fml.common.discovery.ASMDataTable.ASMData; -import net.minecraftforge.fml.common.versioning.ArtifactVersion; -import net.minecraftforge.fml.common.versioning.DefaultArtifactVersion; -import net.minecraftforge.fml.common.versioning.VersionParser; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; - -public class ModAPIManager { - public static final ModAPIManager INSTANCE = new ModAPIManager(); - @SuppressWarnings("unused") - private ModAPITransformer transformer; - private ASMDataTable dataTable; - private Map apiContainers; - - private static class APIContainer extends DummyModContainer { - private List referredMods; - private ArtifactVersion ownerMod; - private ArtifactVersion ourVersion; - private String providedAPI; - private File source; - private String version; - private Set currentReferents; - private Set packages; - private boolean selfReferenced; - - public APIContainer(String providedAPI, String apiVersion, File source, ArtifactVersion ownerMod) - { - this.providedAPI = providedAPI; - this.version = apiVersion; - this.ownerMod = ownerMod; - this.ourVersion = new DefaultArtifactVersion(providedAPI, apiVersion); - this.referredMods = Lists.newArrayList(); - this.source = source; - this.currentReferents = Sets.newHashSet(); - this.packages = Sets.newHashSet(); - } - - @Override - public File getSource() - { - return source; - } - @Override - public String getVersion() - { - return version; - } - @Override - public String getName() - { - return "API: "+providedAPI; - } - @Override - public String getModId() - { - return providedAPI; - } - @Override - public List getDependants() - { - return referredMods; - } - - @Override - public List getDependencies() - { - return selfReferenced ? ImmutableList.of() : ImmutableList.of(ownerMod); - } - - @Override - public ArtifactVersion getProcessedVersion() - { - return ourVersion; - } - - public void validate(String providedAPI, String apiOwner, String apiVersion) - { - if (Loader.instance().getModClassLoader().containsSource(this.getSource())) { - FMLLog.bigWarning("The API {} from source {} is loaded from an incompatible classloader. THIS WILL NOT WORK!", providedAPI, this.getSource().getAbsolutePath()); - } - // TODO Compare this annotation data to the one we first found. Maybe barf if there is inconsistency? - } - - @Override - public String toString() - { - return "APIContainer{"+providedAPI+":"+version+"}"; - } - - public void addAPIReference(String embedded) - { - if (currentReferents.add(embedded)) - { - referredMods.add(VersionParser.parseVersionReference(embedded)); - } - } - - public void addOwnedPackage(String apiPackage) - { - packages.add(apiPackage); - } - - public void addAPIReferences(List candidateIds) - { - for (String modId : candidateIds) - { - addAPIReference(modId); - } - } - - void markSelfReferenced() - { - selfReferenced = true; - } - } - public void registerDataTableAndParseAPI(ASMDataTable dataTable) - { - this.dataTable = dataTable; - - Set apiList = dataTable.getAll("net.minecraftforge.fml.common.API"); - - apiContainers = Maps.newHashMap(); - - for (ASMData data : apiList) - { - Map annotationInfo = data.getAnnotationInfo(); - String apiPackage = data.getClassName().substring(0,data.getClassName().indexOf(".package-info")); - String providedAPI = (String) annotationInfo.get("provides"); - String apiOwner = (String) annotationInfo.get("owner"); - String apiVersion = (String) annotationInfo.get("apiVersion"); - APIContainer container = apiContainers.get(providedAPI); - if (container == null) - { - container = new APIContainer(providedAPI, apiVersion, data.getCandidate().getModContainer(), VersionParser.parseVersionReference(apiOwner)); - apiContainers.put(providedAPI, container); - } - else - { - container.validate(providedAPI, apiOwner, apiVersion); - } - container.addOwnedPackage(apiPackage); - for (ModContainer mc : data.getCandidate().getContainedMods()) - { - String embeddedIn = mc.getModId(); - if (container.currentReferents.contains(embeddedIn)) - { - continue; - } - FMLLog.log.debug("Found API {} (owned by {} providing {}) embedded in {}",apiPackage, apiOwner, providedAPI, embeddedIn); - if (!embeddedIn.equals(apiOwner)) - { - container.addAPIReference(embeddedIn); - } - } - } - - for (APIContainer container : apiContainers.values()) - { - for (String pkg : container.packages) - { - Set candidates = dataTable.getCandidatesFor(pkg); - for (ModCandidate candidate : candidates) - { - List candidateIds = candidate.getContainedMods().stream().map(ModContainer::getModId).collect(Collectors.toCollection(ArrayList::new)); - if (!candidateIds.contains(container.ownerMod.getLabel()) && !container.currentReferents.containsAll(candidateIds)) - { - FMLLog.log.info("Found mod(s) {} containing declared API package {} (owned by {}) without associated API reference",candidateIds, pkg, container.ownerMod); - container.addAPIReferences(candidateIds); - } - } - } - if (apiContainers.containsKey(container.ownerMod.getLabel())) - { - ArtifactVersion owner = container.ownerMod; - do - { - APIContainer parent = apiContainers.get(owner.getLabel()); - if (parent == container) - { - FMLLog.log.trace("APIContainer {} is it's own parent. skipping", owner); - container.markSelfReferenced(); - break; - } - FMLLog.log.trace("Removing upstream parent {} from {}", parent.ownerMod.getLabel(), container); - container.currentReferents.remove(parent.ownerMod.getLabel()); - container.referredMods.remove(parent.ownerMod); - owner = parent.ownerMod; - } - while (apiContainers.containsKey(owner.getLabel())); - } - FMLLog.log.debug("Creating API container dummy for API {}: owner: {}, dependents: {}", container.providedAPI, container.ownerMod, container.referredMods); - } - } - - public void manageAPI(ModClassLoader modClassLoader, ModDiscoverer discoverer) - { - registerDataTableAndParseAPI(discoverer.getASMTable()); - transformer = modClassLoader.addModAPITransformer(dataTable); - } - - public void injectAPIModContainers(List mods, Map nameLookup) - { - mods.addAll(apiContainers.values()); - nameLookup.putAll(apiContainers); - } - - public void cleanupAPIContainers(List mods) - { - mods.removeAll(apiContainers.values()); - } - - public boolean hasAPI(String modId) - { - return apiContainers.containsKey(modId); - } - - public Iterable getAPIList() - { - return apiContainers.values(); - } -} diff --git a/src/main/java/net/minecraftforge/fml/common/ModContainer.java b/src/main/java/net/minecraftforge/fml/common/ModContainer.java index 1442fc0a6..3a4cc7b1c 100644 --- a/src/main/java/net/minecraftforge/fml/common/ModContainer.java +++ b/src/main/java/net/minecraftforge/fml/common/ModContainer.java @@ -19,20 +19,13 @@ package net.minecraftforge.fml.common; -import java.io.File; -import java.net.URL; -import java.security.cert.Certificate; -import java.util.List; +import net.minecraftforge.fml.LifecycleEventProvider; +import net.minecraftforge.fml.ModLoadingStage; +import net.minecraftforge.fml.loading.moddiscovery.IModInfo; + +import java.util.HashMap; import java.util.Map; -import java.util.Set; - -import net.minecraftforge.fml.common.versioning.ArtifactVersion; -import net.minecraftforge.fml.common.versioning.VersionRange; - -import com.google.common.collect.ImmutableMap; -import com.google.common.eventbus.EventBus; - -import javax.annotation.Nullable; +import java.util.function.Consumer; /** * The container that wraps around mods in the system. @@ -47,125 +40,82 @@ import javax.annotation.Nullable; * */ -public interface ModContainer +public abstract class ModContainer { - public static enum Disableable { - YES, RESTART, NEVER, DEPENDENCIES; - + protected final String modId; + protected final IModInfo modInfo; + protected ModLoadingStage modLoadingStage; + protected final Map> triggerMap; + public ModContainer(IModInfo info) + { + this.modId = info.getModId(); + this.modInfo = info; + this.triggerMap = new HashMap<>(); + this.modLoadingStage = ModLoadingStage.BEGIN; } + /** - * The globally unique modid for this mod + * @return the modid for this mod */ - String getModId(); - String getPrefix(); + public final String getModId() + { + return modId; + } /** - * A human readable name + * @return the resource prefix for the mod */ - - String getName(); + public final String getPrefix() + { + return modId; + } /** - * A human readable version identifier + * @return The current loading stage for this mod */ - String getVersion(); + public ModLoadingStage getCurrentState() + { + return modLoadingStage; + } /** - * The location on the file system which this mod came from + * Transition the mod to this event if possible. + * @param event to transition to */ - File getSource(); + public final void transitionState(LifecycleEventProvider.LifecycleEvent event) + { + if (modLoadingStage != event.fromStage()) + { + try + { + triggerMap.getOrDefault(modLoadingStage, e->{}).accept(event); + modLoadingStage = event.toStage(); + } + catch (RuntimeException e) + { + modLoadingStage = ModLoadingStage.ERROR; + } + } + } /** - * The metadata for this mod + * @return the modinfo used to create this mod instance */ - ModMetadata getMetadata(); + public IModInfo getModInfo() + { + return modInfo; + } /** - * Attach this mod to it's metadata from the supplied metadata collection - */ - void bindMetadata(MetadataCollection mc); - - /** - * Set the enabled/disabled state of this mod - */ - void setEnabledState(boolean enabled); - - /** - * A list of the modids that this mod requires loaded prior to loading - */ - Set getRequirements(); - - /** - * A list of modids that should be loaded prior to this one. The special - * value * indicates to load after any other mod. - */ - List getDependencies(); - - /** - * A list of modids that should be loaded after this one. The - * special value * indicates to load before any - * other mod. - */ - List getDependants(); - - /** - * A representative string encapsulating the sorting preferences for this - * mod - */ - String getSortingRules(); - - /** - * Register the event bus for the mod and the controller for error handling - * Returns if this bus was successfully registered - disabled mods and other - * mods that don't need real events should return false and avoid further - * processing + * Does this mod match the supplied mod? * - * @param bus - * @param controller + * @param mod to compare + * @return if the mod matches */ - boolean registerBus(EventBus bus, LoadController controller); + public abstract boolean matches(Object mod); /** - * Does this mod match the supplied mod - * - * @param mod + * @return the mod object instance */ - boolean matches(Object mod); - - /** - * Get the actual mod object - */ - Object getMod(); - - ArtifactVersion getProcessedVersion(); - - boolean isImmutable(); - - String getDisplayVersion(); - - VersionRange acceptableMinecraftVersionRange(); - - @Nullable - Certificate getSigningCertificate(); - - public static final Map EMPTY_PROPERTIES = ImmutableMap.of(); - Map getCustomModProperties(); - - public Class getCustomResourcePackClass(); - - Map getSharedModDescriptor(); - - Disableable canBeDisabled(); - - String getGuiClassName(); - - List getOwnedPackages(); - - boolean shouldLoadInEnvironment(); - - URL getUpdateUrl(); - - void setClassVersion(int classVersion); - - int getClassVersion(); + public abstract Object getMod(); } diff --git a/src/main/java/net/minecraftforge/fml/common/ModContainerFactory.java b/src/main/java/net/minecraftforge/fml/common/ModContainerFactory.java index 1df9a3b85..a1eedbb6a 100644 --- a/src/main/java/net/minecraftforge/fml/common/ModContainerFactory.java +++ b/src/main/java/net/minecraftforge/fml/common/ModContainerFactory.java @@ -25,6 +25,7 @@ import java.util.Map; import net.minecraftforge.fml.common.discovery.ModCandidate; import net.minecraftforge.fml.common.discovery.asm.ASMModParser; +import net.minecraftforge.fml.javafmlmod.FMLModContainer; import net.minecraftforge.fml.loading.moddiscovery.ModAnnotation; import org.objectweb.asm.Type; diff --git a/src/main/java/net/minecraftforge/fml/common/asm/transformers/EventSubscriptionTransformer.java b/src/main/java/net/minecraftforge/fml/common/asm/transformers/EventSubscriptionTransformer.java index f5d470b83..f0aac3b74 100644 --- a/src/main/java/net/minecraftforge/fml/common/asm/transformers/EventSubscriptionTransformer.java +++ b/src/main/java/net/minecraftforge/fml/common/asm/transformers/EventSubscriptionTransformer.java @@ -42,7 +42,7 @@ import static org.objectweb.asm.Type.getMethodDescriptor; import net.minecraft.launchwrapper.IClassTransformer; import net.minecraftforge.fml.common.FMLLog; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Event; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassWriter; @@ -104,7 +104,7 @@ public class EventSubscriptionTransformer implements IClassTransformer // Yes, this recursively loads classes until we get this base class. THIS IS NOT A ISSUE. Coremods should handle re-entry just fine. // If they do not this a COREMOD issue NOT a Forge/LaunchWrapper issue. Class parent = this.getClass().getClassLoader().loadClass(classNode.superName.replace('/', '.')); - if (!Event.class.isAssignableFrom(parent)) + if (!net.minecraftforge.eventbus.api.Event.class.isAssignableFrom(parent)) { return false; } diff --git a/src/main/java/net/minecraftforge/fml/common/event/FMLPreInitializationEvent.java b/src/main/java/net/minecraftforge/fml/common/event/FMLPreInitializationEvent.java index 833675d74..0e90b1f44 100644 --- a/src/main/java/net/minecraftforge/fml/common/event/FMLPreInitializationEvent.java +++ b/src/main/java/net/minecraftforge/fml/common/event/FMLPreInitializationEvent.java @@ -24,7 +24,7 @@ import java.security.CodeSource; import java.security.cert.Certificate; import java.util.Properties; -import net.minecraftforge.fml.common.FMLModContainer; +import net.minecraftforge.fml.javafmlmod.FMLModContainer; import net.minecraftforge.fml.common.ModContainer; import net.minecraftforge.fml.common.ModMetadata; import net.minecraftforge.fml.common.LoaderState.ModState; diff --git a/src/main/java/net/minecraftforge/fml/common/eventhandler/ASMEventHandler.java b/src/main/java/net/minecraftforge/fml/common/eventhandler/ASMEventHandler.java deleted file mode 100644 index 4a72e3032..000000000 --- a/src/main/java/net/minecraftforge/fml/common/eventhandler/ASMEventHandler.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.common.eventhandler; - -import static org.objectweb.asm.Opcodes.*; - -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.lang.reflect.ParameterizedType; -import java.util.HashMap; - -import net.minecraftforge.fml.common.ModContainer; - -import org.apache.logging.log4j.ThreadContext; -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 static final boolean GETCONTEXT = Boolean.parseBoolean(System.getProperty("fml.LogContext", "false")); - - private final IEventListener handler; - private final SubscribeEvent subInfo; - private ModContainer owner; - private String readable; - private java.lang.reflect.Type filter = null; - - @Deprecated - public ASMEventHandler(Object target, Method method, ModContainer owner) throws Exception - { - this(target, method, owner, false); - } - - public ASMEventHandler(Object target, Method method, ModContainer owner, boolean isGeneric) throws Exception - { - this.owner = owner; - if (Modifier.isStatic(method.getModifiers())) - handler = (IEventListener)createWrapper(method).newInstance(); - else - handler = (IEventListener)createWrapper(method).getConstructor(Object.class).newInstance(target); - subInfo = method.getAnnotation(SubscribeEvent.class); - readable = "ASM: " + target + " " + method.getName() + Type.getMethodDescriptor(method); - if (isGeneric) - { - java.lang.reflect.Type type = method.getGenericParameterTypes()[0]; - if (type instanceof ParameterizedType) - { - filter = ((ParameterizedType)type).getActualTypeArguments()[0]; - } - } - } - - @SuppressWarnings("rawtypes") - @Override - public void invoke(Event event) - { - if (GETCONTEXT) - ThreadContext.put("mod", owner == null ? "" : owner.getName()); - if (handler != null) - { - if (!event.isCancelable() || !event.isCanceled() || subInfo.receiveCanceled()) - { - if (filter == null || filter == ((IGenericEvent)event).getGenericType()) - { - handler.invoke(event); - } - } - } - if (GETCONTEXT) - ThreadContext.remove("mod"); - } - - 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; - - boolean isStatic = Modifier.isStatic(callback.getModifiers()); - 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); - { - if (!isStatic) - cw.visitField(ACC_PUBLIC, "instance", "Ljava/lang/Object;", null, null).visitEnd(); - } - { - mv = cw.visitMethod(ACC_PUBLIC, "", isStatic ? "()V" : "(Ljava/lang/Object;)V", null, null); - mv.visitCode(); - mv.visitVarInsn(ALOAD, 0); - mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "", "()V", false); - if (!isStatic) - { - 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); - if (!isStatic) - { - mv.visitFieldInsn(GETFIELD, desc, "instance", "Ljava/lang/Object;"); - mv.visitTypeInsn(CHECKCAST, instType); - } - mv.visitVarInsn(ALOAD, 1); - mv.visitTypeInsn(CHECKCAST, eventType); - mv.visitMethodInsn(isStatic ? INVOKESTATIC : INVOKEVIRTUAL, instType, callback.getName(), Type.getMethodDescriptor(callback), false); - 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); - } - } - - public String toString() - { - return readable; - } -} diff --git a/src/main/java/net/minecraftforge/fml/common/eventhandler/Cancelable.java b/src/main/java/net/minecraftforge/fml/common/eventhandler/Cancelable.java deleted file mode 100644 index 08b7f0352..000000000 --- a/src/main/java/net/minecraftforge/fml/common/eventhandler/Cancelable.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.common.eventhandler; - -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/fml/common/eventhandler/Event.java b/src/main/java/net/minecraftforge/fml/common/eventhandler/Event.java deleted file mode 100644 index 534a526a8..000000000 --- a/src/main/java/net/minecraftforge/fml/common/eventhandler/Event.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.common.eventhandler; - -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 javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import com.google.common.base.Preconditions; - - -/** - * 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 Result result = Result.DEFAULT; - private static ListenerList listeners = new ListenerList(); - private EventPriority phase = null; - - public Event() - { - setup(); - } - - /** - * Determine if this function is cancelable at all. - * @return If access to setCanceled should be allowed - * - * Note: - * Events with the Cancelable annotation will have this method automatically added to return true. - */ - public boolean isCancelable() - { - return false; - } - - /** - * Determine if this event is canceled and should stop executing. - * @return The current canceled state - */ - public boolean isCanceled() - { - return isCanceled; - } - - /** - * Sets the cancel state of this event. Note, not all events are cancelable, and any attempt to - * invoke this method on an event that is not cancelable (as determined by {@link #isCancelable} - * will result in an {@link UnsupportedOperationException}. - * - * 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 UnsupportedOperationException( - "Attempted to call Event#setCanceled() on a non-cancelable event of type: " - + this.getClass().getCanonicalName() - ); - } - isCanceled = cancel; - } - - /** - * Determines if this event expects a significant result value. - * - * Note: - * Events with the HasResult annotation will have this method automatically added to return true. - */ - public boolean hasResult() - { - return false; - } - - /** - * 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 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; - } - - @Nullable - public EventPriority getPhase() - { - return this.phase; - } - - public void setPhase(@Nonnull EventPriority value) - { - Preconditions.checkNotNull(value, "setPhase argument must not be null"); - int prev = phase == null ? -1 : phase.ordinal(); - Preconditions.checkArgument(prev < value.ordinal(), "Attempted to set event phase to %s when already %s", value, phase); - phase = value; - } -} diff --git a/src/main/java/net/minecraftforge/fml/common/eventhandler/EventBus.java b/src/main/java/net/minecraftforge/fml/common/eventhandler/EventBus.java deleted file mode 100644 index f7037eb49..000000000 --- a/src/main/java/net/minecraftforge/fml/common/eventhandler/EventBus.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.common.eventhandler; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -import javax.annotation.Nonnull; - -import net.minecraftforge.fml.common.FMLLog; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.ModContainer; - -import com.google.common.base.Preconditions; -import com.google.common.base.Throwables; -import com.google.common.collect.MapMaker; -import com.google.common.collect.Sets; -import com.google.common.reflect.TypeToken; - -public class EventBus implements IEventExceptionHandler -{ - private static int maxID = 0; - - private ConcurrentHashMap> listeners = new ConcurrentHashMap>(); - private Map listenerOwners = new MapMaker().weakKeys().weakValues().makeMap(); - private final int busID = maxID++; - private IEventExceptionHandler exceptionHandler; - private boolean shutdown; - - public EventBus() - { - ListenerList.resize(busID + 1); - exceptionHandler = this; - } - - public EventBus(@Nonnull IEventExceptionHandler handler) - { - this(); - Preconditions.checkNotNull(handler, "EventBus exception handler can not be null"); - exceptionHandler = handler; - } - - public void register(Object target) - { - if (listeners.containsKey(target)) - { - return; - } - - ModContainer activeModContainer = Loader.instance().activeModContainer(); - if (activeModContainer == null) - { - FMLLog.log.error("Unable to determine registrant mod for {}. This is a critical error and should be impossible", target, new Throwable()); - activeModContainer = Loader.instance().getMinecraftModContainer(); - } - listenerOwners.put(target, activeModContainer); - boolean isStatic = target.getClass() == Class.class; - @SuppressWarnings("unchecked") - Set> supers = isStatic ? Sets.newHashSet((Class)target) : TypeToken.of(target.getClass()).getTypes().rawTypes(); - for (Method method : (isStatic ? (Class)target : target.getClass()).getMethods()) - { - if (isStatic && !Modifier.isStatic(method.getModifiers())) - continue; - else if (!isStatic && Modifier.isStatic(method.getModifiers())) - continue; - - for (Class cls : supers) - { - try - { - Method real = cls.getDeclaredMethod(method.getName(), method.getParameterTypes()); - if (real.isAnnotationPresent(SubscribeEvent.class)) - { - Class[] parameterTypes = method.getParameterTypes(); - if (parameterTypes.length != 1) - { - throw new IllegalArgumentException( - "Method " + method + " has @SubscribeEvent 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 @SubscribeEvent annotation, but takes a argument that is not an Event " + eventType); - } - - register(eventType, target, real, activeModContainer); - break; - } - } - catch (NoSuchMethodException e) - { - ; // Eat the error, this is not unexpected - } - } - } - } - - private void register(Class eventType, Object target, Method method, final ModContainer owner) - { - try - { - Constructor ctr = eventType.getConstructor(); - ctr.setAccessible(true); - Event event = (Event)ctr.newInstance(); - final ASMEventHandler asm = new ASMEventHandler(target, method, owner, IGenericEvent.class.isAssignableFrom(eventType)); - - IEventListener listener = asm; - if (IContextSetter.class.isAssignableFrom(eventType)) - { - listener = new IEventListener() - { - @Override - public void invoke(Event event) - { - ModContainer old = Loader.instance().activeModContainer(); - Loader.instance().setActiveModContainer(owner); - ((IContextSetter)event).setModContainer(owner); - asm.invoke(event); - Loader.instance().setActiveModContainer(old); - } - }; - } - - event.getListenerList().register(busID, asm.getPriority(), listener); - - ArrayList others = listeners.computeIfAbsent(target, k -> new ArrayList<>()); - others.add(listener); - } - catch (Exception e) - { - FMLLog.log.error("Error registering event handler: {} {} {}", owner, eventType, method, e); - } - } - - public void unregister(Object object) - { - ArrayList list = listeners.remove(object); - if(list == null) - return; - for (IEventListener listener : list) - { - ListenerList.unregisterAll(busID, listener); - } - } - - public boolean post(Event event) - { - if (shutdown) return false; - - IEventListener[] listeners = event.getListenerList().getListeners(busID); - int index = 0; - try - { - for (; index < listeners.length; index++) - { - listeners[index].invoke(event); - } - } - catch (Throwable throwable) - { - exceptionHandler.handleException(this, event, listeners, index, throwable); - Throwables.throwIfUnchecked(throwable); - throw new RuntimeException(throwable); - } - return event.isCancelable() && event.isCanceled(); - } - - public void shutdown() - { - FMLLog.log.warn("EventBus {} shutting down - future events will not be posted.", busID); - shutdown = true; - } - - @Override - public void handleException(EventBus bus, Event event, IEventListener[] listeners, int index, Throwable throwable) - { - FMLLog.log.error("Exception caught during firing event {}:", event, throwable); - FMLLog.log.error("Index: {} Listeners:", index); - for (int x = 0; x < listeners.length; x++) - { - FMLLog.log.error("{}: {}", x, listeners[x]); - } - } -} diff --git a/src/main/java/net/minecraftforge/fml/common/eventhandler/EventPriority.java b/src/main/java/net/minecraftforge/fml/common/eventhandler/EventPriority.java deleted file mode 100644 index 3143ac8d7..000000000 --- a/src/main/java/net/minecraftforge/fml/common/eventhandler/EventPriority.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.common.eventhandler; - -public enum EventPriority implements IEventListener -{ - /*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 -; - - @Override - public void invoke(Event event) - { - event.setPhase(this); - } -} diff --git a/src/main/java/net/minecraftforge/fml/common/eventhandler/IContextSetter.java b/src/main/java/net/minecraftforge/fml/common/eventhandler/IContextSetter.java deleted file mode 100644 index 72833f83b..000000000 --- a/src/main/java/net/minecraftforge/fml/common/eventhandler/IContextSetter.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.common.eventhandler; - -import net.minecraftforge.fml.common.ModContainer; - -//Instructs event handlers to set the active mod container. -//This has a major performance impact so use sparingly. -//Note: The context IS NOT thread aware as this would be ungodly slow. -//So This should ONLY be used for Forge mod lifecycle events. -public interface IContextSetter -{ - default void setModContainer(ModContainer mod){}; -} diff --git a/src/main/java/net/minecraftforge/fml/common/eventhandler/IEventExceptionHandler.java b/src/main/java/net/minecraftforge/fml/common/eventhandler/IEventExceptionHandler.java deleted file mode 100644 index d3749dd87..000000000 --- a/src/main/java/net/minecraftforge/fml/common/eventhandler/IEventExceptionHandler.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.common.eventhandler; - -public interface IEventExceptionHandler -{ - /** - * Fired when a EventListener throws an exception for the specified event on the event bus. - * After this function returns, the original Throwable will be propagated upwards. - * - * @param bus The bus the event is being fired on - * @param event The event that is being fired - * @param listeners All listeners that are listening for this event, in order - * @param index Index for the current listener being fired. - * @param throwable The throwable being thrown - */ - void handleException(EventBus bus, Event event, IEventListener[] listeners, int index, Throwable throwable); -} diff --git a/src/main/java/net/minecraftforge/fml/common/eventhandler/IGenericEvent.java b/src/main/java/net/minecraftforge/fml/common/eventhandler/IGenericEvent.java deleted file mode 100644 index 672bc8648..000000000 --- a/src/main/java/net/minecraftforge/fml/common/eventhandler/IGenericEvent.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.common.eventhandler; - -import java.lang.reflect.Type; - -public interface IGenericEvent -{ - Type getGenericType(); -} diff --git a/src/main/java/net/minecraftforge/fml/common/eventhandler/ListenerList.java b/src/main/java/net/minecraftforge/fml/common/eventhandler/ListenerList.java deleted file mode 100644 index 9cb2e1f3e..000000000 --- a/src/main/java/net/minecraftforge/fml/common/eventhandler/ListenerList.java +++ /dev/null @@ -1,278 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.common.eventhandler; - -import java.util.*; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; - -import javax.annotation.Nullable; - - -public class ListenerList -{ - private static ImmutableList allLists = ImmutableList.of(); - private static int maxSize = 0; - - @Nullable - private ListenerList parent; - private ListenerListInst[] lists = new ListenerListInst[0]; - - public ListenerList() - { - this(null); - } - - public ListenerList(@Nullable ListenerList parent) - { - // parent needs to be set before resize ! - this.parent = parent; - extendMasterList(this); - resizeLists(maxSize); - } - - private synchronized static void extendMasterList(ListenerList inst) - { - ImmutableList.Builder builder = ImmutableList.builder(); - builder.addAll(allLists); - builder.add(inst); - allLists = builder.build(); - } - - 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 unregisterAll(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 List children; - - - 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; - if (children != null) - children.clear(); - } - - private ListenerListInst(ListenerListInst parent) - { - this(); - this.parent = parent; - this.parent.addChild(this); - } - - /** - * 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()); - } - - protected void forceRebuild() - { - this.rebuild = true; - if (this.children != null) - { - for (ListenerListInst child : this.children) - child.forceRebuild(); - } - } - - private void addChild(ListenerListInst child) - { - if (this.children == null) - this.children = Lists.newArrayList(); - this.children.add(child); - } - - /** - * 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()) - { - List listeners = getListeners(value); - if (listeners.size() > 0) - { - ret.add(value); //Add the priority to notify the event of it's current phase. - ret.addAll(listeners); - } - } - listeners = ret.toArray(new IEventListener[ret.size()]); - rebuild = false; - } - - public void register(EventPriority priority, IEventListener listener) - { - priorities.get(priority.ordinal()).add(listener); - this.forceRebuild(); - } - - public void unregister(IEventListener listener) - { - for(ArrayList list : priorities) - { - if (list.remove(listener)) - { - this.forceRebuild(); - } - } - } - } -} diff --git a/src/main/java/net/minecraftforge/fml/common/eventhandler/SubscribeEvent.java b/src/main/java/net/minecraftforge/fml/common/eventhandler/SubscribeEvent.java deleted file mode 100644 index 1ce7f3a63..000000000 --- a/src/main/java/net/minecraftforge/fml/common/eventhandler/SubscribeEvent.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fml.common.eventhandler; - -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 SubscribeEvent -{ - EventPriority priority() default EventPriority.NORMAL; - boolean receiveCanceled() default false; -} diff --git a/src/main/java/net/minecraftforge/fml/common/gameevent/InputEvent.java b/src/main/java/net/minecraftforge/fml/common/gameevent/InputEvent.java index 57f19a3c2..87de08090 100644 --- a/src/main/java/net/minecraftforge/fml/common/gameevent/InputEvent.java +++ b/src/main/java/net/minecraftforge/fml/common/gameevent/InputEvent.java @@ -19,7 +19,7 @@ package net.minecraftforge.fml.common.gameevent; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Event; public class InputEvent extends Event { public static class MouseInputEvent extends InputEvent {} diff --git a/src/main/java/net/minecraftforge/fml/common/gameevent/PlayerEvent.java b/src/main/java/net/minecraftforge/fml/common/gameevent/PlayerEvent.java index e7caff788..26d4b2df1 100644 --- a/src/main/java/net/minecraftforge/fml/common/gameevent/PlayerEvent.java +++ b/src/main/java/net/minecraftforge/fml/common/gameevent/PlayerEvent.java @@ -23,7 +23,7 @@ import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Event; import javax.annotation.Nonnull; diff --git a/src/main/java/net/minecraftforge/fml/common/gameevent/TickEvent.java b/src/main/java/net/minecraftforge/fml/common/gameevent/TickEvent.java index e4330d297..a2f4863c2 100644 --- a/src/main/java/net/minecraftforge/fml/common/gameevent/TickEvent.java +++ b/src/main/java/net/minecraftforge/fml/common/gameevent/TickEvent.java @@ -22,10 +22,11 @@ package net.minecraftforge.fml.common.gameevent; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.world.World; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fml.relauncher.Side; -public class TickEvent extends Event { +public class TickEvent extends net.minecraftforge.eventbus.api.Event +{ public enum Type { WORLD, PLAYER, CLIENT, SERVER, RENDER; } diff --git a/src/main/java/net/minecraftforge/fml/common/network/FMLEventChannel.java b/src/main/java/net/minecraftforge/fml/common/network/FMLEventChannel.java index 0eec7b963..38ab4f1ee 100644 --- a/src/main/java/net/minecraftforge/fml/common/network/FMLEventChannel.java +++ b/src/main/java/net/minecraftforge/fml/common/network/FMLEventChannel.java @@ -29,8 +29,8 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.network.NetHandlerPlayServer; import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.eventhandler.EventBus; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.network.internal.FMLProxyPacket; import net.minecraftforge.fml.relauncher.Side; @@ -50,7 +50,7 @@ import javax.annotation.Nullable; */ public class FMLEventChannel { private EnumMap channels; - private EventBus eventBus; + private IEventBus eventBus; /* * This is done this way so that the CLIENT specific code in the factory only loads on the client @@ -100,7 +100,7 @@ public class FMLEventChannel { FMLEventChannel(String name) { this.channels = NetworkRegistry.INSTANCE.newChannel(name, new NetworkEventFiringHandler(this)); - this.eventBus = new EventBus(); + this.eventBus = IEventBus.create(); } /** diff --git a/src/main/java/net/minecraftforge/fml/common/network/FMLNetworkEvent.java b/src/main/java/net/minecraftforge/fml/common/network/FMLNetworkEvent.java index 64d787076..2c4619b48 100644 --- a/src/main/java/net/minecraftforge/fml/common/network/FMLNetworkEvent.java +++ b/src/main/java/net/minecraftforge/fml/common/network/FMLNetworkEvent.java @@ -27,7 +27,7 @@ import net.minecraft.network.INetHandler; import net.minecraft.network.NetworkManager; import net.minecraft.network.play.INetHandlerPlayClient; import net.minecraft.network.play.INetHandlerPlayServer; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fml.common.network.internal.FMLProxyPacket; import net.minecraftforge.fml.relauncher.Side; @@ -242,7 +242,8 @@ public class FMLNetworkEvent extends Event { * @author cpw * */ - public static class CustomNetworkEvent extends Event { + public static class CustomNetworkEvent extends net.minecraftforge.eventbus.api.Event + { private final Object wrappedEvent; public CustomNetworkEvent(Object wrappedEvent) { diff --git a/src/main/java/net/minecraftforge/fml/common/versioning/DependencyParser.java b/src/main/java/net/minecraftforge/fml/common/versioning/DependencyParser.java index de7da1ac3..9deaf20ad 100644 --- a/src/main/java/net/minecraftforge/fml/common/versioning/DependencyParser.java +++ b/src/main/java/net/minecraftforge/fml/common/versioning/DependencyParser.java @@ -30,6 +30,7 @@ import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.LoaderException; +import net.minecraftforge.fml.javafmlmod.FMLModContainer; import net.minecraftforge.fml.relauncher.Side; public final class DependencyParser @@ -182,7 +183,7 @@ public final class DependencyParser } // TODO 1.13: throw these exceptions instead of logging them - /** Based on {@link net.minecraftforge.fml.common.FMLModContainer#sanityCheckModId()} */ + /** Based on {@link FMLModContainer#sanityCheckModId()} */ private static void sanityCheckModId(String modId, String dep, String depModId) { if (Strings.isNullOrEmpty(depModId)) diff --git a/src/main/java/net/minecraftforge/fml/loading/FMLJavaModLanguageProvider.java b/src/main/java/net/minecraftforge/fml/javafmlmod/FMLJavaModLanguageProvider.java similarity index 87% rename from src/main/java/net/minecraftforge/fml/loading/FMLJavaModLanguageProvider.java rename to src/main/java/net/minecraftforge/fml/javafmlmod/FMLJavaModLanguageProvider.java index b8ef96ceb..8c2ce158c 100644 --- a/src/main/java/net/minecraftforge/fml/loading/FMLJavaModLanguageProvider.java +++ b/src/main/java/net/minecraftforge/fml/javafmlmod/FMLJavaModLanguageProvider.java @@ -17,16 +17,15 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.loading; +package net.minecraftforge.fml.javafmlmod; -import net.minecraftforge.fml.common.FMLModContainer; +import net.minecraftforge.fml.javafmlmod.FMLModContainer; import net.minecraftforge.fml.common.ModContainer; -import net.minecraftforge.fml.loading.moddiscovery.ModFile; -import net.minecraftforge.fml.loading.moddiscovery.ModInfo; +import net.minecraftforge.fml.loading.IModLanguageProvider; +import net.minecraftforge.fml.loading.moddiscovery.IModInfo; import net.minecraftforge.fml.loading.moddiscovery.ScanResult; import org.objectweb.asm.Type; -import java.util.List; import java.util.Map; import java.util.function.Consumer; import java.util.function.Function; @@ -53,9 +52,9 @@ public class FMLJavaModLanguageProvider implements IModLanguageProvider } @Override - public ModContainer loadMod(final ModInfo info, final ClassLoader modClassLoader) + public ModContainer loadMod(final IModInfo info, final ClassLoader modClassLoader, final ScanResult scanResults) { - return new FMLModContainer(info, className, modClassLoader); + return new FMLModContainer(info, className, modClassLoader, scanResults); } } diff --git a/src/main/java/net/minecraftforge/fml/javafmlmod/FMLModContainer.java b/src/main/java/net/minecraftforge/fml/javafmlmod/FMLModContainer.java new file mode 100644 index 000000000..bb2f19c13 --- /dev/null +++ b/src/main/java/net/minecraftforge/fml/javafmlmod/FMLModContainer.java @@ -0,0 +1,120 @@ +/* + * Minecraft Forge + * Copyright (c) 2018. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +package net.minecraftforge.fml.javafmlmod; + +import java.lang.reflect.Field; +import java.util.List; +import java.util.Objects; + +import net.minecraftforge.fml.LifecycleEventProvider; +import net.minecraftforge.fml.ModLoadingStage; +import net.minecraftforge.fml.common.Mod.Instance; +import net.minecraftforge.fml.common.ModContainer; +import net.minecraftforge.fml.loading.FMLLoader; +import net.minecraftforge.fml.loading.moddiscovery.IModInfo; +import net.minecraftforge.fml.loading.moddiscovery.ScanResult; + +import org.apache.commons.lang3.tuple.Pair; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.stream.Collectors; + +import org.objectweb.asm.Type; + +import static net.minecraftforge.fml.Logging.LOADING; + +public class FMLModContainer extends ModContainer +{ + private static final Logger LOGGER = LogManager.getLogger("FML"); + private final ScanResult scanResults; + private Object modInstance; + private final Class modClass; + + public FMLModContainer(IModInfo info, String className, ClassLoader modClassLoader, ScanResult scanResults) + { + super(info); + this.scanResults = scanResults; + triggerMap.put(ModLoadingStage.BEGIN, this::constructMod); + triggerMap.put(ModLoadingStage.PREINIT, this::preinitMod); + + try + { + modClass = Class.forName(className, true, modClassLoader); + LOGGER.error(LOADING,"Loaded modclass {} with {}", modClass.getName(), modClass.getClassLoader()); + } + catch (ClassNotFoundException e) + { + LOGGER.error(LOADING, "Failed to load class {}", className, e); + throw new RuntimeException(e); + } + } + + private void preinitMod(LifecycleEventProvider.LifecycleEvent lifecycleEvent) + { + + List> instanceFields = scanResults.getAnnotations().stream(). + filter(a -> Objects.equals(a.getAnnotationType(), Type.getType(Instance.class)) && + Objects.equals(a.getClassType(), Type.getType(modClass))). + map(a->Pair.of(a.getMemberName(), (String)a.getAnnotationData().get("value"))). + collect(Collectors.toList()); + + instanceFields.forEach(p->{ + try + { + final Field field = modClass.getDeclaredField(p.getLeft()); + field.setAccessible(true); + field.set(modInstance, FMLLoader.getModLoader().getModList().getModObjectById(p.getRight()).get()); + } + catch (NoSuchFieldException | IllegalAccessException e) + { + LOGGER.error(LOADING, "Unable to set field {} to mod with ID {}", p.getLeft(), p.getRight(), e); + } + }); + + } + + private void constructMod(LifecycleEventProvider.LifecycleEvent event) + { + try + { + LOGGER.debug(LOADING, "Loading mod instance {} of type {}", getModId(), modClass.getName()); + this.modInstance = modClass.newInstance(); + LOGGER.debug(LOADING, "Loaded mod instance {} of type {}", getModId(), modClass.getName()); + } + catch (InstantiationException | IllegalAccessException e) + { + LOGGER.error("Failed to create mod instance. ModID: {}, class {}", getModId(), modClass.getName(), e); + throw new RuntimeException("Failed to create mod instance", e); + } + } + + @Override + public boolean matches(Object mod) + { + return mod == modInstance; + } + + @Override + public Object getMod() + { + return modInstance; + } + +} diff --git a/src/main/java/net/minecraftforge/fml/FMLConfig.java b/src/main/java/net/minecraftforge/fml/loading/FMLConfig.java similarity index 98% rename from src/main/java/net/minecraftforge/fml/FMLConfig.java rename to src/main/java/net/minecraftforge/fml/loading/FMLConfig.java index 19fc61359..48dc3cd36 100644 --- a/src/main/java/net/minecraftforge/fml/FMLConfig.java +++ b/src/main/java/net/minecraftforge/fml/loading/FMLConfig.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml; +package net.minecraftforge.fml.loading; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; diff --git a/src/main/java/net/minecraftforge/fml/loading/FMLDevClientLaunchProvider.java b/src/main/java/net/minecraftforge/fml/loading/FMLDevClientLaunchProvider.java index 3c2617028..ece30994d 100644 --- a/src/main/java/net/minecraftforge/fml/loading/FMLDevClientLaunchProvider.java +++ b/src/main/java/net/minecraftforge/fml/loading/FMLDevClientLaunchProvider.java @@ -22,12 +22,13 @@ package net.minecraftforge.fml.loading; import cpw.mods.modlauncher.api.IEnvironment; import cpw.mods.modlauncher.api.ILaunchHandlerService; import cpw.mods.modlauncher.api.ITransformingClassLoader; -import net.minecraft.client.main.Main; import net.minecraftforge.api.Side; import java.net.URISyntaxException; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; import java.util.concurrent.Callable; import static net.minecraftforge.fml.Logging.CORE; @@ -41,6 +42,13 @@ public class FMLDevClientLaunchProvider extends FMLCommonLaunchHandler implement return "devfmlclient"; } + private static final List SKIPPACKAGES = Arrays.asList( + "joptsimple.", "org.lwjgl.", "com.mojang.", "com.google.", + "org.apache.commons.", "io.netty.", "net.minecraftforge.fml.loading.", + "net.minecraftforge.eventbus.", "it.unimi.dsi.fastutil.", "net.minecraftforge.api.", + "paulscode.sound.", "com.ibm.icu.", "sun.", "gnu.trove.", "com.electronwill.nightconfig." + ); + @Override public Path[] identifyTransformationTargets() { @@ -62,7 +70,7 @@ public class FMLDevClientLaunchProvider extends FMLCommonLaunchHandler implement return () -> { fmlLog.debug(CORE, "Launching minecraft in {} with arguments {}", launchClassLoader, arguments); super.beforeStart(launchClassLoader); - launchClassLoader.setTargetPackageFilter(cn -> !cn.startsWith("net.minecraftforge.fml.loading.")); + launchClassLoader.addTargetPackageFilter(cn -> SKIPPACKAGES.stream().noneMatch(cn::startsWith)); Class.forName("net.minecraft.client.main.Main", true, launchClassLoader.getInstance()).getMethod("main", String[].class).invoke(null, (Object)arguments); return null; }; diff --git a/src/main/java/net/minecraftforge/fml/FMLEnvironment.java b/src/main/java/net/minecraftforge/fml/loading/FMLEnvironment.java similarity index 95% rename from src/main/java/net/minecraftforge/fml/FMLEnvironment.java rename to src/main/java/net/minecraftforge/fml/loading/FMLEnvironment.java index b5f788856..ff82b0547 100644 --- a/src/main/java/net/minecraftforge/fml/FMLEnvironment.java +++ b/src/main/java/net/minecraftforge/fml/loading/FMLEnvironment.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml; +package net.minecraftforge.fml.loading; import net.minecraftforge.api.Side; import net.minecraftforge.fml.loading.FMLLoader; diff --git a/src/main/java/net/minecraftforge/fml/loading/FMLLoader.java b/src/main/java/net/minecraftforge/fml/loading/FMLLoader.java index 98e3e1b12..620dc2ce7 100644 --- a/src/main/java/net/minecraftforge/fml/loading/FMLLoader.java +++ b/src/main/java/net/minecraftforge/fml/loading/FMLLoader.java @@ -54,6 +54,7 @@ public class FMLLoader private static ILaunchPluginService accessTransformer; private static ModDiscoverer modDiscoverer; private static ICoreModProvider coreModProvider; + private static ILaunchPluginService eventBus; private static LanguageLoadingProvider languageLoadingProvider; private static Side side; private static ModList modList; @@ -70,6 +71,8 @@ public class FMLLoader fmlLog.error(CORE,"Found incompatible ModLauncher specification : {}, version {} from {}", modLauncherPackage.getSpecificationVersion(), modLauncherPackage.getImplementationVersion(), modLauncherPackage.getImplementationVendor()); throw new IncompatibleEnvironmentException("Incompatible modlauncher found "+modLauncherPackage.getSpecificationVersion()); } + fmlLog.debug(CORE, "Initializing modjar URL handler"); + URL.setURLStreamHandlerFactory(p->p.equals("modjar") ? new ModJarURLHandler() : null); accessTransformer = environment.findLaunchPlugin("accesstransformer").orElseThrow(()-> new IncompatibleEnvironmentException("Missing AccessTransformer, cannot run")); @@ -80,6 +83,15 @@ public class FMLLoader throw new IncompatibleEnvironmentException("Incompatible accesstransformer found "+atPackage.getSpecificationVersion()); } + eventBus = environment.findLaunchPlugin("eventbus").orElseThrow(()-> new IncompatibleEnvironmentException("Missing EventBus, cannot run")); + + final Package eventBusPackage = eventBus.getClass().getPackage(); + fmlLog.debug(CORE,"FML found EventBus version : {}", eventBusPackage.getImplementationVersion()); + if (!eventBusPackage.isCompatibleWith("1.0")) { + fmlLog.error(CORE,"Found incompatible EventBus specification : {}, version {} from {}", eventBusPackage.getSpecificationVersion(), eventBusPackage.getImplementationVersion(), eventBusPackage.getImplementationVendor()); + throw new IncompatibleEnvironmentException("Incompatible eventbus found "+eventBusPackage.getSpecificationVersion()); + } + final ArrayList coreModProviders = new ArrayList<>(); ServiceLoader.load(ICoreModProvider.class).forEach(coreModProviders::add); diff --git a/src/main/java/net/minecraftforge/fml/loading/FMLServiceProvider.java b/src/main/java/net/minecraftforge/fml/loading/FMLServiceProvider.java index 6c5e794cc..309623722 100644 --- a/src/main/java/net/minecraftforge/fml/loading/FMLServiceProvider.java +++ b/src/main/java/net/minecraftforge/fml/loading/FMLServiceProvider.java @@ -20,19 +20,16 @@ package net.minecraftforge.fml.loading; import cpw.mods.modlauncher.api.IEnvironment; -import cpw.mods.modlauncher.api.ILaunchHandlerService; import cpw.mods.modlauncher.api.ITransformationService; import cpw.mods.modlauncher.api.ITransformer; import cpw.mods.modlauncher.api.IncompatibleEnvironmentException; import joptsimple.ArgumentAcceptingOptionSpec; import joptsimple.OptionSpecBuilder; -import net.minecraftforge.fml.FMLConfig; import net.minecraftforge.fml.common.FMLPaths; import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.List; -import java.util.Optional; import java.util.Set; import java.util.function.BiFunction; diff --git a/src/main/java/net/minecraftforge/fml/loading/IModLanguageProvider.java b/src/main/java/net/minecraftforge/fml/loading/IModLanguageProvider.java index be2d9e4b9..a749457a1 100644 --- a/src/main/java/net/minecraftforge/fml/loading/IModLanguageProvider.java +++ b/src/main/java/net/minecraftforge/fml/loading/IModLanguageProvider.java @@ -20,11 +20,9 @@ package net.minecraftforge.fml.loading; import net.minecraftforge.fml.common.ModContainer; -import net.minecraftforge.fml.loading.moddiscovery.ModFile; -import net.minecraftforge.fml.loading.moddiscovery.ModInfo; +import net.minecraftforge.fml.loading.moddiscovery.IModInfo; import net.minecraftforge.fml.loading.moddiscovery.ScanResult; -import java.util.List; import java.util.function.Consumer; /** @@ -40,6 +38,6 @@ public interface IModLanguageProvider Consumer getFileVisitor(); interface IModLanguageLoader { - ModContainer loadMod(ModInfo info, ClassLoader modClassLoader); + ModContainer loadMod(IModInfo info, ClassLoader modClassLoader, ScanResult scanResults); } } diff --git a/src/main/java/net/minecraftforge/fml/loading/ModJarURLHandler.java b/src/main/java/net/minecraftforge/fml/loading/ModJarURLHandler.java new file mode 100644 index 000000000..adba13fe1 --- /dev/null +++ b/src/main/java/net/minecraftforge/fml/loading/ModJarURLHandler.java @@ -0,0 +1,54 @@ +/* + * Minecraft Forge + * Copyright (c) 2018. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml.loading; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.net.URLConnection; +import java.net.URLStreamHandler; +import java.nio.file.Files; + +public class ModJarURLHandler extends URLStreamHandler +{ + // modjar:///modid!path/to/file + @Override + protected URLConnection openConnection(URL url) throws IOException { + return new URLConnection(url) { + private String modpath; + private String modid; + + @Override + public void connect() throws IOException + { + final String path = url.getPath(); + final String[] parts = path.split("!"); + if (parts.length!=2) throw new IOException("Illegal URL format "+path); + modid = parts[0]; + modpath = parts[1]; + } + @Override + public InputStream getInputStream() throws IOException + { + return Files.newInputStream(FMLLoader.getModLoader().getModList().getModFileById(modid).getFile().findResource(modpath)); + } + }; + } +} diff --git a/src/main/java/net/minecraftforge/fml/loading/ModList.java b/src/main/java/net/minecraftforge/fml/loading/ModList.java index 0bf83372e..bd3b363d8 100644 --- a/src/main/java/net/minecraftforge/fml/loading/ModList.java +++ b/src/main/java/net/minecraftforge/fml/loading/ModList.java @@ -19,14 +19,22 @@ package net.minecraftforge.fml.loading; -import com.google.common.collect.Multimap; +import net.minecraftforge.fml.LifecycleEventProvider; +import net.minecraftforge.fml.ModLoadingStage; +import net.minecraftforge.fml.common.ModContainer; import net.minecraftforge.fml.loading.moddiscovery.BackgroundScanHandler; +import net.minecraftforge.fml.loading.moddiscovery.IModFileInfo; +import net.minecraftforge.fml.loading.moddiscovery.IModInfo; import net.minecraftforge.fml.loading.moddiscovery.ModFile; +import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo; import net.minecraftforge.fml.loading.moddiscovery.ModInfo; import java.nio.file.Path; -import java.util.ArrayList; +import java.util.Collection; import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -34,44 +42,74 @@ import java.util.stream.Collectors; */ public class ModList { - private final List modFiles; + private final List modFiles; private final List sortedList; + private final Map fileById; private BackgroundScanHandler scanner; + private List mods; + private Map indexedMods; public ModList(final List modFiles, final List sortedList) { - this.modFiles = modFiles; + this.modFiles = modFiles.stream().map(ModFile::getModFileInfo).map(ModFileInfo.class::cast).collect(Collectors.toList()); this.sortedList = sortedList; + this.fileById = this.modFiles.stream().map(ModFileInfo::getMods).flatMap(Collection::stream). + map(ModInfo.class::cast). + collect(Collectors.toMap(ModInfo::getModId, ModInfo::getOwningFile)); } public void addCoreMods() { - modFiles.stream().map(ModFile::getCoreMods).flatMap(List::stream).forEach(FMLLoader.getCoreModProvider()::addCoreMod); + modFiles.stream().map(ModFileInfo::getFile).map(ModFile::getCoreMods).flatMap(List::stream).forEach(FMLLoader.getCoreModProvider()::addCoreMod); } public void addAccessTransformers() { - modFiles.forEach(mod -> mod.getAccessTransformer().ifPresent(path -> FMLLoader.addAccessTransformer(path, mod))); + modFiles.stream().map(ModFileInfo::getFile).forEach(mod -> mod.getAccessTransformer().ifPresent(path -> FMLLoader.addAccessTransformer(path, mod))); } public void addForScanning(BackgroundScanHandler backgroundScanHandler) { this.scanner = backgroundScanHandler; backgroundScanHandler.setModList(this); - modFiles.forEach(backgroundScanHandler::submitForScanning); + modFiles.stream().map(ModFileInfo::getFile).forEach(backgroundScanHandler::submitForScanning); } - public List getModFiles() + public List getModFiles() { return modFiles; } public Path findResource(final String className) { - for (final ModFile mf : modFiles) { - final Path resource = mf.findResource(className); + for (ModFileInfo mf : modFiles) { + final Path resource = mf.getFile().findResource(className); if (resource != null) return resource; } return null; } + + public ModFileInfo getModFileById(String modid) + { + return this.fileById.get(modid); + } + + public void dispatchLifeCycleEvent(LifecycleEventProvider.LifecycleEvent lifecycleEvent) { + this.mods.parallelStream().forEach(m->m.transitionState(lifecycleEvent)); + final List erroredContainers = this.mods.stream().filter(m -> m.getCurrentState() == ModLoadingStage.ERROR).collect(Collectors.toList()); + if (!erroredContainers.isEmpty()) { + throw new RuntimeException("Errored containers found!"); + } + } + + public void setLoadedMods(List modContainers) + { + this.mods = modContainers; + this.indexedMods = modContainers.stream().collect(Collectors.toMap(ModContainer::getModId, Function.identity())); + } + + public Optional getModObjectById(String modId) + { + return Optional.ofNullable(this.indexedMods.get(modId)); + } } diff --git a/src/main/java/net/minecraftforge/fml/loading/ModLoader.java b/src/main/java/net/minecraftforge/fml/loading/ModLoader.java index fd09e277b..d3d4bdfc5 100644 --- a/src/main/java/net/minecraftforge/fml/loading/ModLoader.java +++ b/src/main/java/net/minecraftforge/fml/loading/ModLoader.java @@ -19,7 +19,9 @@ package net.minecraftforge.fml.loading; +import net.minecraftforge.fml.LifecycleEventProvider; import net.minecraftforge.fml.common.ModContainer; +import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo; import java.util.Collection; import java.util.List; @@ -49,6 +51,12 @@ public class ModLoader } public void loadMods() { - final List collect = modList.getModFiles().stream().map(mf -> mf.buildMods(this.modClassLoader)).flatMap(Collection::stream).collect(Collectors.toList()); + modList.setLoadedMods(modList.getModFiles().stream(). + map(ModFileInfo::getFile). + map(mf -> mf.buildMods(this.modClassLoader)). + flatMap(Collection::stream).collect(Collectors.toList())); + + LifecycleEventProvider.LOAD.dispatch(modList); + LifecycleEventProvider.PREINIT.dispatch(modList); } } diff --git a/src/main/java/net/minecraftforge/fml/loading/ModLoadingClassLoader.java b/src/main/java/net/minecraftforge/fml/loading/ModLoadingClassLoader.java index 7a02ad402..161a22c08 100644 --- a/src/main/java/net/minecraftforge/fml/loading/ModLoadingClassLoader.java +++ b/src/main/java/net/minecraftforge/fml/loading/ModLoadingClassLoader.java @@ -22,6 +22,7 @@ package net.minecraftforge.fml.loading; import org.apache.logging.log4j.LogManager; import java.io.IOException; +import java.io.InputStream; import java.net.URL; import java.net.URLConnection; import java.net.URLStreamHandler; @@ -35,25 +36,6 @@ public class ModLoadingClassLoader extends SecureClassLoader { static { ClassLoader.registerAsParallelCapable(); - // We use a custom URL format : modjar:modid!/path/in/jarfile - URL.setURLStreamHandlerFactory(protocol -> "modjar".equals(protocol) ? new URLStreamHandler() { - @Override - protected URLConnection openConnection(URL url) throws IOException { - return new URLConnection(url) { - @Override - public void connect() - { - url.get - } - }; - } - - @Override - protected void parseURL(URL u, String spec, int start, int limit) - { - - } - } : null); } private ModLoader modLoader; diff --git a/src/main/java/net/minecraftforge/fml/loading/ModSorter.java b/src/main/java/net/minecraftforge/fml/loading/ModSorter.java index 3b5ebee5e..643cf674d 100644 --- a/src/main/java/net/minecraftforge/fml/loading/ModSorter.java +++ b/src/main/java/net/minecraftforge/fml/loading/ModSorter.java @@ -19,13 +19,13 @@ package net.minecraftforge.fml.loading; -import net.minecraftforge.common.ForgeVersion; +import net.minecraftforge.fml.DefaultModContainers; import net.minecraftforge.fml.Java9BackportUtils; -import net.minecraftforge.fml.Logging; import net.minecraftforge.fml.common.DuplicateModsFoundException; import net.minecraftforge.fml.common.MissingModsException; import net.minecraftforge.fml.common.toposort.TopologicalSort; import net.minecraftforge.fml.common.versioning.ArtifactVersion; +import net.minecraftforge.fml.loading.moddiscovery.IModInfo; import net.minecraftforge.fml.loading.moddiscovery.ModFile; import net.minecraftforge.fml.loading.moddiscovery.ModInfo; import org.apache.logging.log4j.LogManager; @@ -35,6 +35,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.Function; +import java.util.stream.Collector; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -61,21 +62,21 @@ public class ModSorter } private void sort() { - final TopologicalSort.DirectedGraph topoGraph = new TopologicalSort.DirectedGraph<>(); + final TopologicalSort.DirectedGraph topoGraph = new TopologicalSort.DirectedGraph<>(); modFiles.stream().map(ModFile::getModInfos). flatMap(Collection::stream).forEach(topoGraph::addNode); modFiles.stream().map(ModFile::getModInfos). - flatMap(Collection::stream).map(ModInfo::getDependencies).flatMap(Collection::stream).forEach(dep->addDependency(topoGraph, dep)); + flatMap(Collection::stream).map(IModInfo::getDependencies).flatMap(Collection::stream).forEach(dep->addDependency(topoGraph, dep)); } - private void addDependency(TopologicalSort.DirectedGraph topoGraph, ModInfo.ModVersion dep) + private void addDependency(TopologicalSort.DirectedGraph topoGraph, IModInfo.ModVersion dep) { } private void buildUniqueList() { - final Stream modInfos = modFiles.stream().map(ModFile::getModInfos).flatMap(Collection::stream); - final Map> modIds = modInfos.collect(Collectors.groupingBy(ModInfo::getModId)); + final Stream modInfos = modFiles.stream().map(ModFile::getModInfos).flatMap(Collection::stream).map(ModInfo.class::cast); + final Map> modIds = modInfos.collect(Collectors.groupingBy(IModInfo::getModId)); // TODO: make this figure out dupe handling better final List>> dupedMods = modIds.entrySet().stream().filter(e -> e.getValue().size() > 1).collect(Collectors.toList()); @@ -90,14 +91,14 @@ public class ModSorter private void verifyDependencyVersions() { final Map modVersions = Stream.concat(modFiles.stream().map(ModFile::getModInfos). - flatMap(Collection::stream), ForgeVersion.getModInfos().stream()).collect(Collectors.toMap(ModInfo::getModId, ModInfo::getVersion)); - final Map> modVersionDependencies = modFiles.stream(). + flatMap(Collection::stream), DefaultModContainers.getModInfos().stream()).collect(Collectors.toMap(IModInfo::getModId, IModInfo::getVersion)); + final Map> modVersionDependencies = modFiles.stream(). map(ModFile::getModInfos).flatMap(Collection::stream). collect(Collectors.groupingBy(Function.identity(), Java9BackportUtils.flatMapping(e -> e.getDependencies().stream(), Collectors.toList()))); - final Set mandatoryModVersions = modVersionDependencies.values().stream().flatMap(Collection::stream). + final Set mandatoryModVersions = modVersionDependencies.values().stream().flatMap(Collection::stream). filter(mv -> mv.isMandatory() && mv.getSide().isCorrectSide()).collect(Collectors.toSet()); LogManager.getLogger("FML").debug(LOADING, "Found {} mandatory requirements", mandatoryModVersions.size()); - final Set missingVersions = mandatoryModVersions.stream().filter(mv->this.modVersionMatches(mv, modVersions)).collect(Collectors.toSet()); + final Set missingVersions = mandatoryModVersions.stream().filter(mv->this.modVersionMatches(mv, modVersions)).collect(Collectors.toSet()); LogManager.getLogger("FML").debug(LOADING, "Found {} mandatory mod requirements missing", missingVersions.size()); if (!missingVersions.isEmpty()) { @@ -105,7 +106,7 @@ public class ModSorter } } - private boolean modVersionMatches(final ModInfo.ModVersion mv, final Map modVersions) + private boolean modVersionMatches(final IModInfo.ModVersion mv, final Map modVersions) { return !modVersions.containsKey(mv.getModId()) || !mv.getVersionRange().containsVersion(modVersions.get(mv.getModId())); } diff --git a/src/main/java/net/minecraftforge/fml/StringSubstitutor.java b/src/main/java/net/minecraftforge/fml/loading/StringSubstitutor.java similarity index 98% rename from src/main/java/net/minecraftforge/fml/StringSubstitutor.java rename to src/main/java/net/minecraftforge/fml/loading/StringSubstitutor.java index bb6d62fe1..4035641bc 100644 --- a/src/main/java/net/minecraftforge/fml/StringSubstitutor.java +++ b/src/main/java/net/minecraftforge/fml/loading/StringSubstitutor.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml; +package net.minecraftforge.fml.loading; import com.google.common.collect.ImmutableMap; import net.minecraftforge.common.ForgeVersion; diff --git a/src/main/java/net/minecraftforge/fml/StringUtils.java b/src/main/java/net/minecraftforge/fml/loading/StringUtils.java similarity index 97% rename from src/main/java/net/minecraftforge/fml/StringUtils.java rename to src/main/java/net/minecraftforge/fml/loading/StringUtils.java index f38adc7e9..4b13a25a8 100644 --- a/src/main/java/net/minecraftforge/fml/StringUtils.java +++ b/src/main/java/net/minecraftforge/fml/loading/StringUtils.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml; +package net.minecraftforge.fml.loading; import org.apache.commons.lang3.text.StrSubstitutor; diff --git a/src/main/java/net/minecraftforge/fml/common/eventhandler/GenericEvent.java b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/IModFileInfo.java similarity index 63% rename from src/main/java/net/minecraftforge/fml/common/eventhandler/GenericEvent.java rename to src/main/java/net/minecraftforge/fml/loading/moddiscovery/IModFileInfo.java index fc500be75..86462683b 100644 --- a/src/main/java/net/minecraftforge/fml/common/eventhandler/GenericEvent.java +++ b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/IModFileInfo.java @@ -17,21 +17,23 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fml.common.eventhandler; +package net.minecraftforge.fml.loading.moddiscovery; -import java.lang.reflect.Type; +import com.electronwill.nightconfig.core.UnmodifiableConfig; +import net.minecraftforge.fml.common.versioning.VersionRange; -public class GenericEvent extends Event implements IGenericEvent +import java.net.URL; +import java.util.List; + +public interface IModFileInfo { - private Class type; - protected GenericEvent(Class type) - { - this.type = type; - } + List getMods(); - @Override - public Type getGenericType() - { - return type; - } + UnmodifiableConfig getConfig(); + + URL getUpdateURL(IModFileInfo modFileInfo); + + String getModLoader(); + + VersionRange getModLoaderVersion(); } diff --git a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/IModInfo.java b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/IModInfo.java new file mode 100644 index 000000000..b33d2d147 --- /dev/null +++ b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/IModInfo.java @@ -0,0 +1,107 @@ +/* + * Minecraft Forge + * Copyright (c) 2018. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml.loading.moddiscovery; + +import com.electronwill.nightconfig.core.UnmodifiableConfig; +import net.minecraftforge.fml.common.versioning.ArtifactVersion; +import net.minecraftforge.fml.common.versioning.VersionRange; +import net.minecraftforge.fml.loading.FMLEnvironment; + +import java.util.List; + +public interface IModInfo +{ + VersionRange UNBOUNDED = VersionRange.createFromVersionSpec(""); + + IModFileInfo getOwningFile(); + + String getModId(); + + ArtifactVersion getVersion(); + + List getDependencies(); + + UnmodifiableConfig getModConfig(); + + enum Ordering { + BEFORE, AFTER, NONE + } + + enum DependencySide { + CLIENT, SERVER, BOTH; + + public boolean isCorrectSide() + { + return this == BOTH || FMLEnvironment.side.name().equals(this.name()); + } + } + + class ModVersion { + private IModInfo owner; + private final String modId; + private final VersionRange versionRange; + private final boolean mandatory; + private final Ordering ordering; + private final DependencySide side; + + ModVersion(final IModInfo owner, final UnmodifiableConfig config) { + this.owner = owner; + this.modId = config.get("modId"); + this.versionRange = config.getOptional("versionRange").map(String.class::cast). + map(VersionRange::createFromVersionSpec).orElse(UNBOUNDED); + this.mandatory = config.get("mandatory"); + this.ordering = config.getOptional("ordering").map(String.class::cast). + map(Ordering::valueOf).orElse(Ordering.NONE); + this.side = config.getOptional("side").map(String.class::cast). + map(DependencySide::valueOf).orElse(DependencySide.BOTH); + } + + + public String getModId() + { + return modId; + } + + public VersionRange getVersionRange() + { + return versionRange; + } + + public boolean isMandatory() + { + return mandatory; + } + + public Ordering getOrdering() + { + return ordering; + } + + public DependencySide getSide() + { + return side; + } + + public void setOwner(final IModInfo owner) + { + this.owner = owner; + } + } +} diff --git a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/InvalidModFileException.java b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/InvalidModFileException.java index 53484a4b3..a0581c728 100644 --- a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/InvalidModFileException.java +++ b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/InvalidModFileException.java @@ -21,9 +21,9 @@ package net.minecraftforge.fml.loading.moddiscovery; public class InvalidModFileException extends RuntimeException { - private final ModFile.ModFileInfo modFileInfo; + private final IModFileInfo modFileInfo; - public InvalidModFileException(String message, ModFile.ModFileInfo modFileInfo) + public InvalidModFileException(String message, IModFileInfo modFileInfo) { super(message); this.modFileInfo = modFileInfo; diff --git a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModDiscoverer.java b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModDiscoverer.java index 1ac5efed7..faa7bd9cf 100644 --- a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModDiscoverer.java +++ b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModDiscoverer.java @@ -70,10 +70,10 @@ public class ModDiscoverer { } } fmlLog.debug(SCAN,"Found {} mod files with {} mods", mods::size, ()->mods.stream().mapToInt(mf -> mf.getModInfos().size()).sum()); - final ModList sortedMods = ModSorter.sort(mods); - sortedMods.addCoreMods(); - sortedMods.addAccessTransformers(); - sortedMods.addForScanning(backgroundScanHandler); + final ModList modList = ModSorter.sort(mods); + modList.addCoreMods(); + modList.addAccessTransformers(); + modList.addForScanning(backgroundScanHandler); return backgroundScanHandler; } } diff --git a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java index 034cf0243..8bae29334 100644 --- a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java +++ b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java @@ -19,24 +19,14 @@ package net.minecraftforge.fml.loading.moddiscovery; -import com.electronwill.nightconfig.core.UnmodifiableConfig; -import com.electronwill.nightconfig.core.file.FileConfig; import com.google.common.collect.ImmutableMap; -import net.minecraftforge.common.config.ConfigCategory; -import net.minecraftforge.fml.StringUtils; import net.minecraftforge.fml.common.ModContainer; -import net.minecraftforge.fml.common.versioning.DefaultArtifactVersion; -import net.minecraftforge.fml.common.versioning.VersionRange; import net.minecraftforge.fml.loading.FMLLoader; import net.minecraftforge.fml.loading.IModLanguageProvider; import net.minecraftforge.fml.loading.ModLoadingClassLoader; -import java.net.MalformedURLException; -import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Objects; @@ -84,7 +74,7 @@ public class ModFile public List buildMods(ModLoadingClassLoader modClassLoader) { return getScanResult().getTargets().entrySet().stream(). - map(e->e.getValue().loadMod(this.modInfoMap.get(e.getKey()), modClassLoader)).collect(Collectors.toList()); + map(e->e.getValue().loadMod(this.modInfoMap.get(e.getKey()), modClassLoader, getScanResult())).collect(Collectors.toList()); } public enum Type { @@ -94,8 +84,8 @@ public class ModFile private final Type modFileType; private final Manifest manifest; private final IModLocator locator; - private ModFileInfo modFileInfo; - private Map modInfoMap; + private IModFileInfo modFileInfo; + private Map modInfoMap; private ScanResult fileScanResult; private CompletableFuture futureScanResult; private List coreMods; @@ -125,7 +115,7 @@ public class ModFile return filePath; } - public List getModInfos() { + public List getModInfos() { return modFileInfo.getMods(); } @@ -135,12 +125,12 @@ public class ModFile public boolean identifyMods() { this.modFileInfo = ModFileParser.readModList(this); if (this.modFileInfo == null) return false; - fmlLog.debug(LOADING,"Loading mod file {} with language {}", this.getFilePath(), this.modFileInfo.modLoader); - this.modInfoMap = this.getModInfos().stream().collect(Collectors.toMap(ModInfo::getModId, Function.identity())); + fmlLog.debug(LOADING,"Loading mod file {} with language {}", this.getFilePath(), this.modFileInfo.getModLoader()); + this.modInfoMap = this.getModInfos().stream().collect(Collectors.toMap(IModInfo::getModId, Function.identity())); this.coreMods = ModFileParser.getCoreMods(this); this.coreMods.forEach(mi-> fmlLog.debug(LOADING,"Found coremod {}", mi.getPath())); this.accessTransformer = locator.findPath(this, "META-INF", "accesstransformer.cfg"); - this.loader = FMLLoader.getLanguageLoadingProvider().findLanguage(this.modFileInfo.modLoader, this.modFileInfo.modLoaderVersion); + this.loader = FMLLoader.getLanguageLoadingProvider().findLanguage(this.modFileInfo.getModLoader(), this.modFileInfo.getModLoaderVersion()); return true; } @@ -193,53 +183,7 @@ public class ModFile return locator; } - public ModFileInfo getModFileInfo() { + public IModFileInfo getModFileInfo() { return modFileInfo; } - public static class ModFileInfo { - private final UnmodifiableConfig config; - private final ModFile modFile; - private final URL updateJSONURL; - private final URL issueURL; - private final String modLoader; - private final VersionRange modLoaderVersion; - private final List mods; - private final Map properties; - - public ModFileInfo(final ModFile modFile, final UnmodifiableConfig config) - { - this.modFile = modFile; - this.config = config; - this.modLoader = config.getOptional("modLoader"). - orElseThrow(()->new InvalidModFileException("Missing ModLoader in file", this)); - this.modLoaderVersion = config.getOptional("loaderVersion"). - map(VersionRange::createFromVersionSpec). - orElseThrow(()->new InvalidModFileException("Missing ModLoader version in file", this)); - this.properties = config.getOptional("properties"). - map(UnmodifiableConfig::valueMap).orElse(Collections.emptyMap()); - this.modFile.setFileProperties(this.properties); - final ArrayList modConfigs = config.getOrElse("mods", ArrayList::new); - if (modConfigs.isEmpty()) { - throw new InvalidModFileException("Missing mods list", this); - } - this.mods = modConfigs.stream().map(mi-> new ModInfo(this, mi)).collect(Collectors.toList()); - this.updateJSONURL = config.getOptional("updateJSONURL").map(StringUtils::toURL).orElse(null); - this.issueURL = config.getOptional("issueTrackerURL").map(StringUtils::toURL).orElse(null); - } - - public List getMods() - { - return mods; - } - - public ModFile getFile() - { - return this.modFile; - } - - public UnmodifiableConfig getConfig() - { - return this.config; - } - } } diff --git a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileInfo.java b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileInfo.java new file mode 100644 index 000000000..6148b676d --- /dev/null +++ b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileInfo.java @@ -0,0 +1,99 @@ +/* + * Minecraft Forge + * Copyright (c) 2018. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.fml.loading.moddiscovery; + +import com.electronwill.nightconfig.core.UnmodifiableConfig; +import net.minecraftforge.fml.common.versioning.VersionRange; +import net.minecraftforge.fml.loading.StringUtils; + +import java.net.URL; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class ModFileInfo implements IModFileInfo +{ + private final UnmodifiableConfig config; + private final ModFile modFile; + private final URL updateJSONURL; + private final URL issueURL; + private final String modLoader; + private final VersionRange modLoaderVersion; + private final List mods; + private final Map properties; + + ModFileInfo(final ModFile modFile, final UnmodifiableConfig config) + { + this.modFile = modFile; + this.config = config; + this.modLoader = config.getOptional("modLoader"). + orElseThrow(()->new InvalidModFileException("Missing ModLoader in file", this)); + this.modLoaderVersion = config.getOptional("loaderVersion"). + map(VersionRange::createFromVersionSpec). + orElseThrow(()->new InvalidModFileException("Missing ModLoader version in file", this)); + this.properties = config.getOptional("properties"). + map(UnmodifiableConfig::valueMap).orElse(Collections.emptyMap()); + this.modFile.setFileProperties(this.properties); + final ArrayList modConfigs = config.getOrElse("mods", ArrayList::new); + if (modConfigs.isEmpty()) { + throw new InvalidModFileException("Missing mods list", this); + } + this.mods = modConfigs.stream().map(mi-> new ModInfo(this, mi)).collect(Collectors.toList()); + this.updateJSONURL = config.getOptional("updateJSONURL").map(StringUtils::toURL).orElse(null); + this.issueURL = config.getOptional("issueTrackerURL").map(StringUtils::toURL).orElse(null); + } + + @Override + public List getMods() + { + return mods; + } + + public ModFile getFile() + { + return this.modFile; + } + + @Override + public UnmodifiableConfig getConfig() + { + return this.config; + } + + @Override + public URL getUpdateURL(IModFileInfo modFileInfo) + { + return this.updateJSONURL; + } + + @Override + public String getModLoader() + { + return modLoader; + } + + @Override + public VersionRange getModLoaderVersion() + { + return modLoaderVersion; + } +} diff --git a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileParser.java b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileParser.java index 994cfd37d..37847ca18 100644 --- a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileParser.java +++ b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileParser.java @@ -22,7 +22,6 @@ package net.minecraftforge.fml.loading.moddiscovery; import com.electronwill.nightconfig.core.path.PathConfig; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; -import org.apache.commons.lang3.text.StrSubstitutor; import java.io.IOException; import java.lang.reflect.Type; @@ -37,7 +36,7 @@ import static net.minecraftforge.fml.Logging.LOADING; import static net.minecraftforge.fml.Logging.fmlLog; public class ModFileParser { - public static ModFile.ModFileInfo readModList(final ModFile modFile) { + public static IModFileInfo readModList(final ModFile modFile) { fmlLog.debug(LOADING,"Parsing mod file candidate {}", modFile.getFilePath()); final Path modsjson = modFile.getLocator().findPath(modFile, "META-INF", "mods.toml"); if (!Files.exists(modsjson)) { @@ -47,12 +46,12 @@ public class ModFileParser { return loadModFile(modFile, modsjson); } - public static ModFile.ModFileInfo loadModFile(final ModFile file, final Path modsjson) + public static IModFileInfo loadModFile(final ModFile file, final Path modsjson) { final PathConfig pathConfig = PathConfig.builder(modsjson).build(); pathConfig.load(); pathConfig.close(); - return new ModFile.ModFileInfo(file, pathConfig); + return new ModFileInfo(file, pathConfig); } protected static List getCoreMods(final ModFile modFile) { diff --git a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModInfo.java b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModInfo.java index df1ecedd1..723c838ee 100644 --- a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModInfo.java +++ b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModInfo.java @@ -20,36 +20,29 @@ package net.minecraftforge.fml.loading.moddiscovery; import com.electronwill.nightconfig.core.UnmodifiableConfig; -import net.minecraftforge.fml.FMLEnvironment; -import net.minecraftforge.fml.StringSubstitutor; -import net.minecraftforge.fml.StringUtils; +import net.minecraftforge.fml.loading.StringSubstitutor; import net.minecraftforge.fml.common.versioning.ArtifactVersion; import net.minecraftforge.fml.common.versioning.DefaultArtifactVersion; import net.minecraftforge.fml.common.versioning.VersionRange; -import net.minecraftforge.fml.loading.IModLanguageProvider; import java.util.Arrays; -import java.util.Collection; import java.util.Collections; -import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.stream.Collectors; -public class ModInfo { +public class ModInfo implements IModInfo { private static final DefaultArtifactVersion DEFAULT_VERSION = new DefaultArtifactVersion("1"); - public static final VersionRange UNBOUNDED = VersionRange.createFromVersionSpec(""); - private final ModFile.ModFileInfo owningFile; + private final ModFileInfo owningFile; private final String modId; private final ArtifactVersion version; private final String displayName; private final String description; - private final List dependencies; + private final List dependencies; private final Map properties; private final UnmodifiableConfig modConfig; - public ModInfo(final ModFile.ModFileInfo owningFile, final UnmodifiableConfig modConfig) + public ModInfo(final ModFileInfo owningFile, final UnmodifiableConfig modConfig) { this.owningFile = owningFile; this.modConfig = modConfig; @@ -71,84 +64,29 @@ public class ModInfo { } - public ModFile getOwningFile() { - return owningFile.getFile(); + @Override + public ModFileInfo getOwningFile() { + return owningFile; } + @Override public String getModId() { return modId; } + @Override public ArtifactVersion getVersion() { return version; } - public List getDependencies() { + @Override + public List getDependencies() { return this.dependencies; } - public enum Ordering { - BEFORE, AFTER, NONE + @Override + public UnmodifiableConfig getModConfig() { + return this.modConfig; } - public enum DependencySide { - CLIENT, SERVER, BOTH; - - public boolean isCorrectSide() - { - return this == BOTH || FMLEnvironment.side.name().equals(this.name()); - } - } - - public static class ModVersion { - private ModInfo owner; - private final String modId; - private final VersionRange versionRange; - private final boolean mandatory; - private final Ordering ordering; - private final DependencySide side; - - ModVersion(final ModInfo owner, final UnmodifiableConfig config) { - this.owner = owner; - this.modId = config.get("modId"); - this.versionRange = config.getOptional("versionRange").map(String.class::cast). - map(VersionRange::createFromVersionSpec).orElse(UNBOUNDED); - this.mandatory = config.get("mandatory"); - this.ordering = config.getOptional("ordering").map(String.class::cast). - map(Ordering::valueOf).orElse(Ordering.NONE); - this.side = config.getOptional("side").map(String.class::cast). - map(DependencySide::valueOf).orElse(DependencySide.BOTH); - } - - - public String getModId() - { - return modId; - } - - public VersionRange getVersionRange() - { - return versionRange; - } - - public boolean isMandatory() - { - return mandatory; - } - - public Ordering getOrdering() - { - return ordering; - } - - public DependencySide getSide() - { - return side; - } - - public void setOwner(final ModInfo owner) - { - this.owner = owner; - } - } } diff --git a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModsFolderLocator.java b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModsFolderLocator.java index c7adf78af..144bcc9cc 100644 --- a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModsFolderLocator.java +++ b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModsFolderLocator.java @@ -19,7 +19,7 @@ package net.minecraftforge.fml.loading.moddiscovery; -import net.minecraftforge.fml.StringUtils; +import net.minecraftforge.fml.loading.StringUtils; import net.minecraftforge.fml.common.FMLPaths; import java.io.IOException; diff --git a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ScanResult.java b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ScanResult.java index 1a75c8c21..de00acddd 100644 --- a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ScanResult.java +++ b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ScanResult.java @@ -20,8 +20,6 @@ package net.minecraftforge.fml.loading.moddiscovery; -import com.google.common.collect.Multimap; -import net.minecraftforge.fml.loading.FMLJavaModLanguageProvider; import net.minecraftforge.fml.loading.IModLanguageProvider; import org.objectweb.asm.Type; @@ -66,7 +64,6 @@ public class ScanResult { return modTargets; } - public static class ClassData { private final Type clazz; private final Type parent; @@ -111,6 +108,5 @@ public class ScanResult { public static ScanResult.AnnotationData fromModAnnotation(final Type clazz, final ModAnnotation annotation) { return new AnnotationData(annotation.asmType, clazz, annotation.member, annotation.values); } - } } diff --git a/src/main/java/net/minecraftforge/fml/server/FMLServerHandler.java b/src/main/java/net/minecraftforge/fml/server/FMLServerHandler.java index 9cf088c05..3648a2870 100644 --- a/src/main/java/net/minecraftforge/fml/server/FMLServerHandler.java +++ b/src/main/java/net/minecraftforge/fml/server/FMLServerHandler.java @@ -37,13 +37,13 @@ import net.minecraft.util.IThreadListener; import net.minecraft.util.text.translation.LanguageMap; import net.minecraft.world.storage.SaveFormatOld; import net.minecraftforge.common.util.CompoundDataFixer; +import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.IFMLSidedHandler; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.ModContainer; import net.minecraftforge.fml.common.StartupQuery; -import net.minecraftforge.fml.common.eventhandler.EventBus; import net.minecraftforge.fml.common.network.FMLNetworkEvent; import net.minecraftforge.fml.relauncher.Side; @@ -305,7 +305,7 @@ public class FMLServerHandler implements IFMLSidedHandler } @Override - public void fireNetRegistrationEvent(EventBus bus, NetworkManager manager, Set channelSet, String channel, Side side) + public void fireNetRegistrationEvent(IEventBus bus, NetworkManager manager, Set channelSet, String channel, Side side) { bus.post(new FMLNetworkEvent.CustomPacketRegistrationEvent(manager, channelSet, channel, side, NetHandlerPlayServer.class)); } diff --git a/src/main/java/net/minecraftforge/oredict/OreDictionary.java b/src/main/java/net/minecraftforge/oredict/OreDictionary.java index 9a902f869..d96897f86 100644 --- a/src/main/java/net/minecraftforge/oredict/OreDictionary.java +++ b/src/main/java/net/minecraftforge/oredict/OreDictionary.java @@ -20,7 +20,6 @@ package net.minecraftforge.oredict; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -32,7 +31,6 @@ import net.minecraft.block.BlockPrismarine; import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.ModContainer; -import org.apache.logging.log4j.Level; import net.minecraft.block.Block; import net.minecraft.init.Blocks; @@ -46,15 +44,12 @@ import net.minecraft.item.crafting.ShapedRecipes; import net.minecraft.item.crafting.ShapelessRecipes; import net.minecraftforge.common.MinecraftForge; -import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.eventhandler.Event; -import net.minecraftforge.fml.common.registry.ForgeRegistries; -import net.minecraftforge.registries.GameData; +import net.minecraftforge.eventbus.api.Event; import javax.annotation.Nonnull; @@ -701,7 +696,7 @@ public class OreDictionary MinecraftForge.EVENT_BUS.post(new OreRegisterEvent(name, ore)); } - public static class OreRegisterEvent extends Event + public static class OreRegisterEvent extends net.minecraftforge.eventbus.api.Event { private final String Name; private final ItemStack Ore; diff --git a/src/main/resources/META-INF/services/net.minecraftforge.fml.loading.IModLanguageProvider b/src/main/resources/META-INF/services/net.minecraftforge.fml.loading.IModLanguageProvider index dc3f90283..b0e7d2e1e 100644 --- a/src/main/resources/META-INF/services/net.minecraftforge.fml.loading.IModLanguageProvider +++ b/src/main/resources/META-INF/services/net.minecraftforge.fml.loading.IModLanguageProvider @@ -1 +1 @@ -net.minecraftforge.fml.loading.FMLJavaModLanguageProvider \ No newline at end of file +net.minecraftforge.fml.javafmlmod.FMLJavaModLanguageProvider \ No newline at end of file diff --git a/src/test/java/net/minecraftforge/debug/block/MaterialFogColorTest.java b/src/test/java/net/minecraftforge/debug/block/MaterialFogColorTest.java index c838aeb10..3fb690925 100644 --- a/src/test/java/net/minecraftforge/debug/block/MaterialFogColorTest.java +++ b/src/test/java/net/minecraftforge/debug/block/MaterialFogColorTest.java @@ -44,7 +44,7 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; import net.minecraftforge.fml.relauncher.Side; @@ -93,7 +93,7 @@ public class MaterialFogColorTest } } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerBlocks(RegistryEvent.Register event) { if (ENABLED) @@ -113,7 +113,7 @@ public class MaterialFogColorTest } } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerItems(RegistryEvent.Register event) { if (ENABLED) diff --git a/src/test/java/net/minecraftforge/debug/block/NeighborNotifyEventTest.java b/src/test/java/net/minecraftforge/debug/block/NeighborNotifyEventTest.java index 54d357e04..f59c159ab 100644 --- a/src/test/java/net/minecraftforge/debug/block/NeighborNotifyEventTest.java +++ b/src/test/java/net/minecraftforge/debug/block/NeighborNotifyEventTest.java @@ -24,7 +24,7 @@ import net.minecraftforge.event.world.BlockEvent.NeighborNotifyEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import org.apache.logging.log4j.Logger; @Mod(modid = "neighbornotifyeventtest", name = "NeighborNotifyEventTest", version = "0.0.0", acceptableRemoteVersions = "*") diff --git a/src/test/java/net/minecraftforge/debug/block/ParticleEffectsTest.java b/src/test/java/net/minecraftforge/debug/block/ParticleEffectsTest.java index ac78048e5..5783f5d32 100644 --- a/src/test/java/net/minecraftforge/debug/block/ParticleEffectsTest.java +++ b/src/test/java/net/minecraftforge/debug/block/ParticleEffectsTest.java @@ -42,7 +42,7 @@ import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; diff --git a/src/test/java/net/minecraftforge/debug/block/PathNodeTypeTest.java b/src/test/java/net/minecraftforge/debug/block/PathNodeTypeTest.java index d771c8143..2730ec76a 100644 --- a/src/test/java/net/minecraftforge/debug/block/PathNodeTypeTest.java +++ b/src/test/java/net/minecraftforge/debug/block/PathNodeTypeTest.java @@ -31,7 +31,7 @@ import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; import java.util.Collections; @@ -45,7 +45,7 @@ public class PathNodeTypeTest private static final Block TEST_BLOCK = new TestBlock(); - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void register(RegistryEvent.Register event) { if (ENABLED) @@ -57,7 +57,7 @@ public class PathNodeTypeTest @Mod.EventBusSubscriber(value = Side.CLIENT, modid = MOD_ID) public static class ClientEventHandler { - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerModels(ModelRegistryEvent event) { if (ENABLED) diff --git a/src/test/java/net/minecraftforge/debug/block/SlipperinessTest.java b/src/test/java/net/minecraftforge/debug/block/SlipperinessTest.java index 4aa77cc4d..7a58329e8 100644 --- a/src/test/java/net/minecraftforge/debug/block/SlipperinessTest.java +++ b/src/test/java/net/minecraftforge/debug/block/SlipperinessTest.java @@ -35,7 +35,7 @@ import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; import java.util.Collections; diff --git a/src/test/java/net/minecraftforge/debug/block/StickyBlockTest.java b/src/test/java/net/minecraftforge/debug/block/StickyBlockTest.java index a8688803a..d140b5481 100644 --- a/src/test/java/net/minecraftforge/debug/block/StickyBlockTest.java +++ b/src/test/java/net/minecraftforge/debug/block/StickyBlockTest.java @@ -38,7 +38,7 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.registry.ForgeRegistries; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -62,7 +62,7 @@ public class StickyBlockTest @EventBusSubscriber(value = Side.CLIENT, modid = MODID) public static class BakeEventHandler { - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerModels(ModelRegistryEvent event) { Item item = Item.getItemFromBlock(CUSTOM_SLIME_BLOCK); diff --git a/src/test/java/net/minecraftforge/debug/chat/ClientChatEventTest.java b/src/test/java/net/minecraftforge/debug/chat/ClientChatEventTest.java index 56021bb27..8f1c058ac 100644 --- a/src/test/java/net/minecraftforge/debug/chat/ClientChatEventTest.java +++ b/src/test/java/net/minecraftforge/debug/chat/ClientChatEventTest.java @@ -24,7 +24,7 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; @Mod(modid = "clientchateventtest", name = "Client Chat Event Test", version = "0.0.0", clientSideOnly = true) public class ClientChatEventTest @@ -40,7 +40,7 @@ public class ClientChatEventTest } } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public void onPlayerAttemptChat(ClientChatEvent event) { if (event.getMessage().equals("Cancel")) diff --git a/src/test/java/net/minecraftforge/debug/client/CustomTextureAtlasSpriteTest.java b/src/test/java/net/minecraftforge/debug/client/CustomTextureAtlasSpriteTest.java index d2c0ef598..b7e923606 100644 --- a/src/test/java/net/minecraftforge/debug/client/CustomTextureAtlasSpriteTest.java +++ b/src/test/java/net/minecraftforge/debug/client/CustomTextureAtlasSpriteTest.java @@ -33,7 +33,7 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import org.apache.logging.log4j.Logger; import javax.annotation.Nonnull; @@ -54,7 +54,7 @@ public class CustomTextureAtlasSpriteTest @Mod.EventBusSubscriber(modid = MOD_ID) public static class Registration { - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerBlocks(RegistryEvent.Register event) { event.getRegistry().register(new Block(Material.WOOD).setRegistryName(MOD_ID, "custom_sprite_block").setCreativeTab(CreativeTabs.MISC)); @@ -68,7 +68,7 @@ public class CustomTextureAtlasSpriteTest MinecraftForge.EVENT_BUS.register(this); } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public void textureStitch(TextureStitchEvent.Pre event) { DelegateSprite bottom = DelegateSprite.make("bottom", new ResourceLocation("blocks/diamond_block")); diff --git a/src/test/java/net/minecraftforge/debug/client/FOVModifierEventTest.java b/src/test/java/net/minecraftforge/debug/client/FOVModifierEventTest.java index f9c3ab721..c71ae0f96 100644 --- a/src/test/java/net/minecraftforge/debug/client/FOVModifierEventTest.java +++ b/src/test/java/net/minecraftforge/debug/client/FOVModifierEventTest.java @@ -25,7 +25,7 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; /** * Simple mod to test fov modifier. diff --git a/src/test/java/net/minecraftforge/debug/client/gui/ContainerDrawForegroundEventTest.java b/src/test/java/net/minecraftforge/debug/client/gui/ContainerDrawForegroundEventTest.java index e240633a0..5e47379fe 100644 --- a/src/test/java/net/minecraftforge/debug/client/gui/ContainerDrawForegroundEventTest.java +++ b/src/test/java/net/minecraftforge/debug/client/gui/ContainerDrawForegroundEventTest.java @@ -26,7 +26,7 @@ import net.minecraftforge.client.event.GuiContainerEvent; import net.minecraftforge.fml.client.config.GuiUtils; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; import net.minecraftforge.fml.relauncher.Side; diff --git a/src/test/java/net/minecraftforge/debug/client/model/AnimatedModelTest.java b/src/test/java/net/minecraftforge/debug/client/model/AnimatedModelTest.java index 4f22e1a27..67b928da1 100644 --- a/src/test/java/net/minecraftforge/debug/client/model/AnimatedModelTest.java +++ b/src/test/java/net/minecraftforge/debug/client/model/AnimatedModelTest.java @@ -71,7 +71,7 @@ import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.Mod.Instance; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.registry.EntityRegistry; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; @@ -112,7 +112,7 @@ public class AnimatedModelTest @Mod.EventBusSubscriber(modid = MODID) public static class Registration { - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerBlocks(RegistryEvent.Register event) { GameRegistry.registerTileEntity(Chest.class, MODID + ":" + "tile_" + blockName); @@ -256,7 +256,7 @@ public class AnimatedModelTest }); } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerItems(RegistryEvent.Register event) { event.getRegistry().register( diff --git a/src/test/java/net/minecraftforge/debug/client/model/BlockstateRetextureTest.java b/src/test/java/net/minecraftforge/debug/client/model/BlockstateRetextureTest.java index da4d086cc..5a1547775 100644 --- a/src/test/java/net/minecraftforge/debug/client/model/BlockstateRetextureTest.java +++ b/src/test/java/net/minecraftforge/debug/client/model/BlockstateRetextureTest.java @@ -33,7 +33,7 @@ import net.minecraftforge.client.event.ModelBakeEvent; import net.minecraftforge.client.model.IModel; import net.minecraftforge.client.model.ModelLoaderRegistry; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; @Mod(modid = BlockstateRetextureTest.MODID, name = "BlockstateRetextureTest", version = BlockstateRetextureTest.VERSION, acceptableRemoteVersions = "*", clientSideOnly = true) @@ -57,7 +57,7 @@ public class BlockstateRetextureTest @Mod.EventBusSubscriber(modid = MODID, value = Side.CLIENT) public static class ClientEvents { - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void onModelBakeEvent(ModelBakeEvent event) { if (!ENABLED) diff --git a/src/test/java/net/minecraftforge/debug/client/model/ForgeBlockStatesLoaderTest.java b/src/test/java/net/minecraftforge/debug/client/model/ForgeBlockStatesLoaderTest.java index da9c6eb32..ea970cd52 100644 --- a/src/test/java/net/minecraftforge/debug/client/model/ForgeBlockStatesLoaderTest.java +++ b/src/test/java/net/minecraftforge/debug/client/model/ForgeBlockStatesLoaderTest.java @@ -33,7 +33,7 @@ import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; import net.minecraftforge.fml.relauncher.Side; @@ -69,7 +69,7 @@ public class ForgeBlockStatesLoaderTest ); } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerItems(RegistryEvent.Register event) { event.getRegistry().registerAll( @@ -85,7 +85,7 @@ public class ForgeBlockStatesLoaderTest @Mod.EventBusSubscriber(value = Side.CLIENT, modid = MODID) public static class ClientEventHandler { - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerModels(ModelRegistryEvent event) { //ModelLoader.setCustomStateMapper(blockCustom, new StateMap.Builder().withName(CustomMappedBlock.VARIANT).build()); diff --git a/src/test/java/net/minecraftforge/debug/client/model/ItemLayerModelTest.java b/src/test/java/net/minecraftforge/debug/client/model/ItemLayerModelTest.java index 1e9d73c3b..883626835 100644 --- a/src/test/java/net/minecraftforge/debug/client/model/ItemLayerModelTest.java +++ b/src/test/java/net/minecraftforge/debug/client/model/ItemLayerModelTest.java @@ -34,7 +34,7 @@ import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; import javax.annotation.Nullable; @@ -57,7 +57,7 @@ public class ItemLayerModelTest event.getRegistry().register(new TestItem()); } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerModels(ModelRegistryEvent event) { ModelLoader.setCustomModelResourceLocation(TEST_ITEM, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + TestItem.name, "inventory")); diff --git a/src/test/java/net/minecraftforge/debug/client/model/ItemModelGenerationTest.java b/src/test/java/net/minecraftforge/debug/client/model/ItemModelGenerationTest.java index fbd385554..8137b8f6d 100644 --- a/src/test/java/net/minecraftforge/debug/client/model/ItemModelGenerationTest.java +++ b/src/test/java/net/minecraftforge/debug/client/model/ItemModelGenerationTest.java @@ -26,7 +26,7 @@ import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; @@ -81,7 +81,7 @@ public class ItemModelGenerationTest @Mod.EventBusSubscriber(modid = MOD_ID, value = Side.CLIENT) public static class ClientEventHandler { - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerModels(ModelRegistryEvent event) { setCustomMRL(ANIMATION_TEST); diff --git a/src/test/java/net/minecraftforge/debug/client/model/ModelBakeEventTest.java b/src/test/java/net/minecraftforge/debug/client/model/ModelBakeEventTest.java index 42f5ce845..76cbfa3c9 100644 --- a/src/test/java/net/minecraftforge/debug/client/model/ModelBakeEventTest.java +++ b/src/test/java/net/minecraftforge/debug/client/model/ModelBakeEventTest.java @@ -59,7 +59,7 @@ import net.minecraftforge.common.property.IUnlistedProperty; import net.minecraftforge.common.property.Properties; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; import net.minecraftforge.fml.relauncher.Side; diff --git a/src/test/java/net/minecraftforge/debug/client/model/ModelFluidTest.java b/src/test/java/net/minecraftforge/debug/client/model/ModelFluidTest.java index 3153ade47..06c738608 100644 --- a/src/test/java/net/minecraftforge/debug/client/model/ModelFluidTest.java +++ b/src/test/java/net/minecraftforge/debug/client/model/ModelFluidTest.java @@ -37,7 +37,7 @@ import net.minecraftforge.fluids.BlockFluidClassic; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; import net.minecraftforge.fml.relauncher.Side; diff --git a/src/test/java/net/minecraftforge/debug/client/model/ModelLoaderRegistryTest.java b/src/test/java/net/minecraftforge/debug/client/model/ModelLoaderRegistryTest.java index fce42bcda..42b2db216 100644 --- a/src/test/java/net/minecraftforge/debug/client/model/ModelLoaderRegistryTest.java +++ b/src/test/java/net/minecraftforge/debug/client/model/ModelLoaderRegistryTest.java @@ -62,7 +62,7 @@ import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; import org.apache.logging.log4j.Logger; @@ -113,7 +113,7 @@ public class ModelLoaderRegistryTest @Mod.EventBusSubscriber(modid = MODID) public static class Registration { - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerBlocks(RegistryEvent.Register event) { if (!ENABLED) @@ -133,7 +133,7 @@ public class ModelLoaderRegistryTest //GameRegistry.registerTileEntity(OBJDynamicEyeTileEntity.class, OBJDynamicEye.name); } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerItems(RegistryEvent.Register event) { if (!ENABLED) @@ -152,7 +152,7 @@ public class ModelLoaderRegistryTest event.getRegistry().register(new ItemBlock(block).setRegistryName(block.getRegistryName())); } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerModels(ModelRegistryEvent event) { if (!ENABLED) diff --git a/src/test/java/net/minecraftforge/debug/client/model/MultiLayerModelTest.java b/src/test/java/net/minecraftforge/debug/client/model/MultiLayerModelTest.java index 208ced765..af2c4b52e 100644 --- a/src/test/java/net/minecraftforge/debug/client/model/MultiLayerModelTest.java +++ b/src/test/java/net/minecraftforge/debug/client/model/MultiLayerModelTest.java @@ -32,7 +32,7 @@ import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; @Mod(modid = MultiLayerModelTest.MODID, name = "ForgeDebugMultiLayerModel", version = MultiLayerModelTest.VERSION, acceptableRemoteVersions = "*") @@ -50,7 +50,7 @@ public class MultiLayerModelTest @Mod.EventBusSubscriber(modid = MODID) public static class Registration { - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerBlocks(RegistryEvent.Register event) { if (!ENABLED) @@ -85,7 +85,7 @@ public class MultiLayerModelTest ); } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerItems(RegistryEvent.Register event) { event.getRegistry().register(new ItemBlock(TEST_BLOCK).setRegistryName(TEST_BLOCK.getRegistryName())); diff --git a/src/test/java/net/minecraftforge/debug/client/rendering/FastTESRTransparentTest.java b/src/test/java/net/minecraftforge/debug/client/rendering/FastTESRTransparentTest.java index fccdc2d70..3eb4b89d8 100644 --- a/src/test/java/net/minecraftforge/debug/client/rendering/FastTESRTransparentTest.java +++ b/src/test/java/net/minecraftforge/debug/client/rendering/FastTESRTransparentTest.java @@ -56,7 +56,7 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; @@ -219,7 +219,7 @@ public class FastTESRTransparentTest public static class BlockHolder { - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void onBlockRegister(RegistryEvent.Register evt) { evt.getRegistry().register(testBlock @@ -227,7 +227,7 @@ public class FastTESRTransparentTest .setRegistryName("fluid-tesr-block")); } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void onItemRegister(RegistryEvent.Register evt) { evt.getRegistry().register(new ItemBlock(testBlock) @@ -257,7 +257,7 @@ public class FastTESRTransparentTest @EventBusSubscriber(value = Side.CLIENT, modid = MODID) public static class ClientLoader { - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerModels(ModelRegistryEvent event) { ModelLoader.setCustomStateMapper(testBlock, block -> Collections.emptyMap()); diff --git a/src/test/java/net/minecraftforge/debug/client/rendering/ItemTESRTest.java b/src/test/java/net/minecraftforge/debug/client/rendering/ItemTESRTest.java index 277a3c4e2..7ddeb66c2 100644 --- a/src/test/java/net/minecraftforge/debug/client/rendering/ItemTESRTest.java +++ b/src/test/java/net/minecraftforge/debug/client/rendering/ItemTESRTest.java @@ -39,7 +39,7 @@ import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.registry.ForgeRegistries; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; @@ -57,14 +57,14 @@ public class ItemTESRTest @Mod.EventBusSubscriber(modid = MODID) public static class Registration { - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerBlocks(RegistryEvent.Register event) { event.getRegistry().register(new TestBlock()); GameRegistry.registerTileEntity(CustomTileEntity.class, MODID.toLowerCase() + ":custom_tile_entity"); } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerItems(RegistryEvent.Register event) { event.getRegistry().register(new ItemBlock(TEST_BLOCK).setRegistryName(TEST_BLOCK.getRegistryName())); @@ -85,7 +85,7 @@ public class ItemTESRTest ClientRegistry.bindTileEntitySpecialRenderer(CustomTileEntity.class, TestTESR.instance); } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void onModelBakeEvent(ModelBakeEvent event) { event.getModelManager().getBlockModelShapes().registerBuiltInBlocks(TEST_BLOCK); diff --git a/src/test/java/net/minecraftforge/debug/entity/EntityTravelToDimensionEventTest.java b/src/test/java/net/minecraftforge/debug/entity/EntityTravelToDimensionEventTest.java index 16612c7bc..ed5b24be5 100644 --- a/src/test/java/net/minecraftforge/debug/entity/EntityTravelToDimensionEventTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/EntityTravelToDimensionEventTest.java @@ -24,7 +24,7 @@ import net.minecraftforge.event.entity.EntityTravelToDimensionEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import org.apache.logging.log4j.Logger; @Mod(modid = "entitytraveltodimensioneventtest", name = "EntityTravelToDimensionEventTest", version = "0.0.0", acceptableRemoteVersions = "*") diff --git a/src/test/java/net/minecraftforge/debug/entity/GetCollisionBoxesEventTest.java b/src/test/java/net/minecraftforge/debug/entity/GetCollisionBoxesEventTest.java index 9b161754a..d8a548392 100644 --- a/src/test/java/net/minecraftforge/debug/entity/GetCollisionBoxesEventTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/GetCollisionBoxesEventTest.java @@ -39,7 +39,7 @@ import net.minecraft.world.World; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.event.world.GetCollisionBoxesEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry; @Mod(modid = GetCollisionBoxesEventTest.MODID, name = "CollisionBoxesEventTest", version = "1.0", acceptableRemoteVersions = "*") @@ -53,7 +53,7 @@ public class GetCollisionBoxesEventTest private static final Block BOX_BLOCK = null; private static final ArrayList locations = new ArrayList<>(); - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerBlock(RegistryEvent.Register event) { if (ENABLED) diff --git a/src/test/java/net/minecraftforge/debug/entity/ProjectileImpactEventTest.java b/src/test/java/net/minecraftforge/debug/entity/ProjectileImpactEventTest.java index 52b427914..b32d11394 100644 --- a/src/test/java/net/minecraftforge/debug/entity/ProjectileImpactEventTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/ProjectileImpactEventTest.java @@ -23,7 +23,7 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.ProjectileImpactEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import org.apache.logging.log4j.Logger; @Mod(modid = "projectile_event_test", name = "ProjectileImpactEvent test mod", version = "1.0", acceptableRemoteVersions = "*") @@ -43,7 +43,7 @@ public class ProjectileImpactEventTest } } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void onProjectileImpact(ProjectileImpactEvent event) { logger.info("projectile: {}, impact: {}", event.getEntity().getName(), event.getRayTraceResult()); diff --git a/src/test/java/net/minecraftforge/debug/entity/living/DamageEventTest.java b/src/test/java/net/minecraftforge/debug/entity/living/DamageEventTest.java index ab32c0036..308371920 100644 --- a/src/test/java/net/minecraftforge/debug/entity/living/DamageEventTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/living/DamageEventTest.java @@ -40,7 +40,7 @@ import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.event.FMLServerStartingEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import org.apache.logging.log4j.Logger; @Mod(modid = DamageEventTest.MODID, name = "ForgeDebugLivingDamage", version = "1.0", acceptableRemoteVersions = "*") @@ -155,13 +155,13 @@ public class DamageEventTest public static class TestEventHandler { - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void livingHurtPre(LivingHurtEvent evt) { logger.info("Entity {} damage from {} (pre-reduction): {}", evt.getEntity(), evt.getSource().getDamageType(), evt.getAmount()); } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void livingHurtPost(LivingDamageEvent evt) { logger.info("Entity {} damage from {} (post-reduction): {}", evt.getEntity(), evt.getSource().getDamageType(), evt.getAmount()); diff --git a/src/test/java/net/minecraftforge/debug/entity/living/EquipmentChangeEventTest.java b/src/test/java/net/minecraftforge/debug/entity/living/EquipmentChangeEventTest.java index 007758a31..7e76eece7 100644 --- a/src/test/java/net/minecraftforge/debug/entity/living/EquipmentChangeEventTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/living/EquipmentChangeEventTest.java @@ -23,7 +23,7 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingEquipmentChangeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import org.apache.logging.log4j.Logger; @Mod(modid = "equipment_change_test", name = "Equipment Change Test", version = "1.0.0", acceptableRemoteVersions = "*") diff --git a/src/test/java/net/minecraftforge/debug/entity/living/KnockBackEventTest.java b/src/test/java/net/minecraftforge/debug/entity/living/KnockBackEventTest.java index d22ba417c..a3f0e4fd0 100644 --- a/src/test/java/net/minecraftforge/debug/entity/living/KnockBackEventTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/living/KnockBackEventTest.java @@ -23,7 +23,7 @@ import net.minecraft.entity.passive.EntityCow; import net.minecraft.entity.passive.EntitySheep; import net.minecraftforge.event.entity.living.LivingKnockBackEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; @Mod(modid = "kbhtest", name = "Knock Back Hook Test", version = "1.0", acceptableRemoteVersions = "*") @Mod.EventBusSubscriber @@ -31,7 +31,7 @@ public class KnockBackEventTest { private static final boolean ENABLED = false; - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void onKnockBack(LivingKnockBackEvent event) { if(ENABLED) diff --git a/src/test/java/net/minecraftforge/debug/entity/living/VillagerProfessionTest.java b/src/test/java/net/minecraftforge/debug/entity/living/VillagerProfessionTest.java index cb1860610..ca0ac5c46 100644 --- a/src/test/java/net/minecraftforge/debug/entity/living/VillagerProfessionTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/living/VillagerProfessionTest.java @@ -22,7 +22,7 @@ package net.minecraftforge.debug.entity.living; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerCareer; import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession; diff --git a/src/test/java/net/minecraftforge/debug/entity/player/CriticalHitEventTest.java b/src/test/java/net/minecraftforge/debug/entity/player/CriticalHitEventTest.java index 417a3fec7..1e10cb54b 100644 --- a/src/test/java/net/minecraftforge/debug/entity/player/CriticalHitEventTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/player/CriticalHitEventTest.java @@ -25,8 +25,8 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.eventhandler.Event.Result; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.eventbus.api.Event.Result; import org.apache.logging.log4j.Logger; import net.minecraft.util.EnumHand; diff --git a/src/test/java/net/minecraftforge/debug/entity/player/DamageReworkTest.java b/src/test/java/net/minecraftforge/debug/entity/player/DamageReworkTest.java index 2f988dcfe..8685e52fe 100644 --- a/src/test/java/net/minecraftforge/debug/entity/player/DamageReworkTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/player/DamageReworkTest.java @@ -29,7 +29,7 @@ import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; @Mod(modid = "playerdamagereworktest", name = "PlayerDamageReworkTest", version = "0.0.0", acceptableRemoteVersions = "*") public class DamageReworkTest @@ -44,7 +44,7 @@ public class DamageReworkTest if (ENABLE) MinecraftForge.EVENT_BUS.register(this); } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public void checkForSneakEvent(LivingUpdateEvent event) { if (event.getEntityLiving() instanceof EntityPlayer) diff --git a/src/test/java/net/minecraftforge/debug/entity/player/ItemPickupEventTest.java b/src/test/java/net/minecraftforge/debug/entity/player/ItemPickupEventTest.java index 698169606..a7192478e 100644 --- a/src/test/java/net/minecraftforge/debug/entity/player/ItemPickupEventTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/player/ItemPickupEventTest.java @@ -25,7 +25,7 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.PlayerEvent; @Mod(modid = ItemPickupEventTest.MODID, name = ItemPickupEventTest.NAME, version = ItemPickupEventTest.VERSION, acceptableRemoteVersions = "*") diff --git a/src/test/java/net/minecraftforge/debug/entity/player/PlayerInteractEventTest.java b/src/test/java/net/minecraftforge/debug/entity/player/PlayerInteractEventTest.java index 8decc7076..550987ff7 100644 --- a/src/test/java/net/minecraftforge/debug/entity/player/PlayerInteractEventTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/player/PlayerInteractEventTest.java @@ -34,8 +34,8 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.Event; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.Event; +import net.minecraftforge.eventbus.api.SubscribeEvent; import org.apache.logging.log4j.Logger; @Mod(modid = "playerinteracteventtest", name = "PlayerInteractEventTest", version = "0.0.0", acceptableRemoteVersions = "*") @@ -53,7 +53,7 @@ public class PlayerInteractEventTest MinecraftForge.EVENT_BUS.register(PlayerInteractEventTest.class); // Test Static event listeners } - @SubscribeEvent(receiveCanceled = true) // this triggers after the subclasses below, and we'd like to log them all + @net.minecraftforge.eventbus.api.SubscribeEvent(receiveCanceled = true) // this triggers after the subclasses below, and we'd like to log them all public void global(PlayerInteractEvent evt) { if (!ENABLE) @@ -65,7 +65,7 @@ public class PlayerInteractEventTest logger.info("{} | face: {}", evt.getPos(), evt.getFace()); } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public void leftClickBlock(PlayerInteractEvent.LeftClickBlock evt) { if (!ENABLE) @@ -82,7 +82,7 @@ public class PlayerInteractEventTest } if (evt.getItemStack().getItem() == Items.DIAMOND_PICKAXE) { - evt.setUseBlock(Event.Result.DENY); // Redstone should not activate, pick should still dig + evt.setUseBlock(net.minecraftforge.eventbus.api.Event.Result.DENY); // Redstone should not activate, pick should still dig } if (evt.getItemStack().getItem() == Items.IRON_PICKAXE) { @@ -109,15 +109,15 @@ public class PlayerInteractEventTest TileEntity te = evt.getWorld().getTileEntity(evt.getPos()); if (te instanceof TileEntityDropper) { - evt.setUseBlock(Event.Result.ALLOW); + evt.setUseBlock(net.minecraftforge.eventbus.api.Event.Result.ALLOW); evt.setUseItem(Event.Result.ALLOW); } // Same as above, except the item should no longer be used if (te instanceof TileEntityChest) { - evt.setUseBlock(Event.Result.ALLOW); - evt.setUseItem(Event.Result.DENY); // could be left out as well + evt.setUseBlock(net.minecraftforge.eventbus.api.Event.Result.ALLOW); + evt.setUseItem(net.minecraftforge.eventbus.api.Event.Result.DENY); // could be left out as well } // Case: Flint and steel in main hand on top of a TE will light a fire, not open the TE. @@ -125,14 +125,14 @@ public class PlayerInteractEventTest // If you dual wield flints and steels and right click a chest nothing should happen if (!evt.getItemStack().isEmpty() && evt.getItemStack().getItem() == Items.FLINT_AND_STEEL) { - evt.setUseBlock(Event.Result.DENY); + evt.setUseBlock(net.minecraftforge.eventbus.api.Event.Result.DENY); } // Case: Painting in main hand // Opening a TE will also place a painting on the TE if possible if (evt.getHand() == EnumHand.MAIN_HAND && !evt.getItemStack().isEmpty() && evt.getItemStack().getItem() == Items.PAINTING) { - evt.setUseItem(Event.Result.ALLOW); + evt.setUseItem(net.minecraftforge.eventbus.api.Event.Result.ALLOW); } // Spawn egg in main hand, block in offhand -> block should be placed diff --git a/src/test/java/net/minecraftforge/debug/entity/player/PlayerSetSpawnTest.java b/src/test/java/net/minecraftforge/debug/entity/player/PlayerSetSpawnTest.java index 3d98c235d..dfb002317 100644 --- a/src/test/java/net/minecraftforge/debug/entity/player/PlayerSetSpawnTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/player/PlayerSetSpawnTest.java @@ -24,7 +24,7 @@ import net.minecraftforge.event.entity.player.PlayerSetSpawnEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import org.apache.logging.log4j.Logger; @Mod(modid = "playersetspawntest", name = "Player Set Spawn Test", version = "0.0.0", acceptableRemoteVersions = "*") diff --git a/src/test/java/net/minecraftforge/debug/entity/player/ReachDistanceAttributeTest.java b/src/test/java/net/minecraftforge/debug/entity/player/ReachDistanceAttributeTest.java index 4e4546df6..73583ee2a 100644 --- a/src/test/java/net/minecraftforge/debug/entity/player/ReachDistanceAttributeTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/player/ReachDistanceAttributeTest.java @@ -31,7 +31,7 @@ import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; @Mod(modid = ReachDistanceAttributeTest.MODID, name = ReachDistanceAttributeTest.MODID, version = "1.0", acceptableRemoteVersions = "*") @@ -49,7 +49,7 @@ public class ReachDistanceAttributeTest @Mod.EventBusSubscriber(Side.CLIENT) public static class ClientEvents { - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerModels(ModelRegistryEvent evt) { ModelLoader.setCustomModelResourceLocation(PLATE, 0, new ModelResourceLocation("minecraft:diamond_chestplate", "inventory")); diff --git a/src/test/java/net/minecraftforge/debug/fluid/ColoredFluidTest.java b/src/test/java/net/minecraftforge/debug/fluid/ColoredFluidTest.java index d0f442385..312b2e718 100644 --- a/src/test/java/net/minecraftforge/debug/fluid/ColoredFluidTest.java +++ b/src/test/java/net/minecraftforge/debug/fluid/ColoredFluidTest.java @@ -33,7 +33,7 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; @Mod(modid = ColoredFluidTest.MODID, name = "Test Mod", version = "1.0.0", acceptedMinecraftVersions = "*", acceptableRemoteVersions = "*") diff --git a/src/test/java/net/minecraftforge/debug/fluid/CreateFluidSourceEventTest.java b/src/test/java/net/minecraftforge/debug/fluid/CreateFluidSourceEventTest.java index 6b83f050b..f529fab41 100644 --- a/src/test/java/net/minecraftforge/debug/fluid/CreateFluidSourceEventTest.java +++ b/src/test/java/net/minecraftforge/debug/fluid/CreateFluidSourceEventTest.java @@ -24,8 +24,8 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.world.BlockEvent.CreateFluidSourceEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.Event.Result; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.Event.Result; +import net.minecraftforge.eventbus.api.SubscribeEvent; @Mod(modid = "createfluidsourcetest", name = "CreateFluidSourceTest", version = "1.0", acceptableRemoteVersions = "*") public class CreateFluidSourceEventTest @@ -41,7 +41,7 @@ public class CreateFluidSourceEventTest } } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void onCreateFluidSource(CreateFluidSourceEvent event) { // make it work exactly the opposite of how it works by default diff --git a/src/test/java/net/minecraftforge/debug/fluid/DynBucketTest.java b/src/test/java/net/minecraftforge/debug/fluid/DynBucketTest.java index 6e74d4e9b..c20563647 100644 --- a/src/test/java/net/minecraftforge/debug/fluid/DynBucketTest.java +++ b/src/test/java/net/minecraftforge/debug/fluid/DynBucketTest.java @@ -72,8 +72,8 @@ import net.minecraftforge.fluids.capability.IFluidTankProperties; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.Event.Result; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.Event.Result; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; import net.minecraftforge.fml.relauncher.Side; @@ -119,7 +119,7 @@ public class DynBucketTest GameRegistry.registerTileEntity(TileSimpleTank.class, "simpletank"); } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public void registerItems(RegistryEvent.Register event) { FluidRegistry.addBucketForFluid(FluidRegistry.getFluid(TestFluid.name)); @@ -132,7 +132,7 @@ public class DynBucketTest ); } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public void registerRecipes(RegistryEvent.Register event) { ItemStack filledBucket = FluidUtil.getFilledBucket(new FluidStack(ModelFluidTest.FLUID, Fluid.BUCKET_VOLUME)); @@ -151,7 +151,7 @@ public class DynBucketTest } } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public void onBucketFill(FillBucketEvent event) { RayTraceResult target = event.getTarget(); @@ -182,7 +182,7 @@ public class DynBucketTest @Mod.EventBusSubscriber(value = Side.CLIENT, modid = MODID) public static class ClientEventHandler { - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void setupModels(ModelRegistryEvent event) { if (!ENABLE || !ModelFluidTest.ENABLE) return; diff --git a/src/test/java/net/minecraftforge/debug/fluid/FluidPlacementTest.java b/src/test/java/net/minecraftforge/debug/fluid/FluidPlacementTest.java index 8661fe340..4ac8dac8d 100644 --- a/src/test/java/net/minecraftforge/debug/fluid/FluidPlacementTest.java +++ b/src/test/java/net/minecraftforge/debug/fluid/FluidPlacementTest.java @@ -52,7 +52,7 @@ import net.minecraftforge.fluids.UniversalBucket; import net.minecraftforge.fluids.capability.templates.FluidHandlerItemStack; import net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; diff --git a/src/test/java/net/minecraftforge/debug/gameplay/CraftingSystemTest.java b/src/test/java/net/minecraftforge/debug/gameplay/CraftingSystemTest.java index 7feeb6ea6..28b32a628 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/CraftingSystemTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/CraftingSystemTest.java @@ -29,7 +29,7 @@ import net.minecraftforge.common.crafting.IRecipeFactory; import net.minecraftforge.common.crafting.JsonContext; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -44,7 +44,7 @@ public class CraftingSystemTest static final Logger logger = LogManager.getLogger(MOD_ID); - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerRecipes(RegistryEvent.Register event) { logger.info("Registering Test Recipes:"); diff --git a/src/test/java/net/minecraftforge/debug/gameplay/DifficultyChangeEventTest.java b/src/test/java/net/minecraftforge/debug/gameplay/DifficultyChangeEventTest.java index 504c55c18..951d86dce 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/DifficultyChangeEventTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/DifficultyChangeEventTest.java @@ -24,7 +24,7 @@ import net.minecraftforge.event.DifficultyChangeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import org.apache.logging.log4j.Logger; @Mod(modid = "difficultychangeeventtest", name = "DifficultyChangeEventTest", version = "0.0.0", acceptableRemoteVersions = "*") @@ -43,7 +43,7 @@ public class DifficultyChangeEventTest } } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public void onDifficultyChange(DifficultyChangeEvent event) { logger.info("Difficulty changed from {} to {}", event.getOldDifficulty(), event.getDifficulty()); diff --git a/src/test/java/net/minecraftforge/debug/gameplay/EnchantmentLevelSetEventTest.java b/src/test/java/net/minecraftforge/debug/gameplay/EnchantmentLevelSetEventTest.java index ed74cf6c2..f141334ef 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/EnchantmentLevelSetEventTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/EnchantmentLevelSetEventTest.java @@ -23,7 +23,7 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.enchanting.EnchantmentLevelSetEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import org.apache.logging.log4j.Logger; @Mod(modid = "enchantmentlevelsettest", name = "EnchantmentLevelSetTest", version = "1.0", acceptableRemoteVersions = "*") diff --git a/src/test/java/net/minecraftforge/debug/gameplay/FurnaceFuelBurnTimeEventTest.java b/src/test/java/net/minecraftforge/debug/gameplay/FurnaceFuelBurnTimeEventTest.java index a8f2cdc98..deeb9d380 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/FurnaceFuelBurnTimeEventTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/FurnaceFuelBurnTimeEventTest.java @@ -32,7 +32,7 @@ import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.event.furnace.FurnaceFuelBurnTimeEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry; @Mod(modid = FurnaceFuelBurnTimeEventTest.MOD_ID, name = "Test for FurnaceFuelBurnTimeEvent", version = "1.0", acceptableRemoteVersions = "*") diff --git a/src/test/java/net/minecraftforge/debug/gameplay/InputUpdateEventTest.java b/src/test/java/net/minecraftforge/debug/gameplay/InputUpdateEventTest.java index 4bce435f7..77bc1485d 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/InputUpdateEventTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/InputUpdateEventTest.java @@ -27,7 +27,7 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.util.text.TextComponentString; import net.minecraftforge.client.event.InputUpdateEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; @Mod(modid = InputUpdateEventTest.MODID, name = "InputUpdateTest", version = "1.0", acceptableRemoteVersions = "*") @@ -38,7 +38,7 @@ public class InputUpdateEventTest @Mod.EventBusSubscriber(value = Side.CLIENT, modid = MODID) public static class Registration { - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void onInputUpdate(InputUpdateEvent evt) { EntityPlayer player = evt.getEntityPlayer(); diff --git a/src/test/java/net/minecraftforge/debug/gameplay/NoBedSleepingTest.java b/src/test/java/net/minecraftforge/debug/gameplay/NoBedSleepingTest.java index c44086d14..5c79f584f 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/NoBedSleepingTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/NoBedSleepingTest.java @@ -49,8 +49,8 @@ import net.minecraftforge.event.entity.player.PlayerWakeUpEvent; import net.minecraftforge.event.entity.player.SleepingLocationCheckEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.Event.Result; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.Event.Result; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; import javax.annotation.Nonnull; diff --git a/src/test/java/net/minecraftforge/debug/gameplay/RecipeMatchingTest.java b/src/test/java/net/minecraftforge/debug/gameplay/RecipeMatchingTest.java index db67b15b4..9c70378bc 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/RecipeMatchingTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/RecipeMatchingTest.java @@ -36,7 +36,7 @@ import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.relauncher.FMLLaunchHandler; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.oredict.ShapedOreRecipe; diff --git a/src/test/java/net/minecraftforge/debug/gameplay/advancement/AdvancementCriterionTest.java b/src/test/java/net/minecraftforge/debug/gameplay/advancement/AdvancementCriterionTest.java index 0310a0abe..05d4ed681 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/advancement/AdvancementCriterionTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/advancement/AdvancementCriterionTest.java @@ -25,7 +25,7 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import net.minecraftforge.fml.relauncher.Side; diff --git a/src/test/java/net/minecraftforge/debug/gameplay/advancement/AdvancementEventTest.java b/src/test/java/net/minecraftforge/debug/gameplay/advancement/AdvancementEventTest.java index 7f5d2cb5c..3adbff018 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/advancement/AdvancementEventTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/advancement/AdvancementEventTest.java @@ -23,7 +23,7 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.AdvancementEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import org.apache.logging.log4j.Logger; @Mod(modid = AdvancementEventTest.MOD_ID, name = "AdvancementEvent test mod", version = "1.0.0", acceptableRemoteVersions = "*") diff --git a/src/test/java/net/minecraftforge/debug/gameplay/advancement/OredictTriggerTest.java b/src/test/java/net/minecraftforge/debug/gameplay/advancement/OredictTriggerTest.java index a75caf811..e9f4ae2ba 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/advancement/OredictTriggerTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/advancement/OredictTriggerTest.java @@ -30,7 +30,7 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; diff --git a/src/test/java/net/minecraftforge/debug/gameplay/loot/LootContextTweaksTest.java b/src/test/java/net/minecraftforge/debug/gameplay/loot/LootContextTweaksTest.java index 97227e14c..143d4b00a 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/loot/LootContextTweaksTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/loot/LootContextTweaksTest.java @@ -46,7 +46,7 @@ import net.minecraftforge.event.LootTableLoadEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.registry.ForgeRegistries; @EventBusSubscriber @@ -63,7 +63,7 @@ public class LootContextTweaksTest LootConditionManager.registerCondition(new InBiome.Serialiser()); } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void onLootTableLoad(LootTableLoadEvent event) { if (!ENABLED) return; diff --git a/src/test/java/net/minecraftforge/debug/gameplay/loot/LootTableLoadEventTest.java b/src/test/java/net/minecraftforge/debug/gameplay/loot/LootTableLoadEventTest.java index 5c9ebd7ed..71c238be8 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/loot/LootTableLoadEventTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/loot/LootTableLoadEventTest.java @@ -27,7 +27,7 @@ import net.minecraftforge.event.LootTableLoadEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; @Mod(modid = LootTableLoadEventTest.MODID, name = "LootTableLoadEventTest", version = "1.0", acceptableRemoteVersions = "*") public class LootTableLoadEventTest @@ -44,7 +44,7 @@ public class LootTableLoadEventTest } } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public void onLootTableLoadEvent(LootTableLoadEvent event) { if (LootTableList.CHESTS_SPAWN_BONUS_CHEST.equals(event.getName())) diff --git a/src/test/java/net/minecraftforge/debug/gameplay/loot/LootTableTest.java b/src/test/java/net/minecraftforge/debug/gameplay/loot/LootTableTest.java index d8bd7fe07..f9da40cb8 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/loot/LootTableTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/loot/LootTableTest.java @@ -33,7 +33,7 @@ import net.minecraftforge.event.LootTableLoadEvent; import net.minecraftforge.event.entity.living.LootingLevelEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; @Mod(modid = LootTableTest.MODID, name = "Loot Table Debug", version = "1.0", acceptableRemoteVersions = "*") public class LootTableTest @@ -46,7 +46,7 @@ public class LootTableTest MinecraftForge.EVENT_BUS.register(this); } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public void lootLoad(LootTableLoadEvent event) { if (!event.getName().equals(LootTableList.CHESTS_SPAWN_BONUS_CHEST)) @@ -64,7 +64,7 @@ public class LootTableTest event.getTable().removePool("pool3"); } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public void lootingEvent(LootingLevelEvent event) { // if the player shoots something with a projectile, use looting 3 diff --git a/src/test/java/net/minecraftforge/debug/item/BonemealEventTest.java b/src/test/java/net/minecraftforge/debug/item/BonemealEventTest.java index dac2e089a..085c53b8d 100644 --- a/src/test/java/net/minecraftforge/debug/item/BonemealEventTest.java +++ b/src/test/java/net/minecraftforge/debug/item/BonemealEventTest.java @@ -24,8 +24,8 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.BonemealEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.Event; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.Event; +import net.minecraftforge.eventbus.api.SubscribeEvent; import org.apache.logging.log4j.Logger; @Mod(modid = BonemealEventTest.MODID, name = "Bonemeal Event Test", version = "1.0", acceptableRemoteVersions = "*") @@ -53,7 +53,7 @@ public class BonemealEventTest if (event.getHand() == EnumHand.MAIN_HAND) { // If the bone meal is being used from the main hand, set the result to ALLOW to use up the bone meal without growing the crop - event.setResult(Event.Result.ALLOW); + event.setResult(net.minecraftforge.eventbus.api.Event.Result.ALLOW); logger.info("Prevented bone meal growth effect from main hand"); } else if (event.getHand() == EnumHand.OFF_HAND) diff --git a/src/test/java/net/minecraftforge/debug/item/CanApplyAtEnchantingTableTest.java b/src/test/java/net/minecraftforge/debug/item/CanApplyAtEnchantingTableTest.java index 144fec059..2d3116f84 100644 --- a/src/test/java/net/minecraftforge/debug/item/CanApplyAtEnchantingTableTest.java +++ b/src/test/java/net/minecraftforge/debug/item/CanApplyAtEnchantingTableTest.java @@ -27,7 +27,7 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; @Mod(modid = CanApplyAtEnchantingTableTest.MODID, name = "CanApplyAtEnchantingTableTest", version = "0.0.0", acceptableRemoteVersions = "*") @@ -76,7 +76,7 @@ public class CanApplyAtEnchantingTableTest @Mod.EventBusSubscriber(value = Side.CLIENT, modid = MODID) public static class ClientEventHandler { - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerModels(ModelRegistryEvent event) { if (ENABLE) diff --git a/src/test/java/net/minecraftforge/debug/item/CanDestroyBlocksInCreativeTest.java b/src/test/java/net/minecraftforge/debug/item/CanDestroyBlocksInCreativeTest.java index f60f9ac3c..c14ab2f99 100644 --- a/src/test/java/net/minecraftforge/debug/item/CanDestroyBlocksInCreativeTest.java +++ b/src/test/java/net/minecraftforge/debug/item/CanDestroyBlocksInCreativeTest.java @@ -27,7 +27,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; @Mod(modid = CanDestroyBlocksInCreativeTest.MODID, name = "Item.canDestroyBlockInCreative() Test", version = "1.0", acceptableRemoteVersions = "*") public class CanDestroyBlocksInCreativeTest diff --git a/src/test/java/net/minecraftforge/debug/item/HorseArmorTest.java b/src/test/java/net/minecraftforge/debug/item/HorseArmorTest.java index c690fdf92..fac0bd12b 100644 --- a/src/test/java/net/minecraftforge/debug/item/HorseArmorTest.java +++ b/src/test/java/net/minecraftforge/debug/item/HorseArmorTest.java @@ -34,7 +34,7 @@ import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; import net.minecraftforge.fml.relauncher.Side; @@ -57,7 +57,7 @@ public class HorseArmorTest testArmorType = EnumHelper.addHorseArmor("test", MODID + ":textures/entity/horse/armor/test.png", 15); } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerItems(RegistryEvent.Register event) { if(ENABLED) @@ -67,7 +67,7 @@ public class HorseArmorTest @EventBusSubscriber(modid = MODID, value = Side.CLIENT) public static class ClientEventHandler { - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerModels(ModelRegistryEvent event) { if(ENABLED) diff --git a/src/test/java/net/minecraftforge/debug/item/IsBookEnchantableTest.java b/src/test/java/net/minecraftforge/debug/item/IsBookEnchantableTest.java index 6710490c7..831e882da 100644 --- a/src/test/java/net/minecraftforge/debug/item/IsBookEnchantableTest.java +++ b/src/test/java/net/minecraftforge/debug/item/IsBookEnchantableTest.java @@ -27,7 +27,7 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; @Mod(modid = IsBookEnchantableTest.MOD_ID, name = "Test for isBookEnchantable", version = "1.0", acceptableRemoteVersions = "*") @@ -39,7 +39,7 @@ public class IsBookEnchantableTest private static final Item TEST_ITEM = new TestItem(); - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerItem(RegistryEvent.Register event) { if (ENABLED) @@ -51,7 +51,7 @@ public class IsBookEnchantableTest @Mod.EventBusSubscriber(value = Side.CLIENT, modid = MOD_ID) public static class ClientEventHandler { - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerModels(ModelRegistryEvent event) { if (ENABLED) diff --git a/src/test/java/net/minecraftforge/debug/item/ItemFishedEventTest.java b/src/test/java/net/minecraftforge/debug/item/ItemFishedEventTest.java index 587e25ec4..28e78bfea 100644 --- a/src/test/java/net/minecraftforge/debug/item/ItemFishedEventTest.java +++ b/src/test/java/net/minecraftforge/debug/item/ItemFishedEventTest.java @@ -27,7 +27,7 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.ItemFishedEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import org.apache.logging.log4j.Logger; @Mod(modid = "itemfishtest", name = "ItemFishTest", version = "1.0.0", acceptableRemoteVersions = "*") @@ -48,7 +48,7 @@ public class ItemFishedEventTest } } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public void onItemFished(ItemFishedEvent event) { EntityFishHook hook = event.getHookEntity(); diff --git a/src/test/java/net/minecraftforge/debug/item/MapDataTest.java b/src/test/java/net/minecraftforge/debug/item/MapDataTest.java index 525cf7ea0..d545cf36d 100644 --- a/src/test/java/net/minecraftforge/debug/item/MapDataTest.java +++ b/src/test/java/net/minecraftforge/debug/item/MapDataTest.java @@ -46,7 +46,7 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; diff --git a/src/test/java/net/minecraftforge/debug/item/NBTShareTagTest.java b/src/test/java/net/minecraftforge/debug/item/NBTShareTagTest.java index c2675e661..7c0c602f6 100644 --- a/src/test/java/net/minecraftforge/debug/item/NBTShareTagTest.java +++ b/src/test/java/net/minecraftforge/debug/item/NBTShareTagTest.java @@ -33,7 +33,7 @@ import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; import javax.annotation.Nullable; @@ -49,7 +49,7 @@ public class NBTShareTagTest @Mod.EventBusSubscriber(modid = MODID) public static class Registration { - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerRecipes(RegistryEvent.Register event) { ItemStack crafted = new ItemStack(TEST_ITEM); @@ -60,13 +60,13 @@ public class NBTShareTagTest GameRegistry.addShapelessRecipe(new ResourceLocation(MODID, "nbt_share"), null, crafted, Ingredient.fromItem(Items.STICK)); } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerItems(RegistryEvent.Register event) { event.getRegistry().register(new ShareTagItem().setRegistryName(itemName)); } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerModels(ModelRegistryEvent event) { ModelLoader.setCustomModelResourceLocation(TEST_ITEM, 0, new ModelResourceLocation(itemName, "inventory")); diff --git a/src/test/java/net/minecraftforge/debug/item/OnItemUseFirstTest.java b/src/test/java/net/minecraftforge/debug/item/OnItemUseFirstTest.java index c8580ee4a..1b0c3e6f2 100644 --- a/src/test/java/net/minecraftforge/debug/item/OnItemUseFirstTest.java +++ b/src/test/java/net/minecraftforge/debug/item/OnItemUseFirstTest.java @@ -32,7 +32,7 @@ import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.SidedProxy; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import javax.annotation.Nonnull; diff --git a/src/test/java/net/minecraftforge/debug/item/PotionCurabilityTest.java b/src/test/java/net/minecraftforge/debug/item/PotionCurabilityTest.java index 37ece121e..8fb1335f8 100644 --- a/src/test/java/net/minecraftforge/debug/item/PotionCurabilityTest.java +++ b/src/test/java/net/minecraftforge/debug/item/PotionCurabilityTest.java @@ -31,7 +31,7 @@ import net.minecraft.world.World; import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; import net.minecraftforge.fml.relauncher.Side; @@ -66,7 +66,7 @@ public class PotionCurabilityTest event.getRegistry().register(new Medicine().setRegistryName(MODID, "medicine")); } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerPotions(RegistryEvent.Register event) { if (!ENABLED) return; diff --git a/src/test/java/net/minecraftforge/debug/item/ShieldTest.java b/src/test/java/net/minecraftforge/debug/item/ShieldTest.java index 7e644cf49..c0662475f 100644 --- a/src/test/java/net/minecraftforge/debug/item/ShieldTest.java +++ b/src/test/java/net/minecraftforge/debug/item/ShieldTest.java @@ -35,7 +35,7 @@ import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; diff --git a/src/test/java/net/minecraftforge/debug/mod/CapabilityTest.java b/src/test/java/net/minecraftforge/debug/mod/CapabilityTest.java index a335c2e71..d10b8e884 100644 --- a/src/test/java/net/minecraftforge/debug/mod/CapabilityTest.java +++ b/src/test/java/net/minecraftforge/debug/mod/CapabilityTest.java @@ -42,7 +42,7 @@ import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import org.apache.logging.log4j.Logger; diff --git a/src/test/java/net/minecraftforge/debug/mod/ClientLoadingExceptionTest.java b/src/test/java/net/minecraftforge/debug/mod/ClientLoadingExceptionTest.java index 0a5d937a5..125f08a60 100644 --- a/src/test/java/net/minecraftforge/debug/mod/ClientLoadingExceptionTest.java +++ b/src/test/java/net/minecraftforge/debug/mod/ClientLoadingExceptionTest.java @@ -30,8 +30,7 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLLoadCompleteEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.event.FMLServerStartedEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; @Mod(modid = "clientexceptiontest", version = "1.0", name = "Client Exception Test", clientSideOnly = true) public class ClientLoadingExceptionTest diff --git a/src/test/java/net/minecraftforge/debug/mod/ConfigAnnotationTest.java b/src/test/java/net/minecraftforge/debug/mod/ConfigAnnotationTest.java index 70b553c5c..6c4f6ceba 100644 --- a/src/test/java/net/minecraftforge/debug/mod/ConfigAnnotationTest.java +++ b/src/test/java/net/minecraftforge/debug/mod/ConfigAnnotationTest.java @@ -34,7 +34,7 @@ import net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEve import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import org.apache.logging.log4j.Logger; import java.util.Arrays; diff --git a/src/test/java/net/minecraftforge/debug/mod/ObjectHolderAnnotationTest.java b/src/test/java/net/minecraftforge/debug/mod/ObjectHolderAnnotationTest.java index b26b4801d..2c73d7a67 100644 --- a/src/test/java/net/minecraftforge/debug/mod/ObjectHolderAnnotationTest.java +++ b/src/test/java/net/minecraftforge/debug/mod/ObjectHolderAnnotationTest.java @@ -26,7 +26,7 @@ import net.minecraft.util.SoundEvent; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.registries.IForgeRegistryEntry; import net.minecraftforge.registries.RegistryBuilder; @@ -67,7 +67,7 @@ public class ObjectHolderAnnotationTest @Mod.EventBusSubscriber(modid = MODID) public static class Registration { - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void newRegistry(RegistryEvent.NewRegistry event) { new RegistryBuilder() @@ -77,7 +77,7 @@ public class ObjectHolderAnnotationTest .create(); } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerPotions(RegistryEvent.Register event) { event.getRegistry().register( diff --git a/src/test/java/net/minecraftforge/debug/mod/RegistryOverrideTest.java b/src/test/java/net/minecraftforge/debug/mod/RegistryOverrideTest.java index 80151b2e0..3cb42568a 100644 --- a/src/test/java/net/minecraftforge/debug/mod/RegistryOverrideTest.java +++ b/src/test/java/net/minecraftforge/debug/mod/RegistryOverrideTest.java @@ -34,7 +34,7 @@ import net.minecraft.util.text.TextComponentString; import net.minecraft.world.World; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; @Mod(modid = RegistryOverrideTest.MODID, name = "Registry override test mod", version = "1.0", acceptableRemoteVersions = "*") @Mod.EventBusSubscriber @@ -43,7 +43,7 @@ public class RegistryOverrideTest public static final String MODID = "registry_override_test"; static final boolean ENABLED = false; - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerBlocks(RegistryEvent.Register event) { if (ENABLED) diff --git a/src/test/java/net/minecraftforge/debug/network/BigNetworkMessageTest.java b/src/test/java/net/minecraftforge/debug/network/BigNetworkMessageTest.java index 34d764c49..3b2f053e4 100644 --- a/src/test/java/net/minecraftforge/debug/network/BigNetworkMessageTest.java +++ b/src/test/java/net/minecraftforge/debug/network/BigNetworkMessageTest.java @@ -23,7 +23,7 @@ import io.netty.buffer.ByteBuf; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.PlayerEvent; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; diff --git a/src/test/java/net/minecraftforge/debug/util/ModNameTooltip.java b/src/test/java/net/minecraftforge/debug/util/ModNameTooltip.java index b364d9682..90a1477c8 100644 --- a/src/test/java/net/minecraftforge/debug/util/ModNameTooltip.java +++ b/src/test/java/net/minecraftforge/debug/util/ModNameTooltip.java @@ -29,15 +29,15 @@ import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.ModContainer; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.EventPriority; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; @Mod(modid = "forgemodnametooltip", name = "ForgeModNameTooltip", version = "1.0", clientSideOnly = true) @Mod.EventBusSubscriber(Side.CLIENT) public class ModNameTooltip { - @SubscribeEvent(priority = EventPriority.LOW) + @net.minecraftforge.eventbus.api.SubscribeEvent(priority = net.minecraftforge.eventbus.api.EventPriority.LOW) public static void onToolTip(ItemTooltipEvent event) { ItemStack itemStack = event.getItemStack(); diff --git a/src/test/java/net/minecraftforge/debug/util/RotatingWrench.java b/src/test/java/net/minecraftforge/debug/util/RotatingWrench.java index 012fe0ed3..82112dbf0 100644 --- a/src/test/java/net/minecraftforge/debug/util/RotatingWrench.java +++ b/src/test/java/net/minecraftforge/debug/util/RotatingWrench.java @@ -37,7 +37,7 @@ import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; @Mod(modid = RotatingWrench.modID, name = "Wrench Rotate Debug", version = "0.0.0", acceptableRemoteVersions = "*") @@ -52,7 +52,7 @@ public class RotatingWrench @Mod.EventBusSubscriber(modid = modID) public static class Registration { - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerItems(RegistryEvent.Register event) { event.getRegistry().register(new TestWrench().setRegistryName(testWrenchName)); diff --git a/src/test/java/net/minecraftforge/debug/util/TextureDumper.java b/src/test/java/net/minecraftforge/debug/util/TextureDumper.java index 8bec30c4e..9812bf8ec 100644 --- a/src/test/java/net/minecraftforge/debug/util/TextureDumper.java +++ b/src/test/java/net/minecraftforge/debug/util/TextureDumper.java @@ -24,7 +24,7 @@ import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import org.apache.logging.log4j.Logger; import org.lwjgl.BufferUtils; import org.lwjgl.opengl.GL11; diff --git a/src/test/java/net/minecraftforge/debug/world/ChunkCapabilityTest.java b/src/test/java/net/minecraftforge/debug/world/ChunkCapabilityTest.java index 7ac36d6d1..5386177a3 100644 --- a/src/test/java/net/minecraftforge/debug/world/ChunkCapabilityTest.java +++ b/src/test/java/net/minecraftforge/debug/world/ChunkCapabilityTest.java @@ -38,7 +38,7 @@ import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -148,13 +148,13 @@ public class ChunkCapabilityTest public static class EventBusHandler { - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public void onAttachChunkCapabilities(AttachCapabilitiesEvent event) { event.addCapability(new ResourceLocation(MODID, "pollution"), new PollutionProvider(event.getObject())); } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public void onUseItem(PlayerInteractEvent.RightClickBlock event) { if (!event.getWorld().isRemote) { diff --git a/src/test/java/net/minecraftforge/debug/world/DecorateEventDebug.java b/src/test/java/net/minecraftforge/debug/world/DecorateEventDebug.java index acea89ff1..e5d03915f 100644 --- a/src/test/java/net/minecraftforge/debug/world/DecorateEventDebug.java +++ b/src/test/java/net/minecraftforge/debug/world/DecorateEventDebug.java @@ -24,8 +24,8 @@ import net.minecraftforge.event.terraingen.DecorateBiomeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.Event.Result; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.Event.Result; +import net.minecraftforge.eventbus.api.SubscribeEvent; @Mod(modid = DecorateEventDebug.MODID, name = DecorateEventDebug.NAME, version = DecorateEventDebug.VERSION, acceptableRemoteVersions = "*") public class DecorateEventDebug @@ -45,7 +45,7 @@ public class DecorateEventDebug } } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public void decorateEvent(DecorateBiomeEvent.Decorate event) { event.setResult(Result.DENY); diff --git a/src/test/java/net/minecraftforge/debug/world/TileEntityLoadingTest.java b/src/test/java/net/minecraftforge/debug/world/TileEntityLoadingTest.java index d46db178c..6ab7661a7 100644 --- a/src/test/java/net/minecraftforge/debug/world/TileEntityLoadingTest.java +++ b/src/test/java/net/minecraftforge/debug/world/TileEntityLoadingTest.java @@ -34,7 +34,7 @@ import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; import net.minecraftforge.fml.relauncher.Side; @@ -58,7 +58,7 @@ public class TileEntityLoadingTest @Mod.EventBusSubscriber(modid = MODID) public static class Registration { - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerBlocks(RegistryEvent.Register event) { if (!ENABLED) return; @@ -66,7 +66,7 @@ public class TileEntityLoadingTest GameRegistry.registerTileEntity(TestTE.class, (new ResourceLocation(MODID, TestBlock.NAME)).toString()); } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerItems(RegistryEvent.Register event) { if (!ENABLED) return; @@ -77,7 +77,7 @@ public class TileEntityLoadingTest @Mod.EventBusSubscriber(value = Side.CLIENT, modid = MODID) public static class ClientEventHandler { - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public static void registerModels(ModelRegistryEvent event) { if (!ENABLED) return; diff --git a/src/test/java/net/minecraftforge/debug/world/WorldCapabilityTest.java b/src/test/java/net/minecraftforge/debug/world/WorldCapabilityTest.java index 5480af6fb..cc097454a 100644 --- a/src/test/java/net/minecraftforge/debug/world/WorldCapabilityTest.java +++ b/src/test/java/net/minecraftforge/debug/world/WorldCapabilityTest.java @@ -34,7 +34,7 @@ import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import javax.annotation.Nonnull; diff --git a/src/test/java/net/minecraftforge/fml/test/ForgeNetworkTestMod.java b/src/test/java/net/minecraftforge/fml/test/ForgeNetworkTestMod.java index 0b680c05a..a773f5757 100644 --- a/src/test/java/net/minecraftforge/fml/test/ForgeNetworkTestMod.java +++ b/src/test/java/net/minecraftforge/fml/test/ForgeNetworkTestMod.java @@ -27,7 +27,7 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent; import net.minecraftforge.fml.common.network.FMLEventChannel; import net.minecraftforge.fml.common.network.FMLNetworkEvent; @@ -67,7 +67,7 @@ public class ForgeNetworkTestMod } } - @SubscribeEvent + @net.minecraftforge.eventbus.api.SubscribeEvent public void onPlayerLogin(PlayerLoggedInEvent e) { if (channel == null) diff --git a/src/test/java/net/minecraftforge/fml/test/ModsTomlTest.java b/src/test/java/net/minecraftforge/fml/test/ModsTomlTest.java index 94e99790e..ae6436e1e 100644 --- a/src/test/java/net/minecraftforge/fml/test/ModsTomlTest.java +++ b/src/test/java/net/minecraftforge/fml/test/ModsTomlTest.java @@ -1,18 +1,16 @@ package net.minecraftforge.fml.test; -import net.minecraftforge.fml.loading.moddiscovery.ModFile; +import net.minecraftforge.fml.loading.moddiscovery.IModFileInfo; import net.minecraftforge.fml.loading.moddiscovery.ModFileParser; import org.junit.Test; import java.io.IOException; -import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.nio.file.FileSystem; import java.nio.file.FileSystems; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.jar.JarFile; public class ModsTomlTest { @@ -21,7 +19,7 @@ public class ModsTomlTest { final URL resource = getClass().getClassLoader().getResource("mods.toml"); final Path path = Paths.get(resource.toURI()); - final ModFile.ModFileInfo modFileInfo = ModFileParser.loadModFile(null, path); + final IModFileInfo modFileInfo = ModFileParser.loadModFile(null, path); modFileInfo.getMods(); } diff --git a/src/test/java/net/minecraftforge/fml/test/SpecialSpawnEventTest.java b/src/test/java/net/minecraftforge/fml/test/SpecialSpawnEventTest.java index 6a27ba3ee..383608abb 100644 --- a/src/test/java/net/minecraftforge/fml/test/SpecialSpawnEventTest.java +++ b/src/test/java/net/minecraftforge/fml/test/SpecialSpawnEventTest.java @@ -28,7 +28,7 @@ import net.minecraftforge.event.entity.living.LivingSpawnEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; @Mod(modid = SpecialSpawnEventTest.MOD_ID, version = "1.0", acceptableRemoteVersions="*") public class SpecialSpawnEventTest { diff --git a/src/test/resources/META-INF/mods.toml b/src/test/resources/META-INF/mods.toml new file mode 100644 index 000000000..11d1f6da9 --- /dev/null +++ b/src/test/resources/META-INF/mods.toml @@ -0,0 +1,71 @@ +# The name of the mod loader type to load +modLoader="javafml" +# A version range to match for said mod loader +loaderVersion="[2.0,)" +# A URL to query for updates +updateJSONURL="http://myurl.me/" +# A URL to refer people to when problems occur with this mod +issueTrackerURL="http://my.issue.tracker/" +# Extra mod loader property +randomScalaProperty="fishy" +# Arbitrary key-value property pairs available to mods +[properties] +key="value" + +# A list of mods - how many allowed here is determined by the individual mod loader +[[mods]] + # The modid of the mod + modId="inventorysorter" + # The version number of the mod + version="1.1" + # A display name for the mod + displayName="Inventory Sorter" + # The description text for the mod (multi line!) + description=''' + This is my mod, there may be + others, but this one is mine + ''' + # A random extra property for a mod loader + randomExtraProperty="somevalue" + # Arbitrary key-value pairs + [modproperties.inventorysorter] + key="value" + # A list of dependencies + [[dependencies.inventorysorter]] + # the modid of the dependency + modId="forge" + # Does this dependency have to exist - if not, ordering below must be specified + mandatory=true + # The version range of the dependency + versionRange="[14.23.2.0,)" + # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory + ordering="NONE" + # Side this dependency is applied on - BOTH, CLIENT or SERVER + side="BOTH" + # Here's another dependency + [[dependencies.inventorysorter]] + modId="minecraft" + mandatory=true + versionRange="[1.12.2]" + ordering="NONE" + side="BOTH" +# Here's another mod in this jar +[[mods]] + # Note that other mod types may want to add additional key-value pairs in here + modId="inventorysortertoo" + # ${jarVersion} will read the Implementation-Version of the jar file + version="${jarVersion}" + displayName="Inventory Sorter as well" + description=''' + This is also my mod, there may be + others, but this one is mine + ''' + [[dependencies.inventorysortertoo]] + modId="minecraft" + mandatory=true + versionRange="[1.12.2]" + ordering="NONE" + side="BOTH" +[[mods]] + # A minimal mod + modId="minimalmod" diff --git a/src/test/resources/mod.jar b/src/test/resources/mod.jar new file mode 100644 index 000000000..52feb2af7 Binary files /dev/null and b/src/test/resources/mod.jar differ