Always use {} for control statements

This commit is contained in:
yueh
2017-07-20 21:24:58 +02:00
parent 406013142e
commit f9cad0758d
7 changed files with 32 additions and 0 deletions
@@ -149,21 +149,27 @@ public final class Registration
public static void addBlockToRegister( Block b ) public static void addBlockToRegister( Block b )
{ {
if( blocksToRegister == null ) if( blocksToRegister == null )
{
throw new IllegalStateException( "Past the registration phase already!" ); throw new IllegalStateException( "Past the registration phase already!" );
}
blocksToRegister.add( b ); blocksToRegister.add( b );
} }
public static void addRecipeToRegister( IRecipe r ) public static void addRecipeToRegister( IRecipe r )
{ {
if( recipesToRegister == null ) if( recipesToRegister == null )
{
throw new IllegalStateException( "Past the registration phase already!" ); throw new IllegalStateException( "Past the registration phase already!" );
}
recipesToRegister.add( r ); recipesToRegister.add( r );
} }
public static void addItemToRegister( Item i ) public static void addItemToRegister( Item i )
{ {
if( itemsToRegister == null ) if( itemsToRegister == null )
{
throw new IllegalStateException( "Past the registration phase already!" ); throw new IllegalStateException( "Past the registration phase already!" );
}
itemsToRegister.add( i ); itemsToRegister.add( i );
} }
@@ -82,7 +82,9 @@ public class TileItemGen extends AEBaseTile implements IInventory
// Safeguard for crash // Safeguard for crash
ItemStack testStack = POSSIBLE_ITEMS.peek(); ItemStack testStack = POSSIBLE_ITEMS.peek();
if( testStack.isEmpty() ) if( testStack.isEmpty() )
{
testStack = new ItemStack( Blocks.COBBLESTONE, 1 ); testStack = new ItemStack( Blocks.COBBLESTONE, 1 );
}
return testStack; return testStack;
} }
@@ -59,7 +59,9 @@ public abstract class AEBaseItem extends Item
public final void getSubItems( final CreativeTabs creativeTab, final NonNullList<ItemStack> itemStacks ) public final void getSubItems( final CreativeTabs creativeTab, final NonNullList<ItemStack> itemStacks )
{ {
if( isInCreativeTab( creativeTab ) ) if( isInCreativeTab( creativeTab ) )
{
this.getCheckedSubItems( creativeTab, itemStacks ); this.getCheckedSubItems( creativeTab, itemStacks );
}
} }
@Override @Override
@@ -175,10 +175,14 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
private ItemStack getItemStackInCachedSlot( int pos ) private ItemStack getItemStackInCachedSlot( int pos )
{ {
if( pos > cachedStacks.length ) if( pos > cachedStacks.length )
{
return ItemStack.EMPTY; return ItemStack.EMPTY;
}
if( cachedStacks[pos] == null ) if( cachedStacks[pos] == null )
{
return ItemStack.EMPTY; return ItemStack.EMPTY;
}
return cachedStacks[pos]; return cachedStacks[pos];
} }
@@ -67,9 +67,13 @@ public class PartShapedCraftingFactory extends ShapedOreRecipe
for( Map.Entry<String, JsonElement> entry : JsonUtils.getJsonObject( json, "key" ).entrySet() ) for( Map.Entry<String, JsonElement> entry : JsonUtils.getJsonObject( json, "key" ).entrySet() )
{ {
if( entry.getKey().length() != 1 ) if( entry.getKey().length() != 1 )
{
throw new JsonSyntaxException( "Invalid key entry: '" + entry.getKey() + "' is an invalid symbol (must be 1 character only)." ); throw new JsonSyntaxException( "Invalid key entry: '" + entry.getKey() + "' is an invalid symbol (must be 1 character only)." );
}
if( " ".equals( entry.getKey() ) ) if( " ".equals( entry.getKey() ) )
{
throw new JsonSyntaxException( "Invalid key entry: ' ' is a reserved symbol." ); throw new JsonSyntaxException( "Invalid key entry: ' ' is a reserved symbol." );
}
ingMap.put( entry.getKey().toCharArray()[0], CraftingHelper.getIngredient( entry.getValue(), context ) ); ingMap.put( entry.getKey().toCharArray()[0], CraftingHelper.getIngredient( entry.getValue(), context ) );
} }
@@ -79,14 +83,18 @@ public class PartShapedCraftingFactory extends ShapedOreRecipe
JsonArray patternJ = JsonUtils.getJsonArray( json, "pattern" ); JsonArray patternJ = JsonUtils.getJsonArray( json, "pattern" );
if( patternJ.size() == 0 ) if( patternJ.size() == 0 )
{
throw new JsonSyntaxException( "Invalid pattern: empty pattern not allowed" ); throw new JsonSyntaxException( "Invalid pattern: empty pattern not allowed" );
}
String[] pattern = new String[patternJ.size()]; String[] pattern = new String[patternJ.size()];
for( int x = 0; x < pattern.length; ++x ) for( int x = 0; x < pattern.length; ++x )
{ {
String line = JsonUtils.getString( patternJ.get( x ), "pattern[" + x + "]" ); String line = JsonUtils.getString( patternJ.get( x ), "pattern[" + x + "]" );
if( x > 0 && pattern[0].length() != line.length() ) if( x > 0 && pattern[0].length() != line.length() )
{
throw new JsonSyntaxException( "Invalid pattern: each row must be the same width" ); throw new JsonSyntaxException( "Invalid pattern: each row must be the same width" );
}
pattern[x] = line; pattern[x] = line;
} }
@@ -106,14 +114,18 @@ public class PartShapedCraftingFactory extends ShapedOreRecipe
{ {
net.minecraft.item.crafting.Ingredient ing = ingMap.get( chr ); net.minecraft.item.crafting.Ingredient ing = ingMap.get( chr );
if( ing == null ) if( ing == null )
{
throw new JsonSyntaxException( "Pattern references symbol '" + chr + "' but it's not defined in the key" ); throw new JsonSyntaxException( "Pattern references symbol '" + chr + "' but it's not defined in the key" );
}
primer.input.set( x++, ing ); primer.input.set( x++, ing );
keys.remove( chr ); keys.remove( chr );
} }
} }
if( !keys.isEmpty() ) if( !keys.isEmpty() )
{
throw new JsonSyntaxException( "Key defines symbols that aren't used in pattern: " + keys ); throw new JsonSyntaxException( "Key defines symbols that aren't used in pattern: " + keys );
}
JsonObject resultObject = (JsonObject) json.get( "result" ); JsonObject resultObject = (JsonObject) json.get( "result" );
int count = JsonUtils.getInt( resultObject, "count", 1 ); int count = JsonUtils.getInt( resultObject, "count", 1 );
@@ -60,10 +60,14 @@ public class PartShapelessCraftingFactory extends ShapelessOreRecipe
NonNullList<Ingredient> ings = NonNullList.create(); NonNullList<Ingredient> ings = NonNullList.create();
for( JsonElement ele : JsonUtils.getJsonArray( json, "ingredients" ) ) for( JsonElement ele : JsonUtils.getJsonArray( json, "ingredients" ) )
{
ings.add( CraftingHelper.getIngredient( ele, context ) ); ings.add( CraftingHelper.getIngredient( ele, context ) );
}
if( ings.isEmpty() ) if( ings.isEmpty() )
{
throw new JsonParseException( "No ingredients for shapeless recipe" ); throw new JsonParseException( "No ingredients for shapeless recipe" );
}
JsonObject resultObject = (JsonObject) json.get( "result" ); JsonObject resultObject = (JsonObject) json.get( "result" );
int count = JsonUtils.getInt( resultObject, "count", 1 ); int count = JsonUtils.getInt( resultObject, "count", 1 );
@@ -116,7 +116,9 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
private ItemStack getOldStack( int slot ) private ItemStack getOldStack( int slot )
{ {
if( this.inv[slot] == null ) if( this.inv[slot] == null )
{
return ItemStack.EMPTY; return ItemStack.EMPTY;
}
return this.inv[slot]; return this.inv[slot];
} }