mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-22 12:37:59 +01:00
Use the fabric library for rendering registration.
This commit is contained in:
parent
a40bb7fa02
commit
91274352b4
15 changed files with 54 additions and 40 deletions
|
@ -13,6 +13,7 @@ import com.minelittlepony.client.render.entities.player.RenderPonyPlayer;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.fabricmc.fabric.api.client.render.EntityRendererRegistry;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.render.entity.EntityRenderer;
|
||||
|
@ -71,19 +72,19 @@ public class PonyRenderManager {
|
|||
*
|
||||
* @param state True if we want ponies (the original will be stored)
|
||||
* @param type The type to replace
|
||||
* @param renderer The replacement value
|
||||
* @param factory The replacement value
|
||||
* @param <T> The entity type
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Entity, V extends T> void switchRenderer(boolean state, Class<V> type, Function<EntityRenderDispatcher, EntityRenderer<T>> func) {
|
||||
public <T extends Entity, V extends T> void switchRenderer(boolean state, Class<V> type, EntityRendererRegistry.Factory factory) {
|
||||
if (state) {
|
||||
if (!renderMap.containsKey(type)) {
|
||||
renderMap.put(type, MinecraftClient.getInstance().getEntityRenderManager().getRenderer(type));
|
||||
}
|
||||
MineLPClient.getInstance().getModUtilities().addRenderer((Class<T>)type, func);
|
||||
EntityRendererRegistry.INSTANCE.register(type, factory);
|
||||
} else {
|
||||
if (renderMap.containsKey(type)) {
|
||||
MineLPClient.getInstance().getModUtilities().addRenderer(type, m -> (EntityRenderer<V>)renderMap.get(type));
|
||||
EntityRendererRegistry.INSTANCE.register(type, (m1, c) -> ((Function<EntityRenderDispatcher, EntityRenderer<V>>) m -> (EntityRenderer<V>) renderMap.get(type)).apply(m1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.minelittlepony.client.gui.hdskins;
|
||||
|
||||
import net.fabricmc.fabric.api.client.render.EntityRendererRegistry;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
|
@ -56,7 +57,7 @@ class MineLPHDSkins extends MineLPClient implements ISkinCacheClearListener {
|
|||
super.postInit(minecraft);
|
||||
|
||||
// Preview on the select skin gui
|
||||
getModUtilities().addRenderer(DummyPony.class, RenderDummyPony::new);
|
||||
EntityRendererRegistry.INSTANCE.register(DummyPony.class, RenderDummyPony::new);
|
||||
|
||||
HDSkins manager = HDSkins.getInstance();
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import com.minelittlepony.pony.meta.Race;
|
|||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
import net.fabricmc.fabric.api.client.render.EntityRendererRegistry;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.render.entity.feature.FeatureRenderer;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
@ -25,8 +26,8 @@ class RenderDummyPony extends RenderDummyPlayer<DummyPony, ClientPonyModel<Dummy
|
|||
|
||||
protected final RenderPony<DummyPony, ClientPonyModel<DummyPony>> renderPony = new RenderPony<>(this);
|
||||
|
||||
public RenderDummyPony(EntityRenderDispatcher manager) {
|
||||
super(manager);
|
||||
public RenderDummyPony(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
|
||||
super(manager, context);
|
||||
addFeature(new LayerGear<>(this));
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.minelittlepony.client.render.layer.LayerHeldPonyItem;
|
|||
import com.minelittlepony.client.render.layer.LayerHeldPonyItemMagical;
|
||||
import com.minelittlepony.client.render.layer.LayerEyeGlow.IGlowingRenderer;
|
||||
|
||||
import net.fabricmc.fabric.api.client.render.EntityRendererRegistry;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.render.entity.feature.StuckArrowsFeatureRenderer;
|
||||
|
@ -22,7 +23,7 @@ public class RenderEnderStallion extends RenderPonyMob<EndermanEntity, ModelEnde
|
|||
|
||||
private final Random rnd = new Random();
|
||||
|
||||
public RenderEnderStallion(EntityRenderDispatcher manager) {
|
||||
public RenderEnderStallion(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
|
||||
super(manager, new ModelEnderStallion());
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.minelittlepony.client.render.layer.LayerHeldPonyItem;
|
|||
import com.minelittlepony.client.render.layer.LayerHeldPonyItemMagical;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
import net.fabricmc.fabric.api.client.render.EntityRendererRegistry;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.render.entity.GuardianEntityRenderer;
|
||||
import net.minecraft.entity.EntityDimensions;
|
||||
|
@ -22,7 +23,7 @@ public class RenderPonyGuardian extends GuardianEntityRenderer {
|
|||
|
||||
private final Proxy<GuardianEntity, ModelGuardianPony> ponyRenderer;
|
||||
|
||||
public RenderPonyGuardian(EntityRenderDispatcher manager) {
|
||||
public RenderPonyGuardian(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
|
||||
super(manager);
|
||||
|
||||
features.clear();
|
||||
|
@ -68,8 +69,8 @@ public class RenderPonyGuardian extends GuardianEntityRenderer {
|
|||
|
||||
public static class Elder extends RenderPonyGuardian {
|
||||
|
||||
public Elder(EntityRenderDispatcher manager) {
|
||||
super(manager);
|
||||
public Elder(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
|
||||
super(manager, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.minelittlepony.client.render.layer.LayerHeldItemIllager;
|
|||
import com.minelittlepony.client.render.layer.LayerHeldPonyItem;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
import net.fabricmc.fabric.api.client.render.EntityRendererRegistry;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.entity.mob.EvokerEntity;
|
||||
import net.minecraft.entity.mob.IllagerEntity;
|
||||
|
@ -20,7 +21,7 @@ public abstract class RenderPonyIllager<T extends IllagerEntity> extends RenderP
|
|||
public static final Identifier EVOKER = new Identifier("minelittlepony", "textures/entity/illager/evoker_pony.png");
|
||||
public static final Identifier VINDICATOR = new Identifier("minelittlepony", "textures/entity/illager/vindicator_pony.png");
|
||||
|
||||
public RenderPonyIllager(EntityRenderDispatcher manager) {
|
||||
public RenderPonyIllager(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
|
||||
super(manager, new ModelIllagerPony<>());
|
||||
}
|
||||
|
||||
|
@ -37,8 +38,8 @@ public abstract class RenderPonyIllager<T extends IllagerEntity> extends RenderP
|
|||
|
||||
public static class Vindicator extends RenderPonyIllager<VindicatorEntity> {
|
||||
|
||||
public Vindicator(EntityRenderDispatcher manager) {
|
||||
super(manager);
|
||||
public Vindicator(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
|
||||
super(manager, context);
|
||||
|
||||
}
|
||||
|
||||
|
@ -50,8 +51,8 @@ public abstract class RenderPonyIllager<T extends IllagerEntity> extends RenderP
|
|||
|
||||
public static class Evoker extends RenderPonyIllager<EvokerEntity> {
|
||||
|
||||
public Evoker(EntityRenderDispatcher manager) {
|
||||
super(manager);
|
||||
public Evoker(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
|
||||
super(manager, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -62,8 +63,8 @@ public abstract class RenderPonyIllager<T extends IllagerEntity> extends RenderP
|
|||
|
||||
public static class Illusionist extends RenderPonyIllager<IllusionerEntity> {
|
||||
|
||||
public Illusionist(EntityRenderDispatcher manager) {
|
||||
super(manager);
|
||||
public Illusionist(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
|
||||
super(manager, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.minelittlepony.client.render.entities;
|
||||
|
||||
import net.fabricmc.fabric.api.client.render.EntityRendererRegistry;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.entity.mob.PillagerEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
@ -12,7 +13,7 @@ public class RenderPonyPillager extends RenderPonyMob<PillagerEntity, ModelPilla
|
|||
|
||||
private static final Identifier TEXTURES = new Identifier("minelittlepony", "textures/entity/illager/pillager_pony.png");
|
||||
|
||||
public RenderPonyPillager(EntityRenderDispatcher manager) {
|
||||
public RenderPonyPillager(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
|
||||
super(manager, new ModelPillagerPony<PillagerEntity>());
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.minelittlepony.client.render.layer.LayerHeldPonyItemMagical;
|
|||
import com.minelittlepony.client.render.layer.LayerPonyStrayOverlay;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
import net.fabricmc.fabric.api.client.render.EntityRendererRegistry;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.entity.mob.AbstractSkeletonEntity;
|
||||
import net.minecraft.entity.mob.StrayEntity;
|
||||
|
@ -18,7 +19,7 @@ public class RenderPonySkeleton<Skeleton extends AbstractSkeletonEntity> extends
|
|||
public static final Identifier WITHER = new Identifier("minelittlepony", "textures/entity/skeleton/skeleton_wither_pony.png");
|
||||
public static final Identifier STRAY = new Identifier("minelittlepony", "textures/entity/skeleton/stray_pony.png");
|
||||
|
||||
public RenderPonySkeleton(EntityRenderDispatcher manager) {
|
||||
public RenderPonySkeleton(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
|
||||
super(manager, new ModelSkeletonPony<>());
|
||||
}
|
||||
|
||||
|
@ -34,8 +35,8 @@ public class RenderPonySkeleton<Skeleton extends AbstractSkeletonEntity> extends
|
|||
|
||||
public static class Stray extends RenderPonySkeleton<StrayEntity> {
|
||||
|
||||
public Stray(EntityRenderDispatcher rm) {
|
||||
super(rm);
|
||||
public Stray(EntityRenderDispatcher rm, EntityRendererRegistry.Context context) {
|
||||
super(rm, context);
|
||||
addFeature(new LayerPonyStrayOverlay<>(this));
|
||||
}
|
||||
|
||||
|
@ -47,8 +48,8 @@ public class RenderPonySkeleton<Skeleton extends AbstractSkeletonEntity> extends
|
|||
|
||||
public static class Wither extends RenderPonySkeleton<WitherSkeletonEntity> {
|
||||
|
||||
public Wither(EntityRenderDispatcher rm) {
|
||||
super(rm);
|
||||
public Wither(EntityRenderDispatcher rm, EntityRendererRegistry.Context context) {
|
||||
super(rm, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.minelittlepony.client.render.entities;
|
||||
|
||||
import net.fabricmc.fabric.api.client.render.EntityRendererRegistry;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.entity.passive.WanderingTraderEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
@ -11,7 +12,7 @@ public class RenderPonyTrader extends RenderPonyMob.Caster<WanderingTraderEntity
|
|||
|
||||
public static final Identifier TEXTURE = new Identifier("minelittlepony", "textures/entity/wandering_trader_pony.png");
|
||||
|
||||
public RenderPonyTrader(EntityRenderDispatcher manager) {
|
||||
public RenderPonyTrader(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
|
||||
super(manager, new ModelAlicorn<>(false));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.minelittlepony.client.render.entities;
|
||||
|
||||
import net.fabricmc.fabric.api.client.render.EntityRendererRegistry;
|
||||
import net.minecraft.client.render.entity.BipedEntityRenderer;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.entity.mob.VexEntity;
|
||||
|
@ -16,7 +17,7 @@ public class RenderPonyVex extends BipedEntityRenderer<VexEntity, ModelBreezie<V
|
|||
private static final Identifier VEX = new Identifier("minelittlepony", "textures/entity/illager/vex_pony.png");
|
||||
private static final Identifier VEX_CHARGING = new Identifier("minelittlepony", "textures/entity/illager/vex_charging_pony.png");
|
||||
|
||||
public RenderPonyVex(EntityRenderDispatcher manager) {
|
||||
public RenderPonyVex(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
|
||||
super(manager, new ModelBreezie<>(), 0.3F);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.minelittlepony.util.resources.FormattedTextureSupplier;
|
|||
import com.minelittlepony.util.resources.ITextureSupplier;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
import net.fabricmc.fabric.api.client.render.EntityRendererRegistry;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.render.entity.feature.VillagerClothingFeatureRenderer;
|
||||
|
@ -19,7 +20,7 @@ public class RenderPonyVillager extends RenderPonyMob.Caster<VillagerEntity, Mod
|
|||
|
||||
private static final ITextureSupplier<VillagerEntity> PROFESSIONS = new VillagerProfessionTextureCache<>(FORMATTER);
|
||||
|
||||
public RenderPonyVillager(EntityRenderDispatcher manager) {
|
||||
public RenderPonyVillager(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
|
||||
super(manager, new ModelVillagerPony<>());
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.minelittlepony.client.model.entities.ModelWitchPony;
|
|||
import com.minelittlepony.client.render.layer.LayerHeldPonyItem;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
import net.fabricmc.fabric.api.client.render.EntityRendererRegistry;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.render.model.json.ModelTransformation;
|
||||
import net.minecraft.entity.mob.WitchEntity;
|
||||
|
@ -15,7 +16,7 @@ public class RenderPonyWitch extends RenderPonyMob<WitchEntity, ModelWitchPony>
|
|||
|
||||
private static final Identifier WITCH_TEXTURES = new Identifier("minelittlepony", "textures/entity/witch_pony.png");
|
||||
|
||||
public RenderPonyWitch(EntityRenderDispatcher manager) {
|
||||
public RenderPonyWitch(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
|
||||
super(manager, new ModelWitchPony());
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.minelittlepony.client.render.entities;
|
|||
import com.minelittlepony.client.model.entities.ModelZombiePony;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
import net.fabricmc.fabric.api.client.render.EntityRendererRegistry;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.entity.mob.DrownedEntity;
|
||||
import net.minecraft.entity.mob.GiantEntity;
|
||||
|
@ -18,7 +19,7 @@ public class RenderPonyZombie<Zombie extends ZombieEntity> extends RenderPonyMob
|
|||
public static final Identifier PIGMAN = new Identifier("minelittlepony", "textures/entity/zombie/zombie_pigman_pony.png");
|
||||
public static final Identifier DROWNED = new Identifier("minelittlepony", "textures/entity/zombie/drowned_pony.png");
|
||||
|
||||
public RenderPonyZombie(EntityRenderDispatcher manager) {
|
||||
public RenderPonyZombie(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
|
||||
super(manager, new ModelZombiePony<>());
|
||||
}
|
||||
|
||||
|
@ -30,8 +31,8 @@ public class RenderPonyZombie<Zombie extends ZombieEntity> extends RenderPonyMob
|
|||
|
||||
public static class Drowned extends RenderPonyZombie<DrownedEntity> {
|
||||
|
||||
public Drowned(EntityRenderDispatcher manager) {
|
||||
super(manager);
|
||||
public Drowned(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
|
||||
super(manager, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -42,8 +43,8 @@ public class RenderPonyZombie<Zombie extends ZombieEntity> extends RenderPonyMob
|
|||
|
||||
public static class Pigman extends RenderPonyZombie<ZombiePigmanEntity> {
|
||||
|
||||
public Pigman(EntityRenderDispatcher manager) {
|
||||
super(manager);
|
||||
public Pigman(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
|
||||
super(manager, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -54,8 +55,8 @@ public class RenderPonyZombie<Zombie extends ZombieEntity> extends RenderPonyMob
|
|||
|
||||
public static class Husk extends RenderPonyZombie<HuskEntity> {
|
||||
|
||||
public Husk(EntityRenderDispatcher manager) {
|
||||
super(manager);
|
||||
public Husk(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
|
||||
super(manager, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -73,7 +74,7 @@ public class RenderPonyZombie<Zombie extends ZombieEntity> extends RenderPonyMob
|
|||
|
||||
public static class Giant extends RenderPonyMob.Caster<GiantEntity, ModelZombiePony<GiantEntity>> {
|
||||
|
||||
public Giant(EntityRenderDispatcher manager) {
|
||||
public Giant(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
|
||||
super(manager, new ModelZombiePony<>());
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.minelittlepony.client.model.entities.ModelZombieVillagerPony;
|
|||
import com.minelittlepony.util.resources.FormattedTextureSupplier;
|
||||
import com.minelittlepony.util.resources.ITextureSupplier;
|
||||
|
||||
import net.fabricmc.fabric.api.client.render.EntityRendererRegistry;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.render.entity.feature.VillagerClothingFeatureRenderer;
|
||||
|
@ -18,7 +19,7 @@ public class RenderPonyZombieVillager extends RenderPonyMob.Caster<ZombieVillage
|
|||
|
||||
private static final ITextureSupplier<ZombieVillagerEntity> PROFESSIONS = new VillagerProfessionTextureCache<>(FORMATTER);
|
||||
|
||||
public RenderPonyZombieVillager(EntityRenderDispatcher manager) {
|
||||
public RenderPonyZombieVillager(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
|
||||
super(manager, new ModelZombieVillagerPony());
|
||||
}
|
||||
|
||||
|
|
|
@ -2,13 +2,13 @@ package com.minelittlepony.client.render.tileentities.skull;
|
|||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.minelittlepony.MineLittlePony;
|
||||
import com.minelittlepony.client.MineLPClient;
|
||||
import com.minelittlepony.client.render.LevitatingItemRenderer;
|
||||
import com.minelittlepony.pony.IPony;
|
||||
import com.minelittlepony.settings.PonyConfig;
|
||||
import com.minelittlepony.settings.PonySettings;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.fabricmc.fabric.api.client.render.BlockEntityRendererRegistry;
|
||||
import net.minecraft.block.SkullBlock;
|
||||
import net.minecraft.block.entity.SkullBlockEntity;
|
||||
import net.minecraft.client.render.block.entity.SkullBlockEntityRenderer;
|
||||
|
@ -48,7 +48,7 @@ public class PonySkullRenderer extends SkullBlockEntityRenderer {
|
|||
if (PonySettings.PONYSKULLS.get()) {
|
||||
if (!(INSTANCE instanceof PonySkullRenderer)) {
|
||||
backup = INSTANCE;
|
||||
MineLPClient.getInstance().getModUtilities().addRenderer(SkullBlockEntity.class, ponyInstance);
|
||||
BlockEntityRendererRegistry.INSTANCE.register(SkullBlockEntity.class, ponyInstance);
|
||||
INSTANCE = ponyInstance;
|
||||
}
|
||||
} else {
|
||||
|
@ -57,7 +57,7 @@ public class PonySkullRenderer extends SkullBlockEntityRenderer {
|
|||
if (backup == null) {
|
||||
backup = new SkullBlockEntityRenderer();
|
||||
}
|
||||
MineLPClient.getInstance().getModUtilities().addRenderer(SkullBlockEntity.class, backup);
|
||||
BlockEntityRendererRegistry.INSTANCE.register(SkullBlockEntity.class, backup);
|
||||
INSTANCE = backup;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue