Matter Overdrive compat

This commit is contained in:
FalsePattern committed 2024-06-09 18:46:56 +02:00
1 parent 2b90b7688b
commit fa66c21a8a
6 files changed
+105

No files matched your search

@@ -0,0 +1,20 @@
package com.falsepattern.endlessids.mixin.mixins.common.blockitem.matteroverdrive;
import com.falsepattern.endlessids.util.DataUtil;
import matteroverdrive.data.Inventory;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import net.minecraft.nbt.NBTTagCompound;
@Mixin(Inventory.class)
public abstract class InventoryMixin {
@Redirect(method = "readFromNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/nbt/NBTTagCompound;hasKey(Ljava/lang/String;I)Z"),
require = 1)
private boolean fixHasKey(NBTTagCompound instance, String p_150297_1_, int p_150297_2_) {
return DataUtil.nbtHasID(instance);
}
}
@@ -0,0 +1,70 @@
package com.falsepattern.endlessids.mixin.mixins.common.blockitem.matteroverdrive;
import com.falsepattern.endlessids.constants.VanillaConstants;
import io.netty.buffer.ByteBuf;
import matteroverdrive.data.ItemPattern;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.Constants;
@Mixin(value = ItemPattern.class,
remap = false)
public abstract class ItemPatternMixin {
@Shadow private int itemID;
@Shadow private int progress;
@Shadow private int damage;
@Shadow private int count;
@Inject(method = "writeToNBT",
at = @At("RETURN"),
require = 1)
private void writeToNBT$writeInt(NBTTagCompound nbtTagCompound, CallbackInfo ci) {
int id = this.itemID;
if (id > VanillaConstants.maxItemID) {
nbtTagCompound.setShort("id", (short) 0);
}
nbtTagCompound.setInteger("idExt", id);
}
@Inject(method = "readFromNBT",
at = @At("RETURN"),
require = 1)
private void readFromNBT$readInt(NBTTagCompound nbtTagCompound, CallbackInfo ci) {
if (nbtTagCompound.hasKey("idExt", Constants.NBT.TAG_INT))
this.itemID = nbtTagCompound.getInteger("idExt");
}
/**
* @author FalsePattern
* @reason Extend IDs
*/
@Overwrite
public void writeToBuffer(ByteBuf byteBuf) {
byteBuf.writeInt(this.itemID);
byteBuf.writeByte(this.progress);
byteBuf.writeShort(this.damage);
byteBuf.writeByte(this.count);
}
/**
* @author FalsePattern
* @reason Extend IDs
*/
@Overwrite
public void readFromBuffer(ByteBuf byteBuf) {
this.itemID = byteBuf.readInt();
this.progress = byteBuf.readByte();
this.damage = byteBuf.readShort();
this.count = byteBuf.readByte();
}
}
@@ -186,6 +186,10 @@ public enum Mixin implements IMixin {
DragonAPIBlockPropertiesMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem).and(require(TargetedMod.DRAGONAPI)), "blockitem.dragonapi.BlockPropertiesMixin"),
DragonAPIBlockItemIDTypeMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem).and(require(TargetedMod.DRAGONAPI)), "blockitem.dragonapi.IDTypeMixin"),
//endregion DragonAPI
//region Matter Overdrive
MOInventoryMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem).and(require(TargetedMod.MATTEROVERDRIVE)), "blockitem.matteroverdrive.InventoryMixin"),
MOItemPatternMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem).and(require(TargetedMod.MATTEROVERDRIVE)), "blockitem.matteroverdrive.ItemPatternMixin"),
//endregion Matter Overdrive
//region MFQM
MFQMMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem).and(require(TargetedMod.MFQM)), "blockitem.mfqm.MFQMMixin"),
//endregion MFQM
@@ -37,6 +37,7 @@ public enum TargetedMod implements ITargetedMod {
ICG("Immersive Cavegen", false, startsWith("immersivecavegen")),
IR3("Industrial Revolution by Redstone Rebooted", false, startsWith("industrialrevolutionbyredstonerebooted-")),
LOTR("LOTR Mod", false, startsWith("lotrmod")),
MATTEROVERDRIVE("Matter Overdrive", false, startsWith("matteroverdrive-")),
MFQM("More Fun Quicksand Mod", false, startsWith("morefunquicksandmod-")),
NATURESCOMPASS("Nature's Compass", false, startsWith("naturescompass")),
NETHERLICIOUS("Netherlicious", false, startsWith("netherlicious-")),