Skip to content

Commit

Permalink
Merge pull request #132 from AsoDesu/mc/1.20.5
Browse files Browse the repository at this point in the history
Update to Minecraft 1.20.5
  • Loading branch information
AsoDesu authored May 16, 2024
2 parents 53725a4 + 46de921 commit a42613c
Show file tree
Hide file tree
Showing 26 changed files with 190 additions and 270 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
- name: Build with Gradle
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
Expand Down
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '0.13-SNAPSHOT'
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'maven-publish'
}

Expand All @@ -23,6 +23,7 @@ repositories {
maven { url 'https://jitpack.io' }
maven { url "https://maven.terraformersmc.com/releases/" }
maven { url = "https://maven.isxander.dev/releases" }
maven { url = "https://maven.isxander.dev/snapshots" }
maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url = uri("https://maven.noxcrew.com/public") }
exclusiveContent {
Expand All @@ -46,16 +47,15 @@ dependencies {

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modApi("dev.isxander.yacl:yet-another-config-lib-fabric:3.3.2+1.20.4") {
exclude(group: "org.quiltmc.parsers")
modApi("dev.isxander:yet-another-config-lib:3.4.0+1.20.5-fabric") {
exclude(group: "com.twelvemonkeys.common")
exclude(group: "com.twelvemonkeys.imageio")
}

modApi("com.terraformersmc:modmenu:9.0.0-pre.1")
modApi("com.terraformersmc:modmenu:10.0.0-beta.1")

implementation include('com.github.JnCrMx:discord-game-sdk4j:v0.5.5')
modApi("com.noxcrew.noxesium:fabric:1.2.0")
modApi("com.noxcrew.noxesium:fabric:2.0.1-SNAPSHOT")
}

processResources {
Expand All @@ -67,7 +67,7 @@ processResources {
}
}

def targetJavaVersion = 17
def targetJavaVersion = 21
tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.20.3
yarn_mappings=1.20.3+build.1
loader_version=0.15.0
minecraft_version=1.20.5
yarn_mappings=1.20.5+build.1
loader_version=0.15.10
# Mod Properties
mod_version=1.6.8
maven_group=net.asodev
archives_base_name=islandutils
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.91.1+1.20.3
fabric_version=0.97.5+1.20.5
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
7 changes: 5 additions & 2 deletions src/main/java/net/asodev/islandutils/IslandUtilsClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

import com.mojang.blaze3d.platform.InputConstants;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.noxcrew.noxesium.network.NoxesiumPackets;
import com.noxcrew.noxesium.network.clientbound.ClientboundMccGameStatePacket;
import com.noxcrew.noxesium.network.clientbound.ClientboundMccServerPacket;
import net.asodev.islandutils.discord.DiscordPresenceUpdator;
import net.asodev.islandutils.modules.DisguiseKeybind;
import net.asodev.islandutils.modules.Packets;
import net.asodev.islandutils.modules.NoxesiumIntegration;
import net.asodev.islandutils.modules.plobby.PlobbyFeatures;
import net.asodev.islandutils.modules.plobby.PlobbyJoinCodeCopy;
import net.asodev.islandutils.modules.splits.SplitManager;
Expand Down Expand Up @@ -44,7 +47,6 @@ public void onInitializeClient() {
GLFW.GLFW_KEY_N,
"category.islandutils.keys"
));
Packets.init();
SplitManager.init();
DisguiseKeybind.registerDisguiseInput();
PlobbyFeatures.registerEvents();
Expand All @@ -55,6 +57,7 @@ public void onInitializeClient() {
if (Utils.isLunarClient()) {
SplitUI.setupFallbackRenderer();
}
new NoxesiumIntegration().init();
}

public static void onJoinMCCI(boolean isProduction) {
Expand Down
22 changes: 12 additions & 10 deletions src/main/java/net/asodev/islandutils/mixins/ItemIDMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.core.component.DataComponentHolder;
import net.minecraft.core.component.DataComponents;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.ChestMenu;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.component.CustomData;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -29,11 +33,7 @@
import java.util.List;

@Mixin(ItemStack.class)
public abstract class ItemIDMixin {

@Shadow public abstract boolean hasTag();

@Shadow public abstract @Nullable CompoundTag getTagElement(String string);
public abstract class ItemIDMixin implements DataComponentHolder {

@Inject(
method = "getTooltipLines",
Expand All @@ -44,12 +44,12 @@ public abstract class ItemIDMixin {
),
locals = LocalCapture.CAPTURE_FAILEXCEPTION
)
private void addTooltipLines(@Nullable Player player, TooltipFlag tooltipFlag, CallbackInfoReturnable<List<Component>> cir, List<Component> list) {
private void addTooltipLines(Item.TooltipContext tooltipContext, @Nullable Player player, TooltipFlag tooltipFlag, CallbackInfoReturnable<List<Component>> cir, List list) {
if (!MccIslandState.isOnline() || !IslandOptions.getMisc().isDebugMode()) return;
if (!InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), InputConstants.KEY_LCONTROL)) return;

MutableComponent toAppend = Component.empty();
if (this.hasTag()) tryAddCustomItemID(toAppend); // Append MCCI Custom Item ID
if (this.has(DataComponents.CUSTOM_DATA)) tryAddCustomItemID(toAppend); // Append MCCI Custom Item ID
if (Minecraft.getInstance().screen != null) tryAddSlotNumber(toAppend); // Append Slot Number

if (!toAppend.getSiblings().isEmpty()) { // Add to tooltip lines if not empty
Expand All @@ -59,10 +59,12 @@ private void addTooltipLines(@Nullable Player player, TooltipFlag tooltipFlag, C

@Unique
private void tryAddCustomItemID(MutableComponent toAppend) {
CompoundTag publicBukkitValues = this.getTagElement("PublicBukkitValues");
if (publicBukkitValues == null) return;
CustomData customData = this.get(DataComponents.CUSTOM_DATA);
if (customData == null) return;
CompoundTag tag = customData.getUnsafe();
CompoundTag publicBukkitValues = tag.getCompound("PublicBukkitValues");
String customItemId = publicBukkitValues.getString("mcc:custom_item_id");
if (customItemId.equals("")) return;
if (customItemId.isEmpty()) return;
toAppend.append(Component.literal(customItemId).withStyle(ChatFormatting.AQUA));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ private void renderTooltip(GuiGraphics guiGraphics, int i, int j, CallbackInfo c
@Inject(method = "renderSlot", at = @At("TAIL"))
private void renderSlot(GuiGraphics guiGraphics, Slot slot, CallbackInfo ci) {
if (!MccIslandState.isOnline()) return;
ItemStack slotItem = slot.getItem();

CompoundTag slotTag = slotItem.getTag();
if (slotTag == null) return;
if (!slot.hasItem()) return;

boolean shouldRender = false;

Expand All @@ -93,7 +90,6 @@ private void renderSlot(GuiGraphics guiGraphics, Slot slot, CallbackInfo ci) {

@Inject(method = "render", at = @At("TAIL"))
private void render(GuiGraphics guiGraphics, int i, int j, float f, CallbackInfo ci) {

if (hoveredSlot != null && hoveredSlot.hasItem()) {
ItemStack hoveredItem = hoveredSlot.getItem();
if (IslandOptions.getCosmetics().isShowOnHover()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.*;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import org.jetbrains.annotations.Nullable;
Expand All @@ -16,7 +17,9 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;

import static net.asodev.islandutils.util.ChatUtils.iconsFontStyle;

Expand All @@ -34,14 +37,10 @@ public class PreviewTutorialMixin {

@Inject(
method = "getTooltipLines",
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;shouldShowInTooltip(ILnet/minecraft/world/item/ItemStack$TooltipPart;)Z", shift = At.Shift.BEFORE),
slice = @Slice(
from = @At(value = "INVOKE", target = "Lnet/minecraft/network/chat/ComponentUtils;mergeStyles(Lnet/minecraft/network/chat/MutableComponent;Lnet/minecraft/network/chat/Style;)Lnet/minecraft/network/chat/MutableComponent;"),
to = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;getAttributeModifiers(Lnet/minecraft/world/entity/EquipmentSlot;)Lcom/google/common/collect/Multimap;")
),
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;addAttributeTooltips(Ljava/util/function/Consumer;Lnet/minecraft/world/entity/player/Player;)V", shift = At.Shift.BEFORE),
locals = LocalCapture.CAPTURE_FAILEXCEPTION
)
private void injectedTooltipLines(@Nullable Player player, TooltipFlag tooltipFlag, CallbackInfoReturnable<List<Component>> cir, List<Component> list, MutableComponent mutableComponent) {
private void injectedTooltipLines(Item.TooltipContext tooltipContext, @Nullable Player player, TooltipFlag tooltipFlag, CallbackInfoReturnable<List<Component>> cir, List<Component> list, MutableComponent mutableComponent, Consumer consumer) {
if (CosmeticState.getType((ItemStack)(Object)this) == null) return;
if (!IslandOptions.getCosmetics().isShowPlayerPreview()) return;
list.add(previewComponent);
Expand Down
89 changes: 7 additions & 82 deletions src/main/java/net/asodev/islandutils/mixins/cosmetics/UIMixin.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package net.asodev.islandutils.mixins.cosmetics;

import com.mojang.blaze3d.platform.Lighting;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import net.asodev.islandutils.mixins.accessors.WalkAnimStateAccessor;
import net.asodev.islandutils.modules.cosmetics.CosmeticUI;
import net.asodev.islandutils.options.IslandOptions;
import net.asodev.islandutils.options.categories.CosmeticsOptions;
import net.asodev.islandutils.state.MccIslandState;
Expand All @@ -12,24 +10,16 @@
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.gui.screens.inventory.ContainerScreen;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.ChestMenu;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import org.joml.Quaternionf;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.UUID;

import static net.asodev.islandutils.modules.cosmetics.CosmeticState.applyColor;
import static net.asodev.islandutils.modules.cosmetics.CosmeticState.isCosmeticMenu;

Expand All @@ -45,7 +35,8 @@ public void renderBg(GuiGraphics guiGraphics, float f, int i, int j, CallbackInf

CosmeticsOptions options = IslandOptions.getCosmetics();
if (!options.isShowPlayerPreview()) return;
if (options.isShowOnOnlyCosmeticMenus() && !CosmeticState.isCosmeticMenu(this.menu)) return;
boolean isCosmeticMenu = false;
if (options.isShowOnOnlyCosmeticMenus() && !(isCosmeticMenu = CosmeticState.isCosmeticMenu(this))) return;

checkInspect();

Expand All @@ -62,7 +53,7 @@ public void renderBg(GuiGraphics guiGraphics, float f, int i, int j, CallbackInf
if (CosmeticState.inspectingPlayer == null || CosmeticState.inspectingPlayer.getUUID() == Minecraft.getInstance().player.getUUID()) {
hatSlot = CosmeticState.hatSlot.getContents().getItem(this.menu);
accSlot = CosmeticState.accessorySlot.getContents().getItem(this.menu);
if (isCosmeticMenu(this.menu)) {
if (isCosmeticMenu) {
applyColor(hatSlot);
applyColor(accSlot);

Expand Down Expand Up @@ -91,7 +82,8 @@ public void renderBg(GuiGraphics guiGraphics, float f, int i, int j, CallbackInf
int x = (this.width - this.imageWidth) / 4;
int y = (this.height / 2) + size;

this.renderPlayerInInventory(
CosmeticUI.renderPlayerInInventory(
guiGraphics,
x, // x
y, // y
size , // size
Expand Down Expand Up @@ -119,74 +111,7 @@ public void renderBg(GuiGraphics guiGraphics, float f, int i, int j, CallbackInf
guiGraphics.renderItem(this.minecraft.player, accSlot, itemPos, y+2, x + y * this.imageWidth);
}

// don't ask what this code does
// the answer is "it renders the player, it works, no touch."
private void renderPlayerInInventory(int x, int y, int size, LivingEntity livingEntity) {
float yRot = CosmeticState.yRot;
float xRot = (float)Math.atan(CosmeticState.xRot / 40.0f);;

PoseStack poseStack = RenderSystem.getModelViewStack();
poseStack.pushPose();
poseStack.translate((double)x, (double)y, 1050.0);
poseStack.scale(1.0F, 1.0F, -1.0F);
RenderSystem.applyModelViewMatrix();
PoseStack poseStack2 = new PoseStack();
poseStack2.translate(0.0, 0.0, 1000.0);
poseStack2.scale((float)size, (float)size, (float)size);
Quaternionf quaternionf = (new Quaternionf()).rotateZ(3.1415927F);
Quaternionf quaternionf2 = (new Quaternionf()).rotateX(xRot * 20.0F * 0.017453292F);
quaternionf.mul(quaternionf2);
poseStack2.mulPose(quaternionf);
float m = livingEntity.yBodyRot;
float n = livingEntity.getYRot();
float o = livingEntity.getXRot();
float p = livingEntity.yHeadRotO;
float q = livingEntity.yHeadRot;
livingEntity.yBodyRot = yRot;
livingEntity.setYRot(yRot);
livingEntity.yHeadRot = livingEntity.yBodyRot;
livingEntity.yHeadRotO = livingEntity.yBodyRot;

livingEntity.setXRot(-xRot * 20F);

Lighting.setupForEntityInInventory();
EntityRenderDispatcher entityRenderDispatcher = Minecraft.getInstance().getEntityRenderDispatcher();
entityRenderDispatcher.setRenderShadow(false);
MultiBufferSource.BufferSource bufferSource = Minecraft.getInstance().renderBuffers().bufferSource();
RenderSystem.runAsFancy(() -> {
entityRenderDispatcher.render(livingEntity, 0.0, 0.0, 0.0, 0.0F, 1.0F, poseStack2, bufferSource, 15728880);
});
bufferSource.endBatch();
entityRenderDispatcher.setRenderShadow(true);
livingEntity.yBodyRot = m;
livingEntity.setYRot(n);
livingEntity.setXRot(o);
livingEntity.yHeadRotO = p;
livingEntity.yHeadRot = q;
poseStack.popPose();
RenderSystem.applyModelViewMatrix();
Lighting.setupFor3DItems();
}

private void checkInspect() {
// 11 - Head
// 9 - Hat
// 18 - Accessory
Slot inspectHeadSlot = this.menu.getSlot(11);
Slot inspectHatSlot = this.menu.getSlot(9);
boolean isInspectHead = inspectHeadSlot.hasItem() && inspectHeadSlot.getItem().is(Items.PLAYER_HEAD);
boolean isInspectHat = inspectHeadSlot.hasItem() &&
(CosmeticState.getType(inspectHatSlot.getItem()) != null) || (inspectHatSlot.getItem().getDisplayName().getString().contains("Hat"));
if (isInspectHead && isInspectHat) {
try {
Player player = null;
if (CosmeticState.inspectingPlayer == null) {
UUID uuid = inspectHeadSlot.getItem().getTag().getCompound("SkullOwner").getUUID("Id");
player = Minecraft.getInstance().level.getPlayerByUUID(uuid);
CosmeticState.inspectingPlayer = player;
}
if (player == null) return;
} catch (Exception ignored) {}
}
// TODO: Readd inspect menu support
}
}

This file was deleted.

Loading

0 comments on commit a42613c

Please sign in to comment.