Skip to content

Commit

Permalink
fix: fixed the second layer of skin overlapping with ice and fires ar…
Browse files Browse the repository at this point in the history
…mors
  • Loading branch information
TheBv committed Jan 3, 2024
1 parent 5992f84 commit 4768ff6
Showing 1 changed file with 44 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,34 @@
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.Pathfinding;
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.EntityViewRenderEvent;
import net.minecraftforge.client.event.ScreenOpenEvent;
import net.minecraftforge.client.event.RenderLivingEvent;
import net.minecraftforge.client.event.RenderLevelLastEvent;
import net.minecraftforge.client.event.RenderLivingEvent;
import net.minecraftforge.client.event.ScreenOpenEvent;
import net.minecraftforge.event.entity.EntityMountEvent;
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

import java.util.List;
import java.util.Random;

@OnlyIn(Dist.CLIENT)
Expand Down Expand Up @@ -69,7 +76,7 @@ public void onCameraSetup(EntityViewRenderEvent.CameraSetup 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) {
Expand Down Expand Up @@ -164,6 +171,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
Expand All @@ -190,6 +230,7 @@ public void onGuiOpened(ScreenOpenEvent event) {

// TODO: add this to client side config
public final boolean AUTO_ADAPT_3RD_PERSON = true;

@SubscribeEvent
public void onEntityMount(EntityMountEvent event) {

Expand Down

0 comments on commit 4768ff6

Please sign in to comment.