Reduces visibility of internal fields/methods

Reduces the visibility of all fields to private and create setters/getters
when necessary. Exceptions are fields with GuiSync as these need to be
public.

Reduces the visibility of internal methods to private/protected/default when possible.
This commit is contained in:
yueh
2015-10-08 15:42:42 +02:00
parent 1ea48fb389
commit 500fc47490
463 changed files with 5670 additions and 3757 deletions
@@ -28,7 +28,7 @@ import appeng.util.Platform;
public class CellConfig extends AppEngInternalInventory
{
final ItemStack is;
private final ItemStack is;
public CellConfig( final ItemStack is )
{
@@ -27,7 +27,7 @@ import appeng.util.Platform;
public final class CellUpgrades extends StackUpgradeInventory
{
final ItemStack is;
private final ItemStack is;
public CellUpgrades( final ItemStack is, final int upgrades )
{
@@ -32,9 +32,9 @@ import appeng.util.Platform;
public class NetworkToolViewer implements INetworkTool
{
final AppEngInternalInventory inv;
final ItemStack is;
final IGridHost gh;
private final AppEngInternalInventory inv;
private final ItemStack is;
private final IGridHost gh;
public NetworkToolViewer( final ItemStack is, final IGridHost gHost )
{
@@ -27,7 +27,7 @@ import appeng.api.implementations.guiobjects.IGuiItemObject;
public class QuartzKnifeObj implements IGuiItemObject
{
final ItemStack is;
private final ItemStack is;
public QuartzKnifeObj( final ItemStack o )
{
@@ -71,9 +71,10 @@ import appeng.util.Platform;
public final class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, IUpgradeModule
{
public static final int KILO_SCALAR = 1024;
public static ItemMultiMaterial instance;
private static final int KILO_SCALAR = 1024;
private final Map<Integer, MaterialType> dmgToMaterial = new HashMap<Integer, MaterialType>();
private final NameResolver nameResolver;
@@ -182,13 +183,13 @@ public final class ItemMultiMaterial extends AEBaseItem implements IStorageCompo
enabled = enabled && AEConfig.instance.isFeatureEnabled( f );
}
mat.stackSrc = new MaterialStackSrc( mat );
mat.setStackSrc( new MaterialStackSrc( mat ) );
if( enabled )
{
mat.itemInstance = this;
mat.setItemInstance( this );
mat.markReady();
final int newMaterialNum = mat.damageValue;
final int newMaterialNum = mat.getDamageValue();
if( this.dmgToMaterial.get( newMaterialNum ) == null )
{
@@ -201,7 +202,7 @@ public final class ItemMultiMaterial extends AEBaseItem implements IStorageCompo
}
}
return mat.stackSrc;
return mat.getStackSrc();
}
public void makeUnique()
@@ -245,13 +246,13 @@ public final class ItemMultiMaterial extends AEBaseItem implements IStorageCompo
}
else
{
if( mt.itemInstance == this )
if( mt.getItemInstance() == this )
{
this.dmgToMaterial.remove( mt.damageValue );
this.dmgToMaterial.remove( mt.getDamageValue() );
}
mt.itemInstance = replacement.getItem();
mt.damageValue = replacement.getItemDamage();
mt.setItemInstance( replacement.getItem() );
mt.setDamageValue( replacement.getItemDamage() );
}
}
}
@@ -262,7 +263,7 @@ public final class ItemMultiMaterial extends AEBaseItem implements IStorageCompo
{
if( this.dmgToMaterial.containsKey( dmg ) )
{
return this.dmgToMaterial.get( dmg ).IIcon;
return this.dmgToMaterial.get( dmg ).getIIcon();
}
return new MissingIcon( this );
}
@@ -305,9 +306,9 @@ public final class ItemMultiMaterial extends AEBaseItem implements IStorageCompo
for( final MaterialType mat : types )
{
if( mat.damageValue >= 0 && mat.isRegistered() && mat.itemInstance == this )
if( mat.getDamageValue() >= 0 && mat.isRegistered() && mat.getItemInstance() == this )
{
itemStacks.add( new ItemStack( this, 1, mat.damageValue ) );
itemStacks.add( new ItemStack( this, 1, mat.getDamageValue() ) );
}
}
}
@@ -317,13 +318,13 @@ public final class ItemMultiMaterial extends AEBaseItem implements IStorageCompo
{
for( final MaterialType mat : MaterialType.values() )
{
if( mat.damageValue != -1 )
if( mat.getDamageValue() != -1 )
{
final ItemStack what = new ItemStack( this, 1, mat.damageValue );
final ItemStack what = new ItemStack( this, 1, mat.getDamageValue() );
if( this.getTypeByStack( what ) != MaterialType.InvalidType )
{
final String tex = "appliedenergistics2:" + this.nameOf( what );
mat.IIcon = icoRegister.registerIcon( tex );
mat.setIIcon( icoRegister.registerIcon( tex ) );
}
}
}
@@ -120,31 +120,31 @@ public enum MaterialType
private final EnumSet<AEFeature> features;
// IIcon for the material.
@SideOnly( Side.CLIENT )
public IIcon IIcon;
public Item itemInstance;
public int damageValue;
private IIcon IIcon;
private Item itemInstance;
private int damageValue;
// stack!
public MaterialStackSrc stackSrc;
private MaterialStackSrc stackSrc;
private String oreName;
private Class<? extends Entity> droppedEntity;
private boolean isRegistered = false;
MaterialType( final int metaValue )
{
this.damageValue = metaValue;
this.setDamageValue( metaValue );
this.features = EnumSet.of( AEFeature.Core );
}
MaterialType( final int metaValue, final AEFeature part )
{
this.damageValue = metaValue;
this.setDamageValue( metaValue );
this.features = EnumSet.of( part );
}
MaterialType( final int metaValue, final AEFeature part, final Class<? extends Entity> c )
{
this.features = EnumSet.of( part );
this.damageValue = metaValue;
this.setDamageValue( metaValue );
this.droppedEntity = c;
EntityRegistry.registerModEntity( this.droppedEntity, this.droppedEntity.getSimpleName(), EntityIds.get( this.droppedEntity ), AppEng.instance(), 16, 4, true );
@@ -153,7 +153,7 @@ public enum MaterialType
MaterialType( final int metaValue, final AEFeature part, final String oreDictionary, final Class<? extends Entity> c )
{
this.features = EnumSet.of( part );
this.damageValue = metaValue;
this.setDamageValue( metaValue );
this.oreName = oreDictionary;
this.droppedEntity = c;
EntityRegistry.registerModEntity( this.droppedEntity, this.droppedEntity.getSimpleName(), EntityIds.get( this.droppedEntity ), AppEng.instance(), 16, 4, true );
@@ -162,16 +162,16 @@ public enum MaterialType
MaterialType( final int metaValue, final AEFeature part, final String oreDictionary )
{
this.features = EnumSet.of( part );
this.damageValue = metaValue;
this.setDamageValue( metaValue );
this.oreName = oreDictionary;
}
public ItemStack stack( final int size )
{
return new ItemStack( this.itemInstance, size, this.damageValue );
return new ItemStack( this.getItemInstance(), size, this.getDamageValue() );
}
public EnumSet<AEFeature> getFeature()
EnumSet<AEFeature> getFeature()
{
return this.features;
}
@@ -181,12 +181,12 @@ public enum MaterialType
return this.oreName;
}
public boolean hasCustomEntity()
boolean hasCustomEntity()
{
return this.droppedEntity != null;
}
public Class<? extends Entity> getCustomEntityClass()
Class<? extends Entity> getCustomEntityClass()
{
return this.droppedEntity;
}
@@ -196,9 +196,49 @@ public enum MaterialType
return this.isRegistered;
}
public void markReady()
void markReady()
{
this.isRegistered = true;
}
public int getDamageValue()
{
return this.damageValue;
}
void setDamageValue( final int damageValue )
{
this.damageValue = damageValue;
}
public Item getItemInstance()
{
return this.itemInstance;
}
void setItemInstance( final Item itemInstance )
{
this.itemInstance = itemInstance;
}
IIcon getIIcon()
{
return this.IIcon;
}
void setIIcon( final IIcon iIcon )
{
this.IIcon = iIcon;
}
MaterialStackSrc getStackSrc()
{
return this.stackSrc;
}
void setStackSrc( final MaterialStackSrc stackSrc )
{
this.stackSrc = stackSrc;
}
}
@@ -56,17 +56,17 @@ import appeng.util.Platform;
public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
{
public static final int LEVEL_OFFSET = 200;
public static final int SINGLE_OFFSET = LEVEL_OFFSET * 3;
private static final int LEVEL_OFFSET = 200;
private static final int SINGLE_OFFSET = LEVEL_OFFSET * 3;
public static final int CERTUS = 0;
public static final int NETHER = SINGLE_OFFSET;
public static final int FLUIX = SINGLE_OFFSET * 2;
public static final int FINAL_STAGE = SINGLE_OFFSET * 3;
final IIcon[] certus = new IIcon[3];
final IIcon[] fluix = new IIcon[3];
final IIcon[] nether = new IIcon[3];
private final IIcon[] certus = new IIcon[3];
private final IIcon[] fluix = new IIcon[3];
private final IIcon[] nether = new IIcon[3];
public ItemCrystalSeed()
{
@@ -38,7 +38,7 @@ import appeng.util.Platform;
public class ItemPaintBall extends AEBaseItem
{
public static final int DAMAGE_THRESHOLD = 20;
private static final int DAMAGE_THRESHOLD = 20;
public ItemPaintBall()
{
@@ -57,7 +57,7 @@ public class ItemPaintBall extends AEBaseItem
return super.getItemStackDisplayName( is ) + " - " + this.getExtraName( is );
}
public String getExtraName( final ItemStack is )
private String getExtraName( final ItemStack is )
{
return ( is.getItemDamage() >= DAMAGE_THRESHOLD ? GuiText.Lumen.getLocal() + ' ' : "" ) + this.getColor( is );
}
@@ -132,7 +132,7 @@ public final class ItemMultiPart extends AEBaseItem implements IPartItem, IItemG
enabled &= IntegrationRegistry.INSTANCE.isEnabled( integrationType );
}
final int partDamage = mat.baseDamage + varID;
final int partDamage = mat.getBaseDamage() + varID;
final ActivityState state = ActivityState.from( enabled );
final ItemStackSrc output = new ItemStackSrc( this, partDamage, state );
@@ -259,7 +259,7 @@ public final class ItemMultiPart extends AEBaseItem implements IPartItem, IItemG
}
}
public String getName( final ItemStack is )
private String getName( final ItemStack is )
{
Preconditions.checkNotNull( is );
@@ -296,12 +296,12 @@ public final class ItemMultiPart extends AEBaseItem implements IPartItem, IItemG
try
{
if( type.constructor == null )
if( type.getConstructor() == null )
{
type.constructor = part.getConstructor( ItemStack.class );
type.setConstructor( part.getConstructor( ItemStack.class ) );
}
return type.constructor.newInstance( is );
return type.getConstructor().newInstance( is );
}
catch( final InstantiationException e )
{
+21 -6
View File
@@ -164,12 +164,12 @@ public enum PartType
InterfaceTerminal( 480, EnumSet.of( AEFeature.InterfaceTerminal ), EnumSet.noneOf( IntegrationType.class ), PartInterfaceTerminal.class );
public final int baseDamage;
private final int baseDamage;
private final Set<AEFeature> features;
private final Set<IntegrationType> integrations;
private final Class<? extends IPart> myPart;
private final GuiText extraName;
public Constructor<? extends IPart> constructor;
private Constructor<? extends IPart> constructor;
PartType( final int baseMetaValue, final Set<AEFeature> features, final Set<IntegrationType> integrations, final Class<? extends IPart> c )
{
@@ -190,24 +190,39 @@ public enum PartType
return false;
}
public Set<AEFeature> getFeature()
Set<AEFeature> getFeature()
{
return this.features;
}
public Set<IntegrationType> getIntegrations()
Set<IntegrationType> getIntegrations()
{
return this.integrations;
}
public Class<? extends IPart> getPart()
Class<? extends IPart> getPart()
{
return this.myPart;
}
public GuiText getExtraName()
GuiText getExtraName()
{
return this.extraName;
}
Constructor<? extends IPart> getConstructor()
{
return this.constructor;
}
void setConstructor( final Constructor<? extends IPart> constructor )
{
this.constructor = constructor;
}
int getBaseDamage()
{
return this.baseDamage;
}
}
@@ -182,7 +182,7 @@ public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorag
return new TransitionResult( false, 0 );
}
public World createNewWorld( final ItemStack is )
private World createNewWorld( final ItemStack is )
{
final NBTTagCompound c = Platform.openNbtData( is );
final int newDim = DimensionManager.getNextFreeDimId();
@@ -82,7 +82,7 @@ import appeng.util.item.AEItemStack;
public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCell, IItemGroup, IBlockTool, IMouseWheelItem
{
static final Map<Integer, AEColor> ORE_TO_COLOR = new HashMap<Integer, AEColor>();
private static final Map<Integer, AEColor> ORE_TO_COLOR = new HashMap<Integer, AEColor>();
static
{
@@ -216,7 +216,7 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
return this.getColorFromItem( this.getColor( tol ) );
}
public AEColor getColorFromItem( final ItemStack paintBall )
private AEColor getColorFromItem( final ItemStack paintBall )
{
if( paintBall == null )
{
@@ -337,7 +337,7 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
return newColor;
}
public void setColor( final ItemStack is, final ItemStack newColor )
private void setColor( final ItemStack is, final ItemStack newColor )
{
final NBTTagCompound data = Platform.openNbtData( is );
if( newColor == null )
@@ -135,18 +135,18 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
r = this.heatUp.get( new InWorldToolOperationIngredient( blockID, OreDictionary.WILDCARD_VALUE ) );
}
if( r.BlockItem != null )
if( r.getBlockItem() != null )
{
w.setBlock( x, y, z, Block.getBlockFromItem( r.BlockItem.getItem() ), r.BlockItem.getItemDamage(), 3 );
w.setBlock( x, y, z, Block.getBlockFromItem( r.getBlockItem().getItem() ), r.getBlockItem().getItemDamage(), 3 );
}
else
{
w.setBlock( x, y, z, Platform.AIR_BLOCK, 0, 3 );
}
if( r.Drops != null )
if( r.getDrops() != null )
{
Platform.spawnDrops( w, x, y, z, r.Drops );
Platform.spawnDrops( w, x, y, z, r.getDrops() );
}
}
@@ -171,18 +171,18 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
r = this.coolDown.get( new InWorldToolOperationIngredient( blockID, OreDictionary.WILDCARD_VALUE ) );
}
if( r.BlockItem != null )
if( r.getBlockItem() != null )
{
w.setBlock( x, y, z, Block.getBlockFromItem( r.BlockItem.getItem() ), r.BlockItem.getItemDamage(), 3 );
w.setBlock( x, y, z, Block.getBlockFromItem( r.getBlockItem().getItem() ), r.getBlockItem().getItemDamage(), 3 );
}
else
{
w.setBlock( x, y, z, Platform.AIR_BLOCK, 0, 3 );
}
if( r.Drops != null )
if( r.getDrops() != null )
{
Platform.spawnDrops( w, x, y, z, r.Drops );
Platform.spawnDrops( w, x, y, z, r.getDrops() );
}
}
@@ -319,18 +319,18 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
final InWorldToolOperationResult or = InWorldToolOperationResult.getBlockOperationResult( out.toArray( new ItemStack[out.size()] ) );
w.playSoundEffect( x + 0.5D, y + 0.5D, z + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F );
if( or.BlockItem == null )
if( or.getBlockItem() == null )
{
w.setBlock( x, y, z, Platform.AIR_BLOCK, 0, 3 );
}
else
{
w.setBlock( x, y, z, Block.getBlockFromItem( or.BlockItem.getItem() ), or.BlockItem.getItemDamage(), 3 );
w.setBlock( x, y, z, Block.getBlockFromItem( or.getBlockItem().getItem() ), or.getBlockItem().getItemDamage(), 3 );
}
if( or.Drops != null )
if( or.getDrops() != null )
{
Platform.spawnDrops( w, x, y, z, or.Drops );
Platform.spawnDrops( w, x, y, z, or.getDrops() );
}
return true;