From d0902c096e3e3744c3ba57d3125711abe8135319 Mon Sep 17 00:00:00 2001 From: Lex Manos Date: Tue, 16 Jun 2015 16:01:09 -0700 Subject: [PATCH] Cleanup code format in LayerBreakingTest. --- .../debug/LayerBreakingTest.java | 80 ++++++------------- 1 file changed, 26 insertions(+), 54 deletions(-) diff --git a/src/test/java/net/minecraftforge/debug/LayerBreakingTest.java b/src/test/java/net/minecraftforge/debug/LayerBreakingTest.java index 593101cbb6..aaf3896090 100644 --- a/src/test/java/net/minecraftforge/debug/LayerBreakingTest.java +++ b/src/test/java/net/minecraftforge/debug/LayerBreakingTest.java @@ -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,45 +36,33 @@ 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 list = new ArrayList(); - 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 }; + 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 ) + if (top) { - list.add( new BakedQuad( Ints.concat( vertexToInts( 0.5f, 1.0f, 0, -1, texture, 8, 0 ), vertexToInts( 0.5f, 1.0f, 1, -1, texture, 8, 16 ), vertexToInts( 1, 1.0f, 1, -1, texture, 16, 16 ), vertexToInts( 1, 1.0f, 0, -1, texture, 16, 0 ) ), -1, EnumFacing.UP ) ); + list.add(new BakedQuad(Ints.concat(vertexToInts(0.5f, 1.0f, 0, -1, texture, 8, 0), vertexToInts(0.5f, 1.0f, 1, -1, texture, 8, 16), vertexToInts(1, 1.0f, 1, -1, texture, 16, 16), vertexToInts(1, 1.0f, 0, -1, texture, 16, 0)), -1, EnumFacing.UP)); } else { - list.add( new BakedQuad( Ints.concat( vertexToInts( 0, 1.0f, 0, -1, texture, 0, 0 ), vertexToInts( 0, 1.0f, 1, -1, texture, 0, 16 ), vertexToInts( 0.5f, 1.0f, 1, -1, texture, 8, 16 ), vertexToInts( 0.5f, 1.0f, 0, -1, texture, 8, 0 ) ), -1, EnumFacing.DOWN ) ); + list.add(new BakedQuad(Ints.concat(vertexToInts(0, 1.0f, 0, -1, texture, 0, 0), vertexToInts(0, 1.0f, 1, -1, texture, 0, 16), vertexToInts(0.5f, 1.0f, 1, -1, texture, 8, 16), vertexToInts(0.5f, 1.0f, 0, -1, texture, 8, 0)), -1, EnumFacing.DOWN)); } } @@ -108,8 +97,7 @@ public class LayerBreakingTest } @Override - public List getFaceQuads( - EnumFacing side ) + public List getFaceQuads(EnumFacing side) { return Collections.emptyList(); } @@ -125,17 +113,15 @@ public class LayerBreakingTest { return null; } - }; class TestBlock extends Block { - protected TestBlock() { - super( Material.glass ); - setHardness( 7 ); - setCreativeTab( CreativeTabs.tabBlock ); + super(Material.glass); + setHardness(7); + setCreativeTab(CreativeTabs.tabBlock); } @Override @@ -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,19 +199,16 @@ public class LayerBreakingTest } @Override - public IBakedModel handleBlockState( - IBlockState state ) + public IBakedModel handleBlockState(IBlockState state) { - if ( solid == null ) + 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 ) + if (net.minecraftforge.client.MinecraftForgeClient.getRenderLayer() == EnumWorldBlockLayer.SOLID) { return 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 ) + if (ENABLE && event.getSide() == Side.CLIENT) { - MinecraftForge.EVENT_BUS.register( this ); - GameRegistry.registerBlock( testBlock = new TestBlock(), "LayerBreakingTest" ); + MinecraftForge.EVENT_BUS.register(this); + GameRegistry.registerBlock(testBlock = new TestBlock(), "layer_breaking_test"); } } - }