Skip to content

Commit

Permalink
add helmet to hunter representatives
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheaterpaul committed Feb 6, 2024
1 parent 8a12c48 commit 75516db
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,30 @@
import de.teamlapen.vampirism.REFERENCE;
import de.teamlapen.vampirism.client.core.ModEntitiesRender;
import de.teamlapen.vampirism.client.renderer.entity.layers.TaskMasterTypeLayer;
import de.teamlapen.vampirism.entity.hunter.AdvancedHunterEntity;
import de.teamlapen.vampirism.entity.hunter.HunterTaskMasterEntity;
import de.teamlapen.vampirism.mixin.client.VillagerModelAccessor;
import net.minecraft.client.model.AgeableListModel;
import net.minecraft.client.model.HumanoidArmorModel;
import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.model.VillagerModel;
import net.minecraft.client.model.geom.ModelLayers;
import net.minecraft.client.renderer.ItemInHandRenderer;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.MobRenderer;
import net.minecraft.client.renderer.entity.RenderLayerParent;
import net.minecraft.client.renderer.entity.layers.CustomHeadLayer;
import net.minecraft.client.renderer.entity.layers.HumanoidArmorLayer;
import net.minecraft.client.renderer.entity.layers.RenderLayer;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.armortrim.ArmorTrim;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.jetbrains.annotations.NotNull;
Expand All @@ -28,6 +44,7 @@ public HunterTaskMasterRenderer(EntityRendererProvider.@NotNull Context context)
super(context, new VillagerModel<>(context.bakeLayer(ModEntitiesRender.TASK_MASTER)), 0.5F);
// this.addLayer(new HeldItemLayer<>(this));
this.addLayer(new TaskMasterTypeLayer<>(this, overlay));
this.addLayer(new HelmetLayer(this, context.getItemInHandRenderer()));
}

@NotNull
Expand All @@ -44,5 +61,28 @@ protected void renderNameTag(@NotNull HunterTaskMasterEntity entityIn, @NotNull
}
}

private static class HelmetLayer extends RenderLayer<HunterTaskMasterEntity, VillagerModel<HunterTaskMasterEntity>> {
private final ItemInHandRenderer pItemInHandRenderer;

public HelmetLayer(RenderLayerParent<HunterTaskMasterEntity, VillagerModel<HunterTaskMasterEntity>> pRenderer, ItemInHandRenderer pItemInHandRenderer) {
super(pRenderer);
this.pItemInHandRenderer = pItemInHandRenderer;
}

@Override
public void render(@NotNull PoseStack pPoseStack, @NotNull MultiBufferSource pBuffer, int pPackedLight, HunterTaskMasterEntity pLivingEntity, float pLimbSwing, float pLimbSwingAmount, float pPartialTick, float pAgeInTicks, float pNetHeadYaw, float pHeadPitch) {
ItemStack itemstack = pLivingEntity.getItemBySlot(EquipmentSlot.HEAD);
if (!itemstack.isEmpty()) {
pPoseStack.pushPose();
this.getParentModel().getHead().translateAndRotate(pPoseStack);
CustomHeadLayer.translateToHead(pPoseStack, true);
pPoseStack.translate(0.0F, -0.2F, 0.0F);
pPoseStack.scale(1.1F, 1.1F, 1.1F);
this.pItemInHandRenderer.renderItem(pLivingEntity, itemstack, ItemDisplayContext.HEAD, false, pPoseStack, pBuffer, pPackedLight);
pPoseStack.popPose();
}
}
}


}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.teamlapen.vampirism.entity.hunter;

import de.teamlapen.vampirism.config.BalanceMobProps;
import de.teamlapen.vampirism.core.ModItems;
import de.teamlapen.vampirism.entity.IDefaultTaskMasterEntity;
import de.teamlapen.vampirism.entity.VampirismEntity;
import de.teamlapen.vampirism.entity.ai.goals.ForceLookEntityGoal;
Expand All @@ -18,6 +19,7 @@
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.entity.SpawnGroupData;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
Expand Down Expand Up @@ -67,6 +69,7 @@ public void aiStep() {
public SpawnGroupData finalizeSpawn(@NotNull ServerLevelAccessor worldIn, @NotNull DifficultyInstance difficultyIn, @NotNull MobSpawnType reason, @Nullable SpawnGroupData spawnDataIn, @Nullable CompoundTag dataTag) {
SpawnGroupData data = super.finalizeSpawn(worldIn, difficultyIn, reason, spawnDataIn, dataTag);
this.setBiomeType(VillagerType.byBiome(worldIn.getBiome(this.blockPosition())));
this.setItemSlot(EquipmentSlot.HEAD, ModItems.HUNTER_HAT_HEAD_0.get().getDefaultInstance());
return data;
}

Expand Down

0 comments on commit 75516db

Please sign in to comment.