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 f054bd699b
commit e94a0cfccf
497 changed files with 7865 additions and 6908 deletions
@@ -27,7 +27,7 @@ import appeng.util.Platform;
public class CellConfig extends AppEngInternalInventory
{
final ItemStack is;
private final ItemStack is;
public CellConfig( final ItemStack is )
{
@@ -26,7 +26,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 )
{
@@ -26,7 +26,7 @@ import appeng.api.implementations.guiobjects.IGuiItemObject;
public class QuartzKnifeObj implements IGuiItemObject
{
final ItemStack is;
private final ItemStack is;
public QuartzKnifeObj( final ItemStack o )
{
@@ -118,31 +118,31 @@ public enum MaterialType
private final EnumSet<AEFeature> features;
// TextureAtlasSprite for the material.
@SideOnly( Side.CLIENT )
public TextureAtlasSprite IIcon;
public Item itemInstance;
public int damageValue;
private TextureAtlasSprite 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 );
@@ -151,7 +151,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 );
@@ -160,16 +160,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;
}
@@ -179,12 +179,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;
}
@@ -194,9 +194,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;
}
TextureAtlasSprite getIIcon()
{
return this.IIcon;
}
void setIIcon( final TextureAtlasSprite iIcon )
{
this.IIcon = iIcon;
}
MaterialStackSrc getStackSrc()
{
return this.stackSrc;
}
void setStackSrc( final MaterialStackSrc stackSrc )
{
this.stackSrc = stackSrc;
}
}
@@ -71,9 +71,10 @@ import appeng.util.Platform;
public final class MultiItem extends AEBaseItem implements IStorageComponent, IUpgradeModule
{
public static final int KILO_SCALAR = 1024;
public static MultiItem instance;
private static final int KILO_SCALAR = 1024;
private final Map<Integer, MaterialType> dmgToMaterial = new HashMap<Integer, MaterialType>();
public MultiItem()
@@ -146,7 +147,7 @@ public final class MultiItem extends AEBaseItem implements IStorageComponent, IU
{
if( type != MaterialType.InvalidType )
{
proxy.setIcon( this, type.damageValue, name + "." + type.name() );
proxy.setIcon( this, type.getDamageValue(), name + "." + type.name() );
}
}
}
@@ -193,13 +194,13 @@ public final class MultiItem extends AEBaseItem implements IStorageComponent, IU
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 )
{
@@ -212,7 +213,7 @@ public final class MultiItem extends AEBaseItem implements IStorageComponent, IU
}
}
return mat.stackSrc;
return mat.getStackSrc();
}
public void makeUnique()
@@ -256,13 +257,13 @@ public final class MultiItem extends AEBaseItem implements IStorageComponent, IU
}
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() );
}
}
}
@@ -290,9 +291,9 @@ public final class MultiItem extends AEBaseItem implements IStorageComponent, IU
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() ) );
}
}
}
@@ -57,17 +57,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 ModelResourceLocation[] certus = new ModelResourceLocation[3];
final ModelResourceLocation[] fluix = new ModelResourceLocation[3];
final ModelResourceLocation[] nether = new ModelResourceLocation[3];
private final ModelResourceLocation[] certus = new ModelResourceLocation[3];
private final ModelResourceLocation[] fluix = new ModelResourceLocation[3];
private final ModelResourceLocation[] nether = new ModelResourceLocation[3];
public ItemCrystalSeed()
{
@@ -78,10 +78,10 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
}
@Override
@SideOnly(Side.CLIENT)
@SideOnly( Side.CLIENT )
public void registerIcons( final ClientHelper ir, final String name )
{
final String preFix = name+".";
final String preFix = name + ".";
this.certus[0] = ir.setIcon( this, preFix + "Certus" );
this.certus[1] = ir.setIcon( this, preFix + "Certus2" );
@@ -94,9 +94,9 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
this.fluix[0] = ir.setIcon( this, preFix + "Fluix" );
this.fluix[1] = ir.setIcon( this, preFix + "Fluix2" );
this.fluix[2] = ir.setIcon( this, preFix + "Fluix3" );
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register( this, new ItemMeshDefinition(){
@Override
public ModelResourceLocation getModelLocation(
final ItemStack stack )
@@ -139,9 +139,9 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
return list[2];
}
}
});
} );
}
@Nullable
public static ResolverResult getResolver( final int certus2 )
{
@@ -54,18 +54,18 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
// rather simple client side caching.
private static final Map<ItemStack, ItemStack> SIMPLE_CACHE = new WeakHashMap<ItemStack, ItemStack>();
@SideOnly( Side.CLIENT )
private ModelResourceLocation res;
@SideOnly( Side.CLIENT )
private ModelResourceLocation encodedPatternModel; // TODO: make encoded pattern model!
public ItemEncodedPattern()
{
this.setFeature( EnumSet.of( AEFeature.Patterns ) );
this.setMaxStackSize( 1 );
}
@SideOnly(Side.CLIENT)
ModelResourceLocation res;
@SideOnly(Side.CLIENT)
ModelResourceLocation encodedPatternModel; // TODO: make encoded pattern model!
@Override
public void registerIcons(
final ClientHelper proxy,
@@ -74,34 +74,34 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
this.encodedPatternModel = this.res = proxy.setIcon( this, name );
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register( this, new ItemMeshDefinition(){
boolean recursive = false;
@Override
public ModelResourceLocation getModelLocation(
final ItemStack stack )
{
if ( this.recursive == false )
if( this.recursive == false )
{
this.recursive = true;
final ItemEncodedPattern iep = (ItemEncodedPattern) stack.getItem();
final ItemStack is = iep.getOutput( stack );
if ( Minecraft.getMinecraft().thePlayer.isSneaking() )
if( Minecraft.getMinecraft().thePlayer.isSneaking() )
{
return ItemEncodedPattern.this.encodedPatternModel;
}
this.recursive = false;
}
return ItemEncodedPattern.this.res;
}
});
} );
}
@Override
public ItemStack onItemRightClick( final ItemStack stack, final World w, final EntityPlayer player )
{
@@ -40,7 +40,7 @@ import appeng.items.AEBaseItem;
public class ItemPaintBall extends AEBaseItem
{
public static final int DAMAGE_THRESHOLD = 20;
private static final int DAMAGE_THRESHOLD = 20;
public ItemPaintBall()
{
@@ -76,7 +76,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 );
@@ -254,7 +254,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 );
@@ -291,12 +291,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
@@ -160,12 +160,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 )
{
@@ -186,24 +186,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;
}
}
@@ -181,7 +181,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();
@@ -88,7 +88,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
{
@@ -229,7 +229,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 )
{
@@ -350,7 +350,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 )
@@ -143,19 +143,19 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
r = this.heatUp.get( new InWorldToolOperationIngredient( state.getBlock(), true ) );
}
if( r.BlockItem != null )
if( r.getBlockItem() != null )
{
final Block blk = Block.getBlockFromItem( r.BlockItem.getItem() );
w.setBlockState( pos, blk.getStateFromMeta( r.BlockItem.getItemDamage() ), 3 );
final Block blk = Block.getBlockFromItem( r.getBlockItem().getItem() );
w.setBlockState( pos, blk.getStateFromMeta( r.getBlockItem().getItemDamage() ), 3 );
}
else
{
w.setBlockToAir( pos );
}
if( r.Drops != null )
if( r.getDrops() != null )
{
Platform.spawnDrops( w, pos, r.Drops );
Platform.spawnDrops( w, pos, r.getDrops() );
}
}
@@ -180,19 +180,19 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
r = this.coolDown.get( new InWorldToolOperationIngredient( state.getBlock(), true ) );
}
if( r.BlockItem != null )
if( r.getBlockItem() != null )
{
final Block blk = Block.getBlockFromItem( r.BlockItem.getItem() );
w.setBlockState( pos, blk.getStateFromMeta( r.BlockItem.getItemDamage() ), 3 );
final Block blk = Block.getBlockFromItem( r.getBlockItem().getItem() );
w.setBlockState( pos, blk.getStateFromMeta( r.getBlockItem().getItemDamage() ), 3 );
}
else
{
w.setBlockToAir( pos );
}
if( r.Drops != null )
if( r.getDrops() != null )
{
Platform.spawnDrops( w, pos, r.Drops );
Platform.spawnDrops( w, pos, r.getDrops() );
}
}
@@ -245,7 +245,7 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
return item;
}
@Override
public boolean onItemUse(
final ItemStack item,
@@ -333,19 +333,19 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
final InWorldToolOperationResult or = InWorldToolOperationResult.getBlockOperationResult( out.toArray( new ItemStack[out.size()] ) );
w.playSoundEffect( pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F );
if( or.BlockItem == null )
if( or.getBlockItem() == null )
{
w.setBlockState( pos, Platform.AIR_BLOCK.getDefaultState(), 3 );
}
else
{
final Block blk = Block.getBlockFromItem( or.BlockItem.getItem() );
w.setBlockState( pos, blk.getStateFromMeta( or.BlockItem.getItemDamage() ), 3 );
final Block blk = Block.getBlockFromItem( or.getBlockItem().getItem() );
w.setBlockState( pos, blk.getStateFromMeta( or.getBlockItem().getItemDamage() ), 3 );
}
if( or.Drops != null )
if( or.getDrops() != null )
{
Platform.spawnDrops( w, pos, or.Drops );
Platform.spawnDrops( w, pos, or.getDrops() );
}
return true;
@@ -156,18 +156,18 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
{
return item;
}
final LookDirection dir = Platform.getPlayerRay( p, p.getEyeHeight() );
final Vec3 vec3 = dir.a;
final Vec3 vec31 = dir.b;
final Vec3 vec3 = dir.getA();
final Vec3 vec31 = dir.getB();
final Vec3 direction = vec31.subtract( vec3 );
direction.normalize();
final double d0 = vec3.xCoord;
final double d1 = vec3.yCoord;
final double d2 = vec3.zCoord;
final float penetration = AEApi.instance().registries().matterCannon().getPenetration( ammo ); // 196.96655f;
if( penetration <= 0 )
{