Skip to content

Commit

Permalink
Merge pull request CoFH#18 from DevFactory/release/collapsible-if-sta…
Browse files Browse the repository at this point in the history
…tements-should-not-be-merged-fix-1

Code quality fix - Collapsible "if" statements should be merged.
  • Loading branch information
skyboy authored Jun 21, 2016
2 parents c1b8cbd + 7d2bf0a commit f9fa785
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 47 deletions.
6 changes: 2 additions & 4 deletions src/main/java/cofh/lib/gui/element/ElementTextField.java
Original file line number Diff line number Diff line change
Expand Up @@ -916,10 +916,8 @@ public void drawForeground(int mouseX, int mouseY) {
int startX = posX + 1 - (multiline ? renderStartX : 0), endX = sizeX - 1;
int startY = posY + 1 - renderStartY, endY = startY + font.FONT_HEIGHT;
int drawY = renderStartY + Math.max(0, (sizeY - 2) / font.FONT_HEIGHT) * font.FONT_HEIGHT;
if (enableStencil) {
if (sizeY - (drawY - renderStartY) > 2) {
drawY += font.FONT_HEIGHT;
}
if (enableStencil && sizeY - (drawY - renderStartY) > 2) {
drawY += font.FONT_HEIGHT;
}
int drawX = endX + (multiline ? renderStartX : 0);
for (int i = multiline ? 0 : renderStartX, width = 0, height = 0; i <= textLength; ++i) {
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/cofh/lib/inventory/ComparableItemStackNBT.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ public ComparableItemStackNBT(ItemStack stack) {

super(stack);

if (stack != null) {
if (stack.stackTagCompound != null) {
tag = (NBTTagCompound) stack.stackTagCompound.copy();
}
if (stack != null && stack.stackTagCompound != null) {
tag = (NBTTagCompound) stack.stackTagCompound.copy();
}
}

Expand Down
7 changes: 3 additions & 4 deletions src/main/java/cofh/lib/render/RenderFluidOverlayItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@ public void renderItem(ItemRenderType type, ItemStack stack, Object... data) {
if (item instanceof IFluidContainerItem) {
IFluidContainerItem fluidItem = (IFluidContainerItem) item;
fluid = fluidItem.getFluid(stack);
} else if (item instanceof IFluidOverlayItem) {
if (item.getRenderPasses(ItemHelper.getItemDamage(stack)) == 2) {
fluid = FluidContainerRegistry.getFluidForFilledItem(stack);
}
} else if (item instanceof IFluidOverlayItem
&& item.getRenderPasses(ItemHelper.getItemDamage(stack)) == 2) {
fluid = FluidContainerRegistry.getFluidForFilledItem(stack);
}
doRenderItem(type, stack, item, fluid);
}
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/cofh/lib/transport/EnderRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,11 @@ public void removeDestination(IEnderDestination theAttuned) {
if (dest == null) {
return;
}
if (dest.dimension == theAttuned.dimension()) {
if (dest.x == theAttuned.x() && dest.y == theAttuned.y() && dest.z == theAttuned.z()) {
map.remove(freq);
usedTeleports.get(channel).set(freq, false);
linkConf.getCategory(channel).remove(String.valueOf(freq));
}
if (dest.dimension == theAttuned.dimension()
&& dest.x == theAttuned.x() && dest.y == theAttuned.y() && dest.z == theAttuned.z()) {
map.remove(freq);
usedTeleports.get(channel).set(freq, false);
linkConf.getCategory(channel).remove(String.valueOf(freq));
}
}

Expand Down
15 changes: 7 additions & 8 deletions src/main/java/cofh/lib/util/UtilLiquidMover.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,14 @@ public static boolean manuallyDrainTank(ITankContainerBucketable itcb, EntityPla
filledBucket = null;
}
}
if (filledBucket != null) {
if (ItemHelper.disposePlayerItem(ci, filledBucket, player, true)) {
if (!player.worldObj.isRemote) {
player.openContainer.detectAndSendChanges();
((EntityPlayerMP) player).sendContainerAndContentsToPlayer(player.openContainer, player.openContainer.getInventory());
}
itcb.drain(ForgeDirection.UNKNOWN, bucketLiquid, true);
return true;
if (filledBucket != null
&& ItemHelper.disposePlayerItem(ci, filledBucket, player, true)) {
if (!player.worldObj.isRemote) {
player.openContainer.detectAndSendChanges();
((EntityPlayerMP) player).sendContainerAndContentsToPlayer(player.openContainer, player.openContainer.getInventory());
}
itcb.drain(ForgeDirection.UNKNOWN, bucketLiquid, true);
return true;
}
}
}
Expand Down
12 changes: 5 additions & 7 deletions src/main/java/cofh/lib/util/helpers/ItemHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,11 @@ public static String getNameFromItemStack(ItemStack stack) {

public static ItemStack damageItem(ItemStack stack, int amt, Random rand) {

if (stack != null && stack.isItemStackDamageable()) {
if (stack.attemptDamageItem(amt, rand)) {
if (--stack.stackSize <= 0) {
stack = null;
} else {
stack.setItemDamage(0);
}
if (stack != null && stack.isItemStackDamageable() && stack.attemptDamageItem(amt, rand)) {
if (--stack.stackSize <= 0) {
stack = null;
} else {
stack.setItemDamage(0);
}
}

Expand Down
7 changes: 3 additions & 4 deletions src/main/java/cofh/lib/world/feature/FeatureBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,9 @@ public boolean generateFeature(Random random, int chunkX, int chunkZ, World worl
if (!newGen && !regen) {
return false;
}
if (dimensionRestriction != GenRestriction.NONE) {
if (dimensionRestriction == GenRestriction.BLACKLIST == dimensions.contains(world.provider.dimensionId)) {
return false;
}
if (dimensionRestriction != GenRestriction.NONE
&& dimensionRestriction == GenRestriction.BLACKLIST == dimensions.contains(world.provider.dimensionId)) {
return false;
}
if (rarity > 1 && random.nextInt(rarity) != 0) {
return false;
Expand Down
7 changes: 2 additions & 5 deletions src/main/java/cofh/lib/world/feature/FeatureGenSurface.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,8 @@ public boolean generateFeature(Random random, int chunkX, int chunkZ, World worl
int y = BlockHelper.getSurfaceBlockY(world, x, z);
l: {
Block block = world.getBlock(x, y, z);
if (!block.isAir(world, x, y, z)) {

if (canGenerateInBlock(world, x, y, z, matList)) {
break l;
}
if (!block.isAir(world, x, y, z) && canGenerateInBlock(world, x, y, z, matList)) {
break l;
}
continue;
}
Expand Down
7 changes: 2 additions & 5 deletions src/main/java/cofh/lib/world/feature/FeatureGenTopBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,8 @@ public boolean generateFeature(Random random, int chunkX, int chunkZ, World worl
int y = BlockHelper.getTopBlockY(world, x, z);
l: {
Block block = world.getBlock(x, y, z);
if (!block.isAir(world, x, y, z)) {

if (canGenerateInBlock(world, x, y, z, matList)) {
break l;
}
if (!block.isAir(world, x, y, z) && canGenerateInBlock(world, x, y, z, matList)) {
break l;
}
continue;
}
Expand Down

0 comments on commit f9fa785

Please sign in to comment.