mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-29 07:27:59 +01:00
Make changing mob ponifications not need a restart.
This commit is contained in:
parent
9e951f5aa7
commit
e411f6680d
6 changed files with 65 additions and 6 deletions
|
@ -1,5 +1,6 @@
|
|||
package com.minelittlepony;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.minelittlepony.gui.PonySettingPanel;
|
||||
import com.minelittlepony.hdskins.gui.EntityPonyModel;
|
||||
import com.minelittlepony.hdskins.gui.GuiSkinsMineLP;
|
||||
|
@ -17,10 +18,12 @@ import com.mumfrey.liteloader.util.ModUtilities;
|
|||
import com.voxelmodpack.hdskins.HDSkinManager;
|
||||
import com.voxelmodpack.hdskins.gui.GuiSkins;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.resources.IReloadableResourceManager;
|
||||
import net.minecraft.client.resources.data.MetadataSerializer;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.monster.EntityEvoker;
|
||||
import net.minecraft.entity.monster.EntityHusk;
|
||||
import net.minecraft.entity.monster.EntityPigZombie;
|
||||
|
@ -36,6 +39,8 @@ import org.apache.logging.log4j.LogManager;
|
|||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class MineLittlePony {
|
||||
|
||||
public static final Logger logger = LogManager.getLogger("MineLittlePony");
|
||||
|
@ -54,6 +59,8 @@ public class MineLittlePony {
|
|||
private PonyManager ponyManager;
|
||||
private ProxyContainer proxy;
|
||||
|
||||
private Map<Class<? extends Entity>, Render<?>> renderMap = Maps.newHashMap();
|
||||
|
||||
MineLittlePony() {
|
||||
instance = this;
|
||||
}
|
||||
|
@ -84,22 +91,63 @@ public class MineLittlePony {
|
|||
logger.info("Set MineLP skin server URL.");
|
||||
|
||||
RenderManager rm = minecraft.getRenderManager();
|
||||
this.saveCurrentRenderers(rm);
|
||||
ModUtilities.addRenderer(EntityPonyModel.class, new RenderPonyModel(rm));
|
||||
this.initializeMobRenderers(rm);
|
||||
|
||||
}
|
||||
|
||||
private void saveCurrentRenderers(RenderManager rm) {
|
||||
// villagers
|
||||
this.renderMap.put(EntityVillager.class, rm.getEntityClassRenderObject(EntityVillager.class));
|
||||
this.renderMap.put(EntityZombieVillager.class, rm.getEntityClassRenderObject(EntityZombieVillager.class));
|
||||
// zombies
|
||||
this.renderMap.put(EntityZombie.class, rm.getEntityClassRenderObject(EntityZombie.class));
|
||||
this.renderMap.put(EntityHusk.class, rm.getEntityClassRenderObject(EntityHusk.class));
|
||||
// pig zombie
|
||||
this.renderMap.put(EntityPigZombie.class, rm.getEntityClassRenderObject(EntityPigZombie.class));
|
||||
// skeletons
|
||||
this.renderMap.put(EntitySkeleton.class, rm.getEntityClassRenderObject(EntitySkeleton.class));
|
||||
this.renderMap.put(EntityStray.class, rm.getEntityClassRenderObject(EntityStray.class));
|
||||
this.renderMap.put(EntityWitherSkeleton.class, rm.getEntityClassRenderObject(EntityWitherSkeleton.class));
|
||||
// illagers
|
||||
this.renderMap.put(EntityVex.class, rm.getEntityClassRenderObject(EntityVex.class));
|
||||
this.renderMap.put(EntityEvoker.class, rm.getEntityClassRenderObject(EntityEvoker.class));
|
||||
this.renderMap.put(EntityVindicator.class, rm.getEntityClassRenderObject(EntityVindicator.class));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends Entity> Render<T> getRenderer(Class<T> cl) {
|
||||
Render<T> render = (Render<T>) this.renderMap.get(cl);
|
||||
if (render == null)
|
||||
throw new MissingRendererException(cl);
|
||||
return render;
|
||||
}
|
||||
|
||||
public void initializeMobRenderers(RenderManager rm) {
|
||||
if (this.config.villagers) {
|
||||
ModUtilities.addRenderer(EntityVillager.class, new RenderPonyVillager(rm));
|
||||
ModUtilities.addRenderer(EntityZombieVillager.class, new RenderPonyZombieVillager(rm));
|
||||
logger.info("Villagers are now ponies.");
|
||||
} else {
|
||||
ModUtilities.addRenderer(EntityVillager.class, getRenderer(EntityVillager.class));
|
||||
ModUtilities.addRenderer(EntityZombieVillager.class, getRenderer(EntityZombieVillager.class));
|
||||
}
|
||||
|
||||
if (this.config.zombies) {
|
||||
ModUtilities.addRenderer(EntityZombie.class, new RenderPonyZombie<>(rm));
|
||||
ModUtilities.addRenderer(EntityHusk.class, new RenderPonyZombie.Husk(rm));
|
||||
logger.info("Zombies are now ponies.");
|
||||
} else {
|
||||
ModUtilities.addRenderer(EntityZombie.class, getRenderer(EntityZombie.class));
|
||||
ModUtilities.addRenderer(EntityHusk.class, getRenderer(EntityHusk.class));
|
||||
}
|
||||
|
||||
if (this.config.pigzombies) {
|
||||
ModUtilities.addRenderer(EntityPigZombie.class, new RenderPonyPigman(rm));
|
||||
logger.info("Zombie pigmen are now ponies.");
|
||||
} else {
|
||||
ModUtilities.addRenderer(EntityPigZombie.class, getRenderer(EntityPigZombie.class));
|
||||
}
|
||||
|
||||
if (this.config.skeletons) {
|
||||
|
@ -107,6 +155,10 @@ public class MineLittlePony {
|
|||
ModUtilities.addRenderer(EntityStray.class, new RenderPonySkeleton.Stray(rm));
|
||||
ModUtilities.addRenderer(EntityWitherSkeleton.class, new RenderPonySkeleton.Wither(rm));
|
||||
logger.info("Skeletons are now ponies.");
|
||||
} else {
|
||||
ModUtilities.addRenderer(EntitySkeleton.class, getRenderer(EntitySkeleton.class));
|
||||
ModUtilities.addRenderer(EntityStray.class, getRenderer(EntityStray.class));
|
||||
ModUtilities.addRenderer(EntityWitherSkeleton.class, getRenderer(EntityWitherSkeleton.class));
|
||||
}
|
||||
|
||||
if (this.config.illagers) {
|
||||
|
@ -114,8 +166,11 @@ public class MineLittlePony {
|
|||
ModUtilities.addRenderer(EntityEvoker.class, new RenderPonyEvoker(rm));
|
||||
ModUtilities.addRenderer(EntityVindicator.class, new RenderPonyVindicator(rm));
|
||||
logger.info("Illagers are now ponies.");
|
||||
} else {
|
||||
ModUtilities.addRenderer(EntityVex.class, getRenderer(EntityVex.class));
|
||||
ModUtilities.addRenderer(EntityEvoker.class, getRenderer(EntityEvoker.class));
|
||||
ModUtilities.addRenderer(EntityVindicator.class, getRenderer(EntityVindicator.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void onTick(Minecraft minecraft, boolean inGame) {
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package com.minelittlepony;
|
||||
|
||||
public class MissingRendererException extends RuntimeException {
|
||||
|
||||
public MissingRendererException(Class<?> cl) {
|
||||
super("Could not find a renderer for " + cl.getName() + ". This is a bug.");
|
||||
}
|
||||
}
|
|
@ -177,5 +177,6 @@ public class PonySettingPanel extends GuiScreen {
|
|||
@Override
|
||||
public void onGuiClosed() {
|
||||
LiteLoader.getInstance().writeConfig(config);
|
||||
MineLittlePony.getInstance().initializeMobRenderers(mc.getRenderManager());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
minelp.restart=If you make any changes here, you must restart Minecraft before they will take effect!
|
||||
|
||||
minelp.options.title=Mine Little Pony Settings
|
||||
minelp.options.ponylevel=Pony Level
|
||||
minelp.options.ponylevel.ponies=Ponies Only
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
# Mine Little Pony fr_FR.lang file
|
||||
# Provided by Dalfio (PinkishPie)
|
||||
minelp.restart=Si vous apportez des modifications ici, vous devez redémarrer Minecraft avant qu'ils prennent effet!
|
||||
|
||||
minelp.options.title=Options Mine Little Pony
|
||||
minelp.options.ponylevel=Niveau Poney
|
||||
minelp.options.ponylevel.ponies=Seuls Poneys
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
minelp.restart=Если вы измените эти параметры, то для их активации вы должны перезапустить игру!
|
||||
minelp.options.title=Настроайки мода Mine Little Pony
|
||||
minelp.options.ponylevel=Уровень понификации
|
||||
minelp.options.ponylevel.ponies=Только пони
|
||||
|
|
Loading…
Reference in a new issue