quick fix : Redundant 'if' statement

This commit is contained in:
Alexdoru committed 2023-01-25 23:11:58 +01:00
1 parent ce3ee201a3
commit d0c3b57e22
29 files changed
+48 -130

No files matched your search

@@ -78,10 +78,7 @@ public class TinkerArmor {
GameRegistry.registerTileEntity(DryingRackLogic.class, "Armor.DryingRack");
TinkerArmor.diamondApple = new DiamondApple().setUnlocalizedName("tconstruct.apple.diamond");
GameRegistry.registerItem(TinkerArmor.diamondApple, "diamondApple");
boolean foodOverhaul = false;
if (Loader.isModLoaded("HungerOverhaul") || Loader.isModLoaded("fc_food")) {
foodOverhaul = true;
}
boolean foodOverhaul = Loader.isModLoaded("HungerOverhaul") || Loader.isModLoaded("fc_food");
TinkerArmor.jerky = new Jerky(foodOverhaul).setUnlocalizedName("tconstruct.jerky");
GameRegistry.registerItem(TinkerArmor.jerky, "jerky");
@@ -20,18 +20,12 @@ public class SlotBehavedOnly extends Slot {
int stackL = b.getStackLimit(par1ItemStack);
if (b != null
&& this.inventory.getStackInSlot(this.slotNumber) != null
&& !this.inventory.getStackInSlot(this.slotNumber).isItemEqual(par1ItemStack)) {
if (this.inventory.getStackInSlot(this.slotNumber) != null && !this.inventory.getStackInSlot(this.slotNumber).isItemEqual(par1ItemStack)) {
ItemStack is = this.inventory.getStackInSlot(this.slotNumber);
if (is.stackSize + par1ItemStack.stackSize <= stackL) {
return true;
}
return is.stackSize + par1ItemStack.stackSize <= stackL;
} else {
return par1ItemStack.stackSize <= stackL;
}
return false;
// return b != null;
}
@@ -109,12 +109,8 @@ public class Landmine extends MantleBlock {
* neighbor blockID
*/
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, Block par5) {
boolean var6 = false;
if (!World.doesBlockHaveSolidTopSurface(par1World, par2, par3 - 1, par4)
&& !BlockFence.func_149825_a(par1World.getBlock(par2, par3 - 1, par4))) {
var6 = true;
}
boolean var6 = !World.doesBlockHaveSolidTopSurface(par1World, par2, par3 - 1, par4)
&& !BlockFence.func_149825_a(par1World.getBlock(par2, par3 - 1, par4));
if (var6) {
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
@@ -165,10 +165,8 @@ public class TankLayerScan extends LogicComponent {
protected boolean checkAir(int x, int y, int z) {
Block block = world.getBlock(x, y, z);
if (block == null || world.isAirBlock(x, y, z)) // || block == TContent.tankAir)
return true;
return false;
// || block == TContent.tankAir)
return block == null || world.isAirBlock(x, y, z);
}
protected boolean checkServant(int x, int y, int z) {
@@ -49,9 +49,7 @@ public class CastingRecipe {
return true;
} else if (!ignoreNBT && ItemStack.areItemStacksEqual(cast, inputCast)) {
return true;
} else if (ignoreNBT && cast != null && inputCast != null && cast.isItemEqual(inputCast)) {
return true;
}
} else return ignoreNBT && cast != null && inputCast != null && cast.isItemEqual(inputCast);
}
return false;
}
@@ -72,8 +72,7 @@ public class ToolRecipe {
public boolean validAccessory(Item input) {
if (input == null) {
if (accessoryList.size() < 1) return true;
return false;
return accessoryList.size() < 1;
}
for (Item part : accessoryList) {
if (part == input) return true;
@@ -84,8 +83,7 @@ public class ToolRecipe {
public boolean validExtra(Item input) {
if (input == null) {
if (extraList.size() < 1) return true;
return false;
return extraList.size() < 1;
}
for (Item part : extraList) {
if (part == input) return true;
@@ -196,7 +196,7 @@ public class AbilityHelper {
}
if (entity instanceof EntityPlayer) ((EntityPlayer) player).addExhaustion(0.3F);
if (causedDamage) return true;
return causedDamage;
}
}
}
@@ -27,7 +27,7 @@ public class FletchlingLeafMaterial extends FletchingMaterial {
if (stack != null) {
Block block = BlockUtils.getBlockFromItemStack(stack);
if (block != null) {
if (block.isLeaves(null, 0, 0, 0)) return true;
return block.isLeaves(null, 0, 0, 0);
}
}
return false;
@@ -96,19 +96,15 @@ public abstract class BowBaseAmmo extends ProjectileWeapon {
// no tinker arrow
if (!(stack.getItem() instanceof ArrowAmmo)) return false;
// no ammo left
if (((IAmmo) stack.getItem()).getAmmoCount(stack) <= 0) return false;
return true;
return ((IAmmo) stack.getItem()).getAmmoCount(stack) > 0;
}
private boolean checkVanillaArrow(ItemStack stack) {
// null
if (stack == null) return false;
// no arrow
if (!(stack.getItem() == Items.arrow)) return false;
return stack.getItem() == Items.arrow;
// inventory shouldn't contain stacksize 0 items so we don't have to check that.
return true;
}
@Override
@@ -1,12 +1,7 @@
package tconstruct.mechworks.blocks;
import static net.minecraftforge.common.util.ForgeDirection.*;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import mantle.blocks.BlockUtils;
import mantle.world.WorldHelper;
import net.minecraft.block.Block;
@@ -39,6 +34,11 @@ import tconstruct.mechworks.logic.LandmineExplodeLogic;
import tconstruct.mechworks.logic.TileEntityLandmine;
import tconstruct.world.model.RenderLandmine;
import java.util.List;
import java.util.Random;
import static net.minecraftforge.common.util.ForgeDirection.*;
/**
*
* @author fuj1n
@@ -411,13 +411,7 @@ public class BlockLandmine extends BlockContainer {
private boolean hasItems(World par1World, int par2, int par3, int par4) {
TileEntityLandmine te = (TileEntityLandmine) par1World.getTileEntity(par2, par3, par4);
if (te != null && te.getStackInSlot(0) != null
|| te.getStackInSlot(1) != null
|| te.getStackInSlot(2) != null) {
return true;
} else {
return false;
}
return te != null && (te.getStackInSlot(0) != null || te.getStackInSlot(1) != null || te.getStackInSlot(2) != null);
}
protected int getMineState(World par1World, int par2, int par3, int par4) {
@@ -219,11 +219,7 @@ public class ContainerLandmine extends Container {
slot2 = (Slot) this.inventorySlots.get(par1);
boolean shouldDoStuff = true;
if ((!(slot2 instanceof SlotBehavedOnly))) {
shouldDoStuff = false;
}
boolean shouldDoStuff = slot2 instanceof SlotBehavedOnly;
if (slot2 != null) {
itemstack1 = slot2.getStack();
@@ -13,10 +13,7 @@ public class ModExtraModifier extends ItemModifier {
protected boolean canModify(ItemStack tool, ItemStack[] recipe) {
if (tool != null && tool.getItem() instanceof IModifyable) {
NBTTagCompound tags = this.getModifierTag(tool);
if (tags.getBoolean(key)) {
return false;
}
return true;
return !tags.getBoolean(key);
}
return false;
}
@@ -62,10 +62,9 @@ public class ModFlux extends ModBoolean {
> ((ToolCore) tool.getItem()).getMaxEnergyStored(tool);
}
// otherwise check if we have enough modfiers
else if (tags.getInteger("Modifiers") < modifiersRequired) return false;
else return tags.getInteger("Modifiers") >= modifiersRequired;
// all requirements satisfied!
return true;
}
@Override
@@ -30,7 +30,7 @@ public class ModLapis extends ItemModTypeFilter {
if (!tags.hasKey(key)) return tags.getInteger("Modifiers") > 0 && matchingAmount(input) <= max;
int[] keyPair = tags.getIntArray(key);
if (keyPair[0] + matchingAmount(input) <= max) return true;
return keyPair[0] + matchingAmount(input) <= max;
}
return false;
}
@@ -14,9 +14,7 @@ public class ModPotion extends ItemModifier {
protected boolean canModify(ItemStack tool, ItemStack[] input) {
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
NBTTagCompound potion = tool.getTagCompound().getCompoundTag("Potion");
if (potion == null) return true;
return false;
return potion == null;
}
@Override
@@ -146,15 +146,10 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler {
if (tank.position.contains(relMouse)) {
if ((tank.fluid != null) && tank.fluid.amount > 0) {
if (usage) {
if (!GuiUsageRecipe.openRecipeGui("liquid", new Object[] {tank.fluid})) {
return false;
}
return GuiUsageRecipe.openRecipeGui("liquid", new Object[]{tank.fluid});
} else {
if (!GuiCraftingRecipe.openRecipeGui("liquid", new Object[] {tank.fluid})) {
return false;
}
return GuiCraftingRecipe.openRecipeGui("liquid", new Object[]{tank.fluid});
}
return true;
}
}
}
@@ -57,12 +57,8 @@ public class SmelteryContainer extends ActiveContainer {
int basePos = invRow * columns;
for (int iter = 0; iter < activeInventorySlots.size(); iter++) {
ActiveSlot slot = (ActiveSlot) activeInventorySlots.get(iter);
if (slot.activeSlotNumber >= basePos
&& slot.activeSlotNumber < basePos + columns * SmelteryGui.maxRows) {
slot.setActive(true);
} else {
slot.setActive(false);
}
slot.setActive(slot.activeSlotNumber >= basePos
&& slot.activeSlotNumber < basePos + columns * SmelteryGui.maxRows);
int xPos = (iter - basePos) % columns;
int yPos = (iter - basePos) / columns;
@@ -166,8 +166,7 @@ public class FaucetLogic extends TileEntity implements IFacingLogic, IActiveLogi
@Override
public void setActive(boolean flag) {
if (!active) {
active = true;
if (!activateFaucet()) active = false;
active = activateFaucet();
} else {
active = false;
}
@@ -793,11 +793,8 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
public boolean checkSameLevel(int x, int y, int z, int[] sides) {
lavaTanks.clear();
boolean check = checkBricksOnLevel(x, y, z, sides);
if (check && lavaTanks.size() > 0) return true;
else return false;
return check && lavaTanks.size() > 0;
}
public int recurseStructureUp(int x, int y, int z, int[] sides, int count) {
@@ -57,12 +57,9 @@ public class TActiveOmniMod extends ActiveToolMod {
public boolean beforeBlockBreak(ToolCore tool, ItemStack stack, int x, int y, int z, EntityLivingBase entity) {
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
baconator(tool, stack, entity, tags);
if (entity instanceof EntityPlayer && ((EntityPlayer) entity).capabilities.isCreativeMode) return false;
TinkerTools.modLapis.midStreamModify(stack, tool);
if (autoSmelt(tool, tags, stack, x, y, z, entity)) return true;
return false;
return autoSmelt(tool, tags, stack, x, y, z, entity);
}
@Override
@@ -294,7 +291,6 @@ public class TActiveOmniMod extends ActiveToolMod {
ItemStack stack,
EntityLivingBase player,
Entity entity) {
if (tool == TinkerTools.cutlass && random.nextInt(10) == 0) return true;
return false;
return tool == TinkerTools.cutlass && random.nextInt(10) == 0;
}
}
@@ -37,7 +37,6 @@ public class FancyEntityItem extends EntityItem {
}
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) {
if (par1DamageSource.getDamageType().equals("outOfWorld")) return true;
return false;
return par1DamageSource.getDamageType().equals("outOfWorld");
}
}
@@ -270,11 +270,7 @@ public class PartCrafterGui extends GuiContainer implements INEIGuiHandler {
@Override
public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility) {
if (width - xSize < 107) {
currentVisibility.showWidgets = false;
} else {
currentVisibility.showWidgets = true;
}
currentVisibility.showWidgets = width - xSize >= 107;
if (guiLeft < 58) {
currentVisibility.showStateButtons = false;
@@ -301,9 +297,6 @@ public class PartCrafterGui extends GuiContainer implements INEIGuiHandler {
@Override
public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) {
if (y + h - 4 < guiTop || y + 4 > guiTop + ySize) return false;
if (x - w - 4 < guiLeft - 40 || x + 4 > guiLeft + xSize + DESC_WIDTH) return false;
return true;
return x - w - 4 >= guiLeft - 40 && x + 4 <= guiLeft + xSize + DESC_WIDTH;
}
}
@@ -183,10 +183,6 @@ public class StencilTableGui extends GuiContainer implements INEIGuiHandler {
}
// is it in the horizontal column of the left buttons?
if (x + w > this.buttonsLeftRect[0] && x < this.guiLeft && y + h > this.guiTop && y < this.buttonsLeftRect[1]) {
return true;
}
return false;
return x + w > this.buttonsLeftRect[0] && x < this.guiLeft && y + h > this.guiTop && y < this.buttonsLeftRect[1];
}
}
@@ -268,16 +268,10 @@ public class ToolStationGui extends GuiContainer implements INEIGuiHandler {
@Override
public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility) {
if (width - xSize < 107) {
currentVisibility.showWidgets = false;
} else {
currentVisibility.showWidgets = true;
}
currentVisibility.showWidgets = width - xSize >= 107;
if (guiLeft < 58) {
currentVisibility.showStateButtons = false;
}
return currentVisibility;
}
@@ -299,9 +293,6 @@ public class ToolStationGui extends GuiContainer implements INEIGuiHandler {
@Override
public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) {
if (y + h - 4 < guiTop || y + 4 > guiTop + ySize) return false;
if (x - w - 4 < guiLeft - 40 || x + 4 > guiLeft + xSize + 126) return false;
return true;
return x - w - 4 >= guiLeft - 40 && x + 4 <= guiLeft + xSize + 126;
}
}
@@ -66,8 +66,7 @@ public class PartBuilderLogic extends InventoryLogic implements ISidedInventory
}
}
if (inventory[4] != null || inventory[5] != null) craftedTop = true;
else craftedTop = false;
craftedTop = inventory[4] != null || inventory[5] != null;
}
if (!craftedTop) buildTopPart();
@@ -84,8 +83,7 @@ public class PartBuilderLogic extends InventoryLogic implements ISidedInventory
}
}
if (inventory[6] != null || inventory[7] != null) craftedBottom = true;
else craftedBottom = false;
craftedBottom = inventory[6] != null || inventory[7] != null;
}
if (!craftedBottom) buildBottomPart();
@@ -91,8 +91,7 @@ public class StencilTableLogic extends InventoryLogic implements ISidedInventory
@Override
public boolean canDropInventorySlot(int slot) {
if (slot == 0) return true;
else return false;
return slot == 0;
}
@Override
@@ -32,8 +32,7 @@ public class ToolStationLogic extends InventoryLogic implements ISidedInventory
@Override
public boolean canDropInventorySlot(int slot) {
if (slot == 0) return false;
return true;
return slot != 0;
}
@Override
@@ -15,7 +15,7 @@ public class WeaponryActiveToolMod extends ActiveToolMod {
IAmmo ammo = (IAmmo) stack.getItem();
if (tags.getInteger("Damage") == 0) {
int rem = ammo.consumeAmmo(1, stack);
if (rem > 0) return true;
return rem > 0;
} else if (ammo.getAmmoCount(stack) > 0) {
int d = tags.getInteger("Damage") + damage;
int max = tags.getInteger("TotalDurability");
@@ -26,7 +26,9 @@ public class WeaponryActiveToolMod extends ActiveToolMod {
}
}
// all other ammo items can't be damaged
else if (stack.getItem() instanceof IAmmo) return true;
else {
return stack.getItem() instanceof IAmmo;
}
return false;
}
@@ -1027,10 +1027,7 @@ public class CartEntity extends Entity implements IInventory, IEntityAdditionalS
* @return True if this cart can be ridden.
*/
public boolean canBeRidden() {
if (pullcartType == 0 && getClass() == CartEntity.class) {
return true;
}
return false;
return pullcartType == 0 && getClass() == CartEntity.class;
}
/**