Skip to content
This repository has been archived by the owner on Nov 29, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'vivecraft/Multiloader-1.20.2' into Mult…
Browse files Browse the repository at this point in the history
…iloader-1.20-No-PBuffers

# Conflicts:
#	common/src/main/resources/vivecraft.mixins.json
  • Loading branch information
thejudge156 committed Nov 5, 2023
2 parents 2e69009 + a5fa7cf commit 05c3d68
Show file tree
Hide file tree
Showing 54 changed files with 447 additions and 294 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.3-SNAPSHOT" apply false
id "dev.architectury.loom" version "1.4-SNAPSHOT" apply false
id 'io.github.juuxel.loom-quiltflower' version '1.8.0' apply false
}

Expand Down
6 changes: 6 additions & 0 deletions common/src/main/java/org/vivecraft/client/Xplat.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

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.level.BlockAndTintGetter;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.BiomeSpecialEffects;
Expand Down Expand Up @@ -84,4 +86,8 @@ static Biome.ClimateSettings getBiomeClimateSettings(Biome biome) {
static BiomeSpecialEffects getBiomeEffects(Biome biome) {
return null;
}

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

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

if (this.visibleList != null) {
this.visibleList.render(guiGraphics, pMouseX, pMouseY, pPartialTicks);
Expand Down Expand Up @@ -235,12 +235,13 @@ public boolean mouseDragged(double pMouseX, double p_94741_, int pMouseY, double
return this.visibleList != null ? this.visibleList.mouseDragged(pMouseX, p_94741_, pMouseY, p_94743_, pButton) : super.mouseDragged(pMouseX, p_94741_, pMouseY, p_94743_, pButton);
}

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

return super.mouseScrolled(pMouseX, p_94735_, pMouseY);
return super.mouseScrolled(x, y, scrollAmountX, 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);
this.renderBackground(guiGraphics, i, j, f);
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);
this.renderBackground(guiGraphics, i, j, f);
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,15 +40,19 @@ 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;
}
this.renderBackground(guiGraphics);
super.render(guiGraphics, i, j, f);
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);
this.renderBackground(guiGraphics, pMouseX, pMouseY, pPartialTicks);
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 @@ -77,11 +77,11 @@ public boolean mouseReleased(double pMouseX, double p_94754_, int pMouseY) {
}
}

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

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

@Override
public boolean mouseScrolled(double x, double y, double scrollAmount) {
if (scrollAmount < 0.0 && currentLine < scrollSteps) {
public boolean mouseScrolled(double x, double y, double scrollAmountX, double scrollAmountY) {
if (scrollAmountX < 0.0 && currentLine < scrollSteps) {
currentLine++;
} else if (scrollAmount > 0.0 && currentLine > 0) {
} else if (scrollAmountX > 0.0 && currentLine > 0) {
currentLine--;
} else {
// scroll bar on limit, didn't consume the input
Expand All @@ -157,7 +157,7 @@ public boolean mouseScrolled(double x, double y, double scrollAmount) {
@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, key == GLFW.GLFW_KEY_UP ? 1 : -1)) {
if (mouseScrolled(0, 0, key == GLFW.GLFW_KEY_UP ? 1 : -1, 0)) {
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.game.ServerboundCustomPayloadPacket;
import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket;
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Pose;
Expand All @@ -18,6 +18,7 @@
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 @@ -27,6 +28,7 @@
import org.vivecraft.common.VRServerPerms;
import org.vivecraft.common.network.CommonNetworkHelper;
import org.vivecraft.common.network.VrPlayerState;
import org.vivecraft.common.network.packets.VivecraftDataPacket;

import java.util.UUID;

Expand Down Expand Up @@ -54,14 +56,14 @@ public static ServerboundCustomPayloadPacket getVivecraftClientPacket(CommonNetw
FriendlyByteBuf friendlybytebuf = new FriendlyByteBuf(Unpooled.buffer());
friendlybytebuf.writeByte(command.ordinal());
friendlybytebuf.writeBytes(payload);
return new ServerboundCustomPayloadPacket(CommonNetworkHelper.CHANNEL, friendlybytebuf);
return new ServerboundCustomPayloadPacket(new VivecraftDataPacket(friendlybytebuf));
}

public static ServerboundCustomPayloadPacket createVRActivePacket(boolean vrActive) {
var buffer = new FriendlyByteBuf(Unpooled.buffer());
buffer.writeByte(CommonNetworkHelper.PacketDiscriminators.IS_VR_ACTIVE.ordinal());
buffer.writeBoolean(vrActive);
return new ServerboundCustomPayloadPacket(CommonNetworkHelper.CHANNEL, buffer);
return new ServerboundCustomPayloadPacket(new VivecraftDataPacket(buffer));
}

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

public static void sendVersionInfo() {
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));
//Minecraft.getInstance().getConnection().send(new ServerboundCustomPayloadPacket(new ChannelRegisterPacket(CommonNetworkHelper.CHANNEL.toString())));
Xplat.addNetworkChannel(Minecraft.getInstance().getConnection(), CommonNetworkHelper.CHANNEL);
// 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 @@ -133,7 +133,7 @@ public static ServerboundCustomPayloadPacket createVrPlayerStatePacket(VrPlayerS
var buffer = new FriendlyByteBuf(Unpooled.buffer());
buffer.writeByte(CommonNetworkHelper.PacketDiscriminators.VR_PLAYER_STATE.ordinal());
vrPlayerState.serialize(buffer);
return new ServerboundCustomPayloadPacket(CommonNetworkHelper.CHANNEL, buffer);
return new ServerboundCustomPayloadPacket(new VivecraftDataPacket(buffer));
}

public static void sendLegacyPackets(ClientPacketListener connection, VrPlayerState vrPlayerState) {
Expand All @@ -142,21 +142,21 @@ public static void sendLegacyPackets(ClientPacketListener connection, VrPlayerSt
controller0Buffer.writeByte(CommonNetworkHelper.PacketDiscriminators.CONTROLLER0DATA.ordinal());
controller0Buffer.writeBoolean(ClientDataHolderVR.getInstance().vrSettings.reverseHands);
vrPlayerState.controller0().serialize(controller0Buffer);
connection.send(new ServerboundCustomPayloadPacket(CommonNetworkHelper.CHANNEL, controller0Buffer));
connection.send(new ServerboundCustomPayloadPacket(new VivecraftDataPacket(controller0Buffer)));

// right controller packet
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));
connection.send(new ServerboundCustomPayloadPacket(new VivecraftDataPacket(controller1Buffer)));

// hmd packet
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));
connection.send(new ServerboundCustomPayloadPacket(new VivecraftDataPacket(headBuffer)));
}

public static boolean isLimitedSurvivalTeleport() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,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.getModelName().equals("slim");
boolean flag = mc.player.getSkin().model().id().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.game.ServerboundCustomPayloadPacket;
import net.minecraft.network.protocol.common.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 @@ -4,7 +4,7 @@
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.contents.TranslatableContents;
import net.minecraft.network.protocol.game.ServerboundCustomPayloadPacket;
import net.minecraft.network.protocol.common.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.game.ServerboundCustomPayloadPacket;
import net.minecraft.network.protocol.common.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 @@ -178,7 +178,7 @@ public void setShift(boolean shift) {
}

public void render(GuiGraphics guiGraphics, int pMouseX, int pMouseY, float pPartialTicks) {
this.renderBackground(guiGraphics);
this.renderBackground(guiGraphics, pMouseX, pMouseY, pPartialTicks);
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);
this.renderBackground(guiGraphics, pMouseX, pMouseY, pPartialTicks);
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, 0, NbtAccounter.UNLIMITED);
CompoundTag tag = CompoundTag.TYPE.load(dis, NbtAccounter.unlimitedHeap());
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.getSkinTextureLocation())), combinedLightIn, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, f);
rendererArmIn.render(matrixStackIn, bufferIn.getBuffer(RenderType.entityTranslucent(playerIn.getSkin().texture())), combinedLightIn, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, f);
rendererArmwearIn.xRot = 0.0F;
rendererArmwearIn.render(matrixStackIn, bufferIn.getBuffer(RenderType.entityTranslucent(playerIn.getSkinTextureLocation())), combinedLightIn, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, f);
rendererArmwearIn.render(matrixStackIn, bufferIn.getBuffer(RenderType.entityTranslucent(playerIn.getSkin().texture())), 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
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,8 @@ public static void renderCrosshairAtDepth(boolean depthAlways, PoseStack poseSta
brightness = 0.5F;
}

RenderSystem.setShaderTexture(0, Gui.GUI_ICONS_LOCATION);
TextureAtlasSprite crosshairSprite = Minecraft.getInstance().getGuiSprites().getSprite(Gui.CROSSHAIR_SPRITE);
RenderSystem.setShaderTexture(0, crosshairSprite.atlasLocation());
float uMax = 15.0F / 256.0F;
float vMax = 15.0F / 256.0F;

Expand All @@ -913,13 +914,13 @@ public static void renderCrosshairAtDepth(boolean depthAlways, PoseStack poseSta
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.NEW_ENTITY);

bufferbuilder.vertex(poseStack.last().pose(), -1.0F, 1.0F, 0.0F).color(brightness, brightness, brightness, 1.0F)
.uv(0.0F, vMax).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(0.0F, 0.0F, 1.0F).endVertex();
.uv(crosshairSprite.getU0(), crosshairSprite.getV1()).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(0.0F, 0.0F, 1.0F).endVertex();
bufferbuilder.vertex(poseStack.last().pose(), 1.0F, 1.0F, 0.0F).color(brightness, brightness, brightness, 1.0F)
.uv(uMax, vMax).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(0.0F, 0.0F, 1.0F).endVertex();
.uv(crosshairSprite.getU1(), crosshairSprite.getV1()).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(0.0F, 0.0F, 1.0F).endVertex();
bufferbuilder.vertex(poseStack.last().pose(), 1.0F, -1.0F, 0.0F).color(brightness, brightness, brightness, 1.0F)
.uv(uMax, 0.0F).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(0.0F, 0.0F, 1.0F).endVertex();
.uv(crosshairSprite.getU1(), crosshairSprite.getV0()).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(0.0F, 0.0F, 1.0F).endVertex();
bufferbuilder.vertex(poseStack.last().pose(), -1.0F, -1.0F, 0.0F).color(brightness, brightness, brightness, 1.0F)
.uv(0.0F, 0.0F).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(0.0F, 0.0F, 1.0F).endVertex();
.uv(crosshairSprite.getU0(), crosshairSprite.getV0()).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(0.0F, 0.0F, 1.0F).endVertex();

BufferUploader.drawWithShader(bufferbuilder.end());

Expand Down
Loading

0 comments on commit 05c3d68

Please sign in to comment.