diff --git a/build.gradle b/build.gradle index 660479e0..703190a0 100644 --- a/build.gradle +++ b/build.gradle @@ -27,10 +27,26 @@ minecraft { mappings = forge_mappings makeObfSourceJar = false - replaceIn "SDUnlimited.java" + replaceIn "GTDrawers.java" replace '${version}', project.version } +repositories { + maven { + url "https://cursemaven.com" + } + maven { + name = "hwyla" + url = "https://github.com/TehNut/temporary-maven-thing/raw/master/maven" + } +} + +dependencies { + deobfCompile "curse.maven:storage-drawers-223852:2952606" + deobfCompile "curse.maven:chameleon-230497:2450900" + deobfCompile "mcp.mobius.waila:Hwyla:${hwyla_version}_${mcversion}" +} + processResources { // this will ensure that this task is redone when the versions change. inputs.property "version", project.version diff --git a/gradle.properties b/gradle.properties index e54be7b9..a69bdf58 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,8 +2,9 @@ # This is required to provide enough memory for the Minecraft decompilation process. org.gradle.jvmargs=-Xmx3G -mod_version=1.0.0 +mod_version=1.0.1 mcversion=1.12.2 forge_version=1.12.2-14.23.5.2832 forge_mappings=stable_39 +hwyla_version=1.8.26-B41 diff --git a/libs/Chameleon-1.12.2-4.1.3-dev.jar b/libs/Chameleon-1.12.2-4.1.3-dev.jar deleted file mode 100644 index cb013e95..00000000 Binary files a/libs/Chameleon-1.12.2-4.1.3-dev.jar and /dev/null differ diff --git a/libs/StorageDrawers-1.12.2-5.3.7-deobf.jar b/libs/StorageDrawers-1.12.2-5.3.7-deobf.jar deleted file mode 100644 index 766da228..00000000 Binary files a/libs/StorageDrawers-1.12.2-5.3.7-deobf.jar and /dev/null differ diff --git a/src/main/java/io/github/nomiceu/integration/IIntegrationPlugin.java b/src/main/java/io/github/nomiceu/integration/IIntegrationPlugin.java new file mode 100644 index 00000000..04d280b9 --- /dev/null +++ b/src/main/java/io/github/nomiceu/integration/IIntegrationPlugin.java @@ -0,0 +1,50 @@ +package io.github.nomiceu.integration; + +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.ModContainer; +import net.minecraftforge.fml.common.versioning.ArtifactVersion; +import net.minecraftforge.fml.common.versioning.DefaultArtifactVersion; +import net.minecraftforge.fml.common.versioning.InvalidVersionSpecificationException; +import net.minecraftforge.fml.common.versioning.VersionRange; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.util.List; + +public interface IIntegrationPlugin { + + void init(); + + default boolean versionCheck() { + String pattern = versionPattern(); + if(pattern == null) + return true; + + List modList = Loader.instance().getModList(); + + for(ModContainer mod : modList) { + if(mod.getModId().equals(getModID())) { + try { + VersionRange validVersions = VersionRange.createFromVersionSpec(pattern); + ArtifactVersion version = new DefaultArtifactVersion(mod.getVersion()); + return validVersions.containsVersion(version); + } catch(InvalidVersionSpecificationException e) { + return false; + } + } + } + + return false; + } + + @Nullable + default String versionPattern() { + return null; + } + + @Nonnull + String getModID(); + + void postInit(); + +} diff --git a/src/main/java/io/github/nomiceu/integration/waila/WailaPlugin.java b/src/main/java/io/github/nomiceu/integration/waila/WailaPlugin.java new file mode 100644 index 00000000..06765c05 --- /dev/null +++ b/src/main/java/io/github/nomiceu/integration/waila/WailaPlugin.java @@ -0,0 +1,65 @@ +package io.github.nomiceu.integration.waila; + +import com.jaquadro.minecraft.storagedrawers.StorageDrawers; +import com.jaquadro.minecraft.storagedrawers.block.BlockDrawers; +import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawers; +import com.jaquadro.minecraft.storagedrawers.integration.Waila; +import io.github.nomiceu.integration.IIntegrationPlugin; +import mcp.mobius.waila.api.IWailaConfigHandler; +import mcp.mobius.waila.api.IWailaDataAccessor; +import mcp.mobius.waila.api.IWailaRegistrar; +import mcp.mobius.waila.api.impl.ConfigHandler; +import net.minecraft.client.resources.I18n; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.fml.common.event.FMLInterModComms; + +import javax.annotation.Nonnull; +import java.util.List; + +public class WailaPlugin implements IIntegrationPlugin { + + @Nonnull + @Override + public String getModID() { + return "waila"; + } + + @Override + public void init() { + FMLInterModComms.sendMessage("waila", "register", "eutros.framedcompactdrawers.integration.waila.WailaPlugin.register"); + } + + @Override + public void postInit() { + } + + @SuppressWarnings("unused") + public static void register(IWailaRegistrar registrar) { + ConfigHandler configHandler = ConfigHandler.instance(); + + Waila.WailaDrawer provider = new OverwrittenWailaDrawer(); + + registrar.registerBodyProvider(provider, BlockDrawers.class); + registrar.registerStackProvider(provider, BlockDrawers.class); + + configHandler.addConfig(StorageDrawers.MOD_NAME, "display.content", I18n.format("storageDrawers.waila.config.displayContents"), true); + configHandler.addConfig(StorageDrawers.MOD_NAME, "display.stacklimit", I18n.format("storageDrawers.waila.config.displayStackLimit"), true); + configHandler.addConfig(StorageDrawers.MOD_NAME, "display.status", I18n.format("storageDrawers.waila.config.displayStatus"), true); + } + + public static class OverwrittenWailaDrawer extends Waila.WailaDrawer { + + @Override + @Nonnull + public List getWailaBody(@Nonnull ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { + TileEntity te = accessor.getTileEntity(); + if(!(te instanceof TileEntityDrawers)) + return currenttip; + + return super.getWailaBody(itemStack, currenttip, accessor, config); + } + + } + +} \ No newline at end of file