Cleanup code format in LayerBreakingTest.

This commit is contained in:
Lex Manos 2015-06-16 16:01:09 -07:00
parent 114ac38910
commit d0902c096e

View file

@ -11,6 +11,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BlockModelShapes;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
@ -35,36 +36,24 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
@SuppressWarnings( "deprecation" )
@Mod( modid = "LayerBreakingTest", name = "LayerBreakingTest", version = "0.0.0" )
public class LayerBreakingTest
{
public static final boolean ENABLE = true;
public static TestBlock testBlock;
class TestBakedModel implements IFlexibleBakedModel
{
TextureAtlasSprite texture;
List<BakedQuad> list = new ArrayList<BakedQuad>();
private int[] vertexToInts(
float x,
float y,
float z,
int color,
TextureAtlasSprite texture,
int u,
int v )
private int[] vertexToInts(float x, float y, float z, int color, TextureAtlasSprite texture, int u, int v)
{
return new int[] { Float.floatToRawIntBits(x), Float.floatToRawIntBits(y), Float.floatToRawIntBits(z), color, Float.floatToRawIntBits(texture.getInterpolatedU(u)), Float.floatToRawIntBits(texture.getInterpolatedV(v)), 0 };
}
public TestBakedModel(
TextureAtlasSprite sprite,
boolean top )
public TestBakedModel(TextureAtlasSprite sprite, boolean top)
{
texture = sprite;
if (top)
@ -108,8 +97,7 @@ public class LayerBreakingTest
}
@Override
public List<BakedQuad> getFaceQuads(
EnumFacing side )
public List<BakedQuad> getFaceQuads(EnumFacing side)
{
return Collections.emptyList();
}
@ -125,12 +113,10 @@ public class LayerBreakingTest
{
return null;
}
};
class TestBlock extends Block
{
protected TestBlock()
{
super(Material.glass);
@ -150,35 +136,28 @@ public class LayerBreakingTest
}
@Override
public boolean canRenderInLayer(
EnumWorldBlockLayer layer )
public boolean canRenderInLayer(EnumWorldBlockLayer layer)
{
return layer == EnumWorldBlockLayer.SOLID || layer == EnumWorldBlockLayer.TRANSLUCENT;
}
};
class SmartModel implements IBakedModel, ISmartBlockModel
{
IFlexibleBakedModel solid;
IFlexibleBakedModel translucent;
private class DefState implements IModelState
{
@Override
public TRSRTransformation apply(
IModelPart part )
public TRSRTransformation apply(IModelPart part)
{
return TRSRTransformation.identity();
}
};
@Override
public List getFaceQuads(
EnumFacing p_177551_1_ )
public List getFaceQuads(EnumFacing p_177551_1_)
{
return Collections.emptyList();
}
@ -220,16 +199,13 @@ public class LayerBreakingTest
}
@Override
public IBakedModel handleBlockState(
IBlockState state )
public IBakedModel handleBlockState(IBlockState state)
{
if (solid == null)
{
TextureAtlasSprite a = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState( Blocks.stained_glass.getStateFromMeta( 3 ) ).getTexture();
TextureAtlasSprite b = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState( Blocks.cobblestone.getDefaultState() ).getTexture();
translucent = new TestBakedModel( a, true );
solid = new TestBakedModel( b, false );
BlockModelShapes models = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
translucent = new TestBakedModel(models.getModelForState(Blocks.stained_glass.getStateFromMeta(3)).getTexture(), true);
solid = new TestBakedModel(models.getModelForState(Blocks.cobblestone.getDefaultState()).getTexture(), false);
}
if (net.minecraftforge.client.MinecraftForgeClient.getRenderLayer() == EnumWorldBlockLayer.SOLID)
@ -241,25 +217,21 @@ public class LayerBreakingTest
return translucent;
}
}
};
@SubscribeEvent
public void onModelBakeEvent(
ModelBakeEvent event )
public void onModelBakeEvent(ModelBakeEvent event)
{
event.modelRegistry.putObject( new ModelResourceLocation( "LayerBreakingTest:LayerBreakingTest" ), new SmartModel() );
event.modelRegistry.putObject(new ModelResourceLocation("layerbreakingtest:layer_breaking_test"), new SmartModel());
}
@EventHandler
public void init(
FMLInitializationEvent event )
public void init(FMLInitializationEvent event)
{
if (ENABLE && event.getSide() == Side.CLIENT)
{
MinecraftForge.EVENT_BUS.register(this);
GameRegistry.registerBlock( testBlock = new TestBlock(), "LayerBreakingTest" );
GameRegistry.registerBlock(testBlock = new TestBlock(), "layer_breaking_test");
}
}
}