diff --git a/src/main/java/uk/protonull/civ/chesttracker/CivChestTracker.java b/src/main/java/uk/protonull/civ/chesttracker/CivChestTracker.java deleted file mode 100644 index 8a24f24..0000000 --- a/src/main/java/uk/protonull/civ/chesttracker/CivChestTracker.java +++ /dev/null @@ -1,11 +0,0 @@ -package uk.protonull.civ.chesttracker; - -import org.jetbrains.annotations.ApiStatus; -import uk.protonull.civ.chesttracker.gui.screens.ContainerLocationDeciderScreen; - -public final class CivChestTracker { - @ApiStatus.Internal - public static void bootstrap() { - ContainerLocationDeciderScreen.setupPickerRendering(); - } -} diff --git a/src/main/java/uk/protonull/civ/chesttracker/CivChestTrackerPlugin.java b/src/main/java/uk/protonull/civ/chesttracker/CivChestTrackerPlugin.java new file mode 100644 index 0000000..cef2787 --- /dev/null +++ b/src/main/java/uk/protonull/civ/chesttracker/CivChestTrackerPlugin.java @@ -0,0 +1,73 @@ +package uk.protonull.civ.chesttracker; + +import net.minecraft.client.gui.screens.inventory.BeaconScreen; +import net.minecraft.client.gui.screens.inventory.CartographyTableScreen; +import net.minecraft.client.gui.screens.inventory.EffectRenderingInventoryScreen; +import net.minecraft.client.gui.screens.inventory.EnchantmentScreen; +import net.minecraft.client.gui.screens.inventory.GrindstoneScreen; +import net.minecraft.client.gui.screens.inventory.ItemCombinerScreen; +import net.minecraft.client.gui.screens.inventory.LoomScreen; +import net.minecraft.client.gui.screens.inventory.StonecutterScreen; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.NotNull; +import red.jackf.chesttracker.api.ChestTrackerPlugin; +import red.jackf.chesttracker.api.gui.ScreenBlacklist; +import red.jackf.chesttracker.api.providers.ProviderUtils; +import red.jackf.chesttracker.api.providers.ServerProvider; +import red.jackf.chesttracker.api.providers.context.ScreenCloseContext; +import red.jackf.chesttracker.api.providers.context.ScreenOpenContext; +import red.jackf.jackfredlib.client.api.gps.Coordinate; +import uk.protonull.civ.chesttracker.gui.screens.ContainerLocationDeciderScreen; + +public final class CivChestTrackerPlugin implements ChestTrackerPlugin { + /** + * Pretty heavily based on {@link red.jackf.chesttracker.impl.DefaultChestTrackerPlugin} + */ + @Override + public void load() { + ScreenBlacklist.add( + // workstations with no item retention + CartographyTableScreen.class, + EnchantmentScreen.class, + GrindstoneScreen.class, + ItemCombinerScreen.class, + LoomScreen.class, + StonecutterScreen.class, + BeaconScreen.class, + // inventory (surv & creative) + EffectRenderingInventoryScreen.class + ); + + ProviderUtils.registerProvider(new Provider()); + + ContainerLocationDeciderScreen.setupPickerRendering(); + } + + private static final class Provider extends ServerProvider { + @Override + public ResourceLocation id() { + return ResourceLocation.fromNamespaceAndPath("civchesttracker", "provider"); + } + + @Override + public boolean appliesTo( + final @NotNull Coordinate coordinate + ) { + return true; // Apply to singleplayer, multiplayer, etc + } + + @Override + public void onScreenOpen( + final @NotNull ScreenOpenContext context + ) { + + } + + @Override + public void onScreenClose( + final ScreenCloseContext context + ) { + + } + } +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index aa68d57..c947bb1 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -15,8 +15,8 @@ "icon": "assets/civchesttracker/icon.png", "environment": "client", "entrypoints": { - "client": [ - "uk.protonull.civ.chesttracker.CivChestTracker::bootstrap" + "chesttracker": [ + "uk.protonull.civ.chesttracker.CivChestTrackerPlugin" ], "modmenu": [ "red.jackf.chesttracker.impl.compat.mods.ChestTrackerModMenu"