mirror of
https://github.com/GTNewHorizons/GTNHLib.git
synced 2026-11-08 12:34:52 +00:00
Move model loading to GTNHLib (#51)
* Move model loading to NHLib * spotless
This commit is contained in:
1 parent
48c62819dc
commit
487393a77b
2 files changed
+24
No files matched your search
@@ -1,19 +1,26 @@
|
||||
package com.gtnewhorizon.gtnhlib;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.client.model.ModelLoader.shouldLoadModels;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.model.ModelLoader;
|
||||
import com.gtnewhorizon.gtnhlib.util.AboveHotbarHUD;
|
||||
import com.gtnewhorizon.gtnhlib.util.AnimatedTooltipHandler;
|
||||
|
||||
import cpw.mods.fml.common.event.*;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ClientProxy extends CommonProxy {
|
||||
|
||||
private static boolean modelsBaked = false;
|
||||
|
||||
private final Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
@Override
|
||||
@@ -30,6 +37,11 @@ public class ClientProxy extends CommonProxy {
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
super.postInit(event);
|
||||
MinecraftForge.EVENT_BUS.register(new AnimatedTooltipHandler());
|
||||
|
||||
if (shouldLoadModels()) {
|
||||
Minecraft.getMinecraft().refreshResources();
|
||||
ModelLoader.loadModels();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -117,4 +129,12 @@ public class ClientProxy extends CommonProxy {
|
||||
public void printMessageAboveHotbar(String message, int displayDuration, boolean drawShadow, boolean shouldFade) {
|
||||
AboveHotbarHUD.renderTextAboveHotbar(message, displayDuration, drawShadow, shouldFade);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTick(TickEvent.ClientTickEvent event) {
|
||||
if (!modelsBaked) {
|
||||
ModelLoader.bakeModels();
|
||||
modelsBaked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -123,4 +123,8 @@ public class ModelLoader {
|
||||
public static QuadProvider getModel(Variant loc) {
|
||||
return modelsToBake.get(loc);
|
||||
}
|
||||
|
||||
public static boolean shouldLoadModels() {
|
||||
return !unloadedModels.isEmpty();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user