Fix stuff pointed out by the static analyzer

This commit is contained in:
raoulvdberge
2016-12-28 06:28:55 +01:00
parent 0fb148a060
commit fea1b01233
47 changed files with 150 additions and 142 deletions

View File

@@ -64,6 +64,7 @@ public final class RSUtils {
private static final NonNullList EMPTY_NON_NULL_LIST = new NonNullList<Object>(Collections.emptyList(), null) {
};
@SuppressWarnings("unchecked")
public static <T> NonNullList<T> emptyNonNullList() {
return (NonNullList<T>) EMPTY_NON_NULL_LIST;
}

View File

@@ -41,8 +41,8 @@ public interface IStackList<T> {
* @param stack the stack
* @return whether the remove was successful for the full amount
*/
default void remove(@Nonnull T stack) {
remove(stack, getSizeFromStack(stack));
default boolean remove(@Nonnull T stack) {
return remove(stack, getSizeFromStack(stack));
}
/**

View File

@@ -31,7 +31,6 @@ public class CraftingPattern implements ICraftingPattern {
private List<List<ItemStack>> oreInputs = new ArrayList<>();
private List<ItemStack> outputs = new ArrayList<>();
private List<ItemStack> byproducts = new ArrayList<>();
private boolean mekanism = false; // Cause they are special in so many ways ¯\_(ツ)_/¯
public CraftingPattern(World world, ICraftingPatternContainer container, ItemStack stack) {
this.container = container;
@@ -58,10 +57,11 @@ public class CraftingPattern implements ICraftingPattern {
recipe = CraftingManager.getInstance().getRecipeList().stream().filter(r -> r.matches(inv, world)).findFirst().orElse(null);
if (recipe != null) {
ItemStack output = recipe.getCraftingResult(inv);
if (output != null) {
if (!output.isEmpty()) {
boolean shapedOre = recipe instanceof ShapedOreRecipe;
// It is a dirty fix, but hey someone has to do it. ~ way2muchnoise 2016 "bite me"
mekanism = recipe.getClass().getName().equals("mekanism.common.recipe.ShapedMekanismRecipe");
boolean mekanism = recipe.getClass().getName().equals("mekanism.common.recipe.ShapedMekanismRecipe");
outputs.add(Comparer.stripTags(output.copy()));

View File

@@ -96,7 +96,7 @@ public class NetworkNodeDetector extends NetworkNode implements IComparable, ITy
powered = isPowered(stack == null ? null : stack.getCount());
}
} else {
powered = mode == MODE_AUTOCRAFTING ? !network.getCraftingManager().getTasks().isEmpty() : isPowered(network.getItemStorageCache().getList().getStacks().stream().map(s -> s.getCount()).mapToInt(Number::intValue).sum());
powered = mode == MODE_AUTOCRAFTING ? !network.getCraftingManager().getTasks().isEmpty() : isPowered(network.getItemStorageCache().getList().getStacks().stream().map(ItemStack::getCount).mapToInt(Number::intValue).sum());
}
} else if (type == IType.FLUIDS) {
FluidStack slot = fluidFilters.getFluidStackInSlot(0);

View File

@@ -30,6 +30,7 @@ import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemHandlerHelper;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
public class NetworkNodeDiskDrive extends NetworkNode implements IStorageGui, IStorageProvider, IComparable, IFilterable, IPrioritizable, IType, IExcessVoidable, IAccessType {
@@ -50,6 +51,7 @@ public class NetworkNodeDiskDrive extends NetworkNode implements IStorageGui, IS
}
@Override
@Nullable
public ItemStack insert(@Nonnull ItemStack stack, int size, boolean simulate) {
if (!IFilterable.canTake(itemFilters, mode, getCompare(), stack)) {
return ItemHandlerHelper.copyStackWithSize(stack, size);
@@ -97,7 +99,8 @@ public class NetworkNodeDiskDrive extends NetworkNode implements IStorageGui, IS
}
@Override
public FluidStack insert(FluidStack stack, int size, boolean simulate) {
@Nullable
public FluidStack insert(@Nonnull FluidStack stack, int size, boolean simulate) {
if (!IFilterable.canTakeFluids(fluidFilters, mode, getCompare(), stack)) {
return RSUtils.copyStackWithSize(stack, size);
}

View File

@@ -24,6 +24,7 @@ import net.minecraftforge.items.ItemHandlerHelper;
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
public class NetworkNodeDiskManipulator extends NetworkNode implements IComparable, IFilterable, IType {
@@ -162,7 +163,8 @@ public class NetworkNodeDiskManipulator extends NetworkNode implements IComparab
}
@Override
public FluidStack insert(FluidStack stack, int size, boolean simulate) {
@Nullable
public FluidStack insert(@Nonnull FluidStack stack, int size, boolean simulate) {
if (!IFilterable.canTakeFluids(fluidFilters, mode, getCompare(), stack)) {
return RSUtils.copyStackWithSize(stack, size);
}
@@ -171,7 +173,8 @@ public class NetworkNodeDiskManipulator extends NetworkNode implements IComparab
}
@Override
public FluidStack extract(FluidStack stack, int size, int flags, boolean simulate) {
@Nullable
public FluidStack extract(@Nonnull FluidStack stack, int size, int flags, boolean simulate) {
if (!IFilterable.canTakeFluids(fluidFilters, mode, getCompare(), stack)) {
return null;
}

View File

@@ -22,6 +22,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
public class NetworkNodeFluidStorage extends NetworkNode implements IStorageGui, IStorageProvider, IComparable, IFilterable, IPrioritizable, IExcessVoidable, IAccessType {
@@ -38,7 +40,8 @@ public class NetworkNodeFluidStorage extends NetworkNode implements IStorageGui,
}
@Override
public FluidStack insert(FluidStack stack, int size, boolean simulate) {
@Nullable
public FluidStack insert(@Nonnull FluidStack stack, int size, boolean simulate) {
if (!IFilterable.canTakeFluids(filters, mode, compare, stack)) {
return RSUtils.copyStackWithSize(stack, size);
}
@@ -195,7 +198,7 @@ public class NetworkNodeFluidStorage extends NetworkNode implements IStorageGui,
public EnumFluidStorageType getType() {
if (type == null && holder.world().getBlockState(holder.pos()).getBlock() == RSBlocks.FLUID_STORAGE) {
type = ((EnumFluidStorageType) holder.world().getBlockState(holder.pos()).getValue(BlockFluidStorage.TYPE));
type = (EnumFluidStorageType) holder.world().getBlockState(holder.pos()).getValue(BlockFluidStorage.TYPE);
}
return type == null ? EnumFluidStorageType.TYPE_64K : type;

View File

@@ -197,7 +197,7 @@ public class NetworkNodeStorage extends NetworkNode implements IStorageGui, ISto
public EnumItemStorageType getType() {
if (type == null && holder.world().getBlockState(holder.pos()).getBlock() == RSBlocks.STORAGE) {
type = ((EnumItemStorageType) holder.world().getBlockState(holder.pos()).getValue(BlockStorage.TYPE));
type = (EnumItemStorageType) holder.world().getBlockState(holder.pos()).getValue(BlockStorage.TYPE);
}
return type == null ? EnumItemStorageType.TYPE_1K : type;

View File

@@ -41,8 +41,8 @@ public class StorageFluidExternal implements IStorage<FluidStack> {
return getContents() == null ? RSUtils.emptyNonNullList() : NonNullList.withSize(1, getContents().copy());
}
@Nullable
@Override
@Nullable
public FluidStack insert(@Nonnull FluidStack stack, int size, boolean simulate) {
if (getProperties() != null && IFilterable.canTakeFluids(externalStorage.getFluidFilters(), externalStorage.getMode(), externalStorage.getCompare(), stack) && getProperties().canFillFluidType(stack)) {
int filled = handlerSupplier.get().fill(RSUtils.copyStackWithSize(stack, size), !simulate);
@@ -57,8 +57,8 @@ public class StorageFluidExternal implements IStorage<FluidStack> {
return RSUtils.copyStackWithSize(stack, size);
}
@Nullable
@Override
@Nullable
public FluidStack extract(@Nonnull FluidStack stack, int size, int flags, boolean simulate) {
FluidStack toDrain = RSUtils.copyStackWithSize(stack, size);

View File

@@ -49,9 +49,9 @@ public class ReaderWriterHandlerFluids implements IReaderWriterHandler {
public <T> T getCapability(IReaderWriter readerWriter, Capability<T> capability) {
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
if (readerWriter instanceof IReader) {
return (T) tankReader;
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankReader);
} else if (readerWriter instanceof IWriter) {
return (T) tankWriter;
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankWriter);
}
}

View File

@@ -51,9 +51,9 @@ public class ReaderWriterHandlerItems implements IReaderWriterHandler {
public <T> T getCapability(IReaderWriter readerWriter, Capability<T> capability) {
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
if (readerWriter instanceof IReader) {
return (T) itemsReader;
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(itemsReader);
} else if (readerWriter instanceof IWriter) {
return (T) itemsWriter;
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(itemsWriter);
}
}

View File

@@ -80,6 +80,7 @@ public abstract class StorageFluidNBT implements IStorage<FluidStack> {
}
@Override
@Nullable
public synchronized FluidStack insert(@Nonnull FluidStack stack, int size, boolean simulate) {
for (FluidStack otherStack : stacks) {
if (otherStack.isFluidEqual(stack)) {
@@ -151,6 +152,7 @@ public abstract class StorageFluidNBT implements IStorage<FluidStack> {
}
@Override
@Nullable
public synchronized FluidStack extract(@Nonnull FluidStack stack, int size, int flags, boolean simulate) {
for (FluidStack otherStack : stacks) {
if (API.instance().getComparer().isEqual(otherStack, stack, flags)) {

View File

@@ -117,6 +117,7 @@ public abstract class StorageItemNBT implements IStorage<ItemStack> {
}
@Override
@Nullable
public synchronized ItemStack insert(@Nonnull ItemStack stack, int size, boolean simulate) {
for (ItemStack otherStack : stacks) {
if (API.instance().getComparer().isEqualNoQuantity(otherStack, stack)) {
@@ -188,6 +189,7 @@ public abstract class StorageItemNBT implements IStorage<ItemStack> {
}
@Override
@Nullable
public synchronized ItemStack extract(@Nonnull ItemStack stack, int size, int flags, boolean simulate) {
for (ItemStack otherStack : stacks) {
if (API.instance().getComparer().isEqual(otherStack, stack, flags)) {

View File

@@ -18,7 +18,8 @@ public class StackListFluid implements IStackList<FluidStack> {
private List<FluidStack> removeTracker = new LinkedList<>();
@Override
public void add(FluidStack stack, int size) {
@Nullable
public void add(@Nonnull FluidStack stack, int size) {
for (FluidStack otherStack : stacks.get(stack.getFluid())) {
if (stack.isFluidEqual(otherStack)) {
otherStack.amount += size;
@@ -31,6 +32,7 @@ public class StackListFluid implements IStackList<FluidStack> {
}
@Override
@Nullable
public boolean remove(@Nonnull FluidStack stack, int size) {
for (FluidStack otherStack : stacks.get(stack.getFluid())) {
if (stack.isFluidEqual(otherStack)) {

View File

@@ -64,11 +64,11 @@ public class BlockCable extends BlockNode {
BlockStateContainer.Builder builder = super.createBlockStateBuilder();
builder.add(NORTH)
.add(EAST)
.add(SOUTH)
.add(WEST)
.add(UP)
.add(DOWN);
.add(EAST)
.add(SOUTH)
.add(WEST)
.add(UP)
.add(DOWN);
if (getPlacementType() != null) {
builder.add(DIRECTION);
@@ -81,12 +81,12 @@ public class BlockCable extends BlockNode {
@SuppressWarnings("deprecation")
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
return super.getActualState(state, world, pos)
.withProperty(NORTH, hasConnectionWith(world, pos, EnumFacing.NORTH))
.withProperty(EAST, hasConnectionWith(world, pos, EnumFacing.EAST))
.withProperty(SOUTH, hasConnectionWith(world, pos, EnumFacing.SOUTH))
.withProperty(WEST, hasConnectionWith(world, pos, EnumFacing.WEST))
.withProperty(UP, hasConnectionWith(world, pos, EnumFacing.UP))
.withProperty(DOWN, hasConnectionWith(world, pos, EnumFacing.DOWN));
.withProperty(NORTH, hasConnectionWith(world, pos, EnumFacing.NORTH))
.withProperty(EAST, hasConnectionWith(world, pos, EnumFacing.EAST))
.withProperty(SOUTH, hasConnectionWith(world, pos, EnumFacing.SOUTH))
.withProperty(WEST, hasConnectionWith(world, pos, EnumFacing.WEST))
.withProperty(UP, hasConnectionWith(world, pos, EnumFacing.UP))
.withProperty(DOWN, hasConnectionWith(world, pos, EnumFacing.DOWN));
}
private boolean hasConnectionWith(IBlockAccess world, BlockPos pos, EnumFacing direction) {
@@ -104,12 +104,12 @@ public class BlockCable extends BlockNode {
state = getActualState(state, world, pos);
return isInAABB(CORE_AABB, hitX, hitY, hitZ) ||
(state.getValue(NORTH) && isInAABB(NORTH_AABB, hitX, hitY, hitZ)) ||
(state.getValue(EAST) && isInAABB(EAST_AABB, hitX, hitY, hitZ)) ||
(state.getValue(SOUTH) && isInAABB(SOUTH_AABB, hitX, hitY, hitZ)) ||
(state.getValue(WEST) && isInAABB(WEST_AABB, hitX, hitY, hitZ)) ||
(state.getValue(UP) && isInAABB(UP_AABB, hitX, hitY, hitZ)) ||
(state.getValue(DOWN) && isInAABB(DOWN_AABB, hitX, hitY, hitZ));
(state.getValue(NORTH) && isInAABB(NORTH_AABB, hitX, hitY, hitZ)) ||
(state.getValue(EAST) && isInAABB(EAST_AABB, hitX, hitY, hitZ)) ||
(state.getValue(SOUTH) && isInAABB(SOUTH_AABB, hitX, hitY, hitZ)) ||
(state.getValue(WEST) && isInAABB(WEST_AABB, hitX, hitY, hitZ)) ||
(state.getValue(UP) && isInAABB(UP_AABB, hitX, hitY, hitZ)) ||
(state.getValue(DOWN) && isInAABB(DOWN_AABB, hitX, hitY, hitZ));
}
public List<AxisAlignedBB> getUnionizedCollisionBoxes(IBlockState state) {
@@ -202,6 +202,7 @@ public class BlockCable extends BlockNode {
return BlockRenderLayer.CUTOUT;
}
@Override
public EnumPlacementType getPlacementType() {
return null;
}

View File

@@ -44,9 +44,9 @@ public class BlockController extends BlockBase {
@Override
protected BlockStateContainer createBlockState() {
return createBlockStateBuilder()
.add(TYPE)
.add(ENERGY)
.build();
.add(TYPE)
.add(ENERGY)
.build();
}
@Override
@@ -62,7 +62,7 @@ public class BlockController extends BlockBase {
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
return super.getActualState(state, world, pos)
.withProperty(ENERGY, ((TileController) world.getTileEntity(pos)).getEnergyScaledForDisplay());
.withProperty(ENERGY, ((TileController) world.getTileEntity(pos)).getEnergyScaledForDisplay());
}
@Override

View File

@@ -27,8 +27,8 @@ public class BlockDetector extends BlockNode {
@Override
protected BlockStateContainer createBlockState() {
return createBlockStateBuilder()
.add(POWERED)
.build();
.add(POWERED)
.build();
}
@Override

View File

@@ -44,8 +44,8 @@ public class BlockFluidStorage extends BlockNode {
@Override
protected BlockStateContainer createBlockState() {
return createBlockStateBuilder()
.add(TYPE)
.build();
.add(TYPE)
.build();
}
@Override

View File

@@ -1,7 +1,6 @@
package com.raoulvdberge.refinedstorage.block;
import com.raoulvdberge.refinedstorage.RSGui;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
import com.raoulvdberge.refinedstorage.item.ItemBlockBase;
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
import net.minecraft.block.properties.PropertyEnum;
@@ -40,8 +39,8 @@ public class BlockGrid extends BlockNode {
@Override
protected BlockStateContainer createBlockState() {
return createBlockStateBuilder()
.add(TYPE)
.build();
.add(TYPE)
.build();
}
@Override

View File

@@ -1,7 +1,6 @@
package com.raoulvdberge.refinedstorage.block;
import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
import com.raoulvdberge.refinedstorage.tile.TileNode;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.BlockStateContainer;

View File

@@ -3,7 +3,6 @@ package com.raoulvdberge.refinedstorage.block;
import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.RSGui;
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeSecurityManager;
import com.raoulvdberge.refinedstorage.tile.TileSecurityManager;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;

View File

@@ -30,15 +30,15 @@ public class BlockSolderer extends BlockNode {
super.addInformation(stack, player, tooltip, advanced);
tooltip.add(I18n.format(
"block.refinedstorage:solderer.tooltip.0",
TextFormatting.WHITE + I18n.format("block.refinedstorage:controller.0.name") + TextFormatting.GRAY
"block.refinedstorage:solderer.tooltip.0",
TextFormatting.WHITE + I18n.format("block.refinedstorage:controller.0.name") + TextFormatting.GRAY
));
tooltip.add(I18n.format("block.refinedstorage:solderer.tooltip.1"));
tooltip.add(I18n.format(
"block.refinedstorage:solderer.tooltip.2",
TextFormatting.WHITE + I18n.format("block.refinedstorage:cable.name") + TextFormatting.GRAY
"block.refinedstorage:solderer.tooltip.2",
TextFormatting.WHITE + I18n.format("block.refinedstorage:cable.name") + TextFormatting.GRAY
));
}

View File

@@ -44,8 +44,8 @@ public class BlockStorage extends BlockNode {
@Override
protected BlockStateContainer createBlockState() {
return createBlockStateBuilder()
.add(TYPE)
.build();
.add(TYPE)
.build();
}
@Override

View File

@@ -6,16 +6,16 @@ import net.minecraft.util.math.BlockPos;
public enum EnumPlacementType {
ANY(
EnumFacing.VALUES
EnumFacing.VALUES
),
ANY_FACE_PLAYER(
EnumFacing.VALUES
EnumFacing.VALUES
),
HORIZONTAL(
EnumFacing.NORTH,
EnumFacing.EAST,
EnumFacing.SOUTH,
EnumFacing.WEST
EnumFacing.NORTH,
EnumFacing.EAST,
EnumFacing.SOUTH,
EnumFacing.WEST
);
final EnumFacing[] allowed;

View File

@@ -8,18 +8,18 @@ import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerGridFilter extends ContainerBase {
private ItemHandlerGridFilter filter;
private ItemStack stack;
public ContainerGridFilter(EntityPlayer player, ItemStack stack) {
super(null, player);
this.stack = stack;
this.filter = new ItemHandlerGridFilter(stack);
int y = 20;
int x = 8;
ItemHandlerGridFilter filter = new ItemHandlerGridFilter(stack);
for (int i = 0; i < 27; ++i) {
addSlotToContainer(new SlotFilter(filter, i, x, y));

View File

@@ -97,10 +97,10 @@ public class GuiCraftingMonitor extends GuiBase {
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
if (itemSelectedX != -1 &&
itemSelectedY != -1 &&
itemSelected >= 0 &&
itemSelected < getElements().size() &&
getElements().get(itemSelected).canDrawSelection()) {
itemSelectedY != -1 &&
itemSelected >= 0 &&
itemSelected < getElements().size() &&
getElements().get(itemSelected).canDrawSelection()) {
drawTexture(x + itemSelectedX, y + itemSelectedY, 0, 232, ITEM_WIDTH, ITEM_HEIGHT);
}
}

View File

@@ -1,6 +1,5 @@
package com.raoulvdberge.refinedstorage.gui;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeNetworkTransmitter;
import com.raoulvdberge.refinedstorage.container.ContainerNetworkTransmitter;
import com.raoulvdberge.refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
import com.raoulvdberge.refinedstorage.tile.TileNetworkTransmitter;

View File

@@ -65,8 +65,8 @@ public class GuiPriority extends GuiCraftingStart {
@Override
protected int[] getIncrements() {
return new int[]{
1, 5, 10,
-1, -5, -10
1, 5, 10,
-1, -5, -10
};
}

View File

@@ -75,9 +75,9 @@ public class GuiReaderWriter extends GuiBase {
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
if (itemSelectedX != -1 &&
itemSelectedY != -1 &&
itemSelected >= 0 &&
itemSelected < getChannels().size()) {
itemSelectedY != -1 &&
itemSelected >= 0 &&
itemSelected < getChannels().size()) {
drawTexture(x + itemSelectedX, y + itemSelectedY, 0, 216, ITEM_WIDTH, ITEM_HEIGHT);
}

View File

@@ -84,8 +84,8 @@ public class GuiStorage extends GuiBase {
public void drawForeground(int mouseX, int mouseY) {
drawString(7, 7, t(gui.getGuiTitle()));
drawString(7, 42, gui.getCapacity() == -1 ?
t("misc.refinedstorage:storage.stored_minimal", RSUtils.formatQuantity(gui.getStored())) :
t("misc.refinedstorage:storage.stored_capacity_minimal", RSUtils.formatQuantity(gui.getStored()), RSUtils.formatQuantity(gui.getCapacity()))
t("misc.refinedstorage:storage.stored_minimal", RSUtils.formatQuantity(gui.getStored())) :
t("misc.refinedstorage:storage.stored_capacity_minimal", RSUtils.formatQuantity(gui.getStored()), RSUtils.formatQuantity(gui.getCapacity()))
);
if (texture.contains("disk_drive")) { // HACK!
@@ -102,8 +102,8 @@ public class GuiStorage extends GuiBase {
}
drawTooltip(mouseX, mouseY, (gui.getCapacity() == -1 ?
t("misc.refinedstorage:storage.stored_minimal", gui.getStored()) :
t("misc.refinedstorage:storage.stored_capacity_minimal", gui.getStored(), gui.getCapacity())
t("misc.refinedstorage:storage.stored_minimal", gui.getStored()) :
t("misc.refinedstorage:storage.stored_capacity_minimal", gui.getStored(), gui.getCapacity())
) + "\n" + t("misc.refinedstorage:storage.full", full));
}
}

View File

@@ -186,10 +186,10 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
SORTING_NAME.setSortingDirection(grid.getSortingDirection());
SORTING_QUANTITY.setSortingDirection(grid.getSortingDirection());
Collections.sort(stacks, SORTING_NAME);
stacks.sort(SORTING_NAME);
if (grid.getSortingType() == NetworkNodeGrid.SORTING_TYPE_QUANTITY) {
Collections.sort(stacks, SORTING_QUANTITY);
stacks.sort(SORTING_QUANTITY);
}
}

View File

@@ -50,9 +50,9 @@ public class ReaderWriterHandlerForgeEnergy implements IReaderWriterHandler {
public <T> T getCapability(IReaderWriter readerWriter, Capability<T> capability) {
if (capability == CapabilityEnergy.ENERGY) {
if (readerWriter instanceof IReader) {
return (T) storageReader;
return CapabilityEnergy.ENERGY.cast(storageReader);
} else if (readerWriter instanceof IWriter) {
return (T) storageWriter;
return CapabilityEnergy.ENERGY.cast(storageWriter);
}
}

View File

@@ -59,11 +59,11 @@ public class ReaderWriterHandlerTesla implements IReaderWriterHandler {
public <T> T getCapability(IReaderWriter readerWriter, Capability<T> capability) {
if (readerWriter instanceof IReader || readerWriter instanceof IWriter) {
if (capability == TeslaCapabilities.CAPABILITY_HOLDER) {
return (T) container;
return TeslaCapabilities.CAPABILITY_HOLDER.cast(container);
} else if (capability == TeslaCapabilities.CAPABILITY_CONSUMER && readerWriter instanceof IReader) {
return (T) containerReader;
return TeslaCapabilities.CAPABILITY_CONSUMER.cast(containerReader);
} else if (capability == TeslaCapabilities.CAPABILITY_PRODUCER && readerWriter instanceof IWriter) {
return (T) containerWriter;
return TeslaCapabilities.CAPABILITY_PRODUCER.cast(containerWriter);
}
}

View File

@@ -202,10 +202,10 @@ public abstract class ItemNetworkItem extends ItemBase implements INetworkItemPr
public boolean isValid(ItemStack stack) {
return stack.hasTagCompound()
&& stack.getTagCompound().hasKey(NBT_CONTROLLER_X)
&& stack.getTagCompound().hasKey(NBT_CONTROLLER_Y)
&& stack.getTagCompound().hasKey(NBT_CONTROLLER_Z)
&& stack.getTagCompound().hasKey(NBT_DIMENSION_ID);
&& stack.getTagCompound().hasKey(NBT_CONTROLLER_X)
&& stack.getTagCompound().hasKey(NBT_CONTROLLER_Y)
&& stack.getTagCompound().hasKey(NBT_CONTROLLER_Z)
&& stack.getTagCompound().hasKey(NBT_DIMENSION_ID);
}
private class NetworkItemCapabilityProvider implements ICapabilityProvider {
@@ -218,7 +218,7 @@ public abstract class ItemNetworkItem extends ItemBase implements INetworkItemPr
@Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) {
return capability == CapabilityEnergy.ENERGY ||
(IntegrationTesla.isLoaded() && (capability == TeslaCapabilities.CAPABILITY_HOLDER || capability == TeslaCapabilities.CAPABILITY_CONSUMER));
(IntegrationTesla.isLoaded() && (capability == TeslaCapabilities.CAPABILITY_HOLDER || capability == TeslaCapabilities.CAPABILITY_CONSUMER));
}
@Override

View File

@@ -139,8 +139,8 @@ public class ItemWrench extends ItemBase {
next.writeToNBT(stack.getTagCompound());
player.sendMessage(new TextComponentTranslation(
"item.refinedstorage:wrench.mode",
new TextComponentTranslation("item.refinedstorage:wrench.mode." + next.id).setStyle(new Style().setColor(TextFormatting.YELLOW))
"item.refinedstorage:wrench.mode",
new TextComponentTranslation("item.refinedstorage:wrench.mode." + next.id).setStyle(new Style().setColor(TextFormatting.YELLOW))
));
}

View File

@@ -14,6 +14,7 @@ import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class MessageGridItemUpdate implements IMessage, IMessageHandler<MessageGridItemUpdate, IMessage> {
private INetworkMaster network;
@@ -46,7 +47,7 @@ public class MessageGridItemUpdate implements IMessage, IMessageHandler<MessageG
int size = network.getItemStorageCache().getList().getStacks().size();
for (ICraftingPattern pattern : network.getCraftingManager().getPatterns()) {
size += pattern.getOutputs().stream().filter(o -> o != null).count();
size += pattern.getOutputs().stream().filter(Objects::nonNull).count();
}
buf.writeInt(size);

View File

@@ -1,5 +1,7 @@
package com.raoulvdberge.refinedstorage.proxy;
import javax.annotation.Nonnull;
import com.google.common.base.Preconditions;
import com.raoulvdberge.refinedstorage.api.network.INetworkNode;
import com.raoulvdberge.refinedstorage.api.network.INetworkNodeProxy;
@@ -10,8 +12,6 @@ import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityInject;
import net.minecraftforge.common.capabilities.CapabilityManager;
import javax.annotation.Nonnull;
public class CapabilityNetworkNodeProxy {
@CapabilityInject(INetworkNodeProxy.class)
public static Capability<INetworkNodeProxy> NETWORK_NODE_PROXY_CAPABILITY = null;

View File

@@ -55,58 +55,58 @@ public class ProxyClient extends ProxyCommon {
// Item Variants
ModelBakery.registerItemVariants(RSItems.STORAGE_DISK,
new ResourceLocation("refinedstorage:1k_storage_disk"),
new ResourceLocation("refinedstorage:4k_storage_disk"),
new ResourceLocation("refinedstorage:16k_storage_disk"),
new ResourceLocation("refinedstorage:64k_storage_disk"),
new ResourceLocation("refinedstorage:creative_storage_disk")
new ResourceLocation("refinedstorage:1k_storage_disk"),
new ResourceLocation("refinedstorage:4k_storage_disk"),
new ResourceLocation("refinedstorage:16k_storage_disk"),
new ResourceLocation("refinedstorage:64k_storage_disk"),
new ResourceLocation("refinedstorage:creative_storage_disk")
);
ModelBakery.registerItemVariants(RSItems.STORAGE_PART,
new ResourceLocation("refinedstorage:1k_storage_part"),
new ResourceLocation("refinedstorage:4k_storage_part"),
new ResourceLocation("refinedstorage:16k_storage_part"),
new ResourceLocation("refinedstorage:64k_storage_part")
new ResourceLocation("refinedstorage:1k_storage_part"),
new ResourceLocation("refinedstorage:4k_storage_part"),
new ResourceLocation("refinedstorage:16k_storage_part"),
new ResourceLocation("refinedstorage:64k_storage_part")
);
ModelBakery.registerItemVariants(RSItems.FLUID_STORAGE_DISK,
new ResourceLocation("refinedstorage:64k_fluid_storage_disk"),
new ResourceLocation("refinedstorage:128k_fluid_storage_disk"),
new ResourceLocation("refinedstorage:256k_fluid_storage_disk"),
new ResourceLocation("refinedstorage:512k_fluid_storage_disk"),
new ResourceLocation("refinedstorage:creative_fluid_storage_disk")
new ResourceLocation("refinedstorage:64k_fluid_storage_disk"),
new ResourceLocation("refinedstorage:128k_fluid_storage_disk"),
new ResourceLocation("refinedstorage:256k_fluid_storage_disk"),
new ResourceLocation("refinedstorage:512k_fluid_storage_disk"),
new ResourceLocation("refinedstorage:creative_fluid_storage_disk")
);
ModelBakery.registerItemVariants(RSItems.FLUID_STORAGE_PART,
new ResourceLocation("refinedstorage:64k_fluid_storage_part"),
new ResourceLocation("refinedstorage:128k_fluid_storage_part"),
new ResourceLocation("refinedstorage:256k_fluid_storage_part"),
new ResourceLocation("refinedstorage:512k_fluid_storage_part")
new ResourceLocation("refinedstorage:64k_fluid_storage_part"),
new ResourceLocation("refinedstorage:128k_fluid_storage_part"),
new ResourceLocation("refinedstorage:256k_fluid_storage_part"),
new ResourceLocation("refinedstorage:512k_fluid_storage_part")
);
ModelBakery.registerItemVariants(RSItems.PROCESSOR,
new ResourceLocation("refinedstorage:basic_printed_processor"),
new ResourceLocation("refinedstorage:improved_printed_processor"),
new ResourceLocation("refinedstorage:advanced_printed_processor"),
new ResourceLocation("refinedstorage:basic_processor"),
new ResourceLocation("refinedstorage:improved_processor"),
new ResourceLocation("refinedstorage:advanced_processor"),
new ResourceLocation("refinedstorage:printed_silicon")
new ResourceLocation("refinedstorage:basic_printed_processor"),
new ResourceLocation("refinedstorage:improved_printed_processor"),
new ResourceLocation("refinedstorage:advanced_printed_processor"),
new ResourceLocation("refinedstorage:basic_processor"),
new ResourceLocation("refinedstorage:improved_processor"),
new ResourceLocation("refinedstorage:advanced_processor"),
new ResourceLocation("refinedstorage:printed_silicon")
);
ModelBakery.registerItemVariants(RSItems.CORE,
new ResourceLocation("refinedstorage:construction_core"),
new ResourceLocation("refinedstorage:destruction_core")
new ResourceLocation("refinedstorage:construction_core"),
new ResourceLocation("refinedstorage:destruction_core")
);
ModelBakery.registerItemVariants(RSItems.UPGRADE,
new ResourceLocation("refinedstorage:upgrade"),
new ResourceLocation("refinedstorage:range_upgrade"),
new ResourceLocation("refinedstorage:speed_upgrade"),
new ResourceLocation("refinedstorage:stack_upgrade"),
new ResourceLocation("refinedstorage:interdimensional_upgrade"),
new ResourceLocation("refinedstorage:silk_touch_upgrade"),
new ResourceLocation("refinedstorage:fortune_upgrade")
new ResourceLocation("refinedstorage:upgrade"),
new ResourceLocation("refinedstorage:range_upgrade"),
new ResourceLocation("refinedstorage:speed_upgrade"),
new ResourceLocation("refinedstorage:stack_upgrade"),
new ResourceLocation("refinedstorage:interdimensional_upgrade"),
new ResourceLocation("refinedstorage:silk_touch_upgrade"),
new ResourceLocation("refinedstorage:fortune_upgrade")
);
// Items

View File

@@ -1,6 +1,5 @@
package com.raoulvdberge.refinedstorage.tile;
import com.raoulvdberge.refinedstorage.api.network.INetworkNode;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeConstructor;
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
import com.raoulvdberge.refinedstorage.tile.config.IType;

View File

@@ -121,7 +121,7 @@ public class TileController extends TileBase implements INetworkMaster, IRedston
}
}
Collections.sort(nodes, CLIENT_NODE_COMPARATOR);
nodes.sort(CLIENT_NODE_COMPARATOR);
return nodes;
}
@@ -221,8 +221,8 @@ public class TileController extends TileBase implements INetworkMaster, IRedston
public void update() {
if (!getWorld().isRemote) {
if (canRun()) {
Collections.sort(itemStorage.getStorages(), STORAGE_COMPARATOR);
Collections.sort(fluidStorage.getStorages(), STORAGE_COMPARATOR);
itemStorage.getStorages().sort(STORAGE_COMPARATOR);
fluidStorage.getStorages().sort(STORAGE_COMPARATOR);
craftingManager.update();

View File

@@ -56,7 +56,7 @@ public class TileExporter extends TileNode<NetworkNodeExporter> {
}
});
public static final TileDataParameter<Boolean> CRAFT_ONLY = new TileDataParameter<Boolean>(DataSerializers.BOOLEAN, false, new ITileDataProducer<Boolean, TileExporter>() {
public static final TileDataParameter<Boolean> CRAFT_ONLY = new TileDataParameter<>(DataSerializers.BOOLEAN, false, new ITileDataProducer<Boolean, TileExporter>() {
@Override
public Boolean getValue(TileExporter tile) {
return tile.getNode().isCraftOnly();

View File

@@ -1,6 +1,5 @@
package com.raoulvdberge.refinedstorage.tile;
import com.raoulvdberge.refinedstorage.api.network.INetworkNode;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeInterface;
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;

View File

@@ -1,6 +1,5 @@
package com.raoulvdberge.refinedstorage.tile;
import com.raoulvdberge.refinedstorage.api.network.INetworkNode;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeNetworkTransmitter;
import com.raoulvdberge.refinedstorage.tile.data.ITileDataProducer;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;

View File

@@ -20,7 +20,7 @@ import net.minecraftforge.items.IItemHandler;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public abstract class TileNode<T extends NetworkNode> extends TileBase implements INetworkNodeProxy<T>, INetworkNodeHolder, IRedstoneConfigurable {
public abstract class TileNode<N extends NetworkNode> extends TileBase implements INetworkNodeProxy<N>, INetworkNodeHolder, IRedstoneConfigurable {
public static final TileDataParameter<Integer> REDSTONE_MODE = RedstoneMode.createParameter();
private NBTTagCompound legacyTagToRead;
@@ -121,7 +121,7 @@ public abstract class TileNode<T extends NetworkNode> extends TileBase implement
@Override
@Nonnull
@SuppressWarnings("unchecked")
public T getNode() {
public N getNode() {
INetworkNodeProvider provider = API.instance().getNetworkNodeProvider(getWorld().provider.getDimension());
INetworkNode node = provider.getNode(pos);
@@ -130,10 +130,10 @@ public abstract class TileNode<T extends NetworkNode> extends TileBase implement
provider.setNode(pos, node = createNode());
}
return (T) node;
return (N) node;
}
public abstract T createNode();
public abstract N createNode();
@Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing side) {

View File

@@ -1,6 +1,5 @@
package com.raoulvdberge.refinedstorage.tile;
import com.raoulvdberge.refinedstorage.api.network.INetworkNode;
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeStorage;
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageItemNBT;

View File

@@ -1,6 +1,5 @@
package com.raoulvdberge.refinedstorage.tile;
import com.raoulvdberge.refinedstorage.api.network.INetworkNode;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeWirelessTransmitter;
import com.raoulvdberge.refinedstorage.tile.data.ITileDataProducer;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;

View File

@@ -1,6 +1,5 @@
package com.raoulvdberge.refinedstorage.tile;
import com.raoulvdberge.refinedstorage.api.network.INetworkNode;
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterChannel;
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterHandler;
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IWriter;