Skip to content
This repository has been archived by the owner on Sep 7, 2024. It is now read-only.

Commit

Permalink
解决空指针问题
Browse files Browse the repository at this point in the history
  • Loading branch information
wohaopa committed Feb 7, 2023
1 parent e0778e6 commit 04f3810
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 134 deletions.
26 changes: 13 additions & 13 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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";
Expand All @@ -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
Expand Down
51 changes: 51 additions & 0 deletions src/main/java/com/github/wohaopa/replaymodfixmod/MixinPlugin.java
Original file line number Diff line number Diff line change
@@ -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<String> myTargets, Set<String> otherTargets) {

}

@Override
public List<String> getMixins() {
List<String> 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) {

}
}
Original file line number Diff line number Diff line change
@@ -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;

}
Original file line number Diff line number Diff line change
@@ -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!");
}
}
8 changes: 0 additions & 8 deletions src/main/java/com/myname/mymodid/ClientProxy.java

This file was deleted.

27 changes: 0 additions & 27 deletions src/main/java/com/myname/mymodid/CommonProxy.java

This file was deleted.

20 changes: 0 additions & 20 deletions src/main/java/com/myname/mymodid/Config.java

This file was deleted.

45 changes: 0 additions & 45 deletions src/main/java/com/myname/mymodid/MyMod.java

This file was deleted.

1 change: 1 addition & 0 deletions src/main/resources/META-INF/replaymodfixmod_at.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public net.minecraft.client.network.NetHandlerPlayClient field_147299_f #gameController
21 changes: 0 additions & 21 deletions src/main/resources/mcmod.info

This file was deleted.

0 comments on commit 04f3810

Please sign in to comment.