-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
disclaimer: not something i plan to release anytime soon
- Loading branch information
Showing
22 changed files
with
796 additions
and
1 deletion.
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
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
48 changes: 48 additions & 0 deletions
48
platform/neo/src/main/java/mcp/mobius/waila/jaded/JadeWailaMixinPlugin.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,48 @@ | ||
package mcp.mobius.waila.jaded; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import net.neoforged.fml.loading.FMLLoader; | ||
import org.objectweb.asm.tree.ClassNode; | ||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; | ||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo; | ||
|
||
public class JadeWailaMixinPlugin implements IMixinConfigPlugin { | ||
|
||
private static final boolean HAS_JADE = FMLLoader.getLoadingModList().getModFileById("jade") != null; | ||
|
||
@Override | ||
public void onLoad(String mixinPackage) { | ||
} | ||
|
||
@Override | ||
public String getRefMapperConfig() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { | ||
return HAS_JADE; | ||
} | ||
|
||
@Override | ||
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) { | ||
} | ||
|
||
@Override | ||
public List<String> getMixins() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { | ||
|
||
} | ||
|
||
@Override | ||
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { | ||
|
||
} | ||
|
||
} |
57 changes: 57 additions & 0 deletions
57
platform/neo/src/main/java/mcp/mobius/waila/jaded/j2w/JBlockComponentProvider.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,57 @@ | ||
package mcp.mobius.waila.jaded.j2w; | ||
|
||
import mcp.mobius.waila.api.IBlockAccessor; | ||
import mcp.mobius.waila.api.IBlockComponentProvider; | ||
import mcp.mobius.waila.api.IDataProvider; | ||
import mcp.mobius.waila.api.IDataWriter; | ||
import mcp.mobius.waila.api.IPluginConfig; | ||
import mcp.mobius.waila.api.IServerAccessor; | ||
import mcp.mobius.waila.api.ITooltip; | ||
import mcp.mobius.waila.api.ITooltipComponent; | ||
import mcp.mobius.waila.jaded.w2j.WClientBlockAccessor; | ||
import mcp.mobius.waila.jaded.w2j.WServerBlockAccessor; | ||
import mcp.mobius.waila.jaded.w2j.WTooltip; | ||
import net.minecraft.world.level.block.entity.BlockEntity; | ||
import org.jetbrains.annotations.Nullable; | ||
import snownee.jade.impl.WailaClientRegistration; | ||
import snownee.jade.impl.WailaCommonRegistration; | ||
import snownee.jade.impl.config.PluginConfig; | ||
|
||
public enum JBlockComponentProvider implements IBlockComponentProvider, IDataProvider<BlockEntity> { | ||
|
||
INSTANCE; | ||
|
||
@Override | ||
public @Nullable ITooltipComponent getIcon(IBlockAccessor accessor, IPluginConfig config) { | ||
var jadeAccessor = new WClientBlockAccessor(accessor); | ||
|
||
for (var provider : WailaClientRegistration.instance().getBlockIconProviders(accessor.getBlock(), PluginConfig.INSTANCE::get)) { | ||
var res = provider.getIcon(jadeAccessor, PluginConfig.INSTANCE, null); | ||
if (res != null) { | ||
return new JComponent(res); | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
public void appendBody(ITooltip tooltip, IBlockAccessor accessor, IPluginConfig config) { | ||
var jadeAccessor = new WClientBlockAccessor(accessor); | ||
var jadeTooltip = new WTooltip(tooltip); | ||
|
||
for (var provider : WailaClientRegistration.instance().getBlockProviders(accessor.getBlock(), PluginConfig.INSTANCE::get)) { | ||
provider.appendTooltip(jadeTooltip, jadeAccessor, PluginConfig.INSTANCE); | ||
} | ||
} | ||
|
||
@Override | ||
public void appendData(IDataWriter data, IServerAccessor<BlockEntity> accessor, IPluginConfig config) { | ||
var jadeAccessor = new WServerBlockAccessor(data, accessor); | ||
|
||
for (var provider : WailaCommonRegistration.instance().getBlockNBTProviders(accessor.getTarget())) { | ||
provider.appendServerData(data.raw(), jadeAccessor); | ||
} | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
platform/neo/src/main/java/mcp/mobius/waila/jaded/j2w/JComponent.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,35 @@ | ||
package mcp.mobius.waila.jaded.j2w; | ||
|
||
import mcp.mobius.waila.api.ITooltipComponent; | ||
import net.minecraft.client.gui.GuiGraphics; | ||
import net.minecraft.world.phys.Vec2; | ||
import snownee.jade.api.ui.IElement; | ||
import snownee.jade.overlay.OverlayRenderer; | ||
|
||
public class JComponent implements ITooltipComponent { | ||
|
||
private final IElement element; | ||
private final Vec2 size; | ||
|
||
public JComponent(IElement element) { | ||
this.element = element; | ||
this.size = element.getSize(); | ||
} | ||
|
||
@Override | ||
public int getWidth() { | ||
return (int) size.x; | ||
} | ||
|
||
@Override | ||
public int getHeight() { | ||
return (int) size.y; | ||
} | ||
|
||
@Override | ||
public void render(GuiGraphics ctx, int x, int y, float delta) { | ||
OverlayRenderer.alpha = 1; | ||
element.render(ctx, x, y, x + getWidth(), y + getHeight()); | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
platform/neo/src/main/java/mcp/mobius/waila/jaded/j2w/JEntityComponentProvider.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,25 @@ | ||
package mcp.mobius.waila.jaded.j2w; | ||
|
||
import mcp.mobius.waila.api.IDataProvider; | ||
import mcp.mobius.waila.api.IDataWriter; | ||
import mcp.mobius.waila.api.IEntityComponentProvider; | ||
import mcp.mobius.waila.api.IPluginConfig; | ||
import mcp.mobius.waila.api.IServerAccessor; | ||
import mcp.mobius.waila.jaded.w2j.WServerEntityAccessor; | ||
import net.minecraft.world.entity.Entity; | ||
import snownee.jade.impl.WailaCommonRegistration; | ||
|
||
public enum JEntityComponentProvider implements IEntityComponentProvider, IDataProvider<Entity> { | ||
|
||
INSTANCE; | ||
|
||
@Override | ||
public void appendData(IDataWriter data, IServerAccessor<Entity> accessor, IPluginConfig config) { | ||
var jadeAccessor = new WServerEntityAccessor(data, accessor); | ||
|
||
for (var provider : WailaCommonRegistration.instance().getEntityNBTProviders(accessor.getTarget())) { | ||
provider.appendServerData(data.raw(), jadeAccessor); | ||
} | ||
} | ||
|
||
} |
60 changes: 60 additions & 0 deletions
60
platform/neo/src/main/java/mcp/mobius/waila/jaded/j2w/JPluginDiscoverer.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,60 @@ | ||
package mcp.mobius.waila.jaded.j2w; | ||
|
||
import java.nio.file.Files; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import com.google.common.base.CaseFormat; | ||
import mcp.mobius.waila.Waila; | ||
import mcp.mobius.waila.api.IPluginDiscoverer; | ||
import mcp.mobius.waila.api.IPluginInfo; | ||
import mcp.mobius.waila.api.WailaConstants; | ||
import mcp.mobius.waila.util.ModInfo; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.neoforged.fml.ModList; | ||
import org.apache.commons.lang3.ClassUtils; | ||
import snownee.jade.api.IWailaPlugin; | ||
import snownee.jade.api.WailaPlugin; | ||
|
||
public class JPluginDiscoverer implements IPluginDiscoverer { | ||
|
||
public static final ResourceLocation ID = Waila.id("jade_compat"); | ||
|
||
@Override | ||
public ResourceLocation getDiscovererId() { | ||
return ID; | ||
} | ||
|
||
@Override | ||
public void discover(Candidates candidates) { | ||
if (!ModInfo.get("jade").isPresent()) return; | ||
|
||
candidates.add(WailaConstants.MOD_ID, new ResourceLocation("jade", "pre"), IPluginInfo.Side.BOTH, List.of(), true, JPreWailaPlugin::new); | ||
|
||
for (var info : ModList.get().getModFiles()) { | ||
var modFile = info.getFile(); | ||
var modId = info.getMods().get(0).getModId(); | ||
var hasPluginsJson = Files.exists(modFile.findResource("waila_plugins.json")) || Files.exists(modFile.findResource("wthit_plugins.json")); | ||
|
||
for (var annotation : modFile.getScanResult().getAnnotations()) { | ||
if (annotation.annotationType().getClassName().equals(WailaPlugin.class.getName())) { | ||
var required = (String) annotation.annotationData().get("value"); | ||
|
||
var className = annotation.memberName(); | ||
var shortClassName = CaseFormat.UPPER_CAMEL.converterTo(CaseFormat.LOWER_UNDERSCORE).convert(ClassUtils.getShortClassName(className)); | ||
var pluginId = new ResourceLocation(modId, Objects.requireNonNull(shortClassName)); | ||
var hasDisabler = false; // TODO | ||
|
||
candidates.add( | ||
modId, pluginId, | ||
IPluginInfo.Side.BOTH, required != null ? List.of(required) : List.of(), | ||
!(modId.equals("jade") || hasPluginsJson || hasDisabler), | ||
() -> new JWailaPlugin((IWailaPlugin) Class.forName(className).getConstructor().newInstance())); | ||
} | ||
} | ||
} | ||
|
||
candidates.add(WailaConstants.MOD_ID, new ResourceLocation("jade", "post"), IPluginInfo.Side.BOTH, List.of(), true, JPostWailaPlugin::new); | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
platform/neo/src/main/java/mcp/mobius/waila/jaded/j2w/JPostWailaPlugin.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,25 @@ | ||
package mcp.mobius.waila.jaded.j2w; | ||
|
||
import mcp.mobius.waila.api.IRegistrar; | ||
import mcp.mobius.waila.api.IWailaPlugin; | ||
import mcp.mobius.waila.api.TooltipPosition; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.entity.BlockEntity; | ||
import snownee.jade.Jade; | ||
|
||
public class JPostWailaPlugin implements IWailaPlugin { | ||
|
||
@Override | ||
public void register(IRegistrar registrar) { | ||
Jade.FROZEN = false; | ||
Jade.loadComplete(); | ||
|
||
registrar.addIcon(JBlockComponentProvider.INSTANCE, Block.class); | ||
registrar.addComponent(JBlockComponentProvider.INSTANCE, TooltipPosition.BODY, Block.class); | ||
registrar.addBlockData(JBlockComponentProvider.INSTANCE, BlockEntity.class); | ||
|
||
registrar.addEntityData(JEntityComponentProvider.INSTANCE, Entity.class); | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
platform/neo/src/main/java/mcp/mobius/waila/jaded/j2w/JPreWailaPlugin.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,18 @@ | ||
package mcp.mobius.waila.jaded.j2w; | ||
|
||
import mcp.mobius.waila.api.IRegistrar; | ||
import mcp.mobius.waila.api.IWailaPlugin; | ||
import mcp.mobius.waila.jaded.mixin.AccessPluginConfig; | ||
import mcp.mobius.waila.jaded.mixin.AccessWailaClientRegistration; | ||
import mcp.mobius.waila.jaded.mixin.AccessWailaCommonRegistration; | ||
|
||
public class JPreWailaPlugin implements IWailaPlugin { | ||
|
||
@Override | ||
public void register(IRegistrar registrar) { | ||
AccessPluginConfig.wthit_setInstance(AccessPluginConfig.wthit_new()); | ||
AccessWailaCommonRegistration.wthit_setInstance(AccessWailaCommonRegistration.wthit_new()); | ||
AccessWailaClientRegistration.wthit_setInstance(AccessWailaClientRegistration.wthit_new()); | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
platform/neo/src/main/java/mcp/mobius/waila/jaded/j2w/JWailaPlugin.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,26 @@ | ||
package mcp.mobius.waila.jaded.j2w; | ||
|
||
import mcp.mobius.waila.Waila; | ||
import mcp.mobius.waila.api.IRegistrar; | ||
import mcp.mobius.waila.api.IWailaPlugin; | ||
import snownee.jade.impl.WailaClientRegistration; | ||
import snownee.jade.impl.WailaCommonRegistration; | ||
|
||
public class JWailaPlugin implements IWailaPlugin { | ||
|
||
public final snownee.jade.api.IWailaPlugin jade; | ||
|
||
public JWailaPlugin(snownee.jade.api.IWailaPlugin jade) { | ||
this.jade = jade; | ||
} | ||
|
||
@Override | ||
public void register(IRegistrar registrar) { | ||
jade.register(WailaCommonRegistration.instance()); | ||
|
||
if (Waila.CLIENT_SIDE) { | ||
jade.registerClient(WailaClientRegistration.instance()); | ||
} | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
platform/neo/src/main/java/mcp/mobius/waila/jaded/mixin/AccessPluginConfig.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,22 @@ | ||
package mcp.mobius.waila.jaded.mixin; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Mutable; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
import org.spongepowered.asm.mixin.gen.Invoker; | ||
import snownee.jade.impl.config.PluginConfig; | ||
|
||
@Mixin(PluginConfig.class) | ||
public interface AccessPluginConfig { | ||
|
||
@Invoker("<init>") | ||
static PluginConfig wthit_new() { | ||
throw new AssertionError(""); | ||
} | ||
|
||
@Mutable | ||
@Accessor("INSTANCE") | ||
static void wthit_setInstance(PluginConfig instance) { | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
platform/neo/src/main/java/mcp/mobius/waila/jaded/mixin/AccessWailaClientRegistration.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,22 @@ | ||
package mcp.mobius.waila.jaded.mixin; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Mutable; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
import org.spongepowered.asm.mixin.gen.Invoker; | ||
import snownee.jade.impl.WailaClientRegistration; | ||
|
||
@Mixin(WailaClientRegistration.class) | ||
public interface AccessWailaClientRegistration { | ||
|
||
@Invoker("<init>") | ||
static WailaClientRegistration wthit_new() { | ||
throw new AssertionError(""); | ||
} | ||
|
||
@Mutable | ||
@Accessor("INSTANCE") | ||
static void wthit_setInstance(WailaClientRegistration instance) { | ||
} | ||
|
||
} |
Oops, something went wrong.