diff --git a/gradle.properties b/gradle.properties index 4c8864c..06fa89b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,9 @@ -modName = MyMod +modName = ReplayModFixMod # This is a case-sensitive string to identify your mod. Convention is to use lower case. -modId = mymodid +modId = replaymodfixmod -modGroup = com.myname.mymodid +modGroup = com.github.wohaopa.replaymodfixmod # WHY is there no version field? # The build script relies on git to provide a version via tags. It is super easy and will enable you to always know the @@ -37,11 +37,11 @@ enableModernJavaSyntax = true enableGenericInjection = false # Generate a class with String fields for the mod id, name, version and group name named with the fields below -generateGradleTokenClass = com.myname.mymodid.Tags -gradleTokenModId = MODID -gradleTokenModName = MODNAME -gradleTokenVersion = VERSION -gradleTokenGroupName = GROUPNAME +generateGradleTokenClass = +gradleTokenModId = +gradleTokenModName = +gradleTokenVersion = +gradleTokenGroupName = # [DEPRECATED] # Multiple source files can be defined here by providing a comma-seperated list: Class1.java,Class2.java,Class3.java # public static final String VERSION = "GRADLETOKEN_VERSION"; @@ -57,23 +57,23 @@ apiPackage = # Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/ # Example value: mymodid_at.cfg -accessTransformersFile = +accessTransformersFile = replaymodfixmod_at.cfg # Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled! -usesMixins = false +usesMixins = true # Adds some debug arguments like verbose output and export usesMixinDebug = false # Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise. -mixinPlugin = +mixinPlugin = MixinPlugin # Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail! -mixinsPackage = +mixinsPackage = mixins # Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin! # This parameter is for legacy compatibility only # Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin coreModClass = # If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class # that is annotated with @Mod) you want this to be true. When in doubt: leave it on false! -containsMixinsAndOrCoreModOnly = false +containsMixinsAndOrCoreModOnly = true # Enables Mixins even if this mod doesn't use them, useful if one of the dependencies uses mixins. forceEnableMixins = false diff --git a/src/main/java/com/github/wohaopa/replaymodfixmod/MixinPlugin.java b/src/main/java/com/github/wohaopa/replaymodfixmod/MixinPlugin.java new file mode 100644 index 0000000..083ee05 --- /dev/null +++ b/src/main/java/com/github/wohaopa/replaymodfixmod/MixinPlugin.java @@ -0,0 +1,51 @@ +package com.github.wohaopa.replaymodfixmod; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; +import org.spongepowered.libraries.org.objectweb.asm.tree.ClassNode; + +import cpw.mods.fml.relauncher.FMLLaunchHandler; + +public class MixinPlugin implements IMixinConfigPlugin { + + @Override + public void onLoad(String mixinPackage) { + + } + + @Override + public String getRefMapperConfig() { + return null; + } + + @Override + public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { + return false; + } + + @Override + public void acceptTargets(Set myTargets, Set otherTargets) { + + } + + @Override + public List getMixins() { + List mixins = new ArrayList<>(); + if (FMLLaunchHandler.side().isClient()) mixins.add("NetHandlerPlayClientMixin"); + return mixins; + } + + @Override + public void preApply(String s, ClassNode classNode, String s1, IMixinInfo iMixinInfo) { + + } + + @Override + public void postApply(String s, ClassNode classNode, String s1, IMixinInfo iMixinInfo) { + + } +} diff --git a/src/main/java/com/github/wohaopa/replaymodfixmod/ReplayModFixMod.java b/src/main/java/com/github/wohaopa/replaymodfixmod/ReplayModFixMod.java new file mode 100644 index 0000000..574688d --- /dev/null +++ b/src/main/java/com/github/wohaopa/replaymodfixmod/ReplayModFixMod.java @@ -0,0 +1,23 @@ +package com.github.wohaopa.replaymodfixmod; + +import java.util.logging.LogManager; +import java.util.logging.Logger; + +import cpw.mods.fml.common.Mod; + +@Mod( + modid = ReplayModFixMod.MODID, + name = ReplayModFixMod.NAME, + version = ReplayModFixMod.VERSION, + dependencies = "required-after:spongemixins;") +public class ReplayModFixMod { + + public static final Logger LOG = LogManager.getLogManager().getLogger("ReplayModFixMod"); + + public static final String MODID = "replaymodfixmod"; + public static final String NAME = "ReplayMod Fix Mod"; + public static final String VERSION = "1.0.1"; + @Mod.Instance(MODID) + public static ReplayModFixMod instance; + +} diff --git a/src/main/java/com/github/wohaopa/replaymodfixmod/mixins/NetHandlerPlayClientMixin.java b/src/main/java/com/github/wohaopa/replaymodfixmod/mixins/NetHandlerPlayClientMixin.java new file mode 100644 index 0000000..f645686 --- /dev/null +++ b/src/main/java/com/github/wohaopa/replaymodfixmod/mixins/NetHandlerPlayClientMixin.java @@ -0,0 +1,23 @@ +package com.github.wohaopa.replaymodfixmod.mixins; + +import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.network.play.server.S0CPacketSpawnPlayer; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(NetHandlerPlayClient.class) +public abstract class NetHandlerPlayClientMixin { + + @Inject(method = "handleSpawnPlayer", at = @At("HEAD"), cancellable = true) + public void inject(S0CPacketSpawnPlayer p_147237_1_, CallbackInfo ci) { + if (((NetHandlerPlayClient) (Object) this).gameController.theWorld == null + || p_147237_1_.func_148948_e() == null) { + ci.cancel(); + System.out.println("Wrong packet: " + p_147237_1_); + } + System.out.println("ReplayModFixMod injected!"); + } +} diff --git a/src/main/java/com/myname/mymodid/ClientProxy.java b/src/main/java/com/myname/mymodid/ClientProxy.java deleted file mode 100644 index 45a04dd..0000000 --- a/src/main/java/com/myname/mymodid/ClientProxy.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.myname.mymodid; - -public class ClientProxy extends CommonProxy { - - // Override CommonProxy methods here, if you want a different behaviour on the client (e.g. registering renders). - // Don't forget to call the super methods aswell. - -} diff --git a/src/main/java/com/myname/mymodid/CommonProxy.java b/src/main/java/com/myname/mymodid/CommonProxy.java deleted file mode 100644 index d5df802..0000000 --- a/src/main/java/com/myname/mymodid/CommonProxy.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.myname.mymodid; - -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.event.FMLServerStartingEvent; - -public class CommonProxy { - - // preInit "Run before anything else. Read your config, create blocks, items, etc, and register them with the - // GameRegistry." (Remove if not needed) - public void preInit(FMLPreInitializationEvent event) { - Config.synchronizeConfiguration(event.getSuggestedConfigurationFile()); - - MyMod.LOG.info(Config.greeting); - MyMod.LOG.info("I am " + Tags.MODNAME + " at version " + Tags.VERSION); - } - - // load "Do your mod setup. Build whatever data structures you care about. Register recipes." (Remove if not needed) - public void init(FMLInitializationEvent event) {} - - // postInit "Handle interaction with other mods, complete your setup based on this." (Remove if not needed) - public void postInit(FMLPostInitializationEvent event) {} - - // register server commands in this event handler (Remove if not needed) - public void serverStarting(FMLServerStartingEvent event) {} -} diff --git a/src/main/java/com/myname/mymodid/Config.java b/src/main/java/com/myname/mymodid/Config.java deleted file mode 100644 index b1c4f50..0000000 --- a/src/main/java/com/myname/mymodid/Config.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.myname.mymodid; - -import java.io.File; - -import net.minecraftforge.common.config.Configuration; - -public class Config { - - public static String greeting = "Hello World"; - - public static void synchronizeConfiguration(File configFile) { - Configuration configuration = new Configuration(configFile); - - greeting = configuration.getString("greeting", Configuration.CATEGORY_GENERAL, greeting, "How shall I greet?"); - - if (configuration.hasChanged()) { - configuration.save(); - } - } -} diff --git a/src/main/java/com/myname/mymodid/MyMod.java b/src/main/java/com/myname/mymodid/MyMod.java deleted file mode 100644 index 316b563..0000000 --- a/src/main/java/com/myname/mymodid/MyMod.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.myname.mymodid; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.SidedProxy; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.event.FMLServerStartingEvent; - -@Mod(modid = Tags.MODID, version = Tags.VERSION, name = Tags.MODNAME, acceptedMinecraftVersions = "[1.7.10]") -public class MyMod { - - public static final Logger LOG = LogManager.getLogger(Tags.MODID); - - @SidedProxy(clientSide = "com.myname.mymodid.ClientProxy", serverSide = "com.myname.mymodid.CommonProxy") - public static CommonProxy proxy; - - @Mod.EventHandler - // preInit "Run before anything else. Read your config, create blocks, items, etc, and register them with the - // GameRegistry." (Remove if not needed) - public void preInit(FMLPreInitializationEvent event) { - proxy.preInit(event); - } - - @Mod.EventHandler - // load "Do your mod setup. Build whatever data structures you care about. Register recipes." (Remove if not needed) - public void init(FMLInitializationEvent event) { - proxy.init(event); - } - - @Mod.EventHandler - // postInit "Handle interaction with other mods, complete your setup based on this." (Remove if not needed) - public void postInit(FMLPostInitializationEvent event) { - proxy.postInit(event); - } - - @Mod.EventHandler - // register server commands in this event handler (Remove if not needed) - public void serverStarting(FMLServerStartingEvent event) { - proxy.serverStarting(event); - } -} diff --git a/src/main/resources/META-INF/replaymodfixmod_at.cfg b/src/main/resources/META-INF/replaymodfixmod_at.cfg new file mode 100644 index 0000000..8f08d84 --- /dev/null +++ b/src/main/resources/META-INF/replaymodfixmod_at.cfg @@ -0,0 +1 @@ +public net.minecraft.client.network.NetHandlerPlayClient field_147299_f #gameController diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info deleted file mode 100644 index e61cddf..0000000 --- a/src/main/resources/mcmod.info +++ /dev/null @@ -1,21 +0,0 @@ -{ - "modListVersion": 2, - "modList": [{ - "modid": "${modId}", - "name": "${modName}", - "description": "An example mod for Minecraft 1.7.10 with Forge focused on a stable setup.", - "version": "${modVersion}", - "mcversion": "${minecraftVersion}", - "url": "https://github.com/SinTh0r4s/MyMod", - "updateUrl": "", - "authorList": ["SinTho0r4s"], - "credits": "", - "logoFile": "", - "screenshots": [], - "parent": "", - "requiredMods": [], - "dependencies": [], - "dependants": [], - "useDependencyInformation": true - }] -}