diff --git a/src/main/java/com/portingdeadmods/modjam/ModJamClient.java b/src/main/java/com/portingdeadmods/modjam/ModJamClient.java index c040013f..1d85fd9d 100644 --- a/src/main/java/com/portingdeadmods/modjam/ModJamClient.java +++ b/src/main/java/com/portingdeadmods/modjam/ModJamClient.java @@ -1,11 +1,7 @@ package com.portingdeadmods.modjam; -import com.portingdeadmods.modjam.client.renderer.augments.AugmentLayerRenderer; import com.portingdeadmods.modjam.client.renderer.curios.PrismMonocleCuriosRenderer; import com.portingdeadmods.modjam.registries.MJItems; -import net.minecraft.client.renderer.entity.EntityRenderers; -import net.minecraft.client.renderer.entity.player.PlayerRenderer; -import net.minecraft.world.entity.EntityType; import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.IEventBus; import net.neoforged.fml.ModContainer; @@ -21,15 +17,5 @@ public final class ModJamClient { public ModJamClient(IEventBus modEventBus, ModContainer container) { container.registerExtensionPoint(IConfigScreenFactory.class, ConfigurationScreen::new); - modEventBus.addListener(ModJamClient::clientSetup); - } - - private static void clientSetup(final FMLClientSetupEvent evt) { - CuriosRendererRegistry.register(MJItems.PRISM_MONOCLE.get(), PrismMonocleCuriosRenderer::new); - // EntityRenderers.register(EntityType.PLAYER, ctx -> { - // PlayerRenderer renderer = new PlayerRenderer(ctx, false); - // renderer.addLayer(new AugmentLayerRenderer(renderer)); - // return renderer; - // }); } } \ No newline at end of file diff --git a/src/main/java/com/portingdeadmods/modjam/client/renderer/augments/AugmentLayerRenderer.java b/src/main/java/com/portingdeadmods/modjam/client/renderer/augments/AugmentLayerRenderer.java index 0314ec6f..52718671 100644 --- a/src/main/java/com/portingdeadmods/modjam/client/renderer/augments/AugmentLayerRenderer.java +++ b/src/main/java/com/portingdeadmods/modjam/client/renderer/augments/AugmentLayerRenderer.java @@ -6,6 +6,7 @@ import com.portingdeadmods.modjam.content.augments.AugmentHelper; import com.portingdeadmods.modjam.content.augments.StaticAugment; import net.minecraft.client.model.PlayerModel; +import net.minecraft.client.player.AbstractClientPlayer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.entity.RenderLayerParent; @@ -15,23 +16,25 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Player; -public class AugmentLayerRenderer extends RenderLayer> { - public AugmentLayerRenderer(RenderLayerParent renderLayerParent) { +public class AugmentLayerRenderer extends RenderLayer> { + public AugmentLayerRenderer(RenderLayerParent> renderLayerParent) { super(renderLayerParent); } @Override - public void render(PoseStack poseStack, MultiBufferSource bufferSource, int packedLight, Player player, float limbSwing, float limbSwingAmount, float partialTick, float ageInTicks, float netHeadYaw, float headPitch) { + public void render(PoseStack poseStack, MultiBufferSource bufferSource, int packedLight, AbstractClientPlayer player, float limbSwing, float limbSwingAmount, float partialTick, float ageInTicks, float netHeadYaw, float headPitch) { StaticAugment[] augments = getAugment(player); - for (StaticAugment augment : augments){ - renderAugmentModel(poseStack, bufferSource, packedLight, player, augment.getId()); + for (StaticAugment augment : augments) { + if (augment != null) { + renderAugmentModel(poseStack, bufferSource, packedLight, player, augment.getId()); + } } } private void renderAugmentModel(PoseStack poseStack, MultiBufferSource bufferSource, int packedLight, Player player, int id) { AugmentModel model = new AugmentModel(); ResourceLocation texture = ResourceLocation.fromNamespaceAndPath(ModJam.MODID, "textures/entity/augment/test_texture.png"); - model.renderToBuffer(poseStack,bufferSource.getBuffer(RenderType.entityCutoutNoCull(texture)),packedLight, OverlayTexture.NO_OVERLAY, 0xFFFFFFFF); + model.renderToBuffer(poseStack, bufferSource.getBuffer(RenderType.entityCutoutNoCull(texture)), packedLight, OverlayTexture.NO_OVERLAY, 0xFFFFFFFF); } private StaticAugment[] getAugment(Player player) { diff --git a/src/main/java/com/portingdeadmods/modjam/events/MJClientEvents.java b/src/main/java/com/portingdeadmods/modjam/events/MJClientEvents.java index aaf38fd0..7240e3bb 100644 --- a/src/main/java/com/portingdeadmods/modjam/events/MJClientEvents.java +++ b/src/main/java/com/portingdeadmods/modjam/events/MJClientEvents.java @@ -11,6 +11,7 @@ import com.portingdeadmods.modjam.client.model.block.DrainTopModel; import com.portingdeadmods.modjam.client.model.block.PrismarineCrystalModel; import com.portingdeadmods.modjam.client.model.block.WhiskModel; +import com.portingdeadmods.modjam.client.renderer.augments.AugmentLayerRenderer; import com.portingdeadmods.modjam.client.renderer.blockentities.DrainBERenderer; import com.portingdeadmods.modjam.client.renderer.blockentities.LongDistanceLaserBERenderer; import com.portingdeadmods.modjam.client.renderer.blockentities.MixerBERenderer; @@ -28,6 +29,7 @@ import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; import net.minecraft.client.renderer.FogRenderer; +import net.minecraft.client.renderer.entity.player.PlayerRenderer; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.FastColor; import net.minecraft.world.entity.Entity; @@ -169,5 +171,11 @@ public static void onRenderFog(ViewportEvent.RenderFog event) { } } } + + @SubscribeEvent + public static void onRenderPlayer(RenderPlayerEvent.Post event) { + PlayerRenderer renderer = event.getRenderer(); + renderer.addLayer(new AugmentLayerRenderer(renderer)); + } } }