diff --git a/dependencies.gradle b/dependencies.gradle index f053e7c..05c6e57 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -36,4 +36,5 @@ dependencies { api(project.files("libs/mystcraft-dev.jar")) api("com.github.GTNewHorizons:GTNHLib:0.2.3:dev") + implementation("com.github.GTNewHorizons:TinkersConstruct:1.11.11-GTNH:dev") } diff --git a/src/main/java/de/pilz/mystcraftextras/MystcraftExtrasLateMixins.java b/src/main/java/de/pilz/mystcraftextras/MystcraftExtrasLateMixins.java new file mode 100644 index 0000000..87db3c6 --- /dev/null +++ b/src/main/java/de/pilz/mystcraftextras/MystcraftExtrasLateMixins.java @@ -0,0 +1,34 @@ +package de.pilz.mystcraftextras; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import com.gtnewhorizon.gtnhmixins.ILateMixinLoader; +import com.gtnewhorizon.gtnhmixins.LateMixin; + +@LateMixin +public class MystcraftExtrasLateMixins implements ILateMixinLoader { + + @Override + public String getMixinConfig() { + return "mixins.mystcraftextras.late.json"; + } + + @Override + public List getMixins(Set loadedMods) { + List list = new ArrayList(); + + // Mystcraft + if (loadedMods.contains("Mystcraft")) { + list.add("MixinLinkingAPIDelegate"); + } + + // Tinkers Construct + if (loadedMods.contains("TConstruct")) { + list.add("MixinToolStationLogic"); + } + + return list; + } +} diff --git a/src/main/java/de/pilz/mystcraftextras/compat/tc/RenameOnTinkerTable.java b/src/main/java/de/pilz/mystcraftextras/compat/tc/RenameOnTinkerTable.java new file mode 100644 index 0000000..67779e1 --- /dev/null +++ b/src/main/java/de/pilz/mystcraftextras/compat/tc/RenameOnTinkerTable.java @@ -0,0 +1,8 @@ +package de.pilz.mystcraftextras.compat.tc; + +public class RenameOnTinkerTable { + + public RenameOnTinkerTable(){ + + } +} diff --git a/src/main/java/de/pilz/mystcraftextras/configuration/BlocksAndItemsConfig.java b/src/main/java/de/pilz/mystcraftextras/configuration/BlocksAndItemsConfig.java index 548f453..2c58879 100644 --- a/src/main/java/de/pilz/mystcraftextras/configuration/BlocksAndItemsConfig.java +++ b/src/main/java/de/pilz/mystcraftextras/configuration/BlocksAndItemsConfig.java @@ -1,10 +1,17 @@ package de.pilz.mystcraftextras.configuration; import com.gtnewhorizon.gtnhlib.config.Config; +import com.gtnewhorizon.gtnhlib.config.Config.Comment; +import com.gtnewhorizon.gtnhlib.config.Config.DefaultBoolean; +import com.gtnewhorizon.gtnhlib.config.Config.RequiresMcRestart; import de.pilz.mystcraftextras.MystcraftExtras; @Config(modid = MystcraftExtras.MODID, category = "blocksAndItems") public class BlocksAndItemsConfig { + @Comment("Enables some different textured variants of book stands.") + @DefaultBoolean(true) + @RequiresMcRestart + public static boolean enableAdditionalBookStands; } diff --git a/src/main/java/de/pilz/mystcraftextras/configuration/TweaksConfig.java b/src/main/java/de/pilz/mystcraftextras/configuration/TweaksConfig.java index 7355430..4c95645 100644 --- a/src/main/java/de/pilz/mystcraftextras/configuration/TweaksConfig.java +++ b/src/main/java/de/pilz/mystcraftextras/configuration/TweaksConfig.java @@ -3,6 +3,7 @@ import com.gtnewhorizon.gtnhlib.config.Config; import com.gtnewhorizon.gtnhlib.config.Config.Comment; import com.gtnewhorizon.gtnhlib.config.Config.DefaultBoolean; +import com.gtnewhorizon.gtnhlib.config.Config.RequiresMcRestart; import de.pilz.mystcraftextras.MystcraftExtras; @@ -12,4 +13,9 @@ public class TweaksConfig { @Comment("Enables Intra Linking on newly created linking books by default.") @DefaultBoolean(true) public static boolean enableIntraLinkingByDefault; + + @Comment("Enables the ability to rename Linking Books on a Tool Station from Tinkers Construct.") + @DefaultBoolean(true) + @RequiresMcRestart + public static boolean enableRenameOnTinkerToolStation; } diff --git a/src/main/java/de/pilz/mystcraftextras/mixins/MixinToolStationLogic.java b/src/main/java/de/pilz/mystcraftextras/mixins/MixinToolStationLogic.java new file mode 100644 index 0000000..8d7b2de --- /dev/null +++ b/src/main/java/de/pilz/mystcraftextras/mixins/MixinToolStationLogic.java @@ -0,0 +1,41 @@ +package de.pilz.mystcraftextras.mixins; + +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.CallbackInfoReturnable; + +import com.xcompwiz.mystcraft.item.ItemLinkbook; +import com.xcompwiz.mystcraft.linking.LinkOptions; + +import mantle.blocks.abstracts.InventoryLogic; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import tconstruct.tools.logic.ToolStationLogic; + +@Mixin(ToolStationLogic.class) +public abstract class MixinToolStationLogic extends InventoryLogic { + + public MixinToolStationLogic(int invSize) { + super(invSize); + } + + @Inject(method = "canRename(Lnet/minecraft/nbt/NBTTagCompound;Lnet/minecraft/item/ItemStack;)Z", at = @At("RETURN"), cancellable = true, remap = false) + private static void canRename$mystcraftextras$canRenameLinkingBook(NBTTagCompound tags, ItemStack tool, CallbackInfoReturnable callback) { + if (tool != null && tool.getItem() instanceof ItemLinkbook) { + callback.setReturnValue(true); + } + } + + @Inject(method = "tryRenameTool(Lnet/minecraft/item/ItemStack;Ljava/lang/String;)Lnet/minecraft/item/ItemStack;", at = @At("HEAD"), cancellable = true, remap = false) + protected void tryRenameTool$mystcraftextras$renameLinkingBook(ItemStack output, String name, CallbackInfoReturnable callback) { + var temp = output != null ? output : this.inventory[1].copy(); + + if (temp != null && temp.getItem() instanceof ItemLinkbook && name != null && !name.equals("")) { + LinkOptions.setDisplayName(temp.stackTagCompound, name); + output = temp; + callback.setReturnValue(output); + callback.cancel(); + } + } +} diff --git a/src/main/resources/mixins.mystcraftextras.json b/src/main/resources/mixins.mystcraftextras.json index 259c42d..c6d9151 100644 --- a/src/main/resources/mixins.mystcraftextras.json +++ b/src/main/resources/mixins.mystcraftextras.json @@ -5,9 +5,7 @@ "refmap": "mixins.mystcraftextras.refmap.json", "target": "@env(DEFAULT)", "compatibilityLevel": "JAVA_8", - "mixins": [ - "MixinLinkingAPIDelegate" - ], + "mixins": [], "client": [], "server": [] } diff --git a/src/main/resources/mixins.mystcraftextras.late.json b/src/main/resources/mixins.mystcraftextras.late.json new file mode 100644 index 0000000..3513018 --- /dev/null +++ b/src/main/resources/mixins.mystcraftextras.late.json @@ -0,0 +1,14 @@ +{ + "required": true, + "minVersion": "0.8.5-GTNH", + "package": "de.pilz.mystcraftextras.mixins", + "refmap": "mixins.mystcraftextras.refmap.json", + "target": "@env(DEFAULT)", + "compatibilityLevel": "JAVA_8", + "mixins": [ + "MixinLinkingAPIDelegate", + "MixinToolStationLogic" + ], + "client": [], + "server": [] +}