Future proof: Do NOT reference non-mojang classes outside of their designated context. That's what ModUtilities are for.

This commit is contained in:
Sollace 2019-07-01 10:59:55 +02:00
parent 91274352b4
commit 5116169f64
18 changed files with 46 additions and 59 deletions

View file

@ -45,7 +45,8 @@ dependencies {
modCompile "net.fabricmc:fabric-loader:${project.loader_version}"
compileOnly "com.google.code.findbugs:jsr305:3.0.2"
modCompile "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modCompile "net.fabricmc.fabric-api:fabric-api-base:0.1.0+"
modCompile "net.fabricmc.fabric-api:fabric-events-lifecycle-v0:0.1.0+"
modCompile "com.minelittlepony:Kirin:${project.kirin_version}"
// include "com.minelittlepony:Kirin:${project.kirin_version}"

View file

@ -18,5 +18,5 @@ org.gradle.daemon=false
# Dependencies
fabric_version=0.3.0+
kirin_version=1.14.3-1.1.2-SNAPSHOT
hd_skins_version=1.14.3-5.2.0-SNAPSHOT
kirin_version=1.14.3-1.2.0-SNAPSHOT
hd_skins_version=1.14.3-5.2.1-SNAPSHOT

View file

@ -6,11 +6,11 @@ import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.MinecraftClient;
import com.minelittlepony.client.gui.hdskins.IndirectHDSkins;
import com.minelittlepony.common.client.IModUtilities;
import com.minelittlepony.vendor.fabricmc.ModImpl;
import javax.annotation.Nullable;
public class FabMod implements ClientModInitializer, ClientTickCallback, IModUtilities {
public class FabMod implements ClientModInitializer, ClientTickCallback, ModImpl {
@Nullable
private MineLPClient mlp;

View file

@ -13,7 +13,6 @@ 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;
@ -75,16 +74,16 @@ public class PonyRenderManager {
* @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, EntityRendererRegistry.Factory factory) {
@SuppressWarnings({"unchecked"})
public <T extends Entity, V extends T> void switchRenderer(boolean state, Class<V> type, Function<EntityRenderDispatcher, EntityRenderer<T>> factory) {
if (state) {
if (!renderMap.containsKey(type)) {
renderMap.put(type, MinecraftClient.getInstance().getEntityRenderManager().getRenderer(type));
}
EntityRendererRegistry.INSTANCE.register(type, factory);
MineLPClient.getInstance().getModUtilities().addRenderer((Class<T>)type, factory);
} else {
if (renderMap.containsKey(type)) {
EntityRendererRegistry.INSTANCE.register(type, (m1, c) -> ((Function<EntityRenderDispatcher, EntityRenderer<V>>) m -> (EntityRenderer<V>) renderMap.get(type)).apply(m1));
MineLPClient.getInstance().getModUtilities().addRenderer(type, m -> (EntityRenderer<V>)renderMap.get(type));
}
}
}

View file

@ -1,6 +1,5 @@
package com.minelittlepony.client.gui.hdskins;
import net.fabricmc.fabric.api.client.render.EntityRendererRegistry;
import net.minecraft.client.MinecraftClient;
import net.minecraft.util.Identifier;
@ -57,7 +56,7 @@ class MineLPHDSkins extends MineLPClient implements ISkinCacheClearListener {
super.postInit(minecraft);
// Preview on the select skin gui
EntityRendererRegistry.INSTANCE.register(DummyPony.class, RenderDummyPony::new);
getModUtilities().addRenderer(DummyPony.class, RenderDummyPony::new);
HDSkins manager = HDSkins.getInstance();

View file

@ -14,7 +14,6 @@ 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;
@ -26,8 +25,8 @@ class RenderDummyPony extends RenderDummyPlayer<DummyPony, ClientPonyModel<Dummy
protected final RenderPony<DummyPony, ClientPonyModel<DummyPony>> renderPony = new RenderPony<>(this);
public RenderDummyPony(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
super(manager, context);
public RenderDummyPony(EntityRenderDispatcher manager) {
super(manager);
addFeature(new LayerGear<>(this));
}

View file

@ -6,7 +6,6 @@ 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;
@ -23,7 +22,7 @@ public class RenderEnderStallion extends RenderPonyMob<EndermanEntity, ModelEnde
private final Random rnd = new Random();
public RenderEnderStallion(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
public RenderEnderStallion(EntityRenderDispatcher manager) {
super(manager, new ModelEnderStallion());
}

View file

@ -9,7 +9,6 @@ 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;
@ -23,7 +22,7 @@ public class RenderPonyGuardian extends GuardianEntityRenderer {
private final Proxy<GuardianEntity, ModelGuardianPony> ponyRenderer;
public RenderPonyGuardian(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
public RenderPonyGuardian(EntityRenderDispatcher manager) {
super(manager);
features.clear();
@ -69,8 +68,8 @@ public class RenderPonyGuardian extends GuardianEntityRenderer {
public static class Elder extends RenderPonyGuardian {
public Elder(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
super(manager, context);
public Elder(EntityRenderDispatcher manager) {
super(manager);
}
@Override

View file

@ -5,7 +5,6 @@ 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;
@ -21,7 +20,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, EntityRendererRegistry.Context context) {
public RenderPonyIllager(EntityRenderDispatcher manager) {
super(manager, new ModelIllagerPony<>());
}
@ -38,8 +37,8 @@ public abstract class RenderPonyIllager<T extends IllagerEntity> extends RenderP
public static class Vindicator extends RenderPonyIllager<VindicatorEntity> {
public Vindicator(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
super(manager, context);
public Vindicator(EntityRenderDispatcher manager) {
super(manager);
}
@ -51,8 +50,8 @@ public abstract class RenderPonyIllager<T extends IllagerEntity> extends RenderP
public static class Evoker extends RenderPonyIllager<EvokerEntity> {
public Evoker(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
super(manager, context);
public Evoker(EntityRenderDispatcher manager) {
super(manager);
}
@Override
@ -63,8 +62,8 @@ public abstract class RenderPonyIllager<T extends IllagerEntity> extends RenderP
public static class Illusionist extends RenderPonyIllager<IllusionerEntity> {
public Illusionist(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
super(manager, context);
public Illusionist(EntityRenderDispatcher manager) {
super(manager);
}
@Override

View file

@ -1,6 +1,5 @@
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;
@ -13,7 +12,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, EntityRendererRegistry.Context context) {
public RenderPonyPillager(EntityRenderDispatcher manager) {
super(manager, new ModelPillagerPony<PillagerEntity>());
}

View file

@ -6,7 +6,6 @@ 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;
@ -19,7 +18,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, EntityRendererRegistry.Context context) {
public RenderPonySkeleton(EntityRenderDispatcher manager) {
super(manager, new ModelSkeletonPony<>());
}
@ -35,8 +34,8 @@ public class RenderPonySkeleton<Skeleton extends AbstractSkeletonEntity> extends
public static class Stray extends RenderPonySkeleton<StrayEntity> {
public Stray(EntityRenderDispatcher rm, EntityRendererRegistry.Context context) {
super(rm, context);
public Stray(EntityRenderDispatcher manager) {
super(manager);
addFeature(new LayerPonyStrayOverlay<>(this));
}
@ -48,8 +47,8 @@ public class RenderPonySkeleton<Skeleton extends AbstractSkeletonEntity> extends
public static class Wither extends RenderPonySkeleton<WitherSkeletonEntity> {
public Wither(EntityRenderDispatcher rm, EntityRendererRegistry.Context context) {
super(rm, context);
public Wither(EntityRenderDispatcher manager) {
super(manager);
}
@Override

View file

@ -1,6 +1,5 @@
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;
@ -12,7 +11,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, EntityRendererRegistry.Context context) {
public RenderPonyTrader(EntityRenderDispatcher manager) {
super(manager, new ModelAlicorn<>(false));
}

View file

@ -1,6 +1,5 @@
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;
@ -17,7 +16,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, EntityRendererRegistry.Context context) {
public RenderPonyVex(EntityRenderDispatcher manager) {
super(manager, new ModelBreezie<>(), 0.3F);
}

View file

@ -5,7 +5,6 @@ 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;
@ -20,7 +19,7 @@ public class RenderPonyVillager extends RenderPonyMob.Caster<VillagerEntity, Mod
private static final ITextureSupplier<VillagerEntity> PROFESSIONS = new VillagerProfessionTextureCache<>(FORMATTER);
public RenderPonyVillager(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
public RenderPonyVillager(EntityRenderDispatcher manager) {
super(manager, new ModelVillagerPony<>());
}

View file

@ -4,7 +4,6 @@ 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;
@ -16,7 +15,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, EntityRendererRegistry.Context context) {
public RenderPonyWitch(EntityRenderDispatcher manager) {
super(manager, new ModelWitchPony());
}

View file

@ -3,7 +3,6 @@ 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;
@ -19,7 +18,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, EntityRendererRegistry.Context context) {
public RenderPonyZombie(EntityRenderDispatcher manager) {
super(manager, new ModelZombiePony<>());
}
@ -31,8 +30,8 @@ public class RenderPonyZombie<Zombie extends ZombieEntity> extends RenderPonyMob
public static class Drowned extends RenderPonyZombie<DrownedEntity> {
public Drowned(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
super(manager, context);
public Drowned(EntityRenderDispatcher manager) {
super(manager);
}
@Override
@ -43,8 +42,8 @@ public class RenderPonyZombie<Zombie extends ZombieEntity> extends RenderPonyMob
public static class Pigman extends RenderPonyZombie<ZombiePigmanEntity> {
public Pigman(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
super(manager, context);
public Pigman(EntityRenderDispatcher manager) {
super(manager);
}
@Override
@ -55,8 +54,8 @@ public class RenderPonyZombie<Zombie extends ZombieEntity> extends RenderPonyMob
public static class Husk extends RenderPonyZombie<HuskEntity> {
public Husk(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
super(manager, context);
public Husk(EntityRenderDispatcher manager) {
super(manager);
}
@Override
@ -74,7 +73,7 @@ public class RenderPonyZombie<Zombie extends ZombieEntity> extends RenderPonyMob
public static class Giant extends RenderPonyMob.Caster<GiantEntity, ModelZombiePony<GiantEntity>> {
public Giant(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
public Giant(EntityRenderDispatcher manager) {
super(manager, new ModelZombiePony<>());
}

View file

@ -4,7 +4,6 @@ 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;
@ -19,7 +18,7 @@ public class RenderPonyZombieVillager extends RenderPonyMob.Caster<ZombieVillage
private static final ITextureSupplier<ZombieVillagerEntity> PROFESSIONS = new VillagerProfessionTextureCache<>(FORMATTER);
public RenderPonyZombieVillager(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
public RenderPonyZombieVillager(EntityRenderDispatcher manager) {
super(manager, new ModelZombieVillagerPony());
}

View file

@ -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;
BlockEntityRendererRegistry.INSTANCE.register(SkullBlockEntity.class, ponyInstance);
MineLPClient.getInstance().getModUtilities().addRenderer(SkullBlockEntity.class, ponyInstance);
INSTANCE = ponyInstance;
}
} else {
@ -57,7 +57,7 @@ public class PonySkullRenderer extends SkullBlockEntityRenderer {
if (backup == null) {
backup = new SkullBlockEntityRenderer();
}
BlockEntityRendererRegistry.INSTANCE.register(SkullBlockEntity.class, backup);
MineLPClient.getInstance().getModUtilities().addRenderer(SkullBlockEntity.class, backup);
INSTANCE = backup;
}
}