From f20bfc8344faba490f5d5cf4975927975f46c575 Mon Sep 17 00:00:00 2001 From: TheBv Date: Wed, 3 Jan 2024 14:05:23 +0100 Subject: [PATCH] fix: fixed the second layer of skin overlapping with ice and fires armors --- .../iceandfire/event/ClientEvents.java | 43 ++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/github/alexthe666/iceandfire/event/ClientEvents.java b/src/main/java/com/github/alexthe666/iceandfire/event/ClientEvents.java index a520bb6c8..a8bbef4d1 100644 --- a/src/main/java/com/github/alexthe666/iceandfire/event/ClientEvents.java +++ b/src/main/java/com/github/alexthe666/iceandfire/event/ClientEvents.java @@ -15,16 +15,22 @@ import com.github.alexthe666.iceandfire.entity.props.SirenProperties; import com.github.alexthe666.iceandfire.entity.util.ICustomMoveController; import com.github.alexthe666.iceandfire.enums.EnumParticles; +import com.github.alexthe666.iceandfire.item.IafArmorMaterial; import com.github.alexthe666.iceandfire.message.MessageDragonControl; import com.github.alexthe666.iceandfire.pathfinding.raycoms.WorldEventContext; import net.minecraft.client.CameraType; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.TitleScreen; +import net.minecraft.client.model.HumanoidModel; +import net.minecraft.client.model.PlayerModel; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ArmorItem; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.event.RenderLevelStageEvent; @@ -38,6 +44,7 @@ import net.minecraftforge.fml.common.Mod; import org.jetbrains.annotations.NotNull; +import java.util.List; import java.util.Random; @OnlyIn(Dist.CLIENT) @@ -69,7 +76,7 @@ public void onCameraSetup(ViewportEvent.ComputeCameraAngles event) { int currentView = IceAndFire.PROXY.getDragon3rdPersonView(); float scale = ((EntityDragonBase) player.getVehicle()).getRenderSize() / 3; if (Minecraft.getInstance().options.getCameraType() == CameraType.THIRD_PERSON_BACK || - Minecraft.getInstance().options.getCameraType() == CameraType.THIRD_PERSON_FRONT) { + Minecraft.getInstance().options.getCameraType() == CameraType.THIRD_PERSON_FRONT) { if (currentView == 1) { event.getCamera().move(-event.getCamera().getMaxZoom(scale * 1.2F), 0F, 0); } else if (currentView == 2) { @@ -163,6 +170,39 @@ public void onPreRenderLiving(RenderLivingEvent.Pre event) { if (shouldCancelRender(event.getEntity())) { event.setCanceled(true); } + for (EquipmentSlot slot : List.of(EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET)) { + ItemStack stack = event.getEntity().getItemBySlot(slot); + if (stack.getItem() instanceof ArmorItem armorStack && armorStack.getMaterial() instanceof IafArmorMaterial) { + switch (slot) { + case HEAD -> { + if (event.getRenderer().getModel() instanceof HumanoidModel humanoidModel) { + humanoidModel.hat.visible = false; + } + } + case CHEST -> { + if (event.getRenderer().getModel() instanceof PlayerModel playerModel) { + playerModel.jacket.visible = false; + playerModel.leftSleeve.visible = false; + playerModel.rightSleeve.visible = false; + } + } + case LEGS -> { + if (event.getRenderer().getModel() instanceof PlayerModel playerModel) { + playerModel.leftPants.visible = false; + playerModel.rightPants.visible = false; + } + } + case FEET -> { + if (event.getRenderer().getModel() instanceof PlayerModel playerModel) { + playerModel.leftLeg.visible = false; + playerModel.rightLeg.visible = false; + } + } + } + + } + } + } @SubscribeEvent @@ -189,6 +229,7 @@ public void onGuiOpened(ScreenEvent.Opening event) { // TODO: add this to client side config public final boolean AUTO_ADAPT_3RD_PERSON = true; + @SubscribeEvent public void onEntityMount(EntityMountEvent event) {