Major Refactoring of Bootstrap Code (#75)

- Refactored boostrap code:
  * Completely reworked item/block/tile registration.
  * Fixed server side startup.
  * Fixed server side startup.
  * More documentation.
  * More heavy cleanup
  * More cleanups.
  * Major refactoring of state mapping and fixes a lot of other issue related to item rendering.
  * Fixes sky chest item models (no item TESR).
  * Only use CachingRotatingBakedModel for tile entities automatically.
  Fix default rotation of quartz pillar for item model.
  * Used method reference instead of lambda for ItemMeshDefinition for multiparts.
  * Removed unnecessary IHasSpecialItemModel
  * Removed unused IconReg class.
  * Updated resource pack version.
This commit is contained in:
shartte
2016-08-22 14:25:10 +02:00
committed by Sebastian Hartte
parent 66df324ef0
commit 6f2bbfab4c
172 changed files with 2289 additions and 2863 deletions
@@ -0,0 +1,85 @@
package appeng.items.misc;
import com.google.common.collect.ImmutableList;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.bootstrap.IItemRendering;
import appeng.bootstrap.ItemRenderingCustomizer;
public class ItemCrystalSeedRendering extends ItemRenderingCustomizer
{
private static final ModelResourceLocation[] MODELS_CERTUS = {
new ModelResourceLocation( "appliedenergistics2:crystal_seed_certus" ),
new ModelResourceLocation( "appliedenergistics2:crystal_seed_certus2" ),
new ModelResourceLocation( "appliedenergistics2:crystal_seed_certus3" )
};
private static final ModelResourceLocation[] MODELS_FLUIX = {
new ModelResourceLocation( "appliedenergistics2:crystal_seed_fluix" ),
new ModelResourceLocation( "appliedenergistics2:crystal_seed_fluix2" ),
new ModelResourceLocation( "appliedenergistics2:crystal_seed_fluix3" )
};
private static final ModelResourceLocation[] MODELS_NETHER = {
new ModelResourceLocation( "appliedenergistics2:crystal_seed_nether" ),
new ModelResourceLocation( "appliedenergistics2:crystal_seed_nether2" ),
new ModelResourceLocation( "appliedenergistics2:crystal_seed_nether3" )
};
@Override
@SideOnly( Side.CLIENT )
public void customize( IItemRendering rendering )
{
rendering.variants( ImmutableList.<ResourceLocation>builder().add( MODELS_CERTUS ).add( MODELS_FLUIX ).add( MODELS_NETHER ).build() );
rendering.meshDefinition( getItemMeshDefinition() );
}
private ItemMeshDefinition getItemMeshDefinition()
{
return is ->
{
int damage = ItemCrystalSeed.getProgress( is );
// Split the damage value into crystal type and growth level
int type = damage / ItemCrystalSeed.SINGLE_OFFSET;
int level = ( damage % ItemCrystalSeed.SINGLE_OFFSET ) / ItemCrystalSeed.LEVEL_OFFSET;
// Determine which list of models to use based on the type of crystal
ModelResourceLocation[] models;
switch( type )
{
case 0:
models = MODELS_CERTUS;
break;
case 1:
models = MODELS_NETHER;
break;
case 2:
models = MODELS_FLUIX;
break;
default:
// We use this as the fallback for broken items
models = MODELS_CERTUS;
break;
}
// Return one of the 3 models based on the level
if( level < 0 )
{
level = 0;
}
else if( level >= models.length )
{
level = models.length - 1;
}
return models[level];
};
}
}