Skip to content

Commit

Permalink
api cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
DaFuqs committed Jun 14, 2022
1 parent bed6fd8 commit d9b06b1
Show file tree
Hide file tree
Showing 17 changed files with 30 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -29,8 +28,8 @@ public static void onClientPacket(@NotNull AdvancementUpdateS2CPacket packet) {
Set<Identifier> doneAdvancements = getDoneAdvancements(packet);
Set<Identifier> 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);
Expand Down Expand Up @@ -77,7 +76,7 @@ public static boolean hasDone(Identifier identifier) {

public static void playerLogout() {
RevelationRegistry.addRevelationAwares();
RevelationHolder.cloakAll();
ClientRevelationHolder.cloakAll();
receivedFirstAdvancementPacket = false;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -19,7 +19,7 @@
import java.util.Set;

@Environment(EnvType.CLIENT)
public class RevelationHolder {
public class ClientRevelationHolder {

public static List<RevealingCallback> callbacks = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.dafuqs.revelationary.revelationary;
package de.dafuqs.revelationary;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/de/dafuqs/revelationary/Revelationary.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.dafuqs.revelationary.api.advancements;

import de.dafuqs.revelationary.ClientAdvancements;
import net.minecraft.util.Identifier;

import java.util.Set;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -12,11 +12,11 @@ public interface RevealingCallback {
void trigger(Set<Identifier> advancements, Set<Block> blocks, Set<Item> 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);
}

}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<BakedModel> 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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -16,7 +16,7 @@ public class BlockClientMixin {
@Inject(method = "getName()Lnet/minecraft/text/MutableText;", at = @At("RETURN"), cancellable = true)
private void getCgraloakedName(CallbackInfoReturnable<MutableText> 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()));
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -27,8 +27,8 @@ public class BlockModelsMixin {

@Inject(at = @At("HEAD"), method = "getModel", cancellable = true)
private void getModel(BlockState blockState, CallbackInfoReturnable<BakedModel> 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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<Text> 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()));
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit d9b06b1

Please sign in to comment.