Issue with coremode


#1
[06:47:04] [main/INFO] [mixin]: Instancing error handler class org.spongepowered.mod.mixin.handler.MixinErrorHandler
[06:47:04] [main/INFO] [Sponge]: /********************************************************************************************************/
[06:47:04] [main/INFO] [Sponge]: /*                                                                                                      */
[06:47:04] [main/INFO] [Sponge]: /* Oh dear. It seems like this version of Sponge is not compatible with the version                     */
[06:47:04] [main/INFO] [Sponge]: /* of Forge you are running.                                                                            */
[06:47:04] [main/INFO] [Sponge]: /*                                                                                                      */
[06:47:04] [main/INFO] [Sponge]: /*------------------------------------------------------------------------------------------------------*/
[06:47:04] [main/INFO] [Sponge]: /*                                                                                                      */
[06:47:04] [main/INFO] [Sponge]: /* A errpr was encountered whilst patching:                                                             */
[06:47:04] [main/INFO] [Sponge]: /*                                                                                                      */
[06:47:04] [main/INFO] [Sponge]: /*   One or more Sponge patches could not be applied whilst loading Sponge, this is                     */
[06:47:04] [main/INFO] [Sponge]: /*   a permanent error and you must either:                                                             */
[06:47:04] [main/INFO] [Sponge]: /*                                                                                                      */
[06:47:04] [main/INFO] [Sponge]: /*    * Use the correct build of Forge for this version of Sponge (12.18.3.2477)                        */
[06:47:04] [main/INFO] [Sponge]: /*                                                                                                      */
[06:47:04] [main/INFO] [Sponge]: /*    * Use a version of Sponge for built for your version of Forge                                     */
[06:47:04] [main/INFO] [Sponge]: /*                                                                                                      */
[06:47:04] [main/INFO] [Sponge]: /*   The patch which failed requires Forge build: 12.18.3.2477                                          */
[06:47:04] [main/INFO] [Sponge]: /*   but you are running build:                   12.18.3.2511                                          */
[06:47:04] [main/INFO] [Sponge]: /*                                                                                                      */
[06:47:04] [main/INFO] [Sponge]: /*------------------------------------------------------------------------------------------------------*/
[06:47:04] [main/INFO] [Sponge]: /*                                                                                                      */
[06:47:04] [main/INFO] [Sponge]: /* Technical details:                                                                                   */
[06:47:04] [main/INFO] [Sponge]: /*                                                                                                      */
[06:47:04] [main/INFO] [Sponge]: /*      Failed on class : net.minecraft.entity.player.EntityPlayer                                      */
[06:47:04] [main/INFO] [Sponge]: /*         During phase : DEFAULT                                                                       */
[06:47:04] [main/INFO] [Sponge]: /*                Mixin : entity.player.MixinEntityPlayer                                               */
[06:47:04] [main/INFO] [Sponge]: /*               Config : mixins.common.core.json                                                       */
[06:47:04] [main/INFO] [Sponge]: /*           Error Type : org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException      */
[06:47:04] [main/INFO] [Sponge]: /*            Caused by : java.lang.NullPointerException                                                */
[06:47:04] [main/INFO] [Sponge]: /*              Message : Unexpecteded NullPointerException whilst applying the mixin class: null       */
[06:47:04] [main/INFO] [Sponge]: /*                                                                                                      */
[06:47:04] [main/INFO] [Sponge]: /********************************************************************************************************/

My coremod modify net.minecraft.itemsword to remove cooldown from sword

public class ModClassTransformer implements IClassTransformer
{
@Override 
public byte[] transform(String name, String transformedName, byte[] basicClass) {
		 
		if (name.equals("afg") || name.equals("net.minecraft.item.ItemSword")) {
			return patchItemSword(name, basicClass, name.equals("afg"));
		 
		}
		 
		return basicClass;
		 
		}
private byte[] patchItemSword(String name, byte[] basicClass, boolean obf) {
	 
	String targetMethodName = obf ? "a" : "getItemAttributeModifiers";

	ClassNode classNode = new ClassNode();
	ClassReader classReader = new ClassReader(basicClass);
	classReader.accept(classNode, ClassReader.EXPAND_FRAMES);
	MethodNode mnode = ASMHelper.findMethod(classNode, targetMethodName, "(Lnet/minecraft/inventory/EntityEquipmentSlot;)Lcom/google/common/collect/Multimap;");
	ListIterator<AbstractInsnNode> iter = mnode.instructions.iterator();
	int i = 0;
	while (iter.hasNext())
	{
		AbstractInsnNode test = iter.next();
		i++;
		if (i > 36 && i < 38)
		{
			LdcInsnNode test2 = (LdcInsnNode) test;
			test2.cst = (double)4;
		}
	}

	

	ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
	classNode.accept(cw);
	return cw.toByteArray();
}
		 
}

#2

Try reading the error. :wink:


#3

yes i see the error is from itemSword class who can’t be load


#4

i need to modify sponge ? with my coremode ?


#5

My bad, didn’t see the top line. Probably because it’s just pasted into the post, without codeblock formatting or a pastebin or anything :wink:
Yeah, you should probably be doing a slightly less hardcoded search than the ‘the bytecode between 36 and 38’ (why isn’t that just i == 37? lol). If your mod runs in a non-Mixin environment, I’d say this is a small enough use-case that you don’t need to use Mixin, but do the same thing you’d do with Mixin - look for a landmark, like a method call or something, and find the first AbstractInsnNode which matches instanceof LdcInsnNode rather than assuming that one at a particular index is the correct one and blindly casting it.


#6

ho bad forge version ?


#7

ok thnaks i understand my mistake i correct it thanks


#8

if have change my code to this

private byte[] patchItemSword(String name, byte[] basicClass, boolean obf) {
	 
	String targetMethodName = obf ? "a" : "getItemAttributeModifiers";

	ClassNode classNode = new ClassNode();
	ClassReader classReader = new ClassReader(basicClass);
	classReader.accept(classNode, ClassReader.EXPAND_FRAMES);
	MethodNode mnode = ASMHelper.findMethod(classNode, targetMethodName, "(Lnet/minecraft/inventory/EntityEquipmentSlot;)Lcom/google/common/collect/Multimap;");
	ListIterator<AbstractInsnNode> iter = mnode.instructions.iterator();
	while (iter.hasNext())
	{
		AbstractInsnNode test = iter.next();
		if (test instanceof LdcInsnNode)
		{
			LdcInsnNode test2 = (LdcInsnNode) test;
			if (test2.cst.equals((double)-2.4000000953674316))
				test2.cst = (double)4;
		}
	}

	

	ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
	classNode.accept(cw);
	return cw.toByteArray();
}

but i get the same error

[07:35:03] [main/WARN] [mixin]: Error loading class: net/minecraft/item/ItemSword
[07:35:03] [main/INFO] [mixin]: Instancing error handler class org.spongepowered.mod.mixin.handler.MixinErrorHandler
[07:35:03] [main/INFO] [Sponge]: /********************************************************************************************************/
[07:35:03] [main/INFO] [Sponge]: /*                                                                                                      */
[07:35:03] [main/INFO] [Sponge]: /* Oh dear. It seems like this version of Sponge is not compatible with the version                     */
[07:35:03] [main/INFO] [Sponge]: /* of Forge you are running.                                                                            */
[07:35:03] [main/INFO] [Sponge]: /*                                                                                                      */
[07:35:03] [main/INFO] [Sponge]: /*------------------------------------------------------------------------------------------------------*/
[07:35:03] [main/INFO] [Sponge]: /*                                                                                                      */
[07:35:03] [main/INFO] [Sponge]: /* A errpr was encountered whilst patching:                                                             */
[07:35:03] [main/INFO] [Sponge]: /*                                                                                                      */
[07:35:03] [main/INFO] [Sponge]: /*   One or more Sponge patches could not be applied whilst loading Sponge, this is                     */
[07:35:03] [main/INFO] [Sponge]: /*   a permanent error and you must either:                                                             */
[07:35:03] [main/INFO] [Sponge]: /*                                                                                                      */
[07:35:03] [main/INFO] [Sponge]: /*    * Use the correct build of Forge for this version of Sponge (12.18.3.2477)                        */
[07:35:03] [main/INFO] [Sponge]: /*                                                                                                      */
[07:35:03] [main/INFO] [Sponge]: /*    * Use a version of Sponge for built for your version of Forge                                     */
[07:35:03] [main/INFO] [Sponge]: /*                                                                                                      */
[07:35:03] [main/INFO] [Sponge]: /*   The patch which failed requires Forge build: 12.18.3.2477                                          */
[07:35:03] [main/INFO] [Sponge]: /*   but you are running build:                   12.18.3.2511                                          */
[07:35:03] [main/INFO] [Sponge]: /*                                                                                                      */
[07:35:03] [main/INFO] [Sponge]: /*------------------------------------------------------------------------------------------------------*/
[07:35:03] [main/INFO] [Sponge]: /*                                                                                                      */
[07:35:03] [main/INFO] [Sponge]: /* Technical details:                                                                                   */
[07:35:03] [main/INFO] [Sponge]: /*                                                                                                      */
[07:35:03] [main/INFO] [Sponge]: /*      Failed on class : net.minecraft.entity.player.EntityPlayer                                      */
[07:35:03] [main/INFO] [Sponge]: /*         During phase : DEFAULT                                                                       */
[07:35:03] [main/INFO] [Sponge]: /*                Mixin : entity.player.MixinEntityPlayer                                               */
[07:35:03] [main/INFO] [Sponge]: /*               Config : mixins.common.core.json                                                       */
[07:35:03] [main/INFO] [Sponge]: /*           Error Type : org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException      */
[07:35:03] [main/INFO] [Sponge]: /*            Caused by : java.lang.NullPointerException                                                */
[07:35:03] [main/INFO] [Sponge]: /*              Message : Unexpecteded NullPointerException whilst applying the mixin class: null       */
[07:35:03] [main/INFO] [Sponge]: /*                                                                                                      */
[07:35:03] [main/INFO] [Sponge]: /********************************************************************************************************/

#9

Hm. Question, what happens when you use the version of Forge it’s telling you to use?
(Also, A errpr? lol)


#10
[02:40:00] [main/WARN] [mixin]: Error loading class: net/minecraft/item/ItemSword
[02:40:00] [main/INFO] [mixin]: Instancing error handler class org.spongepowered.mod.mixin.handler.MixinErrorHandler
[02:40:00] [main/INFO] [Sponge]: /********************************************************************************************************/
[02:40:00] [main/INFO] [Sponge]: /*                                                                                                      */
[02:40:00] [main/INFO] [Sponge]: /* Oh dear. Something went wrong and the server had to shut down!                                       */
[02:40:00] [main/INFO] [Sponge]: /*                                                                                                      */
[02:40:00] [main/INFO] [Sponge]: /*------------------------------------------------------------------------------------------------------*/
[02:40:00] [main/INFO] [Sponge]: /*                                                                                                      */
[02:40:00] [main/INFO] [Sponge]: /* A critical error was encountered while blending Sponge with Forge!                                   */
[02:40:00] [main/INFO] [Sponge]: /*                                                                                                      */
[02:40:00] [main/INFO] [Sponge]: /*   Possible causes are:                                                                               */
[02:40:00] [main/INFO] [Sponge]: /*                                                                                                      */
[02:40:00] [main/INFO] [Sponge]: /*    * An incompatible Forge "core mod" is present. Try removing other mods to                         */
[02:40:00] [main/INFO] [Sponge]: /*      see if the problem goes away.                                                                   */
[02:40:00] [main/INFO] [Sponge]: /*                                                                                                      */
[02:40:00] [main/INFO] [Sponge]: /*    * You are using the wrong version of Minecraft Forge. You must use the                            */
[02:40:00] [main/INFO] [Sponge]: /*      correct version of Forge when running Sponge, this version is for                               */
[02:40:00] [main/INFO] [Sponge]: /*      12.18.3.2477 (you are running 12.18.3.2477)                                                     */
[02:40:00] [main/INFO] [Sponge]: /*                                                                                                      */
[02:40:00] [main/INFO] [Sponge]: /*    * An error exists in Sponge itself. Ensure you are running the latest version                     */
[02:40:00] [main/INFO] [Sponge]: /*      of Sponge.                                                                                      */
[02:40:00] [main/INFO] [Sponge]: /*                                                                                                      */
[02:40:00] [main/INFO] [Sponge]: /*    * Gremlins are invading your computer. Did you feed a Mogwai after midnight?                      */
[02:40:00] [main/INFO] [Sponge]: /*                                                                                                      */
[02:40:00] [main/INFO] [Sponge]: /*------------------------------------------------------------------------------------------------------*/
[02:40:00] [main/INFO] [Sponge]: /*                                                                                                      */
[02:40:00] [main/INFO] [Sponge]: /* Technical details:                                                                                   */
[02:40:00] [main/INFO] [Sponge]: /*                                                                                                      */
[02:40:00] [main/INFO] [Sponge]: /*      Failed on class : net.minecraft.entity.player.EntityPlayer                                      */
[02:40:00] [main/INFO] [Sponge]: /*         During phase : DEFAULT                                                                       */
[02:40:00] [main/INFO] [Sponge]: /*                Mixin : entity.player.MixinEntityPlayer                                               */
[02:40:00] [main/INFO] [Sponge]: /*               Config : mixins.common.core.json                                                       */
[02:40:00] [main/INFO] [Sponge]: /*           Error Type : org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException      */
[02:40:00] [main/INFO] [Sponge]: /*            Caused by : java.lang.NullPointerException                                                */
[02:40:00] [main/INFO] [Sponge]: /*              Message : Unexpecteded NullPointerException whilst applying the mixin class: null       */
[02:40:00] [main/INFO] [Sponge]: /*                                                                                                      */
[02:40:00] [main/INFO] [Sponge]: /********************************************************************************************************/
[02:40:00] [main/INFO] [Sponge]: Attempting to shut down the VM cleanly

same issue :disappointed_relieved:


#11

Ok sorry i’m dump i have’nt read correctly the mapping of forge … i have put this
"(Lnet/minecraft/inventory/EntityEquipmentSlot;)Lcom/google/common/collect/Multimap;“
instead of this
”(Lsb;)Lcom/google/common/collect/Multimap;"
sorry :confused:

(can be close)