Remove null checks

This commit is contained in:
Muramasa 2016-08-13 09:10:38 +01:00
parent 9ca24419fb
commit 0345ada52c
18 changed files with 32 additions and 33 deletions

View file

@ -71,11 +71,11 @@ public class GT_Mod
private final String aTextGeneral = "general";
private final String aTextIC2 = "ic2_";
/*static {
static {
if ((509 != GregTech_API.VERSION) || (509 != GT_ModHandler.VERSION) || (509 != GT_OreDictUnificator.VERSION) || (509 != GT_Recipe.VERSION) || (509 != GT_Utility.VERSION) || (509 != GT_RecipeRegistrator.VERSION) || (509 != Element.VERSION) || (509 != Materials.VERSION) || (509 != OrePrefixes.VERSION)) {
throw new GT_ItsNotMyFaultException("One of your Mods included GregTech-API Files inside it's download, mention this to the Mod Author, who does this bad thing, and tell him/her to use reflection. I have added a Version check, to prevent Authors from breaking my Mod that way.");
}
}*/
}
public GT_Mod() {
try {

View file

@ -64,7 +64,7 @@ public enum Dyes implements IColorModulationContainer {
public static Dyes get(String aColor) {
Object tObject = GT_Utility.getFieldContent(Dyes.class, aColor, false, false);
if (tObject != null && tObject instanceof Dyes) return (Dyes) tObject;
if (tObject instanceof Dyes) return (Dyes) tObject;
return _NULL;
}

View file

@ -1393,7 +1393,7 @@ public enum Materials implements IColorModulationContainer, ISubTagContainer {
public static Materials get(String aMaterialName) {
Object tObject = GT_Utility.getFieldContent(Materials.class, aMaterialName, false, false);
if (tObject != null && tObject instanceof Materials) return (Materials) tObject;
if (tObject instanceof Materials) return (Materials) tObject;
return _NULL;
}

View file

@ -638,7 +638,7 @@ public enum OrePrefixes {
public static OrePrefixes getPrefix(String aPrefixName, OrePrefixes aReplacement) {
Object tObject = GT_Utility.getFieldContent(OrePrefixes.class, aPrefixName, false, false);
if (tObject != null && tObject instanceof OrePrefixes) return (OrePrefixes) tObject;
if (tObject instanceof OrePrefixes) return (OrePrefixes) tObject;
return aReplacement;
}

View file

@ -65,9 +65,9 @@ public interface IMetaTileEntityItemPipe extends IMetaTileEntity {
continue;
}
}
if (tItemPipe != null && tItemPipe instanceof BaseMetaPipeEntity) {
if (tItemPipe instanceof BaseMetaPipeEntity) {
IMetaTileEntity tMetaTileEntity = tItemPipe.getMetaTileEntity();
if (tMetaTileEntity != null && tMetaTileEntity instanceof IMetaTileEntityItemPipe && tItemPipe.getCoverBehaviorAtSide(j).letsItemsOut(j, tItemPipe.getCoverIDAtSide(j), tItemPipe.getCoverDataAtSide(j), -2, tItemPipe)) {
if (tMetaTileEntity instanceof IMetaTileEntityItemPipe && tItemPipe.getCoverBehaviorAtSide(j).letsItemsOut(j, tItemPipe.getCoverIDAtSide(j), tItemPipe.getCoverDataAtSide(j), -2, tItemPipe)) {
scanPipes((IMetaTileEntityItemPipe) tMetaTileEntity, aMap, aStep, aSuckItems, aIgnoreCapacity);
}
}
@ -84,7 +84,7 @@ public interface IMetaTileEntityItemPipe extends IMetaTileEntity {
}
if (tItemPipe instanceof BaseMetaPipeEntity) {
IMetaTileEntity tMetaTileEntity = tItemPipe.getMetaTileEntity();
if (tMetaTileEntity != null && tMetaTileEntity instanceof IMetaTileEntityItemPipe && tItemPipe.getCoverBehaviorAtSide(j).letsItemsIn(j, tItemPipe.getCoverIDAtSide(j), tItemPipe.getCoverDataAtSide(j), -2, tItemPipe)) {
if (tMetaTileEntity instanceof IMetaTileEntityItemPipe && tItemPipe.getCoverBehaviorAtSide(j).letsItemsIn(j, tItemPipe.getCoverIDAtSide(j), tItemPipe.getCoverDataAtSide(j), -2, tItemPipe)) {
scanPipes((IMetaTileEntityItemPipe) tMetaTileEntity, aMap, aStep, aSuckItems, aIgnoreCapacity);
}
}

View file

@ -50,7 +50,7 @@ public class GT_Spray_Hardener_Item extends GT_Tool_Item {
}
ItemStack tStack1 = GT_ModHandler.getIC2Item("constructionFoam", 1), tStack2 = GT_ModHandler.getIC2Item("constructionFoamWall", 1);
if (tStack1 != null && tStack1.isItemEqual(new ItemStack(aBlock)) && tStack2 != null && tStack2.getItem() != null && tStack2.getItem() instanceof ItemBlock) {
if (tStack1 != null && tStack1.isItemEqual(new ItemStack(aBlock)) && tStack2 != null && tStack2.getItem() instanceof ItemBlock) {
if (GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) {
GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(102), 1.0F, -1, aX, aY, aZ);
aWorld.setBlock(aX, aY, aZ, GT_Utility.getBlockFromStack(tStack2), 7, 3);

View file

@ -397,7 +397,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
if (getEUCapacity() > 0) {
if (GregTech_API.sMachineFireExplosions && getRandomNumber(1000) == 0) {
Block tBlock = getBlockAtSide((byte) getRandomNumber(6));
if (tBlock != null && tBlock instanceof BlockFire) doEnergyExplosion();
if (tBlock instanceof BlockFire) doEnergyExplosion();
}
if (!hasValidMetaTileEntity()) {

View file

@ -75,7 +75,7 @@ public class BaseMetaTileEntityUE extends BaseMetaTileEntity /*implements IUETil
for (byte i = 0; i < 6; i++) {
if (inputEnergyFrom(i)) {
Object tTileEntity = getTileEntityAtSide(i);
if (tTileEntity != null && tTileEntity instanceof IConductor) {
if (tTileEntity instanceof IConductor) {
rSides.add(ForgeDirection.getOrientation(i));
}
}
@ -88,7 +88,7 @@ public class BaseMetaTileEntityUE extends BaseMetaTileEntity /*implements IUETil
for (byte i = 0; i < 6; i++) {
if (outputsEnergyTo(i)) {
Object tTileEntity = getTileEntityAtSide(i);
if (tTileEntity != null && tTileEntity instanceof IConductor) {
if (tTileEntity instanceof IConductor) {
rSides.add(ForgeDirection.getOrientation(i));
}
}

View file

@ -22,9 +22,9 @@ public class GT_Runnable_MachineBlockUpdate implements Runnable {
private static void stepToUpdateMachine(World aWorld, int aX, int aY, int aZ, ArrayList<ChunkPosition> aList) {
aList.add(new ChunkPosition(aX, aY, aZ));
TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
if (tTileEntity != null && tTileEntity instanceof IMachineBlockUpdateable)
if (tTileEntity instanceof IMachineBlockUpdateable)
((IMachineBlockUpdateable) tTileEntity).onMachineBlockUpdate();
if (aList.size() < 5 || (tTileEntity != null && tTileEntity instanceof IMachineBlockUpdateable) || GregTech_API.isMachineBlock(aWorld.getBlock(aX, aY, aZ), aWorld.getBlockMetadata(aX, aY, aZ))) {
if (aList.size() < 5 || (tTileEntity instanceof IMachineBlockUpdateable) || GregTech_API.isMachineBlock(aWorld.getBlock(aX, aY, aZ), aWorld.getBlockMetadata(aX, aY, aZ))) {
if (!aList.contains(new ChunkPosition(aX + 1, aY, aZ))) stepToUpdateMachine(aWorld, aX + 1, aY, aZ, aList);
if (!aList.contains(new ChunkPosition(aX - 1, aY, aZ))) stepToUpdateMachine(aWorld, aX - 1, aY, aZ, aList);
if (!aList.contains(new ChunkPosition(aX, aY + 1, aZ))) stepToUpdateMachine(aWorld, aX, aY + 1, aZ, aList);

View file

@ -15,7 +15,7 @@ public class GT_PlayedSound {
@Override
public boolean equals(Object aObject) {
if (aObject != null && aObject instanceof GT_PlayedSound) {
if (aObject instanceof GT_PlayedSound) {
return ((GT_PlayedSound) aObject).mX == mX && ((GT_PlayedSound) aObject).mY == mY && ((GT_PlayedSound) aObject).mZ == mZ && ((GT_PlayedSound) aObject).mSoundName.equals(mSoundName);
}
return false;

View file

@ -319,7 +319,7 @@ public class GT_Utility {
}
public static void sendChatToPlayer(EntityPlayer aPlayer, String aChatMessage) {
if (aPlayer != null && aPlayer instanceof EntityPlayerMP && aChatMessage != null) {
if (aPlayer instanceof EntityPlayerMP && aChatMessage != null) {
aPlayer.addChatComponentMessage(new ChatComponentText(aChatMessage));
}
}
@ -500,7 +500,7 @@ public class GT_Utility {
* @return the Amount of moved Items
*/
public static byte moveOneItemStack(Object aTileEntity1, Object aTileEntity2, byte aGrabFrom, byte aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce) {
if (aTileEntity1 != null && aTileEntity1 instanceof IInventory)
if (aTileEntity1 instanceof IInventory)
return moveOneItemStack((IInventory) aTileEntity1, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, true);
return 0;
}
@ -597,7 +597,7 @@ public class GT_Utility {
for (int i = 0; i < tGrabSlots.length; i++) tGrabSlots[i] = i;
}
if (aTileEntity2 != null && aTileEntity2 instanceof IInventory) {
if (aTileEntity2 instanceof IInventory) {
for (int i = 0; i < tGrabSlots.length; i++) {
if (listContainsItem(aFilter, ((IInventory) aTileEntity1).getStackInSlot(tGrabSlots[i]), true, aInvertFilter)) {
if (isAllowedToTakeFromSlot((IInventory) aTileEntity1, tGrabSlots[i], aGrabFrom, ((IInventory) aTileEntity1).getStackInSlot(tGrabSlots[i]))) {
@ -1010,7 +1010,7 @@ public class GT_Utility {
}
public static boolean isBlockValid(Object aBlock) {
return aBlock != null && (aBlock instanceof Block);
return (aBlock instanceof Block);
}
public static boolean isBlockInvalid(Object aBlock) {
@ -1026,7 +1026,7 @@ public class GT_Utility {
}
public static boolean isStackValid(Object aStack) {
return aStack != null && (aStack instanceof ItemStack) && ((ItemStack) aStack).getItem() != null && ((ItemStack) aStack).stackSize >= 0;
return (aStack instanceof ItemStack) && ((ItemStack) aStack).getItem() != null && ((ItemStack) aStack).stackSize >= 0;
}
public static boolean isStackInvalid(Object aStack) {
@ -1558,7 +1558,7 @@ public class GT_Utility {
tList.add("----- X: " + aX + " Y: " + aY + " Z: " + aZ + " -----");
try {
if (tTileEntity != null && tTileEntity instanceof IInventory)
if (tTileEntity instanceof IInventory)
tList.add("Name: " + ((IInventory) tTileEntity).getInventoryName() + " MetaData: " + aWorld.getBlockMetadata(aX, aY, aZ));
else
tList.add("Name: " + tBlock.getUnlocalizedName() + " MetaData: " + aWorld.getBlockMetadata(aX, aY, aZ));

View file

@ -282,8 +282,7 @@ public class GT_Block_Machines
public void onBlockClicked(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer) {
TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
if ((tTileEntity != null) &&
((tTileEntity instanceof IGregTechTileEntity))) {
if (((tTileEntity instanceof IGregTechTileEntity))) {
((IGregTechTileEntity) tTileEntity).onLeftclick(aPlayer);
}
}
@ -341,7 +340,7 @@ public class GT_Block_Machines
public int getComparatorInputOverride(World aWorld, int aX, int aY, int aZ, int aSide) {
TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
if ((tTileEntity != null) && ((tTileEntity instanceof IGregTechTileEntity))) {
if (((tTileEntity instanceof IGregTechTileEntity))) {
return ((IGregTechTileEntity) tTileEntity).getComparatorValue((byte) aSide);
}
return 0;
@ -352,7 +351,7 @@ public class GT_Block_Machines
return 0;
}
TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
if ((tTileEntity != null) && ((tTileEntity instanceof IGregTechTileEntity))) {
if (((tTileEntity instanceof IGregTechTileEntity))) {
return ((IGregTechTileEntity) tTileEntity).getOutputRedstoneSignal(GT_Utility.getOppositeSide(aSide));
}
return 0;
@ -363,7 +362,7 @@ public class GT_Block_Machines
return 0;
}
TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
if ((tTileEntity != null) && ((tTileEntity instanceof IGregTechTileEntity))) {
if (((tTileEntity instanceof IGregTechTileEntity))) {
return ((IGregTechTileEntity) tTileEntity).getStrongOutputRedstoneSignal(GT_Utility.getOppositeSide(aSide));
}
return 0;
@ -429,7 +428,7 @@ public class GT_Block_Machines
public float getExplosionResistance(Entity par1Entity, World aWorld, int aX, int aY, int aZ, double explosionX, double explosionY, double explosionZ) {
TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
if ((tTileEntity != null) && ((tTileEntity instanceof IGregTechTileEntity))) {
if (((tTileEntity instanceof IGregTechTileEntity))) {
return ((IGregTechTileEntity) tTileEntity).getBlastResistance((byte) 6);
}
return 10.0F;

View file

@ -201,7 +201,7 @@ public abstract class GT_Block_Ores_Abstract extends GT_Generic_Block implements
public int getDamageValue(World aWorld, int aX, int aY, int aZ) {
TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
if ((tTileEntity != null) && ((tTileEntity instanceof GT_TileEntity_Ores))) {
if (((tTileEntity instanceof GT_TileEntity_Ores))) {
return ((GT_TileEntity_Ores) tTileEntity).getMetaData();
}
return 0;

View file

@ -128,7 +128,7 @@ public class GT_Entity_Arrow
if (tHitEntity != null) {
tVector = new MovingObjectPosition(tHitEntity);
}
if ((tVector != null) && (tVector.entityHit != null) && ((tVector.entityHit instanceof EntityPlayer))) {
if ((tVector != null) && ((tVector.entityHit instanceof EntityPlayer))) {
EntityPlayer entityplayer = (EntityPlayer) tVector.entityHit;
if ((entityplayer.capabilities.disableDamage) || (((tShootingEntity instanceof EntityPlayer)) && (!((EntityPlayer) tShootingEntity).canAttackPlayer(entityplayer)))) {
tVector = null;

View file

@ -53,7 +53,7 @@ public class GT_SensorCard_Item
ChunkCoordinates target = aCard.getTarget();
TileEntity tTileEntity = world.getTileEntity(target.posX, target.posY, target.posZ);
if ((tTileEntity != null) && ((tTileEntity instanceof IGregTechDeviceInformation)) && (((IGregTechDeviceInformation) tTileEntity).isGivingInformation())) {
if (((tTileEntity instanceof IGregTechDeviceInformation)) && (((IGregTechDeviceInformation) tTileEntity).isGivingInformation())) {
String[] tInfoData = ((IGregTechDeviceInformation) tTileEntity).getInfoData();
for (int i = 0; i < tInfoData.length; i++) {
aCard.setString("mString" + i, tInfoData[i]);

View file

@ -40,7 +40,7 @@ public class Behaviour_Wrench
byte aTargetSide = GT_Utility.determineWrenchingSide((byte) aSide, hitX, hitY, hitZ);
TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ);
try {
if ((aTileEntity != null) && ((aTileEntity instanceof IWrenchable))) {
if (((aTileEntity instanceof IWrenchable))) {
if (((IWrenchable) aTileEntity).wrenchCanSetFacing(aPlayer, aTargetSide)) {
if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) {
((IWrenchable) aTileEntity).setFacing((short) aTargetSide);

View file

@ -115,7 +115,7 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch {
this.mPumpCountBelow = 0;
IGregTechTileEntity tTileEntity;
for (int i = 1; (i < 21) && ((tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance((byte) 0, i)) != null)
&& (tTileEntity.getMetaTileEntity() != null) && ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Pump)); i++) {
&& ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Pump)); i++) {
getBaseMetaTileEntity().setActive(tTileEntity.isActive());
this.mPumpCountBelow += 1;
((GT_MetaTileEntity_Pump) tTileEntity.getMetaTileEntity()).mPumpTimer -= 1;

View file

@ -57,7 +57,7 @@ public class GT_ItemIterator
Iterator tIterator = Item.itemRegistry.iterator();
while (tIterator.hasNext()) {
Object tObject;
if (((tObject = tIterator.next()) != null) && ((tObject instanceof Item)) && (!(tObject instanceof GT_Generic_Item))) {
if (((tObject = tIterator.next()) instanceof Item) && (!(tObject instanceof GT_Generic_Item))) {
Item tItem = (Item) tObject;
String tName;
if ((tName = tItem.getUnlocalizedName()) != null) {