Skip to content

Commit

Permalink
Merge branch 'SkyblockerMod:master' into corpses
Browse files Browse the repository at this point in the history
  • Loading branch information
Fluboxer authored Sep 26, 2024
2 parents 05ccb86 + f4714fb commit 063995c
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 34 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ occlusionculling_version = 0.0.8-SNAPSHOT
## neu repoparser (https://repo.nea.moe/#/releases/moe/nea/neurepoparser/)
repoparser_version = 1.6.0
## Networth Calculator (https://github.com/AzureAaron/networth-calculator)
networth_calculator_version = 1.0.2
networth_calculator_version = 1.0.4
## Legacy Item DFU (https://github.com/AzureAaron/legacy-item-dfu)
legacy_item_dfu_version = 1.0.0+1.21.1
legacy_item_dfu_version = 1.0.1+1.21.1

# Other Libraries
## JGit (https://mvnrepository.com/artifact/org.eclipse.jgit/org.eclipse.jgit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ public class ItemFixerUpper {
private final static Int2ObjectMap<String> SPAWN_EGG_VARIANTS = Int2ObjectMaps.unmodifiable(new Int2ObjectOpenHashMap<>(Map.ofEntries(
//This entry 0 is technically not right but Hypixel decided to make it polar bear so well we use that
Map.entry(0, "minecraft:polar_bear_spawn_egg"),
//This entry 4 does not actually exist, Hypixel uses it as a placeholder for elder guardians
Map.entry(4, "minecraft:elder_guardian_spawn_egg"),
Map.entry(50, "minecraft:creeper_spawn_egg"),
Map.entry(51, "minecraft:skeleton_spawn_egg"),
Map.entry(52, "minecraft:spider_spawn_egg"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static ItemStack fromNEUItem(NEUItem item) {
UUID uuid = UUID.fromString(skullUuid.group(1));
String textureValue = skullTexture.group(1);

stack.set(DataComponentTypes.PROFILE, new ProfileComponent(Optional.of(internalName), Optional.of(uuid), ItemUtils.propertyMapWithTexture(textureValue)));
stack.set(DataComponentTypes.PROFILE, new ProfileComponent(Optional.of(internalName.substring(0, Math.min(internalName.length(), 15))), Optional.of(uuid), ItemUtils.propertyMapWithTexture(textureValue)));
}

// add leather armor dye color
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
import com.google.gson.JsonParser;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.util.UndashedUuid;

import de.hysky.skyblocker.SkyblockerMod;
import de.hysky.skyblocker.annotations.Init;
import de.hysky.skyblocker.mixins.accessors.SkullBlockEntityAccessor;
import de.hysky.skyblocker.skyblock.profileviewer.collections.CollectionsPage;
import de.hysky.skyblocker.skyblock.profileviewer.dungeons.DungeonsPage;
import de.hysky.skyblocker.skyblock.profileviewer.inventory.InventoryPage;
Expand All @@ -22,6 +23,7 @@
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.block.entity.SkullBlockEntity;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
Expand Down Expand Up @@ -146,35 +148,46 @@ private CompletableFuture<Void> fetchPlayerData(String username) {
}
});

CompletableFuture<Void> minecraftProfileFuture = SkullBlockEntityAccessor.invokeFetchProfileByName(username).thenAccept(profile -> {
this.playerName = profile.get().getName();
entity = new OtherClientPlayerEntity(MinecraftClient.getInstance().world, profile.get()) {
@Override
public SkinTextures getSkinTextures() {
PlayerListEntry playerListEntry = new PlayerListEntry(profile.get(), false);
return playerListEntry.getSkinTextures();
}
CompletableFuture<Void> playerFuture = CompletableFuture.runAsync(() -> {
String stringifiedUuid = ApiUtils.name2Uuid(username);

@Override
public boolean isPartVisible(PlayerModelPart modelPart) {
return !(modelPart.getName().equals(PlayerModelPart.CAPE.getName()));
}
if (stringifiedUuid.isEmpty()) {
this.playerName = "User not found";
this.profileNotFound = true;
}

UUID uuid = UndashedUuid.fromStringLenient(stringifiedUuid);

//The fetch by name method can sometimes fail in weird cases and return a fake offline player
SkullBlockEntity.fetchProfileByUuid(uuid).thenAccept(profile -> {
this.playerName = profile.get().getName();
entity = new OtherClientPlayerEntity(MinecraftClient.getInstance().world, profile.get()) {
@Override
public SkinTextures getSkinTextures() {
PlayerListEntry playerListEntry = new PlayerListEntry(profile.get(), false);
return playerListEntry.getSkinTextures();
}

@Override
public boolean isInvisibleTo(PlayerEntity player) {
return true;
}
};
entity.setCustomNameVisible(false);
}).exceptionally(ex -> {
this.playerName = "User not found";
this.profileNotFound = true;
return null;
});
@Override
public boolean isPartVisible(PlayerModelPart modelPart) {
return !(modelPart.getName().equals(PlayerModelPart.CAPE.getName()));
}

return CompletableFuture.allOf(profileFuture, minecraftProfileFuture);
}
@Override
public boolean isInvisibleTo(PlayerEntity player) {
return true;
}
};
entity.setCustomNameVisible(false);
}).exceptionally(ex -> {
this.playerName = "User not found";
this.profileNotFound = true;
return null;
}).join();
});

return CompletableFuture.allOf(profileFuture, playerFuture);
}

public void onNavButtonClick(ProfileViewerNavButton clickedButton) {
if (profileViewerPages[activePage] != null) profileViewerPages[activePage].markWidgetsAsInvisible();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/hysky/skyblocker/utils/ItemUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ public static IntIntPair getDurability(@NotNull ItemStack stack) {
if (stack.getSkyblockId().equals("PICKONIMBUS")) {
int pickonimbusDurability = customData.getInt("pickonimbus_durability");

return IntIntPair.of(customData.contains("pickonimbus_durability") ? pickonimbusDurability : 5000, 5000);
return IntIntPair.of(customData.contains("pickonimbus_durability") ? pickonimbusDurability : 2000, 2000);
}

String drillFuel = Formatting.strip(getLoreLineIf(stack, FUEL_PREDICATE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import de.hysky.skyblocker.events.SkyblockEvents;
import de.hysky.skyblocker.utils.ApiAuthentication;
import de.hysky.skyblocker.utils.Http;
import net.minecraft.util.Util;
import org.slf4j.Logger;

import java.net.URI;
Expand Down Expand Up @@ -130,8 +129,7 @@ public void onError(WebSocket webSocket, Throwable error) {
}

private void handleWholeMessage(List<CharSequence> parts) {
StringBuilder builder = Util.make(new StringBuilder(), sb -> parts.forEach(sb::append));
String message = builder.toString();
String message = String.join("", parts);

if (Debug.debugEnabled() && Debug.webSocketDebug()) LOGGER.info("[Skyblocker WebSocket] Received Message: {}", message);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static void sendMessage(Service service, Message<? extends Message<?>> me
* Useful for sending simple state updates with an optional message
*/
static void sendSimple(Type type, Service service, String serverId, Optional<Message<? extends Message<?>>> message) {
send(type, service, serverId, message.isPresent() ? Optional.of(encodeMessage(message.get())) : Optional.empty());
send(type, service, serverId, message.map(WsMessageHandler::encodeMessage));
}

private static void send(Type type, Service service, String serverId, Optional<Dynamic<?>> message) {
Expand Down

0 comments on commit 063995c

Please sign in to comment.