Skip to content

Commit

Permalink
update to 1.21.3
Browse files Browse the repository at this point in the history
  • Loading branch information
fayer3 committed Dec 7, 2024
1 parent 5545c14 commit 832bc3e
Show file tree
Hide file tree
Showing 138 changed files with 1,807 additions and 2,221 deletions.
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dependencies {
compileOnly('com.electronwill.night-config:toml:3.6.6')

//LaunchPopup
implementation 'com.github.Vivecraft:LaunchPopup:master-SNAPSHOT'
implementation 'com.github.Vivecraft:LaunchPopup:1.1.1'
}
// extract the LaunchPopup classes
jar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public RotInfo getRotationsForPlayer(UUID uuid) {
if (playermodelcontroller$rotinfo != null && this.vivePlayersLast.containsKey(uuid)) {
RotInfo playermodelcontroller$rotinfo1 = this.vivePlayersLast.get(uuid);
RotInfo playermodelcontroller$rotinfo2 = new RotInfo();
float f = Minecraft.getInstance().getTimer().getGameTimeDeltaPartialTick(false);
float f = Minecraft.getInstance().getDeltaTracker().getGameTimeDeltaPartialTick(false);
playermodelcontroller$rotinfo2.reverse = playermodelcontroller$rotinfo.reverse;
playermodelcontroller$rotinfo2.seated = playermodelcontroller$rotinfo.seated;
playermodelcontroller$rotinfo2.hmd = playermodelcontroller$rotinfo.hmd;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.vivecraft.client.extensions;

import java.util.UUID;

public interface EntityRenderStateExtension {
/**
* @return the uuid this state was created for
*/
UUID vivecraft$getEntityUUID();

/**
* set the uuid this state was created for
*/
void vivecraft$setEntityUUID(UUID uuid);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.vivecraft.client.extensions;

import net.minecraft.client.renderer.ShaderInstance;
import net.minecraft.client.renderer.ShaderProgram;
import org.lwjgl.opengl.GL30;

public interface RenderTargetExtension {
Expand All @@ -19,5 +19,5 @@ public interface RenderTargetExtension {

void vivecraft$isLinearFilter(boolean linearFilter);

void vivecraft$blitFovReduction(ShaderInstance instance, int width, int height);
void vivecraft$blitFovReduction(ShaderProgram instance, int width, int height);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.Holder;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;
Expand Down Expand Up @@ -207,15 +208,15 @@ public static void overrideLook(Player player, Vec3 view) {
capturedYaw = player.getYRot();
float f = (float) Math.toDegrees(Math.asin(-view.y / view.length()));
float f1 = (float) Math.toDegrees(Math.atan2(-view.x, view.z));
((LocalPlayer) player).connection.send(new ServerboundMovePlayerPacket.Rot(f1, f, player.onGround()));
((LocalPlayer) player).connection.send(new ServerboundMovePlayerPacket.Rot(f1, f, player.onGround(), player.horizontalCollision));
overrideActive = true;
}
}

public static void restoreLook(Player player) {
if (!serverWantsData) {
if (overrideActive) {
((LocalPlayer) player).connection.send(new ServerboundMovePlayerPacket.Rot(capturedYaw, capturedPitch, player.onGround()));
((LocalPlayer) player).connection.send(new ServerboundMovePlayerPacket.Rot(capturedYaw, capturedPitch, player.onGround(), player.horizontalCollision));
overrideActive = false;
}
}
Expand Down Expand Up @@ -256,11 +257,11 @@ public static void handlePacket(CommonNetworkHelper.PacketDiscriminators packetI

while (buffer.readableBytes() > 0) {
String s12 = buffer.readUtf(16384);
Block block = BuiltInRegistries.BLOCK.get(ResourceLocation.parse(s12));
Holder.Reference<Block> block = BuiltInRegistries.BLOCK.get(ResourceLocation.parse(s12)).orElse(null);

// if the block is not there AIR is returned
if (block != Blocks.AIR) {
dataholder.climbTracker.blocklist.add(block);
if (block != null && block.value() != Blocks.AIR) {
dataholder.climbTracker.blocklist.add(block.value());
}
}
}
Expand Down
13 changes: 7 additions & 6 deletions common/src/main/java/org/vivecraft/client/render/HMDLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,30 @@
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.model.PlayerModel;
import net.minecraft.client.player.AbstractClientPlayer;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.RenderLayerParent;
import net.minecraft.client.renderer.entity.layers.RenderLayer;
import net.minecraft.client.renderer.entity.state.PlayerRenderState;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.resources.ResourceLocation;
import org.vivecraft.client.VRPlayersClient;
import org.vivecraft.client.extensions.EntityRenderStateExtension;

public class HMDLayer extends RenderLayer<AbstractClientPlayer, PlayerModel<AbstractClientPlayer>> {
public class HMDLayer extends RenderLayer<PlayerRenderState, PlayerModel> {

ResourceLocation DIAMOND_HMD = ResourceLocation.parse("vivecraft:textures/diamond_hmd.png");
ResourceLocation GOLD_HMD = ResourceLocation.parse("vivecraft:textures/gold_hmd.png");
ResourceLocation BLACK_HMD = ResourceLocation.parse("vivecraft:textures/black_hmd.png");

public HMDLayer(RenderLayerParent<AbstractClientPlayer, PlayerModel<AbstractClientPlayer>> renderLayerParent) {
public HMDLayer(RenderLayerParent<PlayerRenderState, PlayerModel> renderLayerParent) {
super(renderLayerParent);
}

@Override
public void render(PoseStack poseStack, MultiBufferSource multiBufferSource, int i, AbstractClientPlayer entity, float f, float g, float h, float j, float k, float l) {
if (this.getParentModel().head.visible && this.getParentModel() instanceof VRPlayerModel<?> vrPlayerModel) {
VRPlayersClient.RotInfo rotinfo = VRPlayersClient.getInstance().getRotationsForPlayer(entity.getUUID());
public void render(PoseStack poseStack, MultiBufferSource multiBufferSource, int i, PlayerRenderState entityState, float f, float g) {
if (this.getParentModel().head.visible && this.getParentModel() instanceof VRPlayerModel vrPlayerModel) {
VRPlayersClient.RotInfo rotinfo = VRPlayersClient.getInstance().getRotationsForPlayer(((EntityRenderStateExtension)entityState).vivecraft$getEntityUUID());
ResourceLocation hmd;
switch (rotinfo.hmd) {
default -> hmd = null;
Expand Down
42 changes: 22 additions & 20 deletions common/src/main/java/org/vivecraft/client/render/VRPlayerModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
import net.minecraft.client.model.geom.builders.CubeListBuilder;
import net.minecraft.client.model.geom.builders.MeshDefinition;
import net.minecraft.client.model.geom.builders.PartDefinition;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.client.renderer.entity.state.PlayerRenderState;
import org.vivecraft.client.VRPlayersClient;
import org.vivecraft.client.extensions.EntityRenderStateExtension;

public class VRPlayerModel<T extends LivingEntity> extends PlayerModel<T> {
public class VRPlayerModel extends PlayerModel {
private final boolean slim;
public ModelPart vrHMD;
VRPlayersClient.RotInfo rotInfo;
Expand All @@ -21,41 +22,43 @@ public class VRPlayerModel<T extends LivingEntity> extends PlayerModel<T> {
public VRPlayerModel(ModelPart modelPart, boolean isSlim) {
super(modelPart, isSlim);
this.slim = isSlim;
this.vrHMD = modelPart.getChild("vrHMD");
this.vrHMD = this.head.getChild("vrHMD");
}

public static MeshDefinition createMesh(CubeDeformation p_170826_, boolean p_170827_) {
MeshDefinition meshdefinition = PlayerModel.createMesh(p_170826_, p_170827_);
PartDefinition partdefinition = meshdefinition.getRoot();
partdefinition.addOrReplaceChild("vrHMD", CubeListBuilder.create().texOffs(0, 0).addBox(-3.5F, -6.0F, -7.5F, 7.0F, 4.0F, 5.0F, p_170826_), PartPose.ZERO);
partdefinition.getChild("head").addOrReplaceChild("vrHMD", CubeListBuilder.create().texOffs(0, 0).addBox(-3.5F, -6.0F, -7.5F, 7.0F, 4.0F, 5.0F, p_170826_), PartPose.ZERO);
return meshdefinition;
}


public void setupAnim(T pEntity, float pLimbSwing, float pLimbSwingAmount, float pAgeInTicks, float pNetHeadYaw, float pHeadPitch) {
super.setupAnim(pEntity, pLimbSwing, pLimbSwingAmount, pAgeInTicks, pNetHeadYaw, pHeadPitch);
this.rotInfo = VRPlayersClient.getInstance().getRotationsForPlayer(pEntity.getUUID());
VRPlayersClient.RotInfo rotinfo = VRPlayersClient.getInstance().getRotationsForPlayer(pEntity.getUUID());
public void setupAnim(PlayerRenderState playerRenderState) {
playerRenderState.isCrouching &= !playerRenderState.isVisuallySwimming;

if (rotinfo == null) {
super.setupAnim(playerRenderState);

this.rotInfo = VRPlayersClient.getInstance().getRotationsForPlayer(((EntityRenderStateExtension)playerRenderState).vivecraft$getEntityUUID());

if (this.rotInfo == null) {
return; //how
}

double d0 = -1.501F * rotinfo.heightScale;
float f = (float) Math.toRadians(pEntity.getYRot());
float f1 = (float) Math.atan2(-rotinfo.headRot.x, -rotinfo.headRot.z);
float f2 = (float) Math.asin(rotinfo.headRot.y / rotinfo.headRot.length());
double d1 = rotinfo.getBodyYawRadians();
double d0 = -1.501F * this.rotInfo.heightScale;
float f = (float) Math.toRadians(playerRenderState.yRot);
float f1 = (float) Math.atan2(-this.rotInfo.headRot.x, -this.rotInfo.headRot.z);
float f2 = (float) Math.asin(this.rotInfo.headRot.y / this.rotInfo.headRot.length());
double d1 = this.rotInfo.getBodyYawRadians();
this.head.xRot = -f2;
this.head.yRot = (float) (Math.PI - (double) f1 - d1);
this.laying = this.swimAmount > 0.0F || pEntity.isFallFlying() && !pEntity.isAutoSpinAttack();
this.laying = playerRenderState.swimAmount > 0.0F || playerRenderState.isFallFlying && !playerRenderState.isAutoSpinAttack;

if (this.laying) {
this.head.z = 0.0F;
this.head.x = 0.0F;
this.head.y = -4.0F;
this.head.xRot = (float) ((double) this.head.xRot - (Math.PI / 2D));
} else if (this.crouching) {
} else if (playerRenderState.isCrouching) {
// move head down when crouching
this.head.z = 0.0F;
this.head.x = 0.0F;
Expand All @@ -66,13 +69,12 @@ public void setupAnim(T pEntity, float pLimbSwing, float pLimbSwingAmount, float
this.head.y = 0.0F;
}

this.vrHMD.visible = true;

this.vrHMD.copyFrom(this.head);
this.hat.copyFrom(this.head);
this.vrHMD.visible = false;
}

public void renderHMDR(PoseStack poseStack, VertexConsumer vertexConsumer, int i, int noOverlay) {
this.vrHMD.visible = true;
this.vrHMD.render(poseStack, vertexConsumer, i, noOverlay);
this.vrHMD.visible = false;
}
}
Loading

0 comments on commit 832bc3e

Please sign in to comment.