Skip to content

Commit

Permalink
update to 1.21.4
Browse files Browse the repository at this point in the history
  • Loading branch information
fayer3 committed Dec 8, 2024
1 parent 832bc3e commit c9080aa
Show file tree
Hide file tree
Showing 45 changed files with 182 additions and 228 deletions.
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ allprojects {
maven { url = "https://storage.googleapis.com/devan-maven/" }
maven { url = "https://maven.shedaniel.me/" }
maven { url = "https://aperlambda.github.io/maven" }
maven { url = "https://maven.kotlindiscord.com/repository/terraformers/" }
maven { url = "https://mvn.devos.one/releases/" }
maven { url = "https://mvn.devos.one/snapshots/" }
maven { url = "https://maven.terraformersmc.com/" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public GuiListScreen(Component title, Screen lastScreen) {
@Override
protected void init() {
clearWidgets();
double scrollAmount = list != null ? list.getScrollAmount() : 0.0D;
double scrollAmount = list != null ? list.scrollAmount() : 0.0D;

this.list = new SettingsList(this, minecraft, getEntries());
list.setScrollAmount(scrollAmount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public GuiListValueEditScreen(Component title, Screen lastScreen, ConfigBuilder.
@Override
protected void init() {
clearWidgets();
double scrollAmount = list != null ? list.getScrollAmount() : 0.0D;
double scrollAmount = list != null ? list.scrollAmount() : 0.0D;

this.list = new SettingsList(this, minecraft, getEntries());
list.setScrollAmount(scrollAmount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public SettingsList(Screen parent, Minecraft minecraft, List<SettingsList.BaseEn
}

@Override
protected int getScrollbarPosition() {
return super.getScrollbarPosition() + 8;
protected int scrollBarX() {
return super.scrollBarX() + 8;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void onClick(double x, double y) {
// update scroll position
setCurrentLineFromYPos(y);
}
} else if (this.clicked(x, y)) {
} else if (this.isMouseOver(x, y)) {
Style style = getMouseoverStyle(x, y);
if (style != null && style.getClickEvent() != null) {
Minecraft.getInstance().screen.handleComponentClicked(style);
Expand Down Expand Up @@ -173,7 +173,7 @@ public Style getMouseoverStyle(double x, double y) {
}

private int getLineIndex(double x, double y) {
if (!this.clicked(x, y)) {
if (!this.isMouseOver(x, y)) {
return -1;
} else {
return (int) ((y - this.getY() - padding * 0.5) / 12.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public void setupAnim(PlayerRenderState playerRenderState) {
this.leftArm.yRot = 0.0F;
}

if (getArmPose(playerRenderState, HumanoidArm.RIGHT) == ArmPose.THROW_SPEAR) {
if (playerRenderState.rightArmPose == ArmPose.THROW_SPEAR) {
this.leftHand.xRot = (float) ((double) this.leftHand.xRot - (Math.PI / 2D));
}

Expand All @@ -212,7 +212,7 @@ public void setupAnim(PlayerRenderState playerRenderState) {
this.rightArm.yRot = 0.0F;
}

if (this.getArmPose(playerRenderState, HumanoidArm.RIGHT) == ArmPose.THROW_SPEAR) {
if (playerRenderState.rightArmPose == ArmPose.THROW_SPEAR) {
this.rightHand.xRot = (float) ((double) this.rightHand.xRot - (Math.PI / 2D));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public class ClientDataHolderVR {
public static boolean katvr;
public static boolean infinadeck;
public static boolean viewonly;
public static ModelResourceLocation thirdPersonCameraModel = ModelResourceLocation.inventory(ResourceLocation.fromNamespaceAndPath("vivecraft", "camcorder"));
public static ModelResourceLocation thirdPersonCameraDisplayModel = ModelResourceLocation.inventory(ResourceLocation.fromNamespaceAndPath("vivecraft", "camcorder_display"));
public static ResourceLocation thirdPersonCameraModel = ResourceLocation.fromNamespaceAndPath("vivecraft", "camcorder");
public static ResourceLocation thirdPersonCameraDisplayModel = ResourceLocation.fromNamespaceAndPath("vivecraft", "camcorder_display");
private static ClientDataHolderVR INSTANCE;

public VRPlayer vrPlayer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import org.vivecraft.common.utils.math.Vector3;

public class CameraTracker extends Tracker {
public static final ModelResourceLocation cameraModel = ModelResourceLocation.inventory(ResourceLocation.fromNamespaceAndPath("vivecraft", "camera"));
public static final ModelResourceLocation cameraDisplayModel = ModelResourceLocation.inventory(ResourceLocation.fromNamespaceAndPath("vivecraft", "camera_display"));
public static final ResourceLocation cameraModel = ResourceLocation.fromNamespaceAndPath("vivecraft", "camera");
public static final ResourceLocation cameraDisplayModel = ResourceLocation.fromNamespaceAndPath("vivecraft", "camera_display");
private boolean visible = false;
private Vec3 position = new Vec3(0.0D, 0.0D, 0.0D);
private Quaternion rotation = new Quaternion();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import java.util.*;

public class ClimbTracker extends Tracker {
public static final ModelResourceLocation clawsModel = ModelResourceLocation.inventory(ResourceLocation.fromNamespaceAndPath("vivecraft", "climb_claws"));
public static final ResourceLocation clawsModel = ResourceLocation.fromNamespaceAndPath("vivecraft", "climb_claws");
private final boolean[] latched = new boolean[2];
private final boolean[] wasinblock = new boolean[2];
private final boolean[] wasbutton = new boolean[2];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.core.component.DataComponents;
import net.minecraft.network.chat.contents.TranslatableContents;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -16,7 +15,7 @@

public class TelescopeTracker extends Tracker {
//public static final ResourceLocation scopeResource = new ResourceLocation("vivecraft:trashbin");
public static final ModelResourceLocation scopeModel = ModelResourceLocation.inventory(ResourceLocation.fromNamespaceAndPath("vivecraft", "spyglass_in_hand"));
public static final ResourceLocation scopeModel = ResourceLocation.fromNamespaceAndPath("vivecraft", "spyglass_in_hand");
private static final double lensDistMax = 0.05D;
private static final double lensDistMin = 0.185D;
private static final double lensDotMax = 0.9D;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ public void renderSky(Matrix4fStack poseStack, Vec3 position) {
float f7 = Mth.sin(f6);
float f8 = Mth.cos(f6);
bufferBuilder
.addVertex(modelView, f7 * 120.0F, f8 * 120.0F, -f8 * 40.0F *ARGB.from8BitChannel(ARGB.alpha(sunriseColor)))
.addVertex(modelView, f7 * 120.0F, f8 * 120.0F, -f8 * 40.0F * ARGB.alphaFloat(sunriseColor))
.setColor(ARGB.transparent(sunriseColor));
}

Expand Down Expand Up @@ -1438,10 +1438,10 @@ private void updateSurfaceFog() {
if (f5 > 0.0F && this.menuWorldRenderer.dimensionInfo.isSunriseOrSunset(this.menuWorldRenderer.getTimeOfDay())) {
int color = this.menuWorldRenderer.dimensionInfo.getSunriseOrSunsetColor(this.menuWorldRenderer.getTimeOfDay());

f5 = f5 * ARGB.from8BitChannel(ARGB.alpha(color));
fogRed = fogRed * (1.0f - f5) + ARGB.from8BitChannel(ARGB.red(color)) * f5;
fogGreen = fogGreen * (1.0f - f5) + ARGB.from8BitChannel(ARGB.green(color)) * f5;
fogBlue = fogBlue * (1.0f - f5) + ARGB.from8BitChannel(ARGB.blue(color)) * f5;
f5 = f5 * ARGB.alphaFloat(color);
fogRed = fogRed * (1.0f - f5) + ARGB.redFloat(color) * f5;
fogGreen = fogGreen * (1.0f - f5) + ARGB.greenFloat(color) * f5;
fogBlue = fogBlue * (1.0f - f5) + ARGB.blueFloat(color) * f5;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import net.minecraft.client.player.AbstractClientPlayer;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.client.renderer.item.ItemModelResolver;
import net.minecraft.client.renderer.item.ItemStackRenderState;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.item.*;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
Expand All @@ -23,7 +24,9 @@
public class VivecraftItemRendering {
private static final ClientDataHolderVR dh = ClientDataHolderVR.getInstance();

public static VivecraftItemTransformType getTransformType(ItemStack pStack, AbstractClientPlayer pPlayer, ItemRenderer itemRenderer) {
private static final ItemStackRenderState itemStackRenderState = new ItemStackRenderState();

public static VivecraftItemTransformType getTransformType(ItemStack pStack, AbstractClientPlayer pPlayer, ItemModelResolver itemModelResolver) {
VivecraftItemTransformType rendertype = VivecraftItemTransformType.Item;
Item item = pStack.getItem();
Minecraft minecraft = Minecraft.getInstance();
Expand All @@ -35,9 +38,9 @@ public static VivecraftItemTransformType getTransformType(ItemStack pStack, Abst
if (block instanceof TorchBlock) {
rendertype = VivecraftItemTransformType.Block_Stick;
} else {
BakedModel bakedmodel = itemRenderer.getModel(pStack, minecraft.level, minecraft.player, 0);
itemModelResolver.updateForLiving(itemStackRenderState, pStack, ItemDisplayContext.GUI, false, pPlayer);

if (bakedmodel.isGui3d()) {
if (itemStackRenderState.isGui3d()) {
rendertype = VivecraftItemTransformType.Block_3D;
} else {
rendertype = VivecraftItemTransformType.Block_Item;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ public static void renderTechjarsAwesomeMainMenuRoom(Matrix4fStack poseStack) {
? (long) (dataHolder.menuWorldRenderer.ticks * 10L + 10 * mc.getDeltaTracker().getGameTimeDeltaPartialTick(false))
: (long) ((System.currentTimeMillis() + tzOffset - 21600000) / 86400000D * 24000D);

dataHolder.menuWorldRenderer.time = 1000;

dataHolder.menuWorldRenderer.fogRenderer.setupFogColor();
RenderSystem.clear(GL11C.GL_COLOR_BUFFER_BIT | GL11C.GL_DEPTH_BUFFER_BIT);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public static void renderSingleView(RenderPass eye, DeltaTracker.Timer timer, bo
ItemStack itemstack = mc.player.getInventory().getArmor(3);

if (itemstack.getItem() == Blocks.CARVED_PUMPKIN.asItem()
&& (itemstack.getOrDefault(DataComponents.CUSTOM_MODEL_DATA, CustomModelData.DEFAULT).value() == 0)) {
&& (itemstack.getOrDefault(DataComponents.CUSTOM_MODEL_DATA, CustomModelData.EMPTY) != CustomModelData.EMPTY)) {
dataHolder.pumpkineffect = 1.0F;
} else {
dataHolder.pumpkineffect = 0.0F;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.core.BlockPos;
Expand Down Expand Up @@ -92,8 +93,9 @@ public static void renderVRHandheldCameraWidget() {
}
}

public static void renderVRCameraWidget(float offsetX, float offsetY, float offsetZ, float scale, RenderPass renderPass, ModelResourceLocation model, ModelResourceLocation displayModel, Runnable displayBindFunc, Function<Direction, DisplayFace> displayFaceFunc) {
Minecraft minecraft = Minecraft.getInstance();
public static void renderVRCameraWidget(float offsetX, float offsetY, float offsetZ, float scale, RenderPass renderPass, ResourceLocation model, ResourceLocation displayModel, Runnable displayBindFunc, Function<Direction, DisplayFace> displayFaceFunc) {
// TODO 1.21.4 make models work
/*Minecraft minecraft = Minecraft.getInstance();
ClientDataHolderVR dataholder = ClientDataHolderVR.getInstance();
Matrix4fStack poseStack = RenderSystem.getModelViewStack();
poseStack.pushMatrix();
Expand All @@ -120,7 +122,7 @@ public static void renderVRCameraWidget(float offsetX, float offsetY, float offs
RenderSystem.enableDepthTest();
RenderSystem.defaultBlendFunc();
RenderSystem.setShaderTexture(0, InventoryMenu.BLOCK_ATLAS);
RenderSystem.setShaderTexture(0, TextureAtlas.LOCATION_BLOCKS);
if (minecraft.level != null) {
RenderSystem.setShader(CoreShaders.RENDERTYPE_ENTITY_CUTOUT_NO_CULL);
} else {
Expand Down Expand Up @@ -194,7 +196,7 @@ public static void renderVRCameraWidget(float offsetX, float offsetY, float offs
BufferUploader.drawWithShader(bufferbuilder.buildOrThrow());
minecraft.gameRenderer.lightTexture().turnOffLightLayer();
RenderSystem.enableBlend();
poseStack.popMatrix();
poseStack.popMatrix();*/
}

public enum DisplayFace {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.vivecraft.mixin.client.renderer.entity;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.renderer.entity.LivingEntityRenderer;
import net.minecraft.client.renderer.entity.state.ArmedEntityRenderState;
import net.minecraft.client.renderer.entity.state.LivingEntityRenderState;
import net.minecraft.world.entity.HumanoidArm;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
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 org.vivecraft.client.VRPlayersClient;
import org.vivecraft.client.extensions.EntityRenderStateExtension;
import org.vivecraft.client.network.ClientNetworking;
import org.vivecraft.client_vr.ClientDataHolderVR;
import org.vivecraft.client_vr.gameplay.trackers.ClimbTracker;

@Mixin(ArmedEntityRenderState.class)
public class ArmedEntityRenderStateMixin {
@WrapOperation(method = "extractArmedEntityRenderState", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;getItemHeldByArm(Lnet/minecraft/world/entity/HumanoidArm;)Lnet/minecraft/world/item/ItemStack;"))
private static ItemStack vivecraft$clawOverride(LivingEntity instance, HumanoidArm humanoidArm, Operation<ItemStack> original) {
ItemStack thisStack = original.call(instance, humanoidArm);

ClimbTracker tracker = ClientDataHolderVR.getInstance().climbTracker;
if (ClientNetworking.serverAllowsClimbey && VRPlayersClient.getInstance().isTracked(instance.getUUID()) && !tracker.isClaws(thisStack)) {
ItemStack otherStack = original.call(instance, humanoidArm.getOpposite());
if (tracker.isClaws(otherStack) && !VRPlayersClient.getInstance().getRotationsForPlayer(instance.getUUID()).seated) {
return otherStack;
}
}

return thisStack;
}
}
Original file line number Diff line number Diff line change
@@ -1,40 +1,11 @@
package org.vivecraft.mixin.client.renderer.entity;

import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.client.resources.model.ModelManager;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.vivecraft.client_vr.ClientDataHolderVR;
import org.vivecraft.client_vr.VRState;
import org.vivecraft.client_vr.gameplay.trackers.ClimbTracker;
import org.vivecraft.client_vr.gameplay.trackers.TelescopeTracker;
import org.vivecraft.client_vr.render.RenderPass;

@Mixin(ItemRenderer.class)
public class ItemRendererVRMixin {

@Shadow
@Final
private ModelManager modelManager;

@ModifyVariable(at = @At(value = "STORE"), method = "getModel")
public BakedModel vivecraft$modelOverride(BakedModel bakedModel, ItemStack itemStack) {
// TODO 1.21.3 maybe use item properties?
if (VRState.vrRunning && ClientDataHolderVR.getInstance().currentPass != RenderPass.GUI && itemStack.is(Items.SPYGLASS)) {
return this.modelManager.getModel(TelescopeTracker.scopeModel);
}
if (ClientDataHolderVR.getInstance().climbTracker.isClaws(itemStack)) {
return this.modelManager.getModel(ClimbTracker.clawsModel);
}
return bakedModel;
}

// hand item fade
// needs custom item renderer, since the regular one doesn't accept a non 1.0 alpha
/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,17 @@
package org.vivecraft.mixin.client.renderer.entity;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.renderer.entity.LivingEntityRenderer;
import net.minecraft.client.renderer.entity.state.LivingEntityRenderState;
import net.minecraft.world.entity.HumanoidArm;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
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 org.vivecraft.client.VRPlayersClient;
import org.vivecraft.client.extensions.EntityRenderStateExtension;
import org.vivecraft.client.network.ClientNetworking;
import org.vivecraft.client_vr.ClientDataHolderVR;
import org.vivecraft.client_vr.gameplay.trackers.ClimbTracker;

@Mixin(LivingEntityRenderer.class)
public class LivingEntityRendererMixin {
@WrapOperation(method = "extractRenderState(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/client/renderer/entity/state/LivingEntityRenderState;F)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;getItemHeldByArm(Lnet/minecraft/world/entity/HumanoidArm;)Lnet/minecraft/world/item/ItemStack;"))
private ItemStack vivecraft$clawOverride(LivingEntity instance, HumanoidArm humanoidArm, Operation<ItemStack> original) {
ItemStack thisStack = original.call(instance, humanoidArm);

ClimbTracker tracker = ClientDataHolderVR.getInstance().climbTracker;
if (ClientNetworking.serverAllowsClimbey && VRPlayersClient.getInstance().isTracked(instance.getUUID()) && !tracker.isClaws(thisStack)) {
ItemStack otherStack = original.call(instance, humanoidArm.getOpposite());
if (tracker.isClaws(otherStack) && !VRPlayersClient.getInstance().getRotationsForPlayer(instance.getUUID()).seated) {
return otherStack;
}
}

return thisStack;
}

@Inject(method = "render(Lnet/minecraft/client/renderer/entity/state/LivingEntityRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;pushPose()V", shift = At.Shift.AFTER))
private void vivecraft$vrPlayerHeightScale(CallbackInfo ci, @Local(argsOnly = true) LivingEntityRenderState state, @Local(argsOnly = true) PoseStack poseStack) {
Expand Down
Loading

0 comments on commit c9080aa

Please sign in to comment.