Skip to content

Commit

Permalink
augment rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Thepigcat76 committed Sep 15, 2024
1 parent 6dc7997 commit 1badc29
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
14 changes: 0 additions & 14 deletions src/main/java/com/portingdeadmods/modjam/ModJamClient.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
// });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -15,23 +16,25 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;

public class AugmentLayerRenderer extends RenderLayer<Player, PlayerModel<Player>> {
public AugmentLayerRenderer(RenderLayerParent renderLayerParent) {
public class AugmentLayerRenderer extends RenderLayer<AbstractClientPlayer, PlayerModel<AbstractClientPlayer>> {
public AugmentLayerRenderer(RenderLayerParent<AbstractClientPlayer, PlayerModel<AbstractClientPlayer>> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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));
}
}
}

0 comments on commit 1badc29

Please sign in to comment.