Make fields final if possible to ensure immutability

This commit is contained in:
thatsIch
2014-09-29 09:54:34 +02:00
parent 35f6c84d9f
commit 474596f095
261 changed files with 607 additions and 597 deletions
@@ -70,8 +70,8 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
public class ClientHelper extends ServerHelper
{
private static RenderItem itemRenderer = new RenderItem();
private static RenderBlocks blockRenderer = new RenderBlocks();
private static final RenderItem itemRenderer = new RenderItem();
private static final RenderBlocks blockRenderer = new RenderBlocks();
@Override
public CableRenderMode getRenderMode()
@@ -56,7 +56,7 @@ import cpw.mods.fml.common.ObfuscationReflectionHelper;
public abstract class AEBaseGui extends GuiContainer
{
protected List<InternalSlotME> meSlots = new LinkedList<InternalSlotME>();
protected final List<InternalSlotME> meSlots = new LinkedList<InternalSlotME>();
protected GuiScrollbar myScrollBar = null;
static public boolean switchingGuis;
private boolean subGui;
@@ -177,7 +177,7 @@ public abstract class AEBaseGui extends GuiContainer
Slot bl_clicked;
// drag y
Set<Slot> drag_click = new HashSet<Slot>();
final Set<Slot> drag_click = new HashSet<Slot>();
@Override
protected void handleMouseClick(Slot slot, int slotIdx, int ctrlDown, int key)
@@ -788,7 +788,7 @@ public abstract class AEBaseGui extends GuiContainer
}
}
AppEngRenderItem aeRenderItem = new AppEngRenderItem();
final AppEngRenderItem aeRenderItem = new AppEngRenderItem();
protected boolean isPowered()
{
@@ -27,8 +27,8 @@ import appeng.util.Platform;
public class GuiCellWorkbench extends GuiUpgradeable
{
ContainerCellWorkbench workbench;
TileCellWorkbench tcw;
final ContainerCellWorkbench workbench;
final TileCellWorkbench tcw;
GuiImgButton clear;
GuiImgButton partition;
@@ -22,7 +22,7 @@ import appeng.tile.misc.TileCondenser;
public class GuiCondenser extends AEBaseGui
{
ContainerCondenser cvc;
final ContainerCondenser cvc;
GuiProgressBar pb;
GuiImgButton mode;
@@ -38,15 +38,15 @@ import com.google.common.base.Joiner;
public class GuiCraftConfirm extends AEBaseGui
{
ContainerCraftConfirm ccc;
final ContainerCraftConfirm ccc;
int rows = 5;
final int rows = 5;
IItemList<IAEItemStack> storage = AEApi.instance().storage().createItemList();
IItemList<IAEItemStack> pending = AEApi.instance().storage().createItemList();
IItemList<IAEItemStack> missing = AEApi.instance().storage().createItemList();
final IItemList<IAEItemStack> storage = AEApi.instance().storage().createItemList();
final IItemList<IAEItemStack> pending = AEApi.instance().storage().createItemList();
final IItemList<IAEItemStack> missing = AEApi.instance().storage().createItemList();
List<IAEItemStack> visual = new ArrayList<IAEItemStack>();
final List<IAEItemStack> visual = new ArrayList<IAEItemStack>();
GuiBridge OriginalGui;
@@ -33,7 +33,7 @@ import com.google.common.base.Joiner;
public class GuiCraftingCPU extends AEBaseGui implements ISortSource
{
int rows = 6;
final int rows = 6;
IItemList<IAEItemStack> storage = AEApi.instance().storage().createItemList();
IItemList<IAEItemStack> active = AEApi.instance().storage().createItemList();
@@ -29,7 +29,7 @@ import appeng.parts.reporting.PartTerminal;
public class GuiCraftingStatus extends GuiCraftingCPU
{
ContainerCraftingStatus ccc;
final ContainerCraftingStatus ccc;
GuiButton selectCPU;
GuiTabButton originalGuiBtn;
@@ -12,7 +12,7 @@ import appeng.tile.misc.TileInscriber;
public class GuiInscriber extends AEBaseGui
{
ContainerInscriber cvc;
final ContainerInscriber cvc;
GuiProgressBar pb;
public GuiInscriber(InventoryPlayer inventoryPlayer, TileInscriber te)
@@ -25,9 +25,9 @@ import com.google.common.collect.HashMultimap;
public class GuiInterfaceTerminal extends AEBaseGui
{
HashMap<Long, ClientDCInternalInv> byId = new HashMap<Long, ClientDCInternalInv>();
HashMultimap<String, ClientDCInternalInv> byName = HashMultimap.create();
ArrayList<String> names = new ArrayList<String>();
final HashMap<Long, ClientDCInternalInv> byId = new HashMap<Long, ClientDCInternalInv>();
final HashMultimap<String, ClientDCInternalInv> byName = HashMultimap.create();
final ArrayList<String> names = new ArrayList<String>();
ArrayList<Object> lines = new ArrayList<Object>();
@@ -13,7 +13,7 @@ import appeng.tile.crafting.TileMolecularAssembler;
public class GuiMAC extends GuiUpgradeable
{
ContainerMAC container;
final ContainerMAC container;
GuiProgressBar pb;
@Override
@@ -58,14 +58,14 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
public static int CraftingGridOffsetX;
public static int CraftingGridOffsetY;
ItemRepo repo;
final ItemRepo repo;
GuiText myName;
int offsetX = 9;
final int offsetX = 9;
int perRow = 9;
int reservedSpace = 0;
int lowerTextureOffset = 0;
final int lowerTextureOffset = 0;
boolean customSortOrder = true;
int rows = 0;
@@ -73,17 +73,17 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
int standardSize;
IConfigManager configSrc;
final IConfigManager configSrc;
GuiImgButton ViewBox;
GuiImgButton SortByBox;
GuiImgButton SortDirBox;
GuiImgButton searchBoxSettings, terminalStyleBox;
boolean viewCell;
final boolean viewCell;
ItemStack myCurrentViewCells[] = new ItemStack[5];
ContainerMEMonitorable monitorableContainer;
final ItemStack[] myCurrentViewCells = new ItemStack[5];
final ContainerMEMonitorable monitorableContainer;
public GuiMEMonitorable(InventoryPlayer inventoryPlayer, ITerminalHost te) {
this( inventoryPlayer, te, new ContainerMEMonitorable( inventoryPlayer, te ) );
@@ -30,10 +30,10 @@ import appeng.util.Platform;
public class GuiNetworkStatus extends AEBaseGui implements ISortSource
{
ItemRepo repo;
final ItemRepo repo;
GuiImgButton units;
int rows = 4;
final int rows = 4;
public GuiNetworkStatus(InventoryPlayer inventoryPlayer, INetworkTool te) {
super( new ContainerNetworkStatus( inventoryPlayer, te ) );
@@ -20,7 +20,7 @@ import appeng.core.sync.packets.PacketValueConfig;
public class GuiPatternTerm extends GuiMEMonitorable
{
ContainerPatternTerm container;
final ContainerPatternTerm container;
GuiTabButton tabCraftButton;
GuiTabButton tabProcessButton;
@@ -17,7 +17,7 @@ import appeng.util.Platform;
public class GuiSpatialIOPort extends AEBaseGui
{
ContainerSpatialIOPort container;
final ContainerSpatialIOPort container;
GuiImgButton units;
public GuiSpatialIOPort(InventoryPlayer inventoryPlayer, TileSpatialIOPort te) {
@@ -25,8 +25,8 @@ import appeng.parts.automation.PartImportBus;
public class GuiUpgradeable extends AEBaseGui
{
ContainerUpgradeable cvb;
IUpgradeableHost bc;
final ContainerUpgradeable cvb;
final IUpgradeableHost bc;
GuiImgButton redstoneMode;
GuiImgButton fuzzyMode;
@@ -14,7 +14,7 @@ import appeng.tile.misc.TileVibrationChamber;
public class GuiVibrationChamber extends AEBaseGui
{
ContainerVibrationChamber cvc;
final ContainerVibrationChamber cvc;
GuiProgressBar pb;
public GuiVibrationChamber(InventoryPlayer inventoryPlayer, TileVibrationChamber te)
@@ -36,8 +36,8 @@ public class GuiImgButton extends GuiButton implements ITooltip
class EnumPair
{
Enum setting;
Enum value;
final Enum setting;
final Enum value;
EnumPair(Enum a, Enum b) {
setting = a;
@@ -14,7 +14,7 @@ public class GuiProgressBar extends GuiButton implements ITooltip
HORIZONTAL, VERTICAL
}
private IProgressProvider source;
private final IProgressProvider source;
private ResourceLocation texture;
private int fill_u;
private int fill_v;
@@ -15,14 +15,14 @@ import appeng.client.texture.ExtraBlockTextures;
public class GuiTabButton extends GuiButton implements ITooltip
{
RenderItem itemRenderer;
final RenderItem itemRenderer;
int myIcon = -1;
public int hideEdge = 0;
ItemStack myItem;
String Msg;
final String Msg;
public void setVisibility(boolean vis)
{
@@ -11,11 +11,11 @@ import appeng.client.texture.ExtraBlockTextures;
public class GuiToggleButton extends GuiButton implements ITooltip
{
int iconIdxOn;
int iconIdxOff;
final int iconIdxOn;
final int iconIdxOff;
String Name;
String Hint;
final String Name;
final String Hint;
boolean on;
@@ -6,11 +6,11 @@ import net.minecraft.client.gui.GuiTextField;
public class MEGuiTextField extends GuiTextField
{
int posX;
int posY;
final int posX;
final int posY;
int myWidth;
int myHeight;
final int myWidth;
final int myHeight;
public MEGuiTextField(FontRenderer par1FontRenderer, int xPos, int yPos, int width, int height) {
super( par1FontRenderer, xPos, yPos, width, height );
@@ -8,9 +8,9 @@ public class InternalSlotME
private final ItemRepo repo;
public int offset;
public int xPos;
public int yPos;
public final int offset;
public final int xPos;
public final int yPos;
public InternalSlotME(ItemRepo def, int offset, int displayX, int displayY) {
this.repo = def;
@@ -10,7 +10,7 @@ import appeng.util.Platform;
public class SlotDisconnected extends AppEngSlot
{
public ClientDCInternalInv mySlot;
public final ClientDCInternalInv mySlot;
public SlotDisconnected(ClientDCInternalInv me, int which, int x, int y) {
super( me.inv, which, x, y );
+1 -1
View File
@@ -9,7 +9,7 @@ import appeng.api.storage.data.IAEItemStack;
public class SlotME extends Slot
{
public InternalSlotME mySlot;
public final InternalSlotME mySlot;
public SlotME(InternalSlotME me) {
super( null, 0, me.xPos, me.yPos );
@@ -15,12 +15,12 @@ public class BlockRenderInfo
final public BaseBlockRender rendererInstance;
private boolean useTmp = false;
private TmpFlippableIcon tmpTopIcon = new TmpFlippableIcon();
private TmpFlippableIcon tmpBottomIcon = new TmpFlippableIcon();
private TmpFlippableIcon tmpSouthIcon = new TmpFlippableIcon();
private TmpFlippableIcon tmpNorthIcon = new TmpFlippableIcon();
private TmpFlippableIcon tmpEastIcon = new TmpFlippableIcon();
private TmpFlippableIcon tmpWestIcon = new TmpFlippableIcon();
private final TmpFlippableIcon tmpTopIcon = new TmpFlippableIcon();
private final TmpFlippableIcon tmpBottomIcon = new TmpFlippableIcon();
private final TmpFlippableIcon tmpSouthIcon = new TmpFlippableIcon();
private final TmpFlippableIcon tmpNorthIcon = new TmpFlippableIcon();
private final TmpFlippableIcon tmpEastIcon = new TmpFlippableIcon();
private final TmpFlippableIcon tmpWestIcon = new TmpFlippableIcon();
private FlippableIcon topIcon = null;
private FlippableIcon bottomIcon = null;
@@ -32,8 +32,8 @@ public class BusRenderHelper implements IPartRenderHelper
double maxY = 16;
double maxZ = 16;
AEBaseBlock blk = (AEBaseBlock) AEApi.instance().blocks().blockMultiPart.block();
BaseBlockRender bbr = new BaseBlockRender();
final AEBaseBlock blk = (AEBaseBlock) AEApi.instance().blocks().blockMultiPart.block();
final BaseBlockRender bbr = new BaseBlockRender();
private ForgeDirection ax = ForgeDirection.EAST;
private ForgeDirection ay = ForgeDirection.UP;
@@ -104,12 +104,12 @@ public class BusRenderHelper implements IPartRenderHelper
}
BoundBoxCalculator bbc = new BoundBoxCalculator();
final BoundBoxCalculator bbc = new BoundBoxCalculator();
int renderingForPass = 0;
int currentPass = 0;
int itemsRendered = 0;
boolean noAlphaPass = AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ) == false;
final boolean noAlphaPass = AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ) == false;
public int getItemsRendered()
{
@@ -28,7 +28,7 @@ public class BusRenderer implements IItemRenderer
public static final BusRenderer instance = new BusRenderer();
public RenderBlocksWorkaround renderer = new RenderBlocksWorkaround();
public final RenderBlocksWorkaround renderer = new RenderBlocksWorkaround();
public static final HashMap<Integer, IPart> renderPart = new HashMap<Integer, IPart>();
public IPart getRenderer(ItemStack is, IPartItem c)
@@ -42,19 +42,19 @@ public class RenderBlocksWorkaround extends RenderBlocks
public int bZPos;
public int bZNeg;
public int aoXPos[];
public int aoXNeg[];
public int aoYPos[];
public int aoYNeg[];
public int aoZPos[];
public int aoZNeg[];
public final int[] aoXPos;
public final int[] aoXNeg;
public final int[] aoYPos;
public final int[] aoYNeg;
public final int[] aoZPos;
public final int[] aoZNeg;
public float foXPos[];
public float foXNeg[];
public float foYPos[];
public float foYNeg[];
public float foZPos[];
public float foZNeg[];
public final float[] foXPos;
public final float[] foXNeg;
public final float[] foYPos;
public final float[] foYNeg;
public final float[] foZPos;
public final float[] foZNeg;
public int lightHash;
@@ -656,7 +656,7 @@ public class RenderBlocksWorkaround extends RenderBlocks
return ((LightingCache) sim).lightHash == lh;
}
int lightHashTmp[] = new int[27];
final int[] lightHashTmp = new int[27];
public float opacity = 1.0f;
private int getLightingHash(Block blk, IBlockAccess w, int x, int y, int z)
@@ -15,11 +15,11 @@ import org.lwjgl.opengl.GL11;
public class SpatialSkyRender extends IRenderHandler
{
private static SpatialSkyRender instance = new SpatialSkyRender();
private static final SpatialSkyRender instance = new SpatialSkyRender();
private Random random = new Random();
private final Random random = new Random();
private long cycle = 0;
private int dspList;
private final int dspList;
public SpatialSkyRender() {
dspList = GLAllocation.generateDisplayLists( 1 );
@@ -18,12 +18,12 @@ import cpw.mods.fml.relauncher.SideOnly;
public class WorldRender implements ISimpleBlockRenderingHandler
{
private RenderBlocks renderer = new RenderBlocks();
private final RenderBlocks renderer = new RenderBlocks();
final int renderID = RenderingRegistry.getNextAvailableRenderId();
public static final WorldRender instance = new WorldRender();
boolean hasError = false;
public HashMap<AEBaseBlock, BaseBlockRender> blockRenders = new HashMap<AEBaseBlock, BaseBlockRender>();
public final HashMap<AEBaseBlock, BaseBlockRender> blockRenders = new HashMap<AEBaseBlock, BaseBlockRender>();
void setRender(AEBaseBlock in, BaseBlockRender r)
{
@@ -19,7 +19,7 @@ import appeng.tile.storage.TileSkyChest;
public class RenderBlockSkyChest extends BaseBlockRender
{
ModelChest model = new ModelChest();
final ModelChest model = new ModelChest();
public RenderBlockSkyChest() {
super( true, 80 );
@@ -25,7 +25,7 @@ public class RenderBlockSkyCompass extends BaseBlockRender
{
float r = 0;
ModelCompass model = new ModelCompass();
final ModelCompass model = new ModelCompass();
public RenderBlockSkyCompass() {
super( true, 80 );
@@ -11,10 +11,10 @@ import appeng.entity.EntityFloatingItem;
public class AssemblerFX extends EntityFX
{
IAEItemStack item;
EntityFloatingItem fi;
final IAEItemStack item;
final EntityFloatingItem fi;
float time = 0;
float speed;
final float speed;
public AssemblerFX(World w, double x, double y, double z, double r, double g, double b, float speed, IAEItemStack is) {
super( w, x, y, z, r, g, b );
@@ -15,11 +15,11 @@ import cpw.mods.fml.relauncher.SideOnly;
public class CraftingFx extends EntityBreakingFX
{
private IIcon particleTextureIndex;
private final IIcon particleTextureIndex;
private int startBlkX;
private int startBlkY;
private int startBlkZ;
private final int startBlkX;
private final int startBlkY;
private final int startBlkZ;
@Override
public int getFXLayer()
@@ -15,11 +15,11 @@ import cpw.mods.fml.relauncher.SideOnly;
public class EnergyFx extends EntityBreakingFX
{
private IIcon particleTextureIndex;
private final IIcon particleTextureIndex;
private int startBlkX;
private int startBlkY;
private int startBlkZ;
private final int startBlkX;
private final int startBlkY;
private final int startBlkZ;
@Override
public int getFXLayer()
@@ -5,7 +5,9 @@ import net.minecraft.world.World;
public class LightningArcFX extends LightningFX
{
double rx, ry, rz;
final double rx;
final double ry;
final double rz;
public LightningArcFX(World w, double x, double y, double z, double ex, double ey, double ez, double r, double g, double b) {
super( w, x, y, z, r, g, b, 6 );
@@ -13,8 +13,8 @@ public class LightningFX extends EntityFX
{
final int steps = getSteps();
static Random rng = new Random();
double[][] Steps;
static final Random rng = new Random();
final double[][] Steps;
protected LightningFX(World w, double x, double y, double z, double r, double g, double b, int maxAge) {
super( w, x, y, z, r, g, b );
@@ -172,8 +172,8 @@ public class LightningFX extends EntityFX
}
boolean hasData = false;
double[] I = new double[3];
double[] K = new double[3];
final double[] I = new double[3];
final double[] K = new double[3];
private void draw(Tessellator tess, double[] a, double[] b, double f6, double f8)
{
@@ -11,7 +11,7 @@ import appeng.client.texture.ExtraBlockTextures;
public class MatterCannonFX extends EntityBreakingFX
{
private IIcon particleTextureIndex;
private final IIcon particleTextureIndex;
public MatterCannonFX(World par1World, double par2, double par4, double par6, Item par8Item) {
super( par1World, par2, par4, par6, par8Item );
@@ -14,7 +14,7 @@ import appeng.items.misc.ItemEncodedPattern;
public class ItemEncodedPatternRenderer implements IItemRenderer
{
RenderItem ri = new RenderItem();
final RenderItem ri = new RenderItem();
boolean recursive;
@Override
@@ -6,14 +6,14 @@ import net.minecraft.client.model.ModelRenderer;
public class ModelCompass extends ModelBase
{
ModelRenderer Ring1;
ModelRenderer Ring2;
ModelRenderer Ring3;
ModelRenderer Ring4;
ModelRenderer Middle;
ModelRenderer Base;
final ModelRenderer Ring1;
final ModelRenderer Ring2;
final ModelRenderer Ring3;
final ModelRenderer Ring4;
final ModelRenderer Middle;
final ModelRenderer Base;
ModelRenderer Pointer;
final ModelRenderer Pointer;
public ModelCompass() {
textureWidth = 16;
@@ -10,7 +10,7 @@ import cpw.mods.fml.relauncher.SideOnly;
public class MissingIcon implements IIcon
{
boolean isBlock;
final boolean isBlock;
public MissingIcon(Object forWhat) {
isBlock = forWhat instanceof Block;