Skip to content

Commit

Permalink
Merge pull request #513 from tr7zw/update1.21.3
Browse files Browse the repository at this point in the history
Update to 1.21.3
  • Loading branch information
tr7zw authored Nov 15, 2024
2 parents 49c6985 + 65aee45 commit f2e2440
Show file tree
Hide file tree
Showing 22 changed files with 447 additions and 180 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
java-version: 21
# to cache gradle files
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
uses: gradle/actions/setup-gradle@v4
with:
gradle-home-cache-cleanup: true
dependency-graph: generate-and-submit
Expand Down
56 changes: 56 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -503,3 +503,59 @@ jobs:
name: ${{github.ref_name}}-1.21(.1) - Fabric
files: 'versions/1.21-fabric/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
game-versions: 1.21.x
- name: Publish-1.21.3-forge-Curseforge
uses: Kir-Antipov/mc-publish@v3.3.0
with:
curseforge-id: 333287
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
loaders: forge
name: ${{github.ref_name}}-1.21.3 - Forge
version-type: beta
files: 'versions/1.21.3-forge/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
game-versions: 1.21.3
- name: Publish-1.21.3-forge-Modrinth
uses: Kir-Antipov/mc-publish@v3.3.0
with:
modrinth-id: H5XMjpHi
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
loaders: forge
name: ${{github.ref_name}}-1.21.3 - Forge
files: 'versions/1.21.3-forge/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
game-versions: 1.21.3
- name: Publish-1.21.3-neoforge-Curseforge
uses: Kir-Antipov/mc-publish@v3.3.0
with:
curseforge-id: 333287
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
loaders: neoforge
name: ${{github.ref_name}}-1.21.3 - NeoForge
version-type: beta
files: 'versions/1.21.3-neoforge/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
game-versions: 1.21.3
- name: Publish-1.21.3-neoforge-Modrinth
uses: Kir-Antipov/mc-publish@v3.3.0
with:
modrinth-id: H5XMjpHi
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
loaders: neoforge
name: ${{github.ref_name}}-1.21.3 - NeoForge
files: 'versions/1.21.3-neoforge/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
game-versions: 1.21.3
- name: Publish-1.21.3-fabric-Curseforge
uses: Kir-Antipov/mc-publish@v3.3.0
with:
curseforge-id: 333287
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
loaders: fabric
name: ${{github.ref_name}}-1.21.3 - Fabric
files: 'versions/1.21.3-fabric/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
game-versions: 1.21.3
- name: Publish-1.21.3-fabric-Modrinth
uses: Kir-Antipov/mc-publish@v3.3.0
with:
modrinth-id: H5XMjpHi
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
loaders: fabric
name: ${{github.ref_name}}-1.21.3 - Fabric
files: 'versions/1.21.3-fabric/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
game-versions: 1.21.3
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,20 @@
public class FirstPersonBase {

public static final Logger LOGGER = LogManager.getLogger("FirstPersonModel");
/**
* Stays true till the first entity is rendered when the player is supposed to
* be rendered
*/
@Getter
@Setter
private boolean isRenderingPlayer = false;
/**
* Stays true for the entire render time of the entity, even after the entity
* itself
*/
@Getter
@Setter
private boolean isRenderingPlayerPost = false;
@Getter
@Setter
private boolean enabled = true;
Expand Down
5 changes: 4 additions & 1 deletion settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
"1.20.6-fabric",
"1.21-forge",
"1.21-neoforge",
"1.21-fabric"
"1.21-fabric",
"1.21.3-forge",
"1.21.3-neoforge",
"1.21.3-fabric"
]
}
8 changes: 4 additions & 4 deletions src/main/java/dev/tr7zw/firstperson/LogicHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ public boolean shouldApplyThirdPerson(boolean thirdPerson) {
* @param defValue
* @param delta
*/
public void updatePositionOffset(Entity entity, Vec3 defValue, float delta) {
offset = defValue;
public void updatePositionOffset(Entity entity, float delta) {
offset = Vec3.ZERO;
// handle sleeping
if (entity == client.getCameraEntity() && client.player.isSleeping()) {
return;
Expand Down Expand Up @@ -126,8 +126,8 @@ public void updatePositionOffset(Entity entity, Vec3 defValue, float delta) {
NMSHelper.getYRot(player));
} else {
// Non living entities don't use any custom rotation
// realYaw = Mth.rotLerp(client.getFrameTime(), player.getVehicle().yRotO,
// NMSHelper.getYRot(player.getVehicle()));
// realYaw = Mth.rotLerp(client.getFrameTime(), player.getVehicle().yRotO,
// NMSHelper.getYRot(player.getVehicle()));
}
bodyOffset = Constants.IN_VEHICLE_BODY_OFFSET + fpm.getConfig().sitXOffset / 100f;
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package dev.tr7zw.firstperson.access;

import net.minecraft.client.model.geom.ModelPart;
//#if MC < 12103
//$$import net.minecraft.client.model.geom.ModelPart;
//#endif

public interface PlayerModelAccess {

ModelPart getCloak();
//#if MC < 12103
//$$ ModelPart getCloak();
//#endif

}
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
package dev.tr7zw.firstperson.mixins;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

import dev.tr7zw.firstperson.access.AgeableListModelAccess;
import net.minecraft.client.model.AgeableListModel;
//#if MC < 12103
//$$import org.spongepowered.asm.mixin.Shadow;
//$$import dev.tr7zw.firstperson.access.AgeableListModelAccess;
//$$import net.minecraft.client.model.AgeableListModel;
//#endif
import net.minecraft.client.model.geom.ModelPart;

@Mixin(AgeableListModel.class)
public abstract class AgeableListModelMixin implements AgeableListModelAccess {

@Override
public Iterable<ModelPart> firstPersonHeadPartsGetter() {
return headParts();
}

@Shadow
public abstract Iterable<ModelPart> headParts();

//#if MC >= 12103
@Mixin(ModelPart.class)
public abstract class AgeableListModelMixin {
}
//#else
//$$@Mixin(AgeableListModel.class)
//$$public abstract class AgeableListModelMixin implements AgeableListModelAccess {
//$$
//$$ @Override
//$$ public Iterable<ModelPart> firstPersonHeadPartsGetter() {
//$$ return headParts();
//$$ }
//$$
//$$ @Shadow
//$$ public abstract Iterable<ModelPart> headParts();
//$$
//$$}
//#endif
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import com.mojang.blaze3d.vertex.PoseStack;

Expand All @@ -18,19 +19,69 @@
import net.minecraft.client.renderer.entity.layers.RenderLayer;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
//#if MC >= 12103
import net.minecraft.world.item.equipment.Equippable;
//#endif

// lower prio to run before fabric api
@SuppressWarnings("rawtypes")
@Mixin(value = HumanoidArmorLayer.class, priority = 100)
public abstract class ArmorFeatureRendererMixin<T extends LivingEntity, M extends HumanoidModel<T>, A extends HumanoidModel<T>>
extends RenderLayer<T, M> {
public abstract class ArmorFeatureRendererMixin<T extends LivingEntity, M extends HumanoidModel, A extends HumanoidModel>
extends RenderLayer {

private static Minecraft fpmMcInstance = Minecraft.getInstance();
private static boolean hideLeftArm = false;
private static boolean hideRightArm = false;

protected ArmorFeatureRendererMixin(RenderLayerParent<T, M> context) {
protected ArmorFeatureRendererMixin(RenderLayerParent context) {
super(context);
}

@Inject(method = "renderArmorPiece", at = @At("HEAD"), cancellable = true)
//#if MC >= 12103
@Inject(method = "Lnet/minecraft/client/renderer/entity/layers/HumanoidArmorLayer;shouldRender(Lnet/minecraft/world/item/equipment/Equippable;Lnet/minecraft/world/entity/EquipmentSlot;)Z", at = @At("HEAD"), cancellable = true)
private static void shouldRender(Equippable equippable, EquipmentSlot equipmentSlot,
CallbackInfoReturnable<Boolean> ci) {
hideLeftArm = false;
hideRightArm = false;
if (FirstPersonModelCore.instance.isRenderingPlayer()) {
if (equipmentSlot == EquipmentSlot.HEAD) {
ci.setReturnValue(false);
}
if (equipmentSlot == EquipmentSlot.CHEST) {
if (FirstPersonModelCore.instance.getLogicHandler().isSwimming(Minecraft.getInstance().player)) {
ci.setReturnValue(false);
}
if (FirstPersonModelCore.instance.getLogicHandler().hideArmsAndItems()) {
hideLeftArm = true;
hideRightArm = true;
} else if (FirstPersonModelCore.instance.getLogicHandler().dynamicHandsEnabled()) {// TODO DYNAMIC HAND

if (!Minecraft.getInstance().player.getOffhandItem().isEmpty())
hideLeftArm = true;
if (!Minecraft.getInstance().player.getMainHandItem().isEmpty())
hideRightArm = true;
}
}
}
}

@Inject(method = "setPartVisibility", at = @At("TAIL"))
protected void setPartVisibility(A model, EquipmentSlot slot, CallbackInfo ci) {
if (hideLeftArm) {
((ModelPartBase) (Object) model.leftArm).setHidden();
} else {
((ModelPartBase) (Object) model.leftArm).showAgain();
}
if (hideRightArm) {
((ModelPartBase) (Object) model.rightArm).setHidden();
} else {
((ModelPartBase) (Object) model.rightArm).showAgain();
}
}

//#else
//$$@Inject(method = "renderArmorPiece", at = @At("HEAD"), cancellable = true)
//#endif
private void renderArmor(PoseStack matrices, MultiBufferSource vertexConsumers, T livingEntity,
EquipmentSlot equipmentSlot, int i, A bipedEntityModel, CallbackInfo info) {
if (livingEntity != fpmMcInstance.cameraEntity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,24 @@
import dev.tr7zw.firstperson.FirstPersonModelCore;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.layers.CustomHeadLayer;
import net.minecraft.world.entity.LivingEntity;
//#if MC >= 12103
import net.minecraft.client.renderer.entity.state.LivingEntityRenderState;
//#else
//$$import net.minecraft.world.entity.LivingEntity;
//#endif

//lower prio to run before other mods
@Mixin(value = CustomHeadLayer.class, priority = 100)
public class CustomHeadLayerMixin {

@Inject(method = "render", at = @At("HEAD"), cancellable = true)
public void render(PoseStack poseStack, MultiBufferSource multiBufferSource, int i, LivingEntity livingEntity,
float f, float g, float h, float j, float k, float l, CallbackInfo info) {
//#if MC >= 12103
public void render(PoseStack poseStack, MultiBufferSource multiBufferSource, int i,
LivingEntityRenderState livingEntityRenderState, float f, float g, CallbackInfo info) {
//#else
//$$public void render(PoseStack poseStack, MultiBufferSource multiBufferSource, int i, LivingEntity livingEntity,
//$$ float f, float g, float h, float j, float k, float l, CallbackInfo info) {
//#endif
if (FirstPersonModelCore.instance.isRenderingPlayer()) {
info.cancel();
}
Expand Down
31 changes: 24 additions & 7 deletions src/main/java/dev/tr7zw/firstperson/mixins/ElytraLayerMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,38 @@
import com.mojang.blaze3d.vertex.PoseStack;

import dev.tr7zw.firstperson.FirstPersonModelCore;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.AbstractClientPlayer;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.layers.ElytraLayer;
//#if MC >= 12103
import net.minecraft.client.renderer.entity.layers.WingsLayer;
import net.minecraft.client.renderer.entity.state.HumanoidRenderState;
//#else
//$$import net.minecraft.client.renderer.entity.layers.ElytraLayer;
//#endif
import net.minecraft.world.entity.LivingEntity;

/**
* @author KxmischesDomi | https://github.com/kxmischesdomi
*/
@Mixin(ElytraLayer.class)
//#if MC >= 12103
@Mixin(WingsLayer.class)
//#else
//$$@Mixin(ElytraLayer.class)
//#endif
public class ElytraLayerMixin<T extends LivingEntity> {

@Inject(method = "render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ILnet/minecraft/world/entity/LivingEntity;FFFFFF)V", at = @At("HEAD"), cancellable = true)
public void render(PoseStack poseStack, MultiBufferSource multiBufferSource, int i, T livingEntity, float f,
float g, float h, float j, float k, float l, CallbackInfo ci) {
if (FirstPersonModelCore.instance.isRenderingPlayer() && livingEntity instanceof LocalPlayer player
//#if MC >= 12103
@Inject(method = "render", at = @At("HEAD"), cancellable = true)
public void render(PoseStack poseStack, MultiBufferSource multiBufferSource, int i,
HumanoidRenderState humanoidRenderState, float f, float g, CallbackInfo ci) {
//#else
//$$ @Inject(method = "render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ILnet/minecraft/world/entity/LivingEntity;FFFFFF)V", at = @At("HEAD"), cancellable = true)
//$$ public void render(PoseStack poseStack, MultiBufferSource multiBufferSource, int i, T livingEntity, float f,
//$$ float g, float h, float j, float k, float l, CallbackInfo ci) {
//#endif
if (FirstPersonModelCore.instance.isRenderingPlayer()
&& Minecraft.getInstance().getCameraEntity() instanceof AbstractClientPlayer player
&& FirstPersonModelCore.instance.getLogicHandler().isSwimming(player)) {
ci.cancel();
}
Expand Down
Loading

0 comments on commit f2e2440

Please sign in to comment.