Fixed magic not rendering for items held by other entities

This commit is contained in:
Sollace 2023-10-06 00:45:48 +01:00
parent a7acd2a1c1
commit fa0c903c0f
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
2 changed files with 25 additions and 21 deletions

View file

@ -1,7 +1,7 @@
package com.minelittlepony.client.render; package com.minelittlepony.client.render;
import com.minelittlepony.api.config.PonyConfig;
import com.minelittlepony.api.pony.IPony; import com.minelittlepony.api.pony.IPony;
import com.minelittlepony.client.MineLittlePony;
import com.minelittlepony.client.util.render.RenderLayerUtil; import com.minelittlepony.client.util.render.RenderLayerUtil;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -11,7 +11,6 @@ import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.render.model.json.ModelTransformationMode; import net.minecraft.client.render.model.json.ModelTransformationMode;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.CrossbowItem; import net.minecraft.item.CrossbowItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.screen.PlayerScreenHandler; import net.minecraft.screen.PlayerScreenHandler;
@ -37,13 +36,14 @@ public class LevitatingItemRenderer {
*/ */
public void renderItem(ItemRenderer itemRenderer, @Nullable LivingEntity entity, ItemStack stack, ModelTransformationMode mode, boolean left, MatrixStack matrix, VertexConsumerProvider renderContext, @Nullable World world, int lightUv, int posLong) { public void renderItem(ItemRenderer itemRenderer, @Nullable LivingEntity entity, ItemStack stack, ModelTransformationMode mode, boolean left, MatrixStack matrix, VertexConsumerProvider renderContext, @Nullable World world, int lightUv, int posLong) {
if (entity instanceof PlayerEntity && (mode.isFirstPerson() || mode == ModelTransformationMode.THIRD_PERSON_LEFT_HAND || mode == ModelTransformationMode.THIRD_PERSON_RIGHT_HAND)) { if (mode.isFirstPerson()
|| mode == ModelTransformationMode.THIRD_PERSON_LEFT_HAND
IPony pony = IPony.getManager().getPony((PlayerEntity)entity); || mode == ModelTransformationMode.THIRD_PERSON_RIGHT_HAND
) {
IPony.getManager().getPony(entity).ifPresentOrElse(pony -> {
matrix.push(); matrix.push();
boolean doMagic = MineLittlePony.getInstance().getConfig().fpsmagic.get() && pony.hasMagic(); boolean doMagic = PonyConfig.getInstance().fpsmagic.get() && pony.hasMagic();
if (doMagic && mode.isFirstPerson()) { if (doMagic && mode.isFirstPerson()) {
setupPerspective(itemRenderer, entity, stack, left, matrix); setupPerspective(itemRenderer, entity, stack, left, matrix);
@ -63,6 +63,9 @@ public class LevitatingItemRenderer {
} }
matrix.pop(); matrix.pop();
}, () -> {
itemRenderer.renderItem(entity, stack, mode, left, matrix, renderContext, world, lightUv, OverlayTexture.DEFAULT_UV, posLong);
});
} else { } else {
itemRenderer.renderItem(entity, stack, mode, left, matrix, renderContext, world, lightUv, OverlayTexture.DEFAULT_UV, posLong); itemRenderer.renderItem(entity, stack, mode, left, matrix, renderContext, world, lightUv, OverlayTexture.DEFAULT_UV, posLong);
} }

View file

@ -37,6 +37,7 @@ public class HeldItemFeature<T extends LivingEntity, M extends EntityModel<T> &
return main ? entity.getMainHandStack() : entity.getOffHandStack(); return main ? entity.getMainHandStack() : entity.getOffHandStack();
} }
@Override @Override
public void render(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) { public void render(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {