forked from J0B10/storage-drawers-kappa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.0.1: Waila Plugin (thanks to framed compacting drawers), and change…
… locations of dependencies (lib -> gradle)
- Loading branch information
1 parent
183ba66
commit e8f4be9
Showing
6 changed files
with
134 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
50 changes: 50 additions & 0 deletions
50
src/main/java/io/github/nomiceu/integration/IIntegrationPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ModContainer> 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(); | ||
|
||
} |
65 changes: 65 additions & 0 deletions
65
src/main/java/io/github/nomiceu/integration/waila/WailaPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String> getWailaBody(@Nonnull ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { | ||
TileEntity te = accessor.getTileEntity(); | ||
if(!(te instanceof TileEntityDrawers)) | ||
return currenttip; | ||
|
||
return super.getWailaBody(itemStack, currenttip, accessor, config); | ||
} | ||
|
||
} | ||
|
||
} |