Skip to content

Commit

Permalink
Fixed CraftTweaker(MineTweaker) support.
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoxkk0 committed Aug 8, 2023
1 parent b991784 commit 861bff4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.relauncher.Side;
import io.github.cruciblemc.necrotempus.modules.features.bossbar.compat.crafttweaker.ZenRegister;
import io.github.cruciblemc.necrotempus.modules.features.actionbar.network.ActionBarPacket;
import io.github.cruciblemc.necrotempus.modules.features.actionbar.network.ActionBarPacketHandler;
import io.github.cruciblemc.necrotempus.modules.features.bossbar.network.BossBarPacket;
Expand Down Expand Up @@ -52,6 +53,11 @@ public void preInit(FMLPreInitializationEvent event){
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
proxy.init(event);
try {
ZenRegister.register();
} catch (NoClassDefFoundError e) {
NecroTempus.getInstance().getLogger().warn("CraftTweaker is not available.");
}
}

@Mod.EventHandler
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
package io.github.cruciblemc.necrotempus.modules.features.bossbar.compat;
package io.github.cruciblemc.necrotempus.modules.features.bossbar.compat.crafttweaker;

import cpw.mods.fml.common.FMLCommonHandler;
import io.github.cruciblemc.necrotempus.Tags;
import io.github.cruciblemc.necrotempus.api.bossbar.BossBarColor;
import io.github.cruciblemc.necrotempus.api.bossbar.BossBarType;
import io.github.cruciblemc.necrotempus.modules.features.bossbar.client.render.BossDisplayAdapterListener;
import io.github.cruciblemc.necrotempus.modules.features.bossbar.component.BossDisplayAdapter;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.annotations.ModOnly;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;

@ZenClass(value = "mods.necrotempus.BossBar")
public class CraftTweakerBossBar {
@ZenClass(value = "necrotempus.crafttweaker.BossBar")
@ModOnly(Tags.MODID)
public class BossBar {

@ZenMethod
public static void customize(String entity, int color, String type){
public static void customize(String entity, String type, int color){
MineTweakerAPI.apply(new BossBarCustomizeAction(entity, color, type));
}

Expand All @@ -24,10 +27,10 @@ public static class BossBarCustomizeAction implements IUndoableAction{
private final BossBarColor color;
private final BossBarType type;

public BossBarCustomizeAction(String entity, int color, String type) {
this.entity = entity;
public BossBarCustomizeAction(Object entity, int color, Object type) {
this.entity = (String) entity;
this.color = BossBarColor.valueOfString("$" + color);
this.type = BossBarType.valueOfString(type);
this.type = BossBarType.valueOfString((String) type);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package io.github.cruciblemc.necrotempus.modules.features.bossbar.compat;
package io.github.cruciblemc.necrotempus.modules.features.bossbar.compat.crafttweaker;

import minetweaker.MineTweakerAPI;

public class ZenRegister {

public static void register() {
MineTweakerAPI.registerClass(CraftTweakerBossBar.class);
MineTweakerAPI.registerClass(BossBar.class);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,12 @@
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import io.github.cruciblemc.necrotempus.NecroTempus;
import io.github.cruciblemc.necrotempus.modules.features.bossbar.compat.ZenRegister;

public abstract class CommonProxy {

public void preInit(FMLPreInitializationEvent event){}

public void init(FMLInitializationEvent event){
try {
ZenRegister.register();
} catch (NoClassDefFoundError e) {
NecroTempus.getInstance().getLogger().warn("CraftTweaker is not available.");
}
}
public void init(FMLInitializationEvent event){}

public void postInit(FMLPostInitializationEvent event){}

Expand Down

0 comments on commit 861bff4

Please sign in to comment.