Permalink
Browse files

Extract required textures from models instead

This ensures we will not get missing texture errors in the future, and
allows resource pack artists to use additional textures.
  • Loading branch information...
SquidDev committed Jan 19, 2018
1 parent 2e7302e commit 80b1170b631630a93ee8e43b426395b3ef4f852f
Showing with 33 additions and 15 deletions.
  1. +33 −15 src/main/java/dan200/computercraft/client/proxy/CCTurtleProxyClient.java
@@ -20,6 +20,7 @@
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.client.resources.SimpleReloadableResourceManager;
@@ -115,8 +116,23 @@ private void registerForgeHandlers()
MinecraftForge.EVENT_BUS.register( handlers );
}
public class ForgeHandlers
public static class ForgeHandlers
{
private static final String[] TURTLE_UPGRADES = {
"turtle_modem_off_left",
"turtle_modem_on_left",
"turtle_modem_off_right",
"turtle_modem_on_right",
"turtle_crafting_table_left",
"turtle_crafting_table_right",
"advanced_turtle_modem_off_left",
"advanced_turtle_modem_on_left",
"advanced_turtle_modem_off_right",
"advanced_turtle_modem_on_right",
"turtle_speaker_upgrade_left",
"turtle_speaker_upgrade_right",
};
private TurtleSmartItemModel m_turtleSmartItemModel;
public ForgeHandlers()
@@ -142,25 +158,27 @@ public void onTick( TickEvent.ClientTickEvent event )
@SubscribeEvent
public void onTextureStitchEvent( TextureStitchEvent.Pre event )
{
event.getMap().registerSprite( new ResourceLocation( "computercraft", "blocks/crafty_upgrade" ) );
event.getMap().registerSprite( new ResourceLocation( "computercraft", "blocks/turtle_speaker_face" ) );
// Load all textures for upgrades
TextureMap map = event.getMap();
for( String upgrade : TURTLE_UPGRADES )
{
IModel model = ModelLoaderRegistry.getModelOrMissing( new ResourceLocation( "computercraft", "block/" + upgrade ) );
for( ResourceLocation texture : model.getTextures() )
{
map.registerSprite( texture );
}
}
}
@SubscribeEvent
public void onModelBakeEvent( ModelBakeEvent event )
{
loadModel( event, "turtle_modem_off_left" );
loadModel( event, "turtle_modem_on_left" );
loadModel( event, "turtle_modem_off_right" );
loadModel( event, "turtle_modem_on_right" );
loadModel( event, "turtle_crafting_table_left" );
loadModel( event, "turtle_crafting_table_right" );
loadModel( event, "advanced_turtle_modem_off_left" );
loadModel( event, "advanced_turtle_modem_on_left" );
loadModel( event, "advanced_turtle_modem_off_right" );
loadModel( event, "advanced_turtle_modem_on_right" );
loadModel( event, "turtle_speaker_upgrade_left" );
loadModel( event, "turtle_speaker_upgrade_right" );
// Load all upgrade models
for( String upgrade : TURTLE_UPGRADES )
{
loadModel( event, upgrade );
}
loadSmartModel( event, "turtle_dynamic", m_turtleSmartItemModel );
}

0 comments on commit 80b1170

Please sign in to comment.