/* * Decompiled with CFR 0.152. */ package net.minecraft.client.renderer.entity; import java.util.Optional; import java.util.function.Function; import net.minecraft.client.model.CopperGolemModel; import net.minecraft.client.model.geom.ModelLayers; import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.entity.MobRenderer; import net.minecraft.client.renderer.entity.layers.BlockDecorationLayer; import net.minecraft.client.renderer.entity.layers.CustomHeadLayer; import net.minecraft.client.renderer.entity.layers.ItemInHandLayer; import net.minecraft.client.renderer.entity.layers.LivingEntityEmissiveLayer; import net.minecraft.client.renderer.entity.state.ArmedEntityRenderState; import net.minecraft.client.renderer.entity.state.CopperGolemRenderState; import net.minecraft.client.renderer.rendertype.RenderTypes; import net.minecraft.core.component.DataComponents; import net.minecraft.resources.Identifier; import net.minecraft.world.entity.animal.coppergolem.CopperGolem; import net.minecraft.world.entity.animal.coppergolem.CopperGolemOxidationLevels; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; import net.minecraft.world.item.component.BlockItemStateProperties; public class CopperGolemRenderer extends MobRenderer { public CopperGolemRenderer(EntityRendererProvider.Context context) { super(context, new CopperGolemModel(context.bakeLayer(ModelLayers.COPPER_GOLEM)), 0.5f); this.addLayer(new LivingEntityEmissiveLayer(this, CopperGolemRenderer.getEyeTextureLocationProvider(), (copperGolem, ageInTicks) -> 1.0f, new CopperGolemModel(context.bakeLayer(ModelLayers.COPPER_GOLEM)), RenderTypes::eyes, false)); this.addLayer(new ItemInHandLayer(this)); this.addLayer(new BlockDecorationLayer(this, s -> s.blockOnAntenna, ((CopperGolemModel)this.model)::applyBlockOnAntennaTransform)); this.addLayer(new CustomHeadLayer(this, context.getModelSet(), context.getPlayerSkinRenderCache())); } @Override public Identifier getTextureLocation(CopperGolemRenderState state) { return CopperGolemOxidationLevels.getOxidationLevel(state.weathering).texture(); } private static Function getEyeTextureLocationProvider() { return renderState -> CopperGolemOxidationLevels.getOxidationLevel(renderState.weathering).eyeTexture(); } @Override public CopperGolemRenderState createRenderState() { return new CopperGolemRenderState(); } @Override public void extractRenderState(CopperGolem entity, CopperGolemRenderState state, float partialTicks) { super.extractRenderState(entity, state, partialTicks); ArmedEntityRenderState.extractArmedEntityRenderState(entity, state, this.itemModelResolver, partialTicks); state.weathering = entity.getWeatherState(); state.copperGolemState = entity.getState(); state.idleAnimationState.copyFrom(entity.getIdleAnimationState()); state.interactionGetItem.copyFrom(entity.getInteractionGetItemAnimationState()); state.interactionGetNoItem.copyFrom(entity.getInteractionGetNoItemAnimationState()); state.interactionDropItem.copyFrom(entity.getInteractionDropItemAnimationState()); state.interactionDropNoItem.copyFrom(entity.getInteractionDropNoItemAnimationState()); state.blockOnAntenna = Optional.of(entity.getItemBySlot(CopperGolem.EQUIPMENT_SLOT_ANTENNA)).flatMap(itemStack -> { Item patt0$temp = itemStack.getItem(); if (!(patt0$temp instanceof BlockItem)) { return Optional.empty(); } BlockItem blockItem = (BlockItem)patt0$temp; BlockItemStateProperties blockItemState = itemStack.getOrDefault(DataComponents.BLOCK_STATE, BlockItemStateProperties.EMPTY); return Optional.of(blockItemState.apply(blockItem.getBlock().defaultBlockState())); }); } }