Skip to content

Commit

Permalink
Split Up TrailierTalesClient To Mirror Wilder Wild
Browse files Browse the repository at this point in the history
  • Loading branch information
AViewFromTheTop committed Dec 5, 2024
1 parent 6aa0a17 commit 61ef698
Show file tree
Hide file tree
Showing 11 changed files with 121 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,85 +3,30 @@
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry;
import net.frozenblock.lib.block.api.entity.BlockEntityWithoutLevelRendererRegistry;
import net.frozenblock.lib.debug.client.api.DebugRendererEvents;
import net.frozenblock.lib.debug.client.impl.DebugRenderManager;
import net.frozenblock.lib.menu.api.Panoramas;
import net.frozenblock.lib.menu.api.SplashTextAPI;
import net.frozenblock.trailiertales.block.render.CoffinRenderer;
import net.frozenblock.trailiertales.debug.client.renderer.CoffinDebugRenderer;
import net.frozenblock.trailiertales.entity.render.model.ApparitionModel;
import net.frozenblock.trailiertales.entity.render.model.BoatBannerModel;
import net.frozenblock.trailiertales.entity.render.renderer.ApparitionRenderer;
import net.frozenblock.trailiertales.client.TTBlockRenderLayers;
import net.frozenblock.trailiertales.client.TTModelLayers;
import net.frozenblock.trailiertales.client.TTParticleEngine;
import net.frozenblock.trailiertales.client.renderer.debug.CoffinDebugRenderer;
import net.frozenblock.trailiertales.networking.packet.CoffinDebugPacket;
import net.frozenblock.trailiertales.networking.packet.CoffinRemoveDebugPacket;
import net.frozenblock.trailiertales.particle.GlowingColorBubbleParticle;
import net.frozenblock.trailiertales.particle.GlowingColorTransitionParticle;
import net.frozenblock.trailiertales.particle.GlowingSpellParticle;
import net.frozenblock.trailiertales.particle.provider.TrailierParticleProviders;
import net.frozenblock.trailiertales.registry.TTBlockEntityTypes;
import net.frozenblock.trailiertales.registry.TTBlocks;
import net.frozenblock.trailiertales.registry.TTEntityTypes;
import net.frozenblock.trailiertales.registry.TTParticleTypes;
import net.minecraft.client.model.geom.ModelLayerLocation;
import net.minecraft.client.particle.SoulParticle;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
import net.minecraft.client.renderer.entity.ThrownItemRenderer;
import net.minecraft.resources.ResourceLocation;

@Environment(EnvType.CLIENT)
public class TrailierTalesClient implements ClientModInitializer {
public static final ModelLayerLocation COFFIN_HEAD = new ModelLayerLocation(TTConstants.id("coffin_head"), "main");
public static final ModelLayerLocation COFFIN_FOOT = new ModelLayerLocation(TTConstants.id("coffin_foot"), "main");
public static final ModelLayerLocation APPARITION = new ModelLayerLocation(TTConstants.id("apparition"), "main");
public static final ModelLayerLocation APPARITION_OVERLAY = new ModelLayerLocation(TTConstants.id("apparition"), "overlay");
public static final ModelLayerLocation BOAT_BANNER = new ModelLayerLocation(TTConstants.id("boat"), "banner");

@Override
public void onInitializeClient() {
SplashTextAPI.addSplashLocation(TTConstants.id("texts/splashes.txt"));
addPanorama("catacombs");

BlockEntityWithoutLevelRendererRegistry.register(TTBlocks.COFFIN, TTBlockEntityTypes.COFFIN);

BlockRenderLayerMap renderLayerRegistry = BlockRenderLayerMap.INSTANCE;
renderLayerRegistry.putBlock(TTBlocks.POTTED_CYAN_ROSE, RenderType.cutout());
renderLayerRegistry.putBlock(TTBlocks.CYAN_ROSE, RenderType.cutout());
renderLayerRegistry.putBlock(TTBlocks.CYAN_ROSE_CROP, RenderType.cutout());

renderLayerRegistry.putBlock(TTBlocks.MANEDROP, RenderType.cutout());
renderLayerRegistry.putBlock(TTBlocks.MANEDROP_CROP, RenderType.cutout());

renderLayerRegistry.putBlock(TTBlocks.DAWNTRAIL, RenderType.cutout());
renderLayerRegistry.putBlock(TTBlocks.DAWNTRAIL_CROP, RenderType.cutout());

BlockEntityRenderers.register(TTBlockEntityTypes.COFFIN, CoffinRenderer::new);
EntityModelLayerRegistry.registerModelLayer(COFFIN_HEAD, CoffinRenderer::createHeadLayer);
EntityModelLayerRegistry.registerModelLayer(COFFIN_FOOT, CoffinRenderer::createFootLayer);

EntityRendererRegistry.register(TTEntityTypes.APPARITION, ApparitionRenderer::new);
EntityModelLayerRegistry.registerModelLayer(APPARITION, ApparitionModel::createBodyLayer);
EntityModelLayerRegistry.registerModelLayer(APPARITION_OVERLAY, ApparitionModel::createBodyLayer);

EntityRendererRegistry.register(TTEntityTypes.THROWN_ITEM_PROJECTILE, ThrownItemRenderer::new);

EntityModelLayerRegistry.registerModelLayer(BOAT_BANNER, BoatBannerModel::createBodyLayer);

ParticleFactoryRegistry particleRegistry = ParticleFactoryRegistry.getInstance();
particleRegistry.register(TTParticleTypes.COFFIN_SOUL, SoulParticle.EmissiveProvider::new);
particleRegistry.register(TTParticleTypes.COFFIN_SOUL_ENTER, SoulParticle.EmissiveProvider::new);
particleRegistry.register(TTParticleTypes.GLOWING_BUBBLE, GlowingColorBubbleParticle.Provider::new);
particleRegistry.register(TTParticleTypes.GLOWING_ENTITY_EFFECT, GlowingSpellParticle.MobEffectProvider::new);
particleRegistry.register(TTParticleTypes.GLOWING_DUST_COLOR_TRANSITION, GlowingColorTransitionParticle.Provider::new);
particleRegistry.register(TTParticleTypes.SUSPICIOUS_CONNECTION, TrailierParticleProviders.SuspiciousConnectionProvider::new);
particleRegistry.register(TTParticleTypes.SIEGE_OMEN, GlowingSpellParticle.Provider::new);
particleRegistry.register(TTParticleTypes.TRANSFIGURING, GlowingSpellParticle.Provider::new);
TTBlockRenderLayers.init();
TTModelLayers.init();
TTParticleEngine.init();

DebugRendererEvents.DEBUG_RENDERERS_CREATED.register(client -> {
CoffinDebugRenderer coffinDebugRenderer = new CoffinDebugRenderer(client);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package net.frozenblock.trailiertales.client;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.frozenblock.lib.block.api.entity.BlockEntityWithoutLevelRendererRegistry;
import net.frozenblock.trailiertales.registry.TTBlockEntityTypes;
import net.frozenblock.trailiertales.registry.TTBlocks;
import net.minecraft.client.renderer.RenderType;

@Environment(EnvType.CLIENT)
public class TTBlockRenderLayers {

public static void init() {
BlockEntityWithoutLevelRendererRegistry.register(TTBlocks.COFFIN, TTBlockEntityTypes.COFFIN);

BlockRenderLayerMap renderLayerRegistry = BlockRenderLayerMap.INSTANCE;
renderLayerRegistry.putBlock(TTBlocks.POTTED_CYAN_ROSE, RenderType.cutout());
renderLayerRegistry.putBlock(TTBlocks.CYAN_ROSE, RenderType.cutout());
renderLayerRegistry.putBlock(TTBlocks.CYAN_ROSE_CROP, RenderType.cutout());

renderLayerRegistry.putBlock(TTBlocks.MANEDROP, RenderType.cutout());
renderLayerRegistry.putBlock(TTBlocks.MANEDROP_CROP, RenderType.cutout());

renderLayerRegistry.putBlock(TTBlocks.DAWNTRAIL, RenderType.cutout());
renderLayerRegistry.putBlock(TTBlocks.DAWNTRAIL_CROP, RenderType.cutout());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package net.frozenblock.trailiertales.client;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry;
import net.frozenblock.trailiertales.TTConstants;
import net.frozenblock.trailiertales.client.model.ApparitionModel;
import net.frozenblock.trailiertales.client.model.BoatBannerModel;
import net.frozenblock.trailiertales.client.renderer.blockentity.CoffinRenderer;
import net.frozenblock.trailiertales.client.renderer.entity.ApparitionRenderer;
import net.frozenblock.trailiertales.registry.TTBlockEntityTypes;
import net.frozenblock.trailiertales.registry.TTEntityTypes;
import net.minecraft.client.model.geom.ModelLayerLocation;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
import net.minecraft.client.renderer.entity.ThrownItemRenderer;

@Environment(EnvType.CLIENT)
public class TTModelLayers {
public static final ModelLayerLocation COFFIN_HEAD = new ModelLayerLocation(TTConstants.id("coffin_head"), "main");
public static final ModelLayerLocation COFFIN_FOOT = new ModelLayerLocation(TTConstants.id("coffin_foot"), "main");
public static final ModelLayerLocation APPARITION = new ModelLayerLocation(TTConstants.id("apparition"), "main");
public static final ModelLayerLocation APPARITION_OVERLAY = new ModelLayerLocation(TTConstants.id("apparition"), "overlay");
public static final ModelLayerLocation BOAT_BANNER = new ModelLayerLocation(TTConstants.id("boat"), "banner");

public static void init() {
BlockEntityRenderers.register(TTBlockEntityTypes.COFFIN, CoffinRenderer::new);
EntityModelLayerRegistry.registerModelLayer(COFFIN_HEAD, CoffinRenderer::createHeadLayer);
EntityModelLayerRegistry.registerModelLayer(COFFIN_FOOT, CoffinRenderer::createFootLayer);

EntityRendererRegistry.register(TTEntityTypes.APPARITION, ApparitionRenderer::new);
EntityModelLayerRegistry.registerModelLayer(APPARITION, ApparitionModel::createBodyLayer);
EntityModelLayerRegistry.registerModelLayer(APPARITION_OVERLAY, ApparitionModel::createBodyLayer);

EntityRendererRegistry.register(TTEntityTypes.THROWN_ITEM_PROJECTILE, ThrownItemRenderer::new);

EntityModelLayerRegistry.registerModelLayer(BOAT_BANNER, BoatBannerModel::createBodyLayer);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package net.frozenblock.trailiertales.client;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
import net.frozenblock.trailiertales.particle.GlowingColorBubbleParticle;
import net.frozenblock.trailiertales.particle.GlowingColorTransitionParticle;
import net.frozenblock.trailiertales.particle.GlowingSpellParticle;
import net.frozenblock.trailiertales.particle.provider.TrailierParticleProviders;
import net.frozenblock.trailiertales.registry.TTParticleTypes;
import net.minecraft.client.particle.SoulParticle;

@Environment(EnvType.CLIENT)
public class TTParticleEngine {

public static void init() {
ParticleFactoryRegistry particleRegistry = ParticleFactoryRegistry.getInstance();

particleRegistry.register(TTParticleTypes.COFFIN_SOUL, SoulParticle.EmissiveProvider::new);
particleRegistry.register(TTParticleTypes.COFFIN_SOUL_ENTER, SoulParticle.EmissiveProvider::new);
particleRegistry.register(TTParticleTypes.GLOWING_BUBBLE, GlowingColorBubbleParticle.Provider::new);
particleRegistry.register(TTParticleTypes.GLOWING_ENTITY_EFFECT, GlowingSpellParticle.MobEffectProvider::new);
particleRegistry.register(TTParticleTypes.GLOWING_DUST_COLOR_TRANSITION, GlowingColorTransitionParticle.Provider::new);
particleRegistry.register(TTParticleTypes.SUSPICIOUS_CONNECTION, TrailierParticleProviders.SuspiciousConnectionProvider::new);
particleRegistry.register(TTParticleTypes.SIEGE_OMEN, GlowingSpellParticle.Provider::new);
particleRegistry.register(TTParticleTypes.TRANSFIGURING, GlowingSpellParticle.Provider::new);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.frozenblock.trailiertales.entity.render.model;
package net.frozenblock.trailiertales.client.model;

import com.google.common.collect.ImmutableList;
import com.mojang.blaze3d.vertex.PoseStack;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.frozenblock.trailiertales.entity.render.model;
package net.frozenblock.trailiertales.client.model;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.frozenblock.trailiertales.block.render;
package net.frozenblock.trailiertales.client.renderer.blockentity;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
Expand All @@ -10,6 +10,7 @@
import net.frozenblock.trailiertales.block.entity.coffin.CoffinBlockEntity;
import net.frozenblock.trailiertales.block.entity.coffin.CoffinSpawnerState;
import net.frozenblock.trailiertales.block.impl.CoffinPart;
import net.frozenblock.trailiertales.client.TTModelLayers;
import net.frozenblock.trailiertales.registry.TTBlockEntityTypes;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.model.geom.PartPose;
Expand Down Expand Up @@ -42,11 +43,11 @@ public class CoffinRenderer implements BlockEntityRenderer<CoffinBlockEntity> {
private final ModelPart footLid;

public CoffinRenderer(@NotNull Context context) {
this.headRoot = context.bakeLayer(TrailierTalesClient.COFFIN_HEAD); //left
this.headRoot = context.bakeLayer(TTModelLayers.COFFIN_HEAD); //left
this.headBase = headRoot.getChild(BASE);
this.headLid = headRoot.getChild(LID);

this.footRoot = context.bakeLayer(TrailierTalesClient.COFFIN_FOOT); //right
this.footRoot = context.bakeLayer(TTModelLayers.COFFIN_FOOT); //right
this.footBase = footRoot.getChild(BASE);
this.footLid = footRoot.getChild(LID);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.frozenblock.trailiertales.debug.client.renderer;
package net.frozenblock.trailiertales.client.renderer.debug;

import com.google.common.collect.Maps;
import com.mojang.blaze3d.vertex.PoseStack;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package net.frozenblock.trailiertales.entity.render.renderer;
package net.frozenblock.trailiertales.client.renderer.entity;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Axis;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.frozenblock.trailiertales.TTConstants;
import net.frozenblock.trailiertales.TrailierTalesClient;
import net.frozenblock.trailiertales.client.TTModelLayers;
import net.frozenblock.trailiertales.entity.Apparition;
import net.frozenblock.trailiertales.entity.render.layer.ApparitionOverlayLayer;
import net.frozenblock.trailiertales.entity.render.model.ApparitionModel;
import net.frozenblock.trailiertales.client.renderer.entity.layers.ApparitionOverlayLayer;
import net.frozenblock.trailiertales.client.model.ApparitionModel;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.ItemRenderer;
Expand All @@ -28,7 +29,7 @@ public class ApparitionRenderer extends MobRenderer<Apparition, ApparitionModel<
private static final ResourceLocation TEXTURE = TTConstants.id("textures/entity/apparition/apparition.png");

public ApparitionRenderer(EntityRendererProvider.Context context) {
super(context, new ApparitionModel<>(context.bakeLayer(TrailierTalesClient.APPARITION)), 0.5F);
super(context, new ApparitionModel<>(context.bakeLayer(TTModelLayers.APPARITION)), 0.5F);
this.addLayer(new ApparitionOverlayLayer<>(
context,
this,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package net.frozenblock.trailiertales.entity.render.layer;
package net.frozenblock.trailiertales.client.renderer.entity.layers;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.frozenblock.lib.entity.api.rendering.FrozenRenderType;
import net.frozenblock.trailiertales.TrailierTalesClient;
import net.frozenblock.trailiertales.client.TTModelLayers;
import net.frozenblock.trailiertales.entity.Apparition;
import net.frozenblock.trailiertales.entity.render.model.ApparitionModel;
import net.frozenblock.trailiertales.client.model.ApparitionModel;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
Expand All @@ -32,7 +33,7 @@ public ApparitionOverlayLayer(
super(renderLayerParent);
this.model = new ApparitionModel<>(
cull ? FrozenRenderType::apparitionOuterCull : FrozenRenderType::apparitionOuter,
context.bakeLayer(TrailierTalesClient.APPARITION_OVERLAY),
context.bakeLayer(TTModelLayers.APPARITION_OVERLAY),
innerAlphaFunction,
outlineAlphaFunction,
outerAlphaFunction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
import net.fabricmc.api.Environment;
import net.frozenblock.trailiertales.TTConstants;
import net.frozenblock.trailiertales.TrailierTalesClient;
import net.frozenblock.trailiertales.entity.render.model.BoatBannerModel;
import net.frozenblock.trailiertales.client.TTModelLayers;
import net.frozenblock.trailiertales.client.model.BoatBannerModel;
import net.frozenblock.trailiertales.impl.BoatBannerInterface;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.BoatRenderer;
Expand Down Expand Up @@ -45,7 +46,7 @@ protected BoatRendererMixin(EntityRendererProvider.Context ctx) {

@Inject(method = "<init>", at = @At("TAIL"))
public void trailierTales$init(EntityRendererProvider.Context context, boolean isChest, CallbackInfo info) {
this.trailierTales$boatBannerModel = new BoatBannerModel(context.bakeLayer(TrailierTalesClient.BOAT_BANNER));
this.trailierTales$boatBannerModel = new BoatBannerModel(context.bakeLayer(TTModelLayers.BOAT_BANNER));
this.trailierTales$boatBannerResources = Stream.of(Boat.Type.values())
.collect(ImmutableMap.toImmutableMap(boatVariant -> boatVariant, BoatRendererMixin::trailierTales$getBannerBaseTextureLocation));
}
Expand Down

0 comments on commit 61ef698

Please sign in to comment.