v1.8.2
This commit is contained in:
1 parent
ad405bb974
commit
72415f5d52
5 files changed
+118
-6
No files matched your search
@@ -10,6 +10,8 @@ import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.shaders.Uniform;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.*;
|
||||
import com.mojang.math.Axis;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.ShaderInstance;
|
||||
@@ -17,6 +19,10 @@ import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.neoforged.neoforge.client.GlStateBackup;
|
||||
import org.joml.Matrix4f;
|
||||
@@ -286,4 +292,35 @@ public class ClientNightglow {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void renderHandItem(LivingEntity entity, ItemStack itemStack, ItemDisplayContext displayContext, boolean leftHand, PoseStack poseStack, MultiBufferSource buffer, int seed) {
|
||||
poseStack.pushPose();
|
||||
|
||||
float handSign = leftHand ? -1.0f : 1.0f;
|
||||
|
||||
if(displayContext.firstPerson()) {
|
||||
// 第一人称手提姿态
|
||||
poseStack.translate(handSign * 0.0D, -0.7D, -0.5D);
|
||||
poseStack.mulPose(Axis.ZP.rotationDegrees(handSign * -30.0F));
|
||||
poseStack.mulPose(Axis.YP.rotationDegrees(handSign * 90.0F));
|
||||
}else if(displayContext == ItemDisplayContext.THIRD_PERSON_RIGHT_HAND || displayContext == ItemDisplayContext.THIRD_PERSON_LEFT_HAND) {
|
||||
// 第三人称手提姿态(向下悬挂)
|
||||
poseStack.translate(0.0D, -0.8D, 0.0D);
|
||||
}
|
||||
|
||||
Minecraft.getInstance().getItemRenderer().renderStatic(
|
||||
entity,
|
||||
itemStack,
|
||||
displayContext,
|
||||
leftHand,
|
||||
poseStack,
|
||||
buffer,
|
||||
entity.level(),
|
||||
LightTexture.FULL_BRIGHT,
|
||||
OverlayTexture.NO_OVERLAY,
|
||||
seed
|
||||
);
|
||||
|
||||
poseStack.popPose();
|
||||
}
|
||||
}
|
||||
@@ -26,10 +26,7 @@ import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import net.minecraft.world.item.Tiers;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraft.world.level.ClipContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
@@ -37,6 +34,7 @@ import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.Vector3f;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -223,6 +221,7 @@ public class Nightglow extends MagicWeapon {
|
||||
case Z -> mz = -mz;
|
||||
}
|
||||
summon.setDeltaMovement(new Vec3(mx, my, mz));
|
||||
//SoundUtil.playServerSound(summon.level(), ModSounds.STAR_COLLIDE.get(), summon.position());
|
||||
}
|
||||
|
||||
// 3. 实体碰撞伤害逻辑(全局生效)
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.lzxnone.terraria.mixin;
|
||||
|
||||
import com.lzxnone.terraria.client.config.RenderConfigs;
|
||||
import com.lzxnone.terraria.entity.beam.SwordBeam;
|
||||
import com.lzxnone.terraria.item.ModItems;
|
||||
import com.lzxnone.terraria.item.weapon.RangedWeapon;
|
||||
import com.lzxnone.terraria.item.weapon.ranged.bow.Bow;
|
||||
import net.minecraft.client.model.HumanoidModel;
|
||||
@@ -58,6 +59,19 @@ public abstract class HumanoidModelMixin<T extends LivingEntity> {
|
||||
arm.yRot += (float) Math.toRadians(angleDeg);
|
||||
}
|
||||
|
||||
if(player.getMainHandItem().is(ModItems.NIGHTGLOW.get())) {
|
||||
ModelPart arm = player.getMainArm() == HumanoidArm.RIGHT ? this.rightArm : this.leftArm;
|
||||
arm.xRot = (float) Math.toRadians(-90.0F);
|
||||
arm.yRot = 0.0F;
|
||||
arm.zRot = 0.0F;
|
||||
}
|
||||
if(player.getOffhandItem().is(ModItems.NIGHTGLOW.get())) {
|
||||
ModelPart arm = player.getMainArm() == HumanoidArm.RIGHT ? this.leftArm : this.rightArm;
|
||||
arm.xRot = (float) Math.toRadians(-90.0F);
|
||||
arm.yRot = 0.0F;
|
||||
arm.zRot = 0.0F;
|
||||
}
|
||||
|
||||
if(!player.isUsingItem()) return;
|
||||
|
||||
HumanoidArm usedArm = player.getUsedItemHand() == InteractionHand.MAIN_HAND
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.lzxnone.terraria.mixin;
|
||||
import com.lzxnone.terraria.effect.ModEffects;
|
||||
import com.lzxnone.terraria.client.config.RenderConfigs;
|
||||
import com.lzxnone.terraria.client.item.magic.ClientNebulaBlaze;
|
||||
import com.lzxnone.terraria.client.item.magic.ClientNightglow;
|
||||
import com.lzxnone.terraria.client.item.melee.ClientDevilsDevastation;
|
||||
import com.lzxnone.terraria.entity.ModRenderTypes;
|
||||
import com.lzxnone.terraria.entity.beam.SwordBeam;
|
||||
@@ -13,6 +14,7 @@ import com.lzxnone.terraria.item.weapon.melee.Mace;
|
||||
import com.lzxnone.terraria.item.weapon.summon.whip.Whip;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Axis;
|
||||
import net.minecraft.client.player.AbstractClientPlayer;
|
||||
import net.minecraft.client.renderer.ItemInHandRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
@@ -38,6 +40,10 @@ public class ItemInHandRenderMixin {
|
||||
private void renderPlayerArm(PoseStack poseStack, MultiBufferSource buffer, int packedLight,
|
||||
float equippedProgress, float swingProgress, HumanoidArm side) {}
|
||||
|
||||
@Shadow
|
||||
public void renderItem(LivingEntity entity, ItemStack itemStack, ItemDisplayContext displayContext,
|
||||
boolean leftHand, PoseStack poseStack, MultiBufferSource buffer, int seed) {}
|
||||
|
||||
@Inject(method = "renderArmWithItem", at = @At("HEAD"), cancellable = true)
|
||||
private void renderHand(AbstractClientPlayer player, float partialTicks, float pitch,
|
||||
InteractionHand hand, float swingProgress, ItemStack stack,
|
||||
@@ -45,7 +51,16 @@ public class ItemInHandRenderMixin {
|
||||
MultiBufferSource buffer, int combinedLight, CallbackInfo ci) {
|
||||
if(!RenderConfigs.ENABLE_RENDER_HAND.get()) return;
|
||||
if(!player.isScoping()) {
|
||||
if(stack.is(ModItems.ZENITH.get())
|
||||
if(stack.is(ModItems.NIGHTGLOW.get())) {
|
||||
boolean isMainHand = hand == InteractionHand.MAIN_HAND;
|
||||
HumanoidArm humanoidarm = isMainHand ? player.getMainArm() : player.getMainArm().getOpposite();
|
||||
|
||||
poseStack.pushPose();
|
||||
if(!player.isInvisible()) {
|
||||
this.renderPlayerArm(poseStack, buffer, combinedLight, equippedProgress, swingProgress, humanoidarm);
|
||||
}
|
||||
poseStack.popPose();
|
||||
}else if(stack.is(ModItems.ZENITH.get())
|
||||
|| stack.is(ModItems.TRUE_COPPER_SHORTSWORD.get())
|
||||
|| stack.is(ModItems.FIRST_FRACTAL.get())
|
||||
|| stack.is(ModItems.TERRAGRIM.get())) {
|
||||
@@ -175,6 +190,11 @@ public class ItemInHandRenderMixin {
|
||||
if (SwordBeam.hasActiveBeam(player, SwordBeamBehaviors.TRUE_NIGHTS_EDGE)) {
|
||||
ci.cancel();
|
||||
}
|
||||
}else if(itemStack.is(ModItems.NIGHTGLOW.get()) && entity instanceof Player player) {
|
||||
poseStack.pushPose();
|
||||
ClientNightglow.renderHandItem(player, itemStack, displayContext, leftHand, poseStack, buffer, seed);
|
||||
poseStack.popPose();
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,48 @@
|
||||
{
|
||||
"parent": "lzxnoneterraria:item/sword2",
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "lzxnoneterraria:item/nightglow"
|
||||
},
|
||||
"display": {
|
||||
"gui": {
|
||||
"rotation": [ 0, 0, 0 ],
|
||||
"translation": [ 0, 0, 0 ],
|
||||
"scale": [ 0.6667, 1, 1 ]
|
||||
},
|
||||
"ground": {
|
||||
"rotation": [ 0, 0, 0 ],
|
||||
"translation": [ 0, 2, 0 ],
|
||||
"scale": [ 0.3333, 0.5, 0.5 ]
|
||||
},
|
||||
"head": {
|
||||
"rotation": [ 0, 180, 0 ],
|
||||
"translation": [ 0, 13, 7 ],
|
||||
"scale": [ 0.6667, 1, 1 ]
|
||||
},
|
||||
"fixed": {
|
||||
"rotation": [ 0, 180, 0 ],
|
||||
"translation": [ 0, 0, 0 ],
|
||||
"scale": [ 0.6667, 1, 1 ]
|
||||
},
|
||||
"thirdperson_righthand": {
|
||||
"rotation": [ 0, 0, 0 ],
|
||||
"translation": [ 0, 3, 1 ],
|
||||
"scale": [ 0.7333, 1.1, 1.1 ]
|
||||
},
|
||||
"thirdperson_lefthand": {
|
||||
"rotation": [ 0, 0, 0 ],
|
||||
"translation": [ 0, 3, 1 ],
|
||||
"scale": [ 0.7333, 1.1, 1.1 ]
|
||||
},
|
||||
"firstperson_righthand": {
|
||||
"rotation": [ 0, -90, 25 ],
|
||||
"translation": [ 1.13, 3.2, 1.13 ],
|
||||
"scale": [ 0.9067, 1.36, 1.36 ]
|
||||
},
|
||||
"firstperson_lefthand": {
|
||||
"rotation": [ 0, 90, -25 ],
|
||||
"translation": [ 1.13, 3.2, 1.13 ],
|
||||
"scale": [ 0.9067, 1.36, 1.36 ]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user