This commit is contained in:
raoulvdberge
2017-05-13 16:31:20 +02:00
parent 1428350c67
commit 6c73338fac
37 changed files with 90 additions and 94 deletions

View File

@@ -189,10 +189,10 @@ public class CraftingManager implements ICraftingManager {
} }
runningSteps = craftingTasks.stream() runningSteps = craftingTasks.stream()
.map(ICraftingTask::getSteps) .map(ICraftingTask::getSteps)
.flatMap(List::stream) .flatMap(List::stream)
.filter(ICraftingStep::hasStartedProcessing) .filter(ICraftingStep::hasStartedProcessing)
.collect(Collectors.toList()); .collect(Collectors.toList());
if (craftingTasksChanged) { if (craftingTasksChanged) {
network.getNetwork().markCraftingMonitorForUpdate(); network.getNetwork().markCraftingMonitorForUpdate();

View File

@@ -111,16 +111,16 @@ public class CraftingPattern implements ICraftingPattern {
oreInputs.add(Collections.singletonList(Comparer.stripTags(input))); oreInputs.add(Collections.singletonList(Comparer.stripTags(input)));
} else if (isOredict()) { } else if (isOredict()) {
List<ItemStack> oredict = Arrays.stream(ids) List<ItemStack> oredict = Arrays.stream(ids)
.mapToObj(OreDictionary::getOreName) .mapToObj(OreDictionary::getOreName)
.map(OreDictionary::getOres) .map(OreDictionary::getOres)
.flatMap(List::stream) .flatMap(List::stream)
.map(ItemStack::copy) .map(ItemStack::copy)
.map(Comparer::stripTags) .map(Comparer::stripTags)
.map(s -> { .map(s -> {
s.setCount(input.getCount()); s.setCount(input.getCount());
return s; return s;
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
// Add original stack as first, should prevent some issues // Add original stack as first, should prevent some issues
oredict.add(0, Comparer.stripTags(input.copy())); oredict.add(0, Comparer.stripTags(input.copy()));
oreInputs.add(oredict); oreInputs.add(oredict);
@@ -286,13 +286,13 @@ public class CraftingPattern implements ICraftingPattern {
} }
if (other.getId().equals(this.getId()) if (other.getId().equals(this.getId())
&& other.isOredict() == this.isOredict() && other.isOredict() == this.isOredict()
&& other.isBlocking() == this.isBlocking() && other.isBlocking() == this.isBlocking()
&& other.isProcessing() == this.isProcessing() && other.isProcessing() == this.isProcessing()
&& other.getOreInputs().size() == this.getOreInputs().size() && other.getOreInputs().size() == this.getOreInputs().size()
&& other.getOutputs().size() == this.getOutputs().size()) { && other.getOutputs().size() == this.getOutputs().size()) {
boolean same = true; boolean same = true;
for (int i = 0; i < other.getOreInputs().size(); i++) { for (int i = 0; i < other.getOreInputs().size(); i++) {
same &= other.getOreInputs().get(i).size() == this.getOreInputs().get(i).size(); same &= other.getOreInputs().get(i).size() == this.getOreInputs().get(i).size();
} }
int j = 0; int j = 0;

View File

@@ -5,7 +5,6 @@ import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPatternContainer; import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPatternContainer;
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPatternProvider; import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPatternProvider;
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingStep; import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingStep;
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTask;
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster; import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy; import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy;
import com.raoulvdberge.refinedstorage.api.util.IComparer; import com.raoulvdberge.refinedstorage.api.util.IComparer;

View File

@@ -166,6 +166,7 @@ public abstract class NetworkNode implements INetworkNode, INetworkNeighborhoodA
return holder.world().getTileEntity(holder.pos().offset(holder.getDirection())); return holder.world().getTileEntity(holder.pos().offset(holder.getDirection()));
} }
@Nullable
public IItemHandler getDrops() { public IItemHandler getDrops() {
return null; return null;
} }

View File

@@ -162,15 +162,15 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
if (item.getItem() instanceof ItemBlock) { if (item.getItem() instanceof ItemBlock) {
((ItemBlock) item.getItem()).placeBlockAt( ((ItemBlock) item.getItem()).placeBlockAt(
took, took,
FakePlayerFactory.getMinecraft((WorldServer) holder.world()), FakePlayerFactory.getMinecraft((WorldServer) holder.world()),
holder.world(), holder.world(),
front, front,
holder.getDirection(), holder.getDirection(),
0, 0,
0, 0,
0, 0,
state state
); );
} else { } else {
holder.world().setBlockState(front, state, 1 | 2); holder.world().setBlockState(front, state, 1 | 2);

View File

@@ -112,8 +112,8 @@ public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternC
if (!state) { if (!state) {
network.getCraftingManager().getTasks().stream() network.getCraftingManager().getTasks().stream()
.filter(task -> task.getPattern().getContainer().getPosition().equals(holder.pos())) .filter(task -> task.getPattern().getContainer().getPosition().equals(holder.pos()))
.forEach(task -> network.getCraftingManager().cancel(task)); .forEach(task -> network.getCraftingManager().cancel(task));
} }
network.getCraftingManager().rebuild(); network.getCraftingManager().rebuild();

View File

@@ -52,7 +52,7 @@ public class NetworkNodeImporter extends NetworkNode implements IComparable, IFi
if (network == null || !canUpdate()) { if (network == null || !canUpdate()) {
return; return;
} }
if (type == IType.ITEMS) { if (type == IType.ITEMS) {
IImportingBehavior behavior = ImportingBehaviorItemHandler.INSTANCE; IImportingBehavior behavior = ImportingBehaviorItemHandler.INSTANCE;
if (IntegrationCyclopsCore.isLoaded() && SlotlessItemHandlerHelper.isSlotless(getFacingTile(), holder.getDirection().getOpposite())) { if (IntegrationCyclopsCore.isLoaded() && SlotlessItemHandlerHelper.isSlotless(getFacingTile(), holder.getDirection().getOpposite())) {

View File

@@ -86,8 +86,8 @@ public class NetworkNodeNetworkTransmitter extends NetworkNode {
@Override @Override
public int getEnergyUsage() { public int getEnergyUsage() {
return Math.min( return Math.min(
RS.INSTANCE.config.interdimensionalUpgradeUsage, RS.INSTANCE.config.interdimensionalUpgradeUsage,
RS.INSTANCE.config.networkTransmitterUsage + (isSameDimension() ? (int) Math.ceil(RS.INSTANCE.config.networkTransmitterPerBlockUsage * getDistance()) : 0) + upgrades.getEnergyUsage() RS.INSTANCE.config.networkTransmitterUsage + (isSameDimension() ? (int) Math.ceil(RS.INSTANCE.config.networkTransmitterPerBlockUsage * getDistance()) : 0) + upgrades.getEnergyUsage()
); );
} }

View File

@@ -58,7 +58,7 @@ public class StorageItemCyclops extends StorageItemExternal {
@Override @Override
public int getStored() { public int getStored() {
return getStacks(cyclopsInv.get()).stream().mapToInt(s -> s.getCount()).sum(); return getStacks(cyclopsInv.get()).stream().mapToInt(ItemStack::getCount).sum();
} }
@Override @Override

View File

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

View File

@@ -1,6 +1,5 @@
package com.raoulvdberge.refinedstorage.container; package com.raoulvdberge.refinedstorage.container;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeDestructor;
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterType; import com.raoulvdberge.refinedstorage.container.slot.SlotFilterType;
import com.raoulvdberge.refinedstorage.tile.TileDestructor; import com.raoulvdberge.refinedstorage.tile.TileDestructor;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;

View File

@@ -1,6 +1,5 @@
package com.raoulvdberge.refinedstorage.container; package com.raoulvdberge.refinedstorage.container;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeFluidInterface;
import com.raoulvdberge.refinedstorage.container.slot.SlotFilterFluid; import com.raoulvdberge.refinedstorage.container.slot.SlotFilterFluid;
import com.raoulvdberge.refinedstorage.tile.TileFluidInterface; import com.raoulvdberge.refinedstorage.tile.TileFluidInterface;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;

View File

@@ -85,7 +85,7 @@ public class ContainerGrid extends ContainerBase {
} }
} }
addSlotToContainer(craftingResultSlot = new SlotGridCraftingResult(this, getPlayer(), (NetworkNodeGrid) grid, 0, 130 + 4, headerAndSlots + 22)); addSlotToContainer(craftingResultSlot = new SlotGridCraftingResult(this, getPlayer(), grid, 0, 130 + 4, headerAndSlots + 22));
} else if (grid.getType() == GridType.PATTERN) { } else if (grid.getType() == GridType.PATTERN) {
int x = 8; int x = 8;
int y = headerAndSlots + 4; int y = headerAndSlots + 4;

View File

@@ -1,6 +1,5 @@
package com.raoulvdberge.refinedstorage.container; package com.raoulvdberge.refinedstorage.container;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeInterface;
import com.raoulvdberge.refinedstorage.container.slot.SlotFilter; import com.raoulvdberge.refinedstorage.container.slot.SlotFilter;
import com.raoulvdberge.refinedstorage.container.slot.SlotOutput; import com.raoulvdberge.refinedstorage.container.slot.SlotOutput;
import com.raoulvdberge.refinedstorage.tile.TileInterface; import com.raoulvdberge.refinedstorage.tile.TileInterface;

View File

@@ -1,6 +1,5 @@
package com.raoulvdberge.refinedstorage.container; package com.raoulvdberge.refinedstorage.container;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeWirelessTransmitter;
import com.raoulvdberge.refinedstorage.tile.TileWirelessTransmitter; import com.raoulvdberge.refinedstorage.tile.TileWirelessTransmitter;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;

View File

@@ -1,6 +1,5 @@
package com.raoulvdberge.refinedstorage.container.slot; package com.raoulvdberge.refinedstorage.container.slot;
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode; import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
import com.raoulvdberge.refinedstorage.tile.config.IType; import com.raoulvdberge.refinedstorage.tile.config.IType;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;

View File

@@ -37,8 +37,8 @@ public final class IntegrationCraftingTweaks {
public static class GetGridStartFunction implements Function<ContainerGrid, Integer> { public static class GetGridStartFunction implements Function<ContainerGrid, Integer> {
@Override @Override
public Integer apply(ContainerGrid containerGrid) { public Integer apply(ContainerGrid containerGrid) {
for(int i = 0; i < containerGrid.inventorySlots.size(); i++) { for (int i = 0; i < containerGrid.inventorySlots.size(); i++) {
if(containerGrid.inventorySlots.get(i) instanceof SlotGridCrafting) { if (containerGrid.inventorySlots.get(i) instanceof SlotGridCrafting) {
return i; return i;
} }
} }

View File

@@ -152,7 +152,7 @@ public class EnvironmentNetwork extends AbstractManagedEnvironment {
// First argument: the fluid stack to extract // First argument: the fluid stack to extract
// There is no args.checkFluidStack(), we have to deal with this ourselves // There is no args.checkFluidStack(), we have to deal with this ourselves
Map<String, Object> fluidMap = args.checkTable(0); Map<String, Object> fluidMap = args.checkTable(0);
if(!fluidMap.containsKey("name") || !(fluidMap.get("name") instanceof String) || ((String) fluidMap.get("name")).length() == 0) { if (!fluidMap.containsKey("name") || !(fluidMap.get("name") instanceof String) || ((String) fluidMap.get("name")).length() == 0) {
throw new IllegalArgumentException("no fluid name"); throw new IllegalArgumentException("no fluid name");
} }
String fluid = (String) fluidMap.get("name"); String fluid = (String) fluidMap.get("name");
@@ -162,7 +162,7 @@ public class EnvironmentNetwork extends AbstractManagedEnvironment {
// With the amount ready, we can actually try to create a fluid stack for the given fluid // With the amount ready, we can actually try to create a fluid stack for the given fluid
FluidStack stack = FluidRegistry.getFluidStack(fluid, amount); FluidStack stack = FluidRegistry.getFluidStack(fluid, amount);
if(stack == null) { if (stack == null) {
throw new IllegalArgumentException("invalid fluid stack, does not exist"); throw new IllegalArgumentException("invalid fluid stack, does not exist");
} }
@@ -171,19 +171,19 @@ public class EnvironmentNetwork extends AbstractManagedEnvironment {
// Get the tile-entity on the specified side // Get the tile-entity on the specified side
TileEntity targetEntity = node.getNetwork().getNetworkWorld().getTileEntity(node.getPos().offset(facing)); TileEntity targetEntity = node.getNetwork().getNetworkWorld().getTileEntity(node.getPos().offset(facing));
if(targetEntity == null || !targetEntity.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing.getOpposite())) { if (targetEntity == null || !targetEntity.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing.getOpposite())) {
throw new IllegalArgumentException("No fluid tank on the given side"); throw new IllegalArgumentException("No fluid tank on the given side");
} }
FluidStack extractedSim = node.getNetwork().extractFluid(stack, amount, true); FluidStack extractedSim = node.getNetwork().extractFluid(stack, amount, true);
if(extractedSim == null || extractedSim.amount <= 0) { if (extractedSim == null || extractedSim.amount <= 0) {
return new Object[]{null, "could not extract the specified fluid"}; return new Object[]{null, "could not extract the specified fluid"};
} }
// Simulate inserting the fluid and see how much we were able to insert // Simulate inserting the fluid and see how much we were able to insert
IFluidHandler handler = targetEntity.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing.getOpposite()); IFluidHandler handler = targetEntity.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing.getOpposite());
int filledAmountSim = handler.fill(extractedSim, false); int filledAmountSim = handler.fill(extractedSim, false);
if(filledAmountSim <= 0) { if (filledAmountSim <= 0) {
return new Object[]{0}; return new Object[]{0};
} }
@@ -191,7 +191,7 @@ public class EnvironmentNetwork extends AbstractManagedEnvironment {
FluidStack extracted = node.getNetwork().extractFluid(stack, amount, false); FluidStack extracted = node.getNetwork().extractFluid(stack, amount, false);
handler.fill(extracted, true); handler.fill(extracted, true);
return new Object[] { filledAmountSim }; return new Object[]{filledAmountSim};
} }
@Callback(doc = "function(stack:table):table -- Gets a fluid from the network.") @Callback(doc = "function(stack:table):table -- Gets a fluid from the network.")
@@ -202,18 +202,18 @@ public class EnvironmentNetwork extends AbstractManagedEnvironment {
// There is no args.checkFluidStack(), we have to deal with this ourselves // There is no args.checkFluidStack(), we have to deal with this ourselves
Map<String, Object> fluidMap = args.checkTable(0); Map<String, Object> fluidMap = args.checkTable(0);
if(!fluidMap.containsKey("name") || !(fluidMap.get("name") instanceof String) || ((String) fluidMap.get("name")).length() == 0) { if (!fluidMap.containsKey("name") || !(fluidMap.get("name") instanceof String) || ((String) fluidMap.get("name")).length() == 0) {
throw new IllegalArgumentException("no fluid name"); throw new IllegalArgumentException("no fluid name");
} }
String fluid = (String) fluidMap.get("name"); String fluid = (String) fluidMap.get("name");
FluidStack needle = FluidRegistry.getFluidStack(fluid, 1000); FluidStack needle = FluidRegistry.getFluidStack(fluid, 1000);
if(needle == null) { if (needle == null) {
throw new IllegalArgumentException("invalid fluid stack, does not exist"); throw new IllegalArgumentException("invalid fluid stack, does not exist");
} }
return new Object[]{ node.getNetwork().getFluidStorageCache().getList().get(needle) }; return new Object[]{node.getNetwork().getFluidStorageCache().getList().get(needle)};
} }
@Callback(doc = "function():table -- Gets a list of all fluids in this network.") @Callback(doc = "function():table -- Gets a list of all fluids in this network.")
@@ -245,7 +245,7 @@ public class EnvironmentNetwork extends AbstractManagedEnvironment {
// Get the tile-entity on the specified side // Get the tile-entity on the specified side
TileEntity targetEntity = node.getNetwork().getNetworkWorld().getTileEntity(node.getPos().offset(facing)); TileEntity targetEntity = node.getNetwork().getNetworkWorld().getTileEntity(node.getPos().offset(facing));
if(targetEntity == null || !targetEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite())) { if (targetEntity == null || !targetEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite())) {
throw new IllegalArgumentException("No inventory on the given side"); throw new IllegalArgumentException("No inventory on the given side");
} }
@@ -273,7 +273,7 @@ public class EnvironmentNetwork extends AbstractManagedEnvironment {
ItemStack extracted = node.getNetwork().extractItem(stack, count, false); ItemStack extracted = node.getNetwork().extractItem(stack, count, false);
ItemHandlerHelper.insertItemStacked(handler, extracted, false); ItemHandlerHelper.insertItemStacked(handler, extracted, false);
return new Object[] { transferableAmount }; return new Object[]{transferableAmount};
} }
@Callback(doc = "function(stack:table[, compareMeta:boolean[, compareNBT:boolean[, compareOreDict:boolean]]]):table -- Gets an item from the network.") @Callback(doc = "function(stack:table[, compareMeta:boolean[, compareNBT:boolean[, compareOreDict:boolean]]]):table -- Gets an item from the network.")

View File

@@ -10,6 +10,7 @@ import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.energy.CapabilityEnergy;
import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public class CapabilityProviderEnergy implements ICapabilityProvider { public class CapabilityProviderEnergy implements ICapabilityProvider {
@@ -20,13 +21,13 @@ public class CapabilityProviderEnergy implements ICapabilityProvider {
} }
@Override @Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) { public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
return capability == CapabilityEnergy.ENERGY || 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 @Override
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) { public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
if (capability == CapabilityEnergy.ENERGY) { if (capability == CapabilityEnergy.ENERGY) {
return CapabilityEnergy.ENERGY.cast(new ItemEnergyForge(stack, ItemEnergyItem.CAPACITY)); return CapabilityEnergy.ENERGY.cast(new ItemEnergyForge(stack, ItemEnergyItem.CAPACITY));
} }

View File

@@ -1,4 +1,3 @@
package com.raoulvdberge.refinedstorage.network; package com.raoulvdberge.refinedstorage.network;
import com.raoulvdberge.refinedstorage.proxy.ProxyClient; import com.raoulvdberge.refinedstorage.proxy.ProxyClient;

View File

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

View File

@@ -1,11 +1,10 @@
package com.raoulvdberge.refinedstorage.render; package com.raoulvdberge.refinedstorage.render;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import net.minecraftforge.common.property.IUnlistedProperty; import net.minecraftforge.common.property.IUnlistedProperty;
import java.util.Objects; import java.util.Objects;
import java.util.function.Function;
import java.util.function.Predicate;
public class PropertyObject<T> implements IUnlistedProperty<T> { public class PropertyObject<T> implements IUnlistedProperty<T> {
private final String name; private final String name;
@@ -21,7 +20,7 @@ public class PropertyObject<T> implements IUnlistedProperty<T> {
} }
public PropertyObject(String name, Class<T> clazz) { public PropertyObject(String name, Class<T> clazz) {
this(name, clazz, Predicates.alwaysTrue(), input -> Objects.toString(input)); this(name, clazz, v -> true, Objects::toString);
} }
@Override @Override
@@ -31,7 +30,7 @@ public class PropertyObject<T> implements IUnlistedProperty<T> {
@Override @Override
public boolean isValid(T value) { public boolean isValid(T value) {
return validator.apply(value); return validator.test(value);
} }
@Override @Override

View File

@@ -107,6 +107,7 @@ public abstract class TileBase extends TileEntity {
return oldState.getBlock() != newState.getBlock(); return oldState.getBlock() != newState.getBlock();
} }
@Nullable
public IItemHandler getDrops() { public IItemHandler getDrops() {
return null; return null;
} }

View File

@@ -741,7 +741,7 @@ public class TileController extends TileBase implements ITickable, INetworkMaste
} }
@Override @Override
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) { public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
if (capability == CapabilityEnergy.ENERGY) { if (capability == CapabilityEnergy.ENERGY) {
return CapabilityEnergy.ENERGY.cast(energy); return CapabilityEnergy.ENERGY.cast(energy);
} }
@@ -763,7 +763,7 @@ public class TileController extends TileBase implements ITickable, INetworkMaste
} }
@Override @Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) { public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
return capability == CapabilityEnergy.ENERGY return capability == CapabilityEnergy.ENERGY
|| (energyTesla != null && (capability == TeslaCapabilities.CAPABILITY_HOLDER || capability == TeslaCapabilities.CAPABILITY_CONSUMER)) || (energyTesla != null && (capability == TeslaCapabilities.CAPABILITY_HOLDER || capability == TeslaCapabilities.CAPABILITY_CONSUMER))
|| capability == CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY || capability == CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY

View File

@@ -148,12 +148,12 @@ public class TileDiskDrive extends TileNode<NetworkNodeDiskDrive> {
} }
@Override @Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) { public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing); return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
} }
@Override @Override
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) { public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(getNode().getDisks()); return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(getNode().getDisks());
} }

View File

@@ -66,7 +66,7 @@ public class TileDiskManipulator extends TileNode<NetworkNodeDiskManipulator> {
} }
@Override @Override
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) { public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(facing == EnumFacing.DOWN ? getNode().getOutputDisks() : getNode().getInputDisks()); return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(facing == EnumFacing.DOWN ? getNode().getOutputDisks() : getNode().getInputDisks());
} }
@@ -75,7 +75,7 @@ public class TileDiskManipulator extends TileNode<NetworkNodeDiskManipulator> {
} }
@Override @Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) { public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing); return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
} }

View File

@@ -37,12 +37,12 @@ public class TileFluidInterface extends TileNode<NetworkNodeFluidInterface> {
} }
@Override @Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) { public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, facing); return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
} }
@Override @Override
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) { public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(getNode().getTank()); return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(getNode().getTank());
} }

View File

@@ -18,7 +18,7 @@ public class TileInterface extends TileNode<NetworkNodeInterface> {
} }
@Override @Override
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) { public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(getNode().getItems()); return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(getNode().getItems());
} }
@@ -27,7 +27,7 @@ public class TileInterface extends TileNode<NetworkNodeInterface> {
} }
@Override @Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) { public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing); return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
} }

View File

@@ -48,12 +48,12 @@ public class TileNetworkTransmitter extends TileNode<NetworkNodeNetworkTransmitt
} }
@Override @Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) { public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing); return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
} }
@Override @Override
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) { public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(getNode().getNetworkCard()); return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(getNode().getNetworkCard());
} }

View File

@@ -84,6 +84,8 @@ public abstract class TileNode<N extends NetworkNode> extends TileBase implement
getNode().setActive(tag.getBoolean(NBT_ACTIVE)); getNode().setActive(tag.getBoolean(NBT_ACTIVE));
} }
@Override
@Nullable
public IItemHandler getDrops() { public IItemHandler getDrops() {
return getNode().getDrops(); return getNode().getDrops();
} }
@@ -148,7 +150,7 @@ public abstract class TileNode<N extends NetworkNode> extends TileBase implement
public abstract N createNode(); public abstract N createNode();
@Override @Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing side) { public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing side) {
if (capability == CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY) { if (capability == CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY) {
return true; return true;
} }
@@ -157,7 +159,7 @@ public abstract class TileNode<N extends NetworkNode> extends TileBase implement
} }
@Override @Override
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing side) { public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing side) {
if (capability == CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY) { if (capability == CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY) {
return CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY.cast(this); return CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY.cast(this);
} }

View File

@@ -19,6 +19,7 @@ import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public class TileProcessingPatternEncoder extends TileBase { public class TileProcessingPatternEncoder extends TileBase {
@@ -150,12 +151,13 @@ public class TileProcessingPatternEncoder extends TileBase {
} }
@Override @Override
@Nullable
public IItemHandler getDrops() { public IItemHandler getDrops() {
return patterns; return patterns;
} }
@Override @Override
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) { public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(patterns); return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(patterns);
} }
@@ -164,7 +166,7 @@ public class TileProcessingPatternEncoder extends TileBase {
} }
@Override @Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) { public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing); return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
} }
} }

View File

@@ -61,7 +61,7 @@ public class TileReader extends TileNode<NetworkNodeReader> {
} }
@Override @Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) { public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
if (super.hasCapability(capability, facing)) { if (super.hasCapability(capability, facing)) {
return true; return true;
} }
@@ -96,7 +96,7 @@ public class TileReader extends TileNode<NetworkNodeReader> {
} }
@Override @Override
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) { public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
T foundCapability = super.getCapability(capability, facing); T foundCapability = super.getCapability(capability, facing);
if (foundCapability == null) { if (foundCapability == null) {

View File

@@ -43,7 +43,7 @@ public class TileSolderer extends TileNode<NetworkNodeSolderer> {
} }
@Override @Override
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) { public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(getNode().getItems()); return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(getNode().getItems());
} }
@@ -52,7 +52,7 @@ public class TileSolderer extends TileNode<NetworkNodeSolderer> {
} }
@Override @Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) { public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing); return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
} }

View File

@@ -35,7 +35,7 @@ public class TileWriter extends TileNode<NetworkNodeWriter> {
} }
@Override @Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) { public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
if (super.hasCapability(capability, facing)) { if (super.hasCapability(capability, facing)) {
return true; return true;
} }
@@ -70,7 +70,7 @@ public class TileWriter extends TileNode<NetworkNodeWriter> {
} }
@Override @Override
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) { public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
T foundCapability = super.getCapability(capability, facing); T foundCapability = super.getCapability(capability, facing);
if (foundCapability == null) { if (foundCapability == null) {

View File

@@ -26,8 +26,8 @@ public interface IType {
((IType) tile.getNode()).setType(value); ((IType) tile.getNode()).setType(value);
tile.getWorld().playerEntities.stream() tile.getWorld().playerEntities.stream()
.filter(p -> p.openContainer instanceof ContainerBase && ((ContainerBase) p.openContainer).getTile().getPos().equals(tile.getPos())) .filter(p -> p.openContainer instanceof ContainerBase && ((ContainerBase) p.openContainer).getTile().getPos().equals(tile.getPos()))
.forEach(p -> p.openContainer.detectAndSendChanges()); .forEach(p -> p.openContainer.detectAndSendChanges());
} }
} }
}); });

View File

@@ -1,4 +1,3 @@
package com.raoulvdberge.refinedstorage.tile.grid; package com.raoulvdberge.refinedstorage.tile.grid;
import com.raoulvdberge.refinedstorage.RS; import com.raoulvdberge.refinedstorage.RS;

View File

@@ -519,13 +519,13 @@ public class TilePortableGrid extends TileBase implements IGrid, IPortableGrid,
} }
@Override @Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) { public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
return capability == CapabilityEnergy.ENERGY || super.hasCapability(capability, facing); return capability == CapabilityEnergy.ENERGY || super.hasCapability(capability, facing);
} }
@Nullable @Nullable
@Override @Override
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) { public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
if (capability == CapabilityEnergy.ENERGY) { if (capability == CapabilityEnergy.ENERGY) {
return CapabilityEnergy.ENERGY.cast(energyStorage); return CapabilityEnergy.ENERGY.cast(energyStorage);
} }