This repository has been archived by the owner on Sep 24, 2024. It is now read-only.
generated from MeteorDevelopment/meteor-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
711 additions
and
100 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
12 changes: 9 additions & 3 deletions
12
...a/nekiplay/meteorplus/MeteorPlusMain.java → src/main/java/nekiplay/Main.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 |
---|---|---|
@@ -1,18 +1,24 @@ | ||
package nekiplay.meteorplus; | ||
package nekiplay; | ||
|
||
import nekiplay.bozeplus.BozePlusAddon; | ||
import nekiplay.meteorplus.items.ModItems; | ||
import net.fabricmc.api.ModInitializer; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import static nekiplay.meteorplus.MeteorPlusAddon.LOGPREFIX; | ||
|
||
public class MeteorPlusMain implements ModInitializer { | ||
public static final Logger LOG = LoggerFactory.getLogger(MeteorPlusMain.class); | ||
public class Main implements ModInitializer { | ||
public static final Logger LOG = LoggerFactory.getLogger(Main.class); | ||
@Override | ||
public void onInitialize() { | ||
LOG.info(LOGPREFIX + " initializing items..."); | ||
ModItems.Initialize(); | ||
LOG.info(LOGPREFIX + " loaded items"); | ||
|
||
if (MixinPlugin.isBozeAPI) { | ||
BozePlusAddon bozePlusMain = new BozePlusAddon(); | ||
bozePlusMain.onInitialize(); | ||
} | ||
} | ||
} |
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,101 @@ | ||
package nekiplay; | ||
|
||
import net.fabricmc.loader.api.FabricLoader; | ||
import org.objectweb.asm.tree.ClassNode; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; | ||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public class MixinPlugin implements IMixinConfigPlugin { | ||
public static final Logger LOG = LoggerFactory.getLogger(MixinPlugin.class); | ||
public static final String LOGPREFIX = "[Meteor+ Mixins]"; | ||
|
||
private static final String mixinPackageMeteorPlus = "nekiplay.meteorplus.mixin"; | ||
private static final String mixinPackageBozePlus = "nekiplay.bozeplus.mixin"; | ||
public static boolean isMeteorClient = false; | ||
public static boolean isBaritonePresent = false; | ||
public static boolean isJourneyMapPresent = false; | ||
public static boolean isXaeroWorldMapresent = false; | ||
public static boolean isXaeroMiniMapresent= false; | ||
public static boolean isXaeroPlusMapresent = false; | ||
public static boolean isLitematicaMapresent = false; | ||
public static boolean isWhereIsIt = false; | ||
public static boolean isMeteorRejects= false; | ||
|
||
public static boolean isBozeAPI= false; | ||
|
||
@Override | ||
public void onLoad(String mixinPackage) { | ||
FabricLoader loader = FabricLoader.getInstance(); | ||
|
||
isMeteorClient = loader.isModLoaded("meteor-client"); | ||
isBozeAPI = loader.isModLoaded("boze-api"); | ||
|
||
isMeteorRejects = loader.isModLoaded("meteor-rejects"); | ||
|
||
isBaritonePresent = loader.isModLoaded("baritone"); | ||
isJourneyMapPresent = loader.isModLoaded("journeymap"); | ||
isXaeroWorldMapresent = loader.isModLoaded("xaeroworldmap"); | ||
isXaeroMiniMapresent = loader.isModLoaded("xaerominimap"); | ||
isXaeroPlusMapresent = loader.isModLoaded("xaeroplus"); | ||
isLitematicaMapresent = loader.isModLoaded("litematica"); | ||
isWhereIsIt = loader.isModLoaded("whereisit"); | ||
} | ||
|
||
@Override | ||
public String getRefMapperConfig() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { | ||
if (!mixinClassName.startsWith(mixinPackageMeteorPlus)) { | ||
throw new RuntimeException(LOGPREFIX + " " + mixinClassName + " is not in the mixin package"); | ||
} | ||
else if (mixinClassName.startsWith(mixinPackageMeteorPlus + ".meteorclient")) { | ||
if (mixinClassName.contains("FreecamMixin") || mixinClassName.contains("WaypointsModuleMixin")) { | ||
return isBaritonePresent && isMeteorClient; | ||
} | ||
return isMeteorClient; | ||
} | ||
else if (mixinClassName.startsWith(mixinPackageMeteorPlus + ".journeymap")) { | ||
return isBaritonePresent && isJourneyMapPresent && isMeteorClient; | ||
} | ||
else if (mixinClassName.startsWith(mixinPackageMeteorPlus + ".xaero.minimap")) { | ||
return isXaeroWorldMapresent && isMeteorClient; | ||
} | ||
else if (mixinClassName.startsWith(mixinPackageMeteorPlus + ".xaero.worldmap")) { | ||
return isBaritonePresent && isXaeroWorldMapresent && isMeteorClient; | ||
} | ||
else if (mixinClassName.startsWith(mixinPackageMeteorPlus + ".whereisit")) { | ||
return isWhereIsIt && isMeteorClient; | ||
} | ||
else if (mixinClassName.startsWith(mixinPackageMeteorPlus + ".minecraft")) { | ||
return isMeteorClient; | ||
} | ||
|
||
else if (mixinClassName.startsWith(mixinPackageBozePlus + ".minecraft")) { | ||
return isBozeAPI; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
@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) {} | ||
|
||
} |
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,107 @@ | ||
package nekiplay.bozeplus; | ||
|
||
import com.google.gson.JsonObject; | ||
import dev.boze.api.BozeInstance; | ||
import dev.boze.api.Globals; | ||
import dev.boze.api.addon.Addon; | ||
import dev.boze.api.addon.AddonMetadata; | ||
import dev.boze.api.addon.AddonVersion; | ||
import dev.boze.api.addon.command.AddonDispatcher; | ||
import dev.boze.api.addon.module.AddonModule; | ||
import dev.boze.api.config.Serializable; | ||
import dev.boze.api.exception.AddonInitializationException; | ||
import meteordevelopment.orbit.EventBus; | ||
import meteordevelopment.orbit.IEventBus; | ||
import nekiplay.MixinPlugin; | ||
import nekiplay.bozeplus.features.modules.movement.spider.SpiderPlus; | ||
import nekiplay.bozeplus.impl.BozePlusDispatcher; | ||
import nekiplay.bozeplus.impl.BozePlusModule; | ||
import net.fabricmc.loader.impl.util.log.Log; | ||
import net.fabricmc.loader.impl.util.log.LogCategory; | ||
|
||
import java.lang.invoke.MethodHandles; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class BozePlusAddon implements Addon, Serializable<BozePlusAddon> { | ||
public static final IEventBus EVENT_BUS = new EventBus(); | ||
|
||
private static BozePlusAddon instance; | ||
|
||
public static BozePlusAddon getInstance() { | ||
return instance; | ||
} | ||
|
||
public final AddonMetadata metadata = new AddonMetadata( | ||
"boze-plus", | ||
"Boze Plus", | ||
"An example addon for Boze", | ||
new AddonVersion(1, 0, 0)); | ||
|
||
private final ArrayList<AddonModule> modules = new ArrayList<>(); | ||
private BozePlusDispatcher dispatcher; | ||
|
||
public void onInitialize() { | ||
try { | ||
BozeInstance.INSTANCE.registerAddon(this); | ||
} catch (AddonInitializationException e) { | ||
Log.error(LogCategory.LOG, "Failed to initialize addon: " + getMetadata().id(), e); | ||
} | ||
} | ||
|
||
@Override | ||
public AddonMetadata getMetadata() { | ||
return metadata; | ||
} | ||
|
||
@Override | ||
public boolean initialize() { | ||
instance = this; | ||
BozeInstance.INSTANCE.registerPackage("nekiplay.bozeplus"); | ||
EVENT_BUS.registerLambdaFactory("nekiplay.bozeplus" , (lookupInMethod, klass) -> (MethodHandles.Lookup) lookupInMethod.invoke(null, klass, MethodHandles.lookup())); | ||
|
||
// Load config | ||
Globals.getJsonTools().loadObject(this, "config", this); | ||
|
||
SpiderPlus spiderPlus = new SpiderPlus(); | ||
|
||
modules.add(spiderPlus); | ||
EVENT_BUS.subscribe(spiderPlus); | ||
|
||
return true; | ||
} | ||
|
||
@Override | ||
public void shutdown() { | ||
Globals.getJsonTools().saveObject(this, "config", this); | ||
} | ||
|
||
@Override | ||
public List<AddonModule> getModules() { | ||
return modules; | ||
} | ||
|
||
@Override | ||
public AddonDispatcher getDispatcher() { | ||
return dispatcher; | ||
} | ||
|
||
@Override | ||
public JsonObject toJson() { | ||
JsonObject object = new JsonObject(); | ||
for (AddonModule module : modules) { | ||
object.add(module.getInfo().getName(), ((BozePlusModule) module).toJson()); | ||
} | ||
return object; | ||
} | ||
|
||
@Override | ||
public BozePlusAddon fromJson(JsonObject jsonObject) { | ||
for (AddonModule module : modules) { | ||
if (jsonObject.has(module.getInfo().getName())) { | ||
((BozePlusModule) module).fromJson(jsonObject.getAsJsonObject(module.getInfo().getName())); | ||
} | ||
} | ||
return this; | ||
} | ||
} |
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,17 @@ | ||
package nekiplay.bozeplus.events; | ||
|
||
import meteordevelopment.orbit.ICancellable; | ||
|
||
public class Cancellable implements ICancellable { | ||
private boolean cancelled = false; | ||
|
||
@Override | ||
public void setCancelled(boolean cancelled) { | ||
this.cancelled = cancelled; | ||
} | ||
|
||
@Override | ||
public boolean isCancelled() { | ||
return cancelled; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/nekiplay/bozeplus/events/packets/PacketEvent.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,44 @@ | ||
package nekiplay.bozeplus.events.packets; | ||
|
||
import nekiplay.bozeplus.events.Cancellable; | ||
import net.minecraft.network.listener.PacketListener; | ||
import net.minecraft.network.packet.Packet; | ||
|
||
public class PacketEvent { | ||
public static class Receive extends Cancellable { | ||
private static final Receive INSTANCE = new Receive(); | ||
|
||
public Packet<?> packet; | ||
public PacketListener packetListener; | ||
|
||
public static Receive get(Packet<?> packet, PacketListener listener) { | ||
INSTANCE.setCancelled(false); | ||
INSTANCE.packet = packet; | ||
INSTANCE.packetListener = listener; | ||
return INSTANCE; | ||
} | ||
} | ||
|
||
public static class Send extends Cancellable { | ||
private static final Send INSTANCE = new Send(); | ||
|
||
public Packet<?> packet; | ||
|
||
public static Send get(Packet<?> packet) { | ||
INSTANCE.setCancelled(false); | ||
INSTANCE.packet = packet; | ||
return INSTANCE; | ||
} | ||
} | ||
|
||
public static class Sent { | ||
private static final Sent INSTANCE = new Sent(); | ||
|
||
public Packet<?> packet; | ||
|
||
public static Sent get(Packet<?> packet) { | ||
INSTANCE.packet = packet; | ||
return INSTANCE; | ||
} | ||
} | ||
} |
Oops, something went wrong.