Skip to content

Commit

Permalink
backport to 1.20.1
Browse files Browse the repository at this point in the history
  • Loading branch information
fayer3 committed Feb 28, 2024
1 parent e27cbd3 commit 21b16f4
Show file tree
Hide file tree
Showing 65 changed files with 311 additions and 967 deletions.
5 changes: 0 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,6 @@ allprojects {
}
}

maven {
name = "neoforge"
url = "https://maven.neoforged.net/releases/"
}

maven { url = "https://hephaestus.dev/release" }
maven { url = "https://cursemaven.com" }
maven { url = "https://maven.parchmentmc.org" }
Expand Down
14 changes: 7 additions & 7 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@ dependencies {
modApi("dev.architectury:architectury-fabric:${rootProject.architectury_version}") { exclude group: "net.fabricmc" exclude group: "net.fabricmc.fabric-api" }

// for sodium compat
modCompileOnly "maven.modrinth:sodium:mc1.20.2-0.5.5"
modCompileOnly "maven.modrinth:sodium:mc1.20.1-0.5.8"

// for iris compat
modCompileOnly "maven.modrinth:iris:1.6.14+1.20.2"
modCompileOnly "maven.modrinth:iris:1.6.17+1.20.1"

// for REI compat
modCompileOnly("me.shedaniel:RoughlyEnoughItems-fabric:13.0.685") { exclude group: "net.fabricmc" exclude group: "net.fabricmc.fabric-api" exclude group: "dev.architectury" }
modCompileOnly("me.shedaniel:RoughlyEnoughItems-fabric:12.0.684") { exclude group: "net.fabricmc" exclude group: "net.fabricmc.fabric-api" exclude group: "dev.architectury" }

// for Pehkui compat
modApi("com.github.Virtuoel:Pehkui:3.7.12") { exclude group: "net.fabricmc" exclude group: "net.fabricmc.fabric-api" }

// other mods
modCompileOnly "maven.modrinth:dynamic-fps:3.4.1"
// modCompileOnly("com.simibubi.create:create-fabric-1.19.2:0.5.0.i-969+1.19.2")
// modCompileOnly "maven.modrinth:lithium:mc1.20.2-0.12.0"
// modCompileOnly "maven.modrinth:indium:1.0.28+mc1.20.4"
modCompileOnly "maven.modrinth:resolution-control-plus:3.0.0"
// modCompileOnly "maven.modrinth:lithium:mc1.20.1-0.11.2"
// modCompileOnly "maven.modrinth:indium:1.0.30+mc1.20.4"
modCompileOnly "maven.modrinth:resolution-control-plus:1.20-3.0.0"
modCompileOnly "maven.modrinth:better-combat:1.8.3+1.20.1-fabric"

// for immersive portals compat
modCompileOnly('com.github.iPortalTeam.ImmersivePortalsMod:imm_ptl_core:v4.1.4-mc1.20.2') { transitive false }
modCompileOnly('com.github.iPortalTeam.ImmersivePortalsMod:imm_ptl_core:v3.3.7-mc1.20.1') { transitive false }

//for epic fight compat
modCompileOnly("maven.modrinth:epic-fight:20.6.3")
Expand Down
6 changes: 0 additions & 6 deletions common/src/main/java/org/vivecraft/client/Xplat.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import com.mojang.blaze3d.pipeline.RenderTarget;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockAndTintGetter;
Expand Down Expand Up @@ -93,8 +91,4 @@ static BiomeSpecialEffects getBiomeEffects(Biome biome) {
static double getItemEntityReach(double baseRange, ItemStack itemStack, EquipmentSlot slot) {
return 0;
}

@ExpectPlatform
static void addNetworkChannel(ClientPacketListener listener, ResourceLocation resourceLocation) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public void render(GuiGraphics guiGraphics, int pMouseX, int pMouseY, float pPar
}
}

super.render(guiGraphics, pMouseX, pMouseY, pPartialTicks);
this.renderBackground(guiGraphics);

if (this.visibleList != null) {
this.visibleList.render(guiGraphics, pMouseX, pMouseY, pPartialTicks);
Expand All @@ -207,6 +207,7 @@ public void render(GuiGraphics guiGraphics, int pMouseX, int pMouseY, float pPar
this.btnDone.visible = this.drawDefaultButtons;
}

super.render(guiGraphics, pMouseX, pMouseY, pPartialTicks);
renderTooltip(guiGraphics, pMouseX, pMouseY);
}

Expand Down Expand Up @@ -242,12 +243,12 @@ public boolean mouseDragged(double pMouseX, double p_94741_, int pMouseY, double
}

@Override
public boolean mouseScrolled(double x, double y, double scrollAmountX, double scrollAmountY) {
public boolean mouseScrolled(double x, double y, double scrollAmountY) {
if (this.visibleList != null) {
this.visibleList.mouseScrolled(x, y, scrollAmountX, scrollAmountY);
this.visibleList.mouseScrolled(x, y, scrollAmountY);
}

return super.mouseScrolled(x, y, scrollAmountX, scrollAmountY);
return super.mouseScrolled(x, y, scrollAmountY);
}

public boolean keyPressed(int pKeyCode, int pScanCode, int pModifiers) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected void init() {

@Override
public void render(@NotNull GuiGraphics guiGraphics, int i, int j, float f) {
this.renderBackground(guiGraphics, i, j, f);
this.renderBackground(guiGraphics);
guiGraphics.drawCenteredString(this.font, this.title, this.width / 2, 15, 16777215);

super.render(guiGraphics, i, j, f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected void init() {

@Override
public void render(@NotNull GuiGraphics guiGraphics, int i, int j, float f) {
this.renderBackground(guiGraphics, i, j, f);
this.renderBackground(guiGraphics);
guiGraphics.drawCenteredString(this.font, this.title, this.width / 2, 15, 16777215);
super.render(guiGraphics, i, j, f);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected void init() {

@Override
public void render(@NotNull GuiGraphics guiGraphics, int i, int j, float f) {
this.renderBackground(guiGraphics, i, j, f);
this.renderBackground(guiGraphics);
guiGraphics.drawCenteredString(this.font, this.title, this.width / 2, 15, 16777215);
super.render(guiGraphics, i, j, f);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,15 @@ public void onClose() {
this.minecraft.setScreen(lastScreen);
}

@Override
public void renderBackground(GuiGraphics guiGraphics, int i, int j, float f) {
this.renderDirtBackground(guiGraphics);
}

@Override
public void render(GuiGraphics guiGraphics, int i, int j, float f) {
if (reinit) {
init();
reinit = false;
}
super.render(guiGraphics, i, j, f);
this.renderBackground(guiGraphics);
list.render(guiGraphics, i, j, f);
guiGraphics.drawCenteredString(this.font, this.title, this.width / 2, 8, 0xFFFFFF);
super.render(guiGraphics, i, j, f);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void init() {
}

public void render(GuiGraphics guiGraphics, int pMouseX, int pMouseY, float pPartialTicks) {
this.renderBackground(guiGraphics, pMouseX, pMouseY, pPartialTicks);
this.renderBackground(guiGraphics);
guiGraphics.drawCenteredString(this.font, "Quick Commands", this.width / 2, 16, 16777215);
super.render(guiGraphics, pMouseX, pMouseY, pPartialTicks);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ public boolean mouseReleased(double pMouseX, double p_94754_, int pMouseY) {
}
}

public boolean mouseScrolled(double x, double y, double scrollAmountX, double scrollAmountY) {
if (this.btnDelete.mouseScrolled(x, y, scrollAmountX, scrollAmountY)) {
public boolean mouseScrolled(double x, double y, double scrollAmountY) {
if (this.btnDelete.mouseScrolled(x, y, scrollAmountY)) {
return true;
} else {
return this.txt.mouseScrolled(x, y, scrollAmountX, scrollAmountY) || super.mouseScrolled(x, y, scrollAmountX, scrollAmountY);
return this.txt.mouseScrolled(x, y, scrollAmountY) || super.mouseScrolled(x, y, scrollAmountY);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private void setCurrentLineFromYPos(double y) {
}

@Override
public boolean mouseScrolled(double x, double y, double scrollAmountX, double scrollAmountY) {
public boolean mouseScrolled(double x, double y, double scrollAmountY) {
if (scrollAmountY < 0.0 && currentLine < scrollSteps) {
currentLine++;
} else if (scrollAmountY > 0.0 && currentLine > 0) {
Expand All @@ -156,7 +156,7 @@ public boolean mouseScrolled(double x, double y, double scrollAmountX, double sc
@Override
public boolean keyPressed(int key, int scancode, int mods) {
if (key == GLFW.GLFW_KEY_UP || key == GLFW.GLFW_KEY_DOWN) {
if (mouseScrolled(0, 0, 0, key == GLFW.GLFW_KEY_UP ? 1 : -1)) {
if (mouseScrolled(0, 0, key == GLFW.GLFW_KEY_UP ? 1 : -1)) {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket;
import net.minecraft.network.protocol.game.ServerboundCustomPayloadPacket;
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Pose;
Expand All @@ -18,7 +18,6 @@
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.phys.Vec3;
import org.vivecraft.client.VRPlayersClient;
import org.vivecraft.client.Xplat;
import org.vivecraft.client_vr.ClientDataHolderVR;
import org.vivecraft.client_vr.VRState;
import org.vivecraft.client_vr.gameplay.VRPlayer;
Expand All @@ -29,7 +28,6 @@
import org.vivecraft.common.network.BufferSerializable;
import org.vivecraft.common.network.CommonNetworkHelper;
import org.vivecraft.common.network.VrPlayerState;
import org.vivecraft.common.network.packets.VivecraftDataPacket;

import java.util.UUID;

Expand All @@ -54,11 +52,17 @@ public class ClientNetworking {
public static boolean needsReset = true;

public static ServerboundCustomPayloadPacket getVivecraftClientPacket(CommonNetworkHelper.PacketDiscriminators command, byte[] payload) {
return new ServerboundCustomPayloadPacket(new VivecraftDataPacket(command, payload));
FriendlyByteBuf buffer = new FriendlyByteBuf(Unpooled.buffer());
buffer.writeByte(command.ordinal());
buffer.writeBytes(payload);
return new ServerboundCustomPayloadPacket(CommonNetworkHelper.CHANNEL, buffer);
}

public static ServerboundCustomPayloadPacket createVRActivePacket(boolean vrActive) {
return new ServerboundCustomPayloadPacket(new VivecraftDataPacket(CommonNetworkHelper.PacketDiscriminators.IS_VR_ACTIVE, new byte[]{(byte) (vrActive ? 1 : 0)}));
FriendlyByteBuf buffer = new FriendlyByteBuf(Unpooled.buffer());
buffer.writeByte(CommonNetworkHelper.PacketDiscriminators.IS_VR_ACTIVE.ordinal());
buffer.writeBoolean(vrActive);
return new ServerboundCustomPayloadPacket(CommonNetworkHelper.CHANNEL, buffer);
}

public static void resetServerSettings() {
Expand All @@ -83,8 +87,10 @@ public static void resetServerSettings() {
}

public static void sendVersionInfo() {
//Minecraft.getInstance().getConnection().send(new ServerboundCustomPayloadPacket(new ChannelRegisterPacket(CommonNetworkHelper.CHANNEL.toString())));
Xplat.addNetworkChannel(Minecraft.getInstance().getConnection(), CommonNetworkHelper.CHANNEL);
String s = CommonNetworkHelper.CHANNEL.toString();
FriendlyByteBuf friendlybytebuf = new FriendlyByteBuf(Unpooled.buffer());
friendlybytebuf.writeBytes(s.getBytes());
Minecraft.getInstance().getConnection().send(new ServerboundCustomPayloadPacket(new ResourceLocation("minecraft:register"), friendlybytebuf));
// send version string, with currently running
Minecraft.getInstance().getConnection().send(getVivecraftClientPacket(CommonNetworkHelper.PacketDiscriminators.VERSION,
(CommonDataHolder.getInstance().versionIdentifier + (VRState.vrRunning ? " VR" : " NONVR")
Expand Down Expand Up @@ -146,18 +152,33 @@ private static byte[] serializeToArray(BufferSerializable object, byte[] additio
}

public static ServerboundCustomPayloadPacket createVrPlayerStatePacket(VrPlayerState vrPlayerState) {
return new ServerboundCustomPayloadPacket(new VivecraftDataPacket(CommonNetworkHelper.PacketDiscriminators.VR_PLAYER_STATE, serializeToArray(vrPlayerState, null)));
FriendlyByteBuf buffer = new FriendlyByteBuf(Unpooled.buffer());
buffer.writeByte(CommonNetworkHelper.PacketDiscriminators.VR_PLAYER_STATE.ordinal());
vrPlayerState.serialize(buffer);
return new ServerboundCustomPayloadPacket(CommonNetworkHelper.CHANNEL, buffer);
}

public static void sendLegacyPackets(ClientPacketListener connection, VrPlayerState vrPlayerState) {
// left controller packet
connection.send(new ServerboundCustomPayloadPacket(new VivecraftDataPacket(CommonNetworkHelper.PacketDiscriminators.CONTROLLER0DATA, serializeToArray(vrPlayerState.controller0(), new byte[]{(byte) (ClientDataHolderVR.getInstance().vrSettings.reverseHands ? 1 : 0)}))));
FriendlyByteBuf controller0Buffer = new FriendlyByteBuf(Unpooled.buffer());
controller0Buffer.writeByte(CommonNetworkHelper.PacketDiscriminators.CONTROLLER0DATA.ordinal());
controller0Buffer.writeBoolean(ClientDataHolderVR.getInstance().vrSettings.reverseHands);
vrPlayerState.controller0().serialize(controller0Buffer);
connection.send(new ServerboundCustomPayloadPacket(CommonNetworkHelper.CHANNEL, controller0Buffer));

// right controller packet
connection.send(new ServerboundCustomPayloadPacket(new VivecraftDataPacket(CommonNetworkHelper.PacketDiscriminators.CONTROLLER0DATA, serializeToArray(vrPlayerState.controller1(), new byte[]{(byte) (ClientDataHolderVR.getInstance().vrSettings.reverseHands ? 1 : 0)}))));
FriendlyByteBuf controller1Buffer = new FriendlyByteBuf(Unpooled.buffer());
controller1Buffer.writeByte(CommonNetworkHelper.PacketDiscriminators.CONTROLLER1DATA.ordinal());
controller1Buffer.writeBoolean(ClientDataHolderVR.getInstance().vrSettings.reverseHands);
vrPlayerState.controller1().serialize(controller1Buffer);
connection.send(new ServerboundCustomPayloadPacket(CommonNetworkHelper.CHANNEL, controller1Buffer));

// hmd packet
connection.send(new ServerboundCustomPayloadPacket(new VivecraftDataPacket(CommonNetworkHelper.PacketDiscriminators.CONTROLLER0DATA, serializeToArray(vrPlayerState.hmd(), new byte[]{(byte) (ClientDataHolderVR.getInstance().vrSettings.seated ? 1 : 0)}))));
FriendlyByteBuf headBuffer = new FriendlyByteBuf(Unpooled.buffer());
headBuffer.writeByte(CommonNetworkHelper.PacketDiscriminators.HEADDATA.ordinal());
headBuffer.writeBoolean(ClientDataHolderVR.getInstance().vrSettings.seated);
vrPlayerState.hmd().serialize(headBuffer);
connection.send(new ServerboundCustomPayloadPacket(CommonNetworkHelper.CHANNEL, headBuffer));
}

public static boolean isThirdPersonItems() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ public static Vec3 applyGUIModelView(RenderPass currentPass, PoseStack pMatrixSt
guirot = Matrix4f.multiply(guirot, Matrix4f.rotationY(0.9424779F * (float) i));
guipos = RenderHelper.getControllerRenderPos(1);
dh.vr.hudPopup = true;
boolean flag = mc.player.getSkin().model().id().equals("slim");
boolean flag = mc.player.getModelName().equals("slim");
scale = 0.4F;
guilocal = new Vec3((float) i * -0.136F * dh.vrPlayer.vrdata_world_render.worldScale, (flag ? 0.13D : 0.12D) * (double) dh.vrPlayer.vrdata_world_render.worldScale, 0.06D * (double) dh.vrPlayer.vrdata_world_render.worldScale);
guirot = Matrix4f.multiply(guirot, Matrix4f.rotationY(((float) Math.PI / 5F) * (float) i));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import net.minecraft.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket;
import net.minecraft.network.protocol.game.ServerboundCustomPayloadPacket;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.LivingEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.contents.TranslatableContents;
import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket;
import net.minecraft.network.protocol.game.ServerboundCustomPayloadPacket;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.item.ItemStack;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket;
import net.minecraft.network.protocol.game.ServerboundCustomPayloadPacket;
import net.minecraft.world.entity.Pose;
import org.vivecraft.client.Xplat;
import org.vivecraft.client.network.ClientNetworking;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public void setShift(boolean shift) {
}

public void render(GuiGraphics guiGraphics, int pMouseX, int pMouseY, float pPartialTicks) {
this.renderBackground(guiGraphics, pMouseX, pMouseY, pPartialTicks);
this.renderBackground(guiGraphics);
guiGraphics.drawCenteredString(this.font, "Keyboard", this.width / 2, 2, 16777215);
super.render(guiGraphics, 0, 0, pPartialTicks);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void setShift(boolean shift) {
}

public void render(GuiGraphics guiGraphics, int pMouseX, int pMouseY, float pPartialTicks) {
this.renderBackground(guiGraphics, pMouseX, pMouseY, pPartialTicks);
this.renderBackground(guiGraphics);
super.render(guiGraphics, 0, 0, pPartialTicks);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ void readPalette(DataInputStream dis, int dataVersion) throws IOException {
int size = dis.readInt();

for (int i = 0; i < size; i++) {
CompoundTag tag = CompoundTag.TYPE.load(dis, NbtAccounter.unlimitedHeap());
CompoundTag tag = CompoundTag.TYPE.load(dis, 0, NbtAccounter.UNLIMITED);
tag = (CompoundTag) dataFixer.update(References.BLOCK_STATE, new Dynamic<>(NbtOps.INSTANCE, tag), dataVersion, SharedConstants.getCurrentVersion().getDataVersion().getVersion()).getValue();
this.paletteMap.add(NbtUtils.readBlockState(BuiltInRegistries.BLOCK.asLookup(), tag));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ private void renderItem(ControllerType side, PoseStack matrixStackIn, MultiBuffe
playermodel.leftSleeve.copyFrom(playermodel.leftArm);
playermodel.rightSleeve.copyFrom(playermodel.rightArm);
float f = SwingTracker.getItemFade((LocalPlayer) playerIn, ItemStack.EMPTY);
rendererArmIn.render(matrixStackIn, bufferIn.getBuffer(RenderType.entityTranslucent(playerIn.getSkin().texture())), combinedLightIn, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, f);
rendererArmIn.render(matrixStackIn, bufferIn.getBuffer(RenderType.entityTranslucent(playerIn.getSkinTextureLocation())), combinedLightIn, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, f);
rendererArmwearIn.xRot = 0.0F;
rendererArmwearIn.render(matrixStackIn, bufferIn.getBuffer(RenderType.entityTranslucent(playerIn.getSkin().texture())), combinedLightIn, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, f);
rendererArmwearIn.render(matrixStackIn, bufferIn.getBuffer(RenderType.entityTranslucent(playerIn.getSkinTextureLocation())), combinedLightIn, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, f);
RenderSystem.disableBlend();
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
}
Expand Down
Loading

0 comments on commit 21b16f4

Please sign in to comment.