mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 01:54:59 +00:00
Code cleanup (#133)
* gradle updateBuildScript * fix comments and commented-out code Code deletion, converting comments into javadocs, and refactoring code to not need comments. * remove redundant suppressions * replace C-style array declaration with Java-style * make private field final * remove unnecessary semicolon * extract a common part from an if * simplify boolean expression * simplify ternary if * remove unused imports * convert escaped characters for clarity * replace while with for * replace explicit types with diamond operators * replace anonymous type with lambda * enable modern Java syntax * migrate to enhanced switch * migrate to pattern variables for instanceof * remove empty javadoc * add Nonnull annotation to overrides of Nonnull methods * replace wailaStack with null When wailaStack is not null, the flow breaks out of the loop, so there's no need to confuse the reader with putting wailaStack both as the result and the parameter of the call - there's no recursion. * int cannot be bigger than its max value * suppress dataflow warning * remove redundant initializer The default value of int is 0. * null check is covered by instanceof * simplify some calls of addVertexWithUV * fix typos and add TODOs * make flipState more understandable
This commit is contained in:
1 parent
f87b76347e
commit
d5b8ef6ea9
89 files changed
+421
-633
No files matched your search
@@ -22,7 +22,7 @@ import li.cil.oc.api.Items;
|
||||
import li.cil.oc.api.detail.ItemInfo;
|
||||
|
||||
/**
|
||||
* Shell class to organize proxy replacements and hide the ugliness
|
||||
* A shell class to organize proxy replacements and hide the ugliness
|
||||
*/
|
||||
public class ItemReplacements {
|
||||
|
||||
@@ -78,9 +78,11 @@ public class ItemReplacements {
|
||||
registry.put("extracells:storage.physical.void", voidCell);
|
||||
deprecateItem("pattern.fluid", ItemAndBlockHolder.PATTERN);
|
||||
deprecateWireless("terminal.fluid.wireless", ItemAndBlockHolder.WIRELESS_FLUID_TERM);
|
||||
|
||||
/* Storage casings */
|
||||
deprecateItem("storage.casing", 0, AEApi.instance().definitions().materials().emptyAdvancedStorageCell());
|
||||
deprecateItem("storage.casing", 1, ItemAndBlockHolder.CELL_HOUSING, 2);
|
||||
|
||||
/* Storage components (1k component, etc.) */
|
||||
deprecateItem("storage.component", 0, AEApi.instance().definitions().materials().cell256kPart());
|
||||
deprecateItem("storage.component", 1, AEApi.instance().definitions().materials().cell1024kPart());
|
||||
|
||||
@@ -69,8 +69,7 @@ public class ProxyItem extends FCBaseItem {
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int p_77663_4_, boolean p_77663_5_) {
|
||||
if (!worldIn.isRemote && entityIn instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) entityIn;
|
||||
if (!worldIn.isRemote && entityIn instanceof EntityPlayer player) {
|
||||
for (int i = 0; i < player.inventory.getSizeInventory(); ++i) {
|
||||
ItemStack s = player.inventory.getStackInSlot(i);
|
||||
if (s == stack) {
|
||||
|
||||
@@ -4,6 +4,8 @@ import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -186,6 +188,7 @@ public class ProxyPart implements IPart, IPartDeprecated {
|
||||
return def;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound transformNBT(NBTTagCompound extra) {
|
||||
return extra;
|
||||
|
||||
@@ -23,12 +23,6 @@ public class ProxyPartItem extends ProxyItem implements IPartItem {
|
||||
super(ec2itemName);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param srcMeta
|
||||
* @param replacement
|
||||
* @param part
|
||||
*/
|
||||
protected void addItemPart(int srcMeta, Item replacement, Function<ProxyPartItem, ProxyPart> part) {
|
||||
this.replacements.put(srcMeta, new PartReplacement(replacement, part));
|
||||
}
|
||||
@@ -42,8 +36,7 @@ public class ProxyPartItem extends ProxyItem implements IPartItem {
|
||||
@Override
|
||||
public IPart createPartFromItemStack(ItemStack is) {
|
||||
final int meta = is.getItemDamage();
|
||||
if (this.replacements.get(meta) instanceof PartReplacement) {
|
||||
PartReplacement part = (PartReplacement) this.replacements.get(meta);
|
||||
if (this.replacements.get(meta) instanceof PartReplacement part) {
|
||||
return part.proxyPart.apply(this);
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.glodblock.github.crossmod.extracells.parts;
|
||||
|
||||
import static net.minecraftforge.common.util.Constants.NBT.TAG_COMPOUND;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
@@ -25,6 +27,7 @@ public class ProxyFluidBusIO extends ProxyPart {
|
||||
super(partItem);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound transformNBT(NBTTagCompound extra) {
|
||||
// Transform NBT in place
|
||||
@@ -50,18 +53,10 @@ public class ProxyFluidBusIO extends ProxyPart {
|
||||
// Redstone mode
|
||||
RedstoneMode redstoneMode = RedstoneMode.values()[extra.getInteger("redstoneMode")];
|
||||
switch (redstoneMode) {
|
||||
case LOW_SIGNAL:
|
||||
extra.setString("REDSTONE_CONTROLLED", "LOW_SIGNAL");
|
||||
break;
|
||||
case HIGH_SIGNAL:
|
||||
extra.setString("REDSTONE_CONTROLLED", "HIGH_SIGNAL");
|
||||
break;
|
||||
case SIGNAL_PULSE:
|
||||
extra.setString("REDSTONE_CONTROLLED", "SIGNAL_PULSE");
|
||||
break;
|
||||
default:
|
||||
extra.setString("REDSTONE_CONTROLLED", "IGNORE");
|
||||
break;
|
||||
case LOW_SIGNAL -> extra.setString("REDSTONE_CONTROLLED", "LOW_SIGNAL");
|
||||
case HIGH_SIGNAL -> extra.setString("REDSTONE_CONTROLLED", "HIGH_SIGNAL");
|
||||
case SIGNAL_PULSE -> extra.setString("REDSTONE_CONTROLLED", "SIGNAL_PULSE");
|
||||
default -> extra.setString("REDSTONE_CONTROLLED", "IGNORE");
|
||||
}
|
||||
extra.removeTag("redstoneMode");
|
||||
// Part data
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.glodblock.github.crossmod.extracells.parts;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
@@ -13,6 +15,7 @@ public class ProxyFluidInterface extends ProxyPart {
|
||||
super(item);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound transformNBT(NBTTagCompound extra) {
|
||||
// Internal fluids - ConfigInv and FluidInv
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.glodblock.github.crossmod.extracells.parts;
|
||||
|
||||
import static net.minecraftforge.common.util.Constants.NBT.TAG_COMPOUND;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
@@ -31,6 +33,7 @@ public class ProxyFluidStorage extends ProxyPart {
|
||||
super(item);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound transformNBT(NBTTagCompound extra) {
|
||||
// Transform in place, less messy IMO
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.glodblock.github.crossmod.extracells.parts;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.glodblock.github.crossmod.extracells.ProxyPart;
|
||||
@@ -13,6 +15,7 @@ public class ProxyLevelEmitter extends ProxyPart {
|
||||
super(item);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound transformNBT(NBTTagCompound extra) {
|
||||
// Fluid
|
||||
|
||||
+4
-1
@@ -1,5 +1,7 @@
|
||||
package com.glodblock.github.crossmod.extracells.parts;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.glodblock.github.crossmod.extracells.ProxyPart;
|
||||
@@ -13,9 +15,10 @@ public class ProxyOreDictExportBus extends ProxyPart {
|
||||
super(item);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound transformNBT(NBTTagCompound extra) {
|
||||
// Node tag... should've used OOP here but im too lazy to fix it now
|
||||
// TODO: Node tag... should use OOP here.
|
||||
extra.setTag("part", extra.getCompoundTag("node").getCompoundTag("node0"));
|
||||
extra.removeTag("node");
|
||||
// Ore dict card
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.glodblock.github.crossmod.extracells.parts;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
@@ -13,6 +15,7 @@ public class ProxyStorageMonitor extends ProxyPart {
|
||||
super(item);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound transformNBT(NBTTagCompound extra) {
|
||||
// Fluid
|
||||
|
||||
-1
@@ -45,7 +45,6 @@ public class ProxyFluidStorageCell extends ProxyItem implements IStorageFluidCel
|
||||
|
||||
@Override
|
||||
public boolean isBlackListed(ItemStack cellItem, IAEFluidStack requestedAddition) {
|
||||
// What even is a null fluid
|
||||
return requestedAddition == null || requestedAddition.getFluid() == null
|
||||
|| FluidCraftAPI.instance().isBlacklistedInStorage(requestedAddition.getFluid().getClass());
|
||||
}
|
||||
|
||||
+1
-2
@@ -28,8 +28,7 @@ public class ProxyVoidStorageCell extends ItemVoidStorageCell {
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int p_77663_4_, boolean p_77663_5_) {
|
||||
if (!worldIn.isRemote && entityIn instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) entityIn;
|
||||
if (!worldIn.isRemote && entityIn instanceof EntityPlayer player) {
|
||||
for (int i = 0; i < player.inventory.getSizeInventory(); ++i) {
|
||||
ItemStack s = player.inventory.getStackInSlot(i);
|
||||
if (s == stack) {
|
||||
|
||||
+1
-2
@@ -73,8 +73,7 @@ public class DriverDualFluidInterface implements SidedBlock {
|
||||
}
|
||||
Node node = node().network().node(address);
|
||||
if (!(node instanceof Component)) throw new IllegalArgumentException("no such component");
|
||||
if (!(node.host() instanceof Database)) throw new IllegalArgumentException("not a database");
|
||||
Database database = (Database) node.host();
|
||||
if (!(node.host() instanceof Database database)) throw new IllegalArgumentException("not a database");
|
||||
if (index >= 0 && index < DualityFluidInterface.NUMBER_OF_TANKS) {
|
||||
ItemStack data = database.getStackInSlot(entry - 1);
|
||||
if (data == null) {
|
||||
|
||||
+1
-2
@@ -77,9 +77,8 @@ public class DriverOCPatternEditor extends DriverSidedTileEntity {
|
||||
if (pattern == null) {
|
||||
throw new IllegalArgumentException("No pattern here!");
|
||||
}
|
||||
if (pattern.getItem() instanceof ItemEncodedPattern
|
||||
if (pattern.getItem() instanceof ItemEncodedPattern iep
|
||||
&& !(pattern.getItem() instanceof ItemFluidEncodedPattern)) {
|
||||
ItemEncodedPattern iep = (ItemEncodedPattern) pattern.getItem();
|
||||
return iep.getOutput(pattern) == null;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -40,7 +40,7 @@ public class AspectUtil {
|
||||
}
|
||||
|
||||
public static boolean isEssentiaGas(Fluid fluid) {
|
||||
return fluid != null && fluid instanceof GaseousEssentia;
|
||||
return fluid instanceof GaseousEssentia;
|
||||
}
|
||||
|
||||
public static boolean isEssentiaGas(FluidStack fluid) {
|
||||
|
||||
@@ -35,8 +35,7 @@ public class FCTooltipHandlerWaila extends TooltipHandlerWaila {
|
||||
+ EnumChatFormatting.RESET);
|
||||
}
|
||||
String modName = Util.getFluidModName(fs.getFluid());
|
||||
if (modName != null && !modName.equals(""))
|
||||
currenttip.set(currenttip.size() - 1, "\u00a79\u00a7o" + modName);
|
||||
if (modName != null && !modName.equals("")) currenttip.set(currenttip.size() - 1, "§9§o" + modName);
|
||||
}
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class PartWailaDataProvider implements IWailaDataProvider {
|
||||
ItemStack wailaStack = null;
|
||||
|
||||
for (final IPartWailaDataProvider provider : this.providers) {
|
||||
wailaStack = provider.getWailaStack(part, config, wailaStack);
|
||||
wailaStack = provider.getWailaStack(part, config, null);
|
||||
if (wailaStack != null) break;
|
||||
}
|
||||
return wailaStack;
|
||||
|
||||
Reference in new issue
Block a user