From d9b06b1793c559c07e32ceb2e9be5ef4b7a6869c Mon Sep 17 00:00:00 2001 From: DaFuqs Date: Tue, 14 Jun 2022 21:01:54 +0200 Subject: [PATCH] api cleanup --- .../{api/advancements => }/ClientAdvancements.java | 11 +++++------ ...elationHolder.java => ClientRevelationHolder.java} | 4 ++-- .../{revelationary => }/RevelationDataLoader.java | 3 +-- .../{revelationary => }/RevelationRegistry.java | 2 +- .../java/de/dafuqs/revelationary/Revelationary.java | 2 -- .../api/advancements/AdvancementHelper.java | 4 ++-- .../advancements/ClientAdvancementPacketCallback.java | 1 + .../api/revelations/RevealingCallback.java | 6 +++--- .../api/revelations/RevelationAware.java | 2 +- .../revelationary/mixin/AbstractBlockMixin.java | 2 +- .../dafuqs/revelationary/mixin/ItemModelsMixin.java | 6 +++--- .../mixin/PlayerAdvancementTrackerMixin.java | 2 +- .../revelationary/mixin/client/BlockClientMixin.java | 4 ++-- .../revelationary/mixin/client/BlockModelsMixin.java | 6 +++--- .../mixin/client/ClientAdvancementManagerMixin.java | 2 +- .../dafuqs/revelationary/mixin/client/ItemMixin.java | 4 ++-- .../mixin/client/MinecraftClientMixin.java | 2 +- 17 files changed, 30 insertions(+), 33 deletions(-) rename src/main/java/de/dafuqs/revelationary/{api/advancements => }/ClientAdvancements.java (88%) rename src/main/java/de/dafuqs/revelationary/{revelationary/RevelationHolder.java => ClientRevelationHolder.java} (98%) rename src/main/java/de/dafuqs/revelationary/{revelationary => }/RevelationDataLoader.java (91%) rename src/main/java/de/dafuqs/revelationary/{revelationary => }/RevelationRegistry.java (99%) diff --git a/src/main/java/de/dafuqs/revelationary/api/advancements/ClientAdvancements.java b/src/main/java/de/dafuqs/revelationary/ClientAdvancements.java similarity index 88% rename from src/main/java/de/dafuqs/revelationary/api/advancements/ClientAdvancements.java rename to src/main/java/de/dafuqs/revelationary/ClientAdvancements.java index 4baf2c9..bdd42c7 100644 --- a/src/main/java/de/dafuqs/revelationary/api/advancements/ClientAdvancements.java +++ b/src/main/java/de/dafuqs/revelationary/ClientAdvancements.java @@ -1,8 +1,7 @@ -package de.dafuqs.revelationary.api.advancements; +package de.dafuqs.revelationary; +import de.dafuqs.revelationary.api.advancements.ClientAdvancementPacketCallback; import de.dafuqs.revelationary.mixin.client.AccessorClientAdvancementManager; -import de.dafuqs.revelationary.revelationary.RevelationHolder; -import de.dafuqs.revelationary.revelationary.RevelationRegistry; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.advancement.Advancement; @@ -29,8 +28,8 @@ public static void onClientPacket(@NotNull AdvancementUpdateS2CPacket packet) { Set doneAdvancements = getDoneAdvancements(packet); Set removedAdvancements = packet.getAdvancementIdsToRemove(); - RevelationHolder.processRemovedAdvancements(removedAdvancements); - RevelationHolder.processNewAdvancements(doneAdvancements, !hadPacketBefore); + ClientRevelationHolder.processRemovedAdvancements(removedAdvancements); + ClientRevelationHolder.processNewAdvancements(doneAdvancements, !hadPacketBefore); for(ClientAdvancementPacketCallback callback : callbacks) { callback.onClientAdvancementPacket(doneAdvancements, removedAdvancements, !hadPacketBefore); @@ -77,7 +76,7 @@ public static boolean hasDone(Identifier identifier) { public static void playerLogout() { RevelationRegistry.addRevelationAwares(); - RevelationHolder.cloakAll(); + ClientRevelationHolder.cloakAll(); receivedFirstAdvancementPacket = false; } diff --git a/src/main/java/de/dafuqs/revelationary/revelationary/RevelationHolder.java b/src/main/java/de/dafuqs/revelationary/ClientRevelationHolder.java similarity index 98% rename from src/main/java/de/dafuqs/revelationary/revelationary/RevelationHolder.java rename to src/main/java/de/dafuqs/revelationary/ClientRevelationHolder.java index 22bf120..d3511db 100644 --- a/src/main/java/de/dafuqs/revelationary/revelationary/RevelationHolder.java +++ b/src/main/java/de/dafuqs/revelationary/ClientRevelationHolder.java @@ -1,4 +1,4 @@ -package de.dafuqs.revelationary.revelationary; +package de.dafuqs.revelationary; import de.dafuqs.revelationary.api.revelations.RevealingCallback; import de.dafuqs.revelationary.api.revelations.RevelationAware; @@ -19,7 +19,7 @@ import java.util.Set; @Environment(EnvType.CLIENT) -public class RevelationHolder { +public class ClientRevelationHolder { public static List callbacks = new ArrayList<>(); diff --git a/src/main/java/de/dafuqs/revelationary/revelationary/RevelationDataLoader.java b/src/main/java/de/dafuqs/revelationary/RevelationDataLoader.java similarity index 91% rename from src/main/java/de/dafuqs/revelationary/revelationary/RevelationDataLoader.java rename to src/main/java/de/dafuqs/revelationary/RevelationDataLoader.java index ba7b4d7..2007a77 100644 --- a/src/main/java/de/dafuqs/revelationary/revelationary/RevelationDataLoader.java +++ b/src/main/java/de/dafuqs/revelationary/RevelationDataLoader.java @@ -1,8 +1,7 @@ -package de.dafuqs.revelationary.revelationary; +package de.dafuqs.revelationary; import com.google.gson.Gson; import com.google.gson.JsonElement; -import de.dafuqs.revelationary.Revelationary; import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener; import net.minecraft.resource.JsonDataLoader; import net.minecraft.resource.ResourceManager; diff --git a/src/main/java/de/dafuqs/revelationary/revelationary/RevelationRegistry.java b/src/main/java/de/dafuqs/revelationary/RevelationRegistry.java similarity index 99% rename from src/main/java/de/dafuqs/revelationary/revelationary/RevelationRegistry.java rename to src/main/java/de/dafuqs/revelationary/RevelationRegistry.java index 56042a7..8af5ba6 100644 --- a/src/main/java/de/dafuqs/revelationary/revelationary/RevelationRegistry.java +++ b/src/main/java/de/dafuqs/revelationary/RevelationRegistry.java @@ -1,4 +1,4 @@ -package de.dafuqs.revelationary.revelationary; +package de.dafuqs.revelationary; import com.google.gson.JsonElement; import com.google.gson.JsonObject; diff --git a/src/main/java/de/dafuqs/revelationary/Revelationary.java b/src/main/java/de/dafuqs/revelationary/Revelationary.java index f22e1b0..7d0a8e1 100644 --- a/src/main/java/de/dafuqs/revelationary/Revelationary.java +++ b/src/main/java/de/dafuqs/revelationary/Revelationary.java @@ -1,8 +1,6 @@ package de.dafuqs.revelationary; import de.dafuqs.revelationary.api.advancements.AdvancementCriteria; -import de.dafuqs.revelationary.revelationary.RevelationDataLoader; -import de.dafuqs.revelationary.revelationary.RevelationRegistry; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerWorldEvents; import net.fabricmc.fabric.api.resource.ResourceManagerHelper; diff --git a/src/main/java/de/dafuqs/revelationary/api/advancements/AdvancementHelper.java b/src/main/java/de/dafuqs/revelationary/api/advancements/AdvancementHelper.java index 91fd82c..ecfdd08 100644 --- a/src/main/java/de/dafuqs/revelationary/api/advancements/AdvancementHelper.java +++ b/src/main/java/de/dafuqs/revelationary/api/advancements/AdvancementHelper.java @@ -1,6 +1,7 @@ package de.dafuqs.revelationary.api.advancements; import de.dafuqs.revelationary.Revelationary; +import de.dafuqs.revelationary.ClientAdvancements; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.advancement.Advancement; @@ -30,8 +31,7 @@ public static boolean hasAdvancement(PlayerEntity playerEntity, Identifier advan } else if (playerEntity.getClass().getCanonicalName().startsWith("net.minecraft")) { return hasAdvancementClient(advancementIdentifier); } else { - // thank you, Kibe FakePlayerEntity - // it neither is a ServerPlayerEntity, nor a ClientPlayerEntity + // Kibe's FakePlayerEntity is neither is a ServerPlayerEntity, nor a ClientPlayerEntity return false; } } diff --git a/src/main/java/de/dafuqs/revelationary/api/advancements/ClientAdvancementPacketCallback.java b/src/main/java/de/dafuqs/revelationary/api/advancements/ClientAdvancementPacketCallback.java index d80bb98..7569ab7 100644 --- a/src/main/java/de/dafuqs/revelationary/api/advancements/ClientAdvancementPacketCallback.java +++ b/src/main/java/de/dafuqs/revelationary/api/advancements/ClientAdvancementPacketCallback.java @@ -1,5 +1,6 @@ package de.dafuqs.revelationary.api.advancements; +import de.dafuqs.revelationary.ClientAdvancements; import net.minecraft.util.Identifier; import java.util.Set; diff --git a/src/main/java/de/dafuqs/revelationary/api/revelations/RevealingCallback.java b/src/main/java/de/dafuqs/revelationary/api/revelations/RevealingCallback.java index 2b95ef2..37fe61d 100644 --- a/src/main/java/de/dafuqs/revelationary/api/revelations/RevealingCallback.java +++ b/src/main/java/de/dafuqs/revelationary/api/revelations/RevealingCallback.java @@ -1,6 +1,6 @@ package de.dafuqs.revelationary.api.revelations; -import de.dafuqs.revelationary.revelationary.RevelationHolder; +import de.dafuqs.revelationary.ClientRevelationHolder; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.util.Identifier; @@ -12,11 +12,11 @@ public interface RevealingCallback { void trigger(Set advancements, Set blocks, Set items, boolean isJoinPacket); static void register(RevealingCallback callback) { - RevelationHolder.callbacks.add(callback); + ClientRevelationHolder.callbacks.add(callback); } static void unregister(RevealingCallback callback) { - RevelationHolder.callbacks.remove(callback); + ClientRevelationHolder.callbacks.remove(callback); } } \ No newline at end of file diff --git a/src/main/java/de/dafuqs/revelationary/api/revelations/RevelationAware.java b/src/main/java/de/dafuqs/revelationary/api/revelations/RevelationAware.java index 1d3abe3..b3637d6 100644 --- a/src/main/java/de/dafuqs/revelationary/api/revelations/RevelationAware.java +++ b/src/main/java/de/dafuqs/revelationary/api/revelations/RevelationAware.java @@ -1,7 +1,7 @@ package de.dafuqs.revelationary.api.revelations; import de.dafuqs.revelationary.api.advancements.AdvancementHelper; -import de.dafuqs.revelationary.revelationary.RevelationRegistry; +import de.dafuqs.revelationary.RevelationRegistry; import net.minecraft.block.BlockState; import net.minecraft.block.EntityShapeContext; import net.minecraft.block.ShapeContext; diff --git a/src/main/java/de/dafuqs/revelationary/mixin/AbstractBlockMixin.java b/src/main/java/de/dafuqs/revelationary/mixin/AbstractBlockMixin.java index 0300fa0..760a290 100644 --- a/src/main/java/de/dafuqs/revelationary/mixin/AbstractBlockMixin.java +++ b/src/main/java/de/dafuqs/revelationary/mixin/AbstractBlockMixin.java @@ -1,7 +1,7 @@ package de.dafuqs.revelationary.mixin; import de.dafuqs.revelationary.api.revelations.RevelationAware; -import de.dafuqs.revelationary.revelationary.RevelationRegistry; +import de.dafuqs.revelationary.RevelationRegistry; import net.minecraft.block.AbstractBlock; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; diff --git a/src/main/java/de/dafuqs/revelationary/mixin/ItemModelsMixin.java b/src/main/java/de/dafuqs/revelationary/mixin/ItemModelsMixin.java index 043d968..8367753 100644 --- a/src/main/java/de/dafuqs/revelationary/mixin/ItemModelsMixin.java +++ b/src/main/java/de/dafuqs/revelationary/mixin/ItemModelsMixin.java @@ -1,6 +1,6 @@ package de.dafuqs.revelationary.mixin; -import de.dafuqs.revelationary.revelationary.RevelationHolder; +import de.dafuqs.revelationary.ClientRevelationHolder; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import net.minecraft.client.render.item.ItemModels; import net.minecraft.client.render.model.BakedModel; @@ -27,8 +27,8 @@ public class ItemModelsMixin { @Inject(at = @At("HEAD"), method = "getModel(Lnet/minecraft/item/ItemStack;)Lnet/minecraft/client/render/model/BakedModel;", cancellable = true) private void revelationary$getModel(ItemStack itemStack, CallbackInfoReturnable callbackInfoReturnable) { - if (RevelationHolder.isCloaked(itemStack.getItem())) { - Item destinationItem = RevelationHolder.getCloakTarget(itemStack.getItem()); + if (ClientRevelationHolder.isCloaked(itemStack.getItem())) { + Item destinationItem = ClientRevelationHolder.getCloakTarget(itemStack.getItem()); BakedModel overriddenModel = this.models.getOrDefault(Item.getRawId(destinationItem), modelManager.getMissingModel()); callbackInfoReturnable.setReturnValue(overriddenModel); } diff --git a/src/main/java/de/dafuqs/revelationary/mixin/PlayerAdvancementTrackerMixin.java b/src/main/java/de/dafuqs/revelationary/mixin/PlayerAdvancementTrackerMixin.java index bbe7fc5..64ff108 100644 --- a/src/main/java/de/dafuqs/revelationary/mixin/PlayerAdvancementTrackerMixin.java +++ b/src/main/java/de/dafuqs/revelationary/mixin/PlayerAdvancementTrackerMixin.java @@ -1,7 +1,7 @@ package de.dafuqs.revelationary.mixin; import de.dafuqs.revelationary.api.advancements.AdvancementCriteria; -import de.dafuqs.revelationary.revelationary.RevelationRegistry; +import de.dafuqs.revelationary.RevelationRegistry; import net.minecraft.advancement.Advancement; import net.minecraft.advancement.AdvancementProgress; import net.minecraft.advancement.PlayerAdvancementTracker; diff --git a/src/main/java/de/dafuqs/revelationary/mixin/client/BlockClientMixin.java b/src/main/java/de/dafuqs/revelationary/mixin/client/BlockClientMixin.java index a66a0b9..7bba216 100644 --- a/src/main/java/de/dafuqs/revelationary/mixin/client/BlockClientMixin.java +++ b/src/main/java/de/dafuqs/revelationary/mixin/client/BlockClientMixin.java @@ -1,6 +1,6 @@ package de.dafuqs.revelationary.mixin.client; -import de.dafuqs.revelationary.revelationary.RevelationHolder; +import de.dafuqs.revelationary.ClientRevelationHolder; import net.minecraft.block.Block; import net.minecraft.text.LiteralText; import net.minecraft.text.MutableText; @@ -16,7 +16,7 @@ public class BlockClientMixin { @Inject(method = "getName()Lnet/minecraft/text/MutableText;", at = @At("RETURN"), cancellable = true) private void getCgraloakedName(CallbackInfoReturnable callbackInfoReturnable) { Block thisBlock = (Block) (Object) this; - if (RevelationHolder.isCloaked(thisBlock)) { + if (ClientRevelationHolder.isCloaked(thisBlock)) { // Get the localized name of the block and scatter it using §k to make it unreadable Language language = Language.getInstance(); LiteralText newText = new LiteralText("§k" + language.get(thisBlock.getTranslationKey())); diff --git a/src/main/java/de/dafuqs/revelationary/mixin/client/BlockModelsMixin.java b/src/main/java/de/dafuqs/revelationary/mixin/client/BlockModelsMixin.java index 2510f55..8ea315d 100644 --- a/src/main/java/de/dafuqs/revelationary/mixin/client/BlockModelsMixin.java +++ b/src/main/java/de/dafuqs/revelationary/mixin/client/BlockModelsMixin.java @@ -1,6 +1,6 @@ package de.dafuqs.revelationary.mixin.client; -import de.dafuqs.revelationary.revelationary.RevelationHolder; +import de.dafuqs.revelationary.ClientRevelationHolder; import net.minecraft.block.BlockState; import net.minecraft.client.render.block.BlockModels; import net.minecraft.client.render.model.BakedModel; @@ -27,8 +27,8 @@ public class BlockModelsMixin { @Inject(at = @At("HEAD"), method = "getModel", cancellable = true) private void getModel(BlockState blockState, CallbackInfoReturnable callbackInfoReturnable) { - if (RevelationHolder.isCloaked(blockState)) { - BlockState destinationBlockState = RevelationHolder.getCloakTarget(blockState); + if (ClientRevelationHolder.isCloaked(blockState)) { + BlockState destinationBlockState = ClientRevelationHolder.getCloakTarget(blockState); BakedModel overriddenModel = this.models.getOrDefault(destinationBlockState, modelManager.getMissingModel()); callbackInfoReturnable.setReturnValue(overriddenModel); } diff --git a/src/main/java/de/dafuqs/revelationary/mixin/client/ClientAdvancementManagerMixin.java b/src/main/java/de/dafuqs/revelationary/mixin/client/ClientAdvancementManagerMixin.java index 2f626ea..f2f316b 100644 --- a/src/main/java/de/dafuqs/revelationary/mixin/client/ClientAdvancementManagerMixin.java +++ b/src/main/java/de/dafuqs/revelationary/mixin/client/ClientAdvancementManagerMixin.java @@ -1,6 +1,6 @@ package de.dafuqs.revelationary.mixin.client; -import de.dafuqs.revelationary.api.advancements.ClientAdvancements; +import de.dafuqs.revelationary.ClientAdvancements; import net.minecraft.client.network.ClientAdvancementManager; import net.minecraft.network.packet.s2c.play.AdvancementUpdateS2CPacket; import org.spongepowered.asm.mixin.Mixin; diff --git a/src/main/java/de/dafuqs/revelationary/mixin/client/ItemMixin.java b/src/main/java/de/dafuqs/revelationary/mixin/client/ItemMixin.java index 9ada90c..ead2b36 100644 --- a/src/main/java/de/dafuqs/revelationary/mixin/client/ItemMixin.java +++ b/src/main/java/de/dafuqs/revelationary/mixin/client/ItemMixin.java @@ -1,6 +1,6 @@ package de.dafuqs.revelationary.mixin.client; -import de.dafuqs.revelationary.revelationary.RevelationHolder; +import de.dafuqs.revelationary.ClientRevelationHolder; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.item.Item; @@ -20,7 +20,7 @@ public abstract class ItemMixin { @Inject(at = @At("HEAD"), method = "getName(Lnet/minecraft/item/ItemStack;)Lnet/minecraft/text/Text;", cancellable = true) public void getCloakedName(ItemStack stack, CallbackInfoReturnable callbackInfoReturnable) { Item thisItem = (Item) (Object) this; - if (RevelationHolder.isCloaked(thisItem)) { + if (ClientRevelationHolder.isCloaked(thisItem)) { // Get the localized name of the item and scatter it using §k to make it unreadable Language language = Language.getInstance(); LiteralText newText = new LiteralText("§k" + language.get(thisItem.getTranslationKey())); diff --git a/src/main/java/de/dafuqs/revelationary/mixin/client/MinecraftClientMixin.java b/src/main/java/de/dafuqs/revelationary/mixin/client/MinecraftClientMixin.java index e9e6441..afd4068 100644 --- a/src/main/java/de/dafuqs/revelationary/mixin/client/MinecraftClientMixin.java +++ b/src/main/java/de/dafuqs/revelationary/mixin/client/MinecraftClientMixin.java @@ -1,6 +1,6 @@ package de.dafuqs.revelationary.mixin.client; -import de.dafuqs.revelationary.api.advancements.ClientAdvancements; +import de.dafuqs.revelationary.ClientAdvancements; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.Screen; import org.spongepowered.asm.mixin.Mixin;