Respect NonNull for real real
This commit is contained in:
@@ -1,75 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.network.node;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class NetworkNodeDummy implements INetworkNode {
|
||||
@Override
|
||||
public int getEnergyUsage() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnected(INetwork network) {
|
||||
// NO OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisconnected(INetwork network) {
|
||||
// NO OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public INetwork getNetwork() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
// NO OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound write(NBTTagCompound tag) {
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getPos() {
|
||||
return BlockPos.ORIGIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
// NO OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return "dummy";
|
||||
}
|
||||
}
|
||||
@@ -3,37 +3,49 @@ package com.raoulvdberge.refinedstorage.capability;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeDummy;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.CapabilityInject;
|
||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public class CapabilityNetworkNodeProxy {
|
||||
@CapabilityInject(INetworkNodeProxy.class)
|
||||
public static Capability<INetworkNodeProxy> NETWORK_NODE_PROXY_CAPABILITY = null;
|
||||
|
||||
public static void register() {
|
||||
CapabilityManager.INSTANCE.register(INetworkNodeProxy.class, new Capability.IStorage<INetworkNodeProxy>() {
|
||||
public NBTBase writeNBT(Capability<INetworkNodeProxy> capability, INetworkNodeProxy instance, EnumFacing side) {
|
||||
return new NBTTagCompound();
|
||||
}
|
||||
|
||||
public void readNBT(Capability<INetworkNodeProxy> capability, INetworkNodeProxy instance, EnumFacing side, NBTBase base) {
|
||||
// NO OP
|
||||
}
|
||||
}, () -> new INetworkNodeProxy() {
|
||||
@Override
|
||||
@Nonnull
|
||||
public INetworkNode getNode() {
|
||||
return new NetworkNodeDummy();
|
||||
}
|
||||
});
|
||||
CapabilityManager.INSTANCE.register(INetworkNodeProxy.class, new Storage(), new Factory());
|
||||
|
||||
Preconditions.checkNotNull(NETWORK_NODE_PROXY_CAPABILITY, "Capability not registered");
|
||||
}
|
||||
|
||||
private static class Storage implements Capability.IStorage<INetworkNodeProxy> {
|
||||
@Nullable
|
||||
@Override
|
||||
public NBTBase writeNBT(Capability<INetworkNodeProxy> capability, INetworkNodeProxy instance, EnumFacing side) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNBT(Capability<INetworkNodeProxy> capability, INetworkNodeProxy instance, EnumFacing side, NBTBase nbt) {
|
||||
// NO OP
|
||||
}
|
||||
}
|
||||
|
||||
private static class Factory implements Callable<INetworkNodeProxy> {
|
||||
@Override
|
||||
public INetworkNodeProxy call() throws Exception {
|
||||
return new INetworkNodeProxy() {
|
||||
@Nonnull
|
||||
@Override
|
||||
public INetworkNode getNode() {
|
||||
throw new UnsupportedOperationException("Cannot use default implementation");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user