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