mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-04-01 01:05:27 +02:00
Fix crash caused by PonySkullRenderer.resolve() being called too early.
This commit is contained in:
parent
127c150107
commit
37433ce75d
4 changed files with 10 additions and 13 deletions
|
@ -93,6 +93,9 @@ public class MineLittlePony implements ClientModInitializer {
|
||||||
ClientTickCallback.EVENT.register(this::onTick);
|
ClientTickCallback.EVENT.register(this::onTick);
|
||||||
ClientReadyCallback.EVENT.register(this::onClientReady);
|
ClientReadyCallback.EVENT.register(this::onClientReady);
|
||||||
ScreenInitCallback.EVENT.register(this::onScreenInit);
|
ScreenInitCallback.EVENT.register(this::onScreenInit);
|
||||||
|
if (config.ponyskulls.get()) {
|
||||||
|
PonySkullRenderer.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
if (FabricLoader.getInstance().isModLoaded("hdskins")) {
|
if (FabricLoader.getInstance().isModLoaded("hdskins")) {
|
||||||
IndirectHDSkins.initialize();
|
IndirectHDSkins.initialize();
|
||||||
|
@ -135,8 +138,6 @@ public class MineLittlePony implements ClientModInitializer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PonySkullRenderer.resolve();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onScreenInit(Screen screen, ScreenInitCallback.ButtonList buttons) {
|
private void onScreenInit(Screen screen, ScreenInitCallback.ButtonList buttons) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.minelittlepony.client.gui;
|
package com.minelittlepony.client.gui;
|
||||||
|
|
||||||
|
import com.minelittlepony.client.render.tileentities.skull.PonySkullRenderer;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.resource.language.I18n;
|
import net.minecraft.client.resource.language.I18n;
|
||||||
import net.minecraft.text.LiteralText;
|
import net.minecraft.text.LiteralText;
|
||||||
|
@ -155,5 +156,7 @@ public class GuiPonySettings extends GameGui {
|
||||||
public void onClose() {
|
public void onClose() {
|
||||||
super.onClose();
|
super.onClose();
|
||||||
config.save();
|
config.save();
|
||||||
|
|
||||||
|
PonySkullRenderer.resolve();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package com.minelittlepony.client.render.layer;
|
||||||
import com.minelittlepony.client.model.AbstractPonyModel;
|
import com.minelittlepony.client.model.AbstractPonyModel;
|
||||||
import com.minelittlepony.client.model.IPonyModel;
|
import com.minelittlepony.client.model.IPonyModel;
|
||||||
import com.minelittlepony.client.render.IPonyRender;
|
import com.minelittlepony.client.render.IPonyRender;
|
||||||
import com.minelittlepony.client.render.tileentities.skull.PonySkullRenderer;
|
|
||||||
import com.minelittlepony.model.BodyPart;
|
import com.minelittlepony.model.BodyPart;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
|
|
||||||
|
@ -11,6 +10,7 @@ import net.minecraft.block.AbstractSkullBlock;
|
||||||
import net.minecraft.block.SkullBlock.SkullType;
|
import net.minecraft.block.SkullBlock.SkullType;
|
||||||
import net.minecraft.block.entity.SkullBlockEntity;
|
import net.minecraft.block.entity.SkullBlockEntity;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.render.block.entity.SkullBlockEntityRenderer;
|
||||||
import net.minecraft.client.render.entity.model.EntityModel;
|
import net.minecraft.client.render.entity.model.EntityModel;
|
||||||
import net.minecraft.client.render.model.json.ModelTransformation;
|
import net.minecraft.client.render.model.json.ModelTransformation;
|
||||||
import net.minecraft.entity.EquipmentSlot;
|
import net.minecraft.entity.EquipmentSlot;
|
||||||
|
@ -97,7 +97,7 @@ public class LayerPonyCustomHead<T extends LivingEntity, M extends EntityModel<T
|
||||||
|
|
||||||
SkullType type = ((AbstractSkullBlock) ((BlockItem) itemstack.getItem()).getBlock()).getSkullType();
|
SkullType type = ((AbstractSkullBlock) ((BlockItem) itemstack.getItem()).getBlock()).getSkullType();
|
||||||
|
|
||||||
PonySkullRenderer.resolve().render(-0.5F, 0, -0.5F, null, 180, type, profile, -1, limbSwing);
|
SkullBlockEntityRenderer.INSTANCE.render(-0.5F, 0, -0.5F, null, 180, type, profile, -1, limbSwing);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -28,7 +28,7 @@ import static com.mojang.blaze3d.platform.GlStateManager.*;
|
||||||
*/
|
*/
|
||||||
public class PonySkullRenderer extends SkullBlockEntityRenderer {
|
public class PonySkullRenderer extends SkullBlockEntityRenderer {
|
||||||
|
|
||||||
public static PonySkullRenderer ponyInstance = new PonySkullRenderer();
|
private static final PonySkullRenderer ponyInstance = new PonySkullRenderer();
|
||||||
private static SkullBlockEntityRenderer backup = null;
|
private static SkullBlockEntityRenderer backup = null;
|
||||||
|
|
||||||
private static final Map<SkullBlock.SkullType, ISkull> skullMap = SystemUtil.consume(Maps.newHashMap(), (skullMap) -> {
|
private static final Map<SkullBlock.SkullType, ISkull> skullMap = SystemUtil.consume(Maps.newHashMap(), (skullMap) -> {
|
||||||
|
@ -44,27 +44,20 @@ public class PonySkullRenderer extends SkullBlockEntityRenderer {
|
||||||
*
|
*
|
||||||
* Original/Existing renderer is stored to a backup variable as a fallback in case of mods.
|
* Original/Existing renderer is stored to a backup variable as a fallback in case of mods.
|
||||||
*/
|
*/
|
||||||
public static SkullBlockEntityRenderer resolve() {
|
public static void resolve() {
|
||||||
if (MineLittlePony.getInstance().getConfig().ponyskulls.get()) {
|
if (MineLittlePony.getInstance().getConfig().ponyskulls.get()) {
|
||||||
if (!(INSTANCE instanceof PonySkullRenderer)) {
|
if (!(INSTANCE instanceof PonySkullRenderer)) {
|
||||||
backup = INSTANCE;
|
backup = INSTANCE;
|
||||||
BlockEntityRendererRegistry.INSTANCE.register(SkullBlockEntity.class, ponyInstance);
|
BlockEntityRendererRegistry.INSTANCE.register(SkullBlockEntity.class, ponyInstance);
|
||||||
INSTANCE = ponyInstance;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((INSTANCE instanceof PonySkullRenderer)) {
|
if ((INSTANCE instanceof PonySkullRenderer)) {
|
||||||
ponyInstance = (PonySkullRenderer) INSTANCE;
|
|
||||||
if (backup == null) {
|
if (backup == null) {
|
||||||
backup = new SkullBlockEntityRenderer();
|
backup = new SkullBlockEntityRenderer();
|
||||||
}
|
}
|
||||||
BlockEntityRendererRegistry.INSTANCE.register(SkullBlockEntity.class, backup);
|
BlockEntityRendererRegistry.INSTANCE.register(SkullBlockEntity.class, backup);
|
||||||
INSTANCE = backup;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANCE.setRenderManager(BlockEntityRenderDispatcher.INSTANCE);
|
|
||||||
|
|
||||||
return INSTANCE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Reference in a new issue