More SonarQube fixes.
This commit is contained in:
@@ -214,17 +214,17 @@ public class ProcessingNode extends Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateFinishedQuantity() {
|
public void updateFinishedQuantity() {
|
||||||
int quantityFinished = totalQuantity;
|
int tempQuantityFinished = totalQuantity;
|
||||||
|
|
||||||
for (StackListEntry<ItemStack> toReceive : singleItemSetToReceive.getStacks()) {
|
for (StackListEntry<ItemStack> toReceive : singleItemSetToReceive.getStacks()) {
|
||||||
if (itemsReceived.get(toReceive.getStack()) != null) {
|
if (itemsReceived.get(toReceive.getStack()) != null) {
|
||||||
int ratioReceived = itemsReceived.get(toReceive.getStack()).getCount() / toReceive.getStack().getCount();
|
int ratioReceived = itemsReceived.get(toReceive.getStack()).getCount() / toReceive.getStack().getCount();
|
||||||
|
|
||||||
if (quantityFinished > ratioReceived) {
|
if (tempQuantityFinished > ratioReceived) {
|
||||||
quantityFinished = ratioReceived;
|
tempQuantityFinished = ratioReceived;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
quantityFinished = 0;
|
tempQuantityFinished = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,15 +232,15 @@ public class ProcessingNode extends Node {
|
|||||||
if (fluidsReceived.get(toReceive.getStack()) != null) {
|
if (fluidsReceived.get(toReceive.getStack()) != null) {
|
||||||
int ratioReceived = fluidsReceived.get(toReceive.getStack()).getAmount() / toReceive.getStack().getAmount();
|
int ratioReceived = fluidsReceived.get(toReceive.getStack()).getAmount() / toReceive.getStack().getAmount();
|
||||||
|
|
||||||
if (quantityFinished > ratioReceived) {
|
if (tempQuantityFinished > ratioReceived) {
|
||||||
quantityFinished = ratioReceived;
|
tempQuantityFinished = ratioReceived;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
quantityFinished = 0;
|
tempQuantityFinished = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.quantityFinished = quantityFinished;
|
this.quantityFinished = tempQuantityFinished;
|
||||||
|
|
||||||
if (this.quantityFinished == this.totalQuantity) {
|
if (this.quantityFinished == this.totalQuantity) {
|
||||||
this.state = ProcessingState.PROCESSED;
|
this.state = ProcessingState.PROCESSED;
|
||||||
|
@@ -22,87 +22,45 @@ public class CraftingPreviewElementFactory {
|
|||||||
for (StackListEntry<ItemStack> stack : info.getMissing().getStacks()) {
|
for (StackListEntry<ItemStack> stack : info.getMissing().getStacks()) {
|
||||||
int hash = API.instance().getItemStackHashCode(stack.getStack());
|
int hash = API.instance().getItemStackHashCode(stack.getStack());
|
||||||
|
|
||||||
ItemCraftingPreviewElement previewStack = map.get(hash);
|
ItemCraftingPreviewElement previewStack = map.computeIfAbsent(hash, key -> new ItemCraftingPreviewElement(stack.getStack()));
|
||||||
|
|
||||||
if (previewStack == null) {
|
|
||||||
previewStack = new ItemCraftingPreviewElement(stack.getStack());
|
|
||||||
}
|
|
||||||
|
|
||||||
previewStack.setMissing(true);
|
previewStack.setMissing(true);
|
||||||
previewStack.addToCraft(stack.getStack().getCount());
|
previewStack.addToCraft(stack.getStack().getCount());
|
||||||
|
|
||||||
map.put(hash, previewStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (StackListEntry<FluidStack> stack : info.getMissingFluids().getStacks()) {
|
for (StackListEntry<FluidStack> stack : info.getMissingFluids().getStacks()) {
|
||||||
int hash = API.instance().getFluidStackHashCode(stack.getStack());
|
int hash = API.instance().getFluidStackHashCode(stack.getStack());
|
||||||
|
|
||||||
FluidCraftingPreviewElement previewStack = mapFluids.get(hash);
|
FluidCraftingPreviewElement previewStack = mapFluids.computeIfAbsent(hash, key -> new FluidCraftingPreviewElement(stack.getStack()));
|
||||||
|
|
||||||
if (previewStack == null) {
|
|
||||||
previewStack = new FluidCraftingPreviewElement(stack.getStack());
|
|
||||||
}
|
|
||||||
|
|
||||||
previewStack.setMissing(true);
|
previewStack.setMissing(true);
|
||||||
previewStack.addToCraft(stack.getStack().getAmount());
|
previewStack.addToCraft(stack.getStack().getAmount());
|
||||||
|
|
||||||
mapFluids.put(hash, previewStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ItemStack stack : ImmutableList.copyOf(info.getToCraft()).reverse()) {
|
for (ItemStack stack : ImmutableList.copyOf(info.getToCraft()).reverse()) {
|
||||||
int hash = API.instance().getItemStackHashCode(stack);
|
int hash = API.instance().getItemStackHashCode(stack);
|
||||||
|
|
||||||
ItemCraftingPreviewElement previewStack = map.get(hash);
|
ItemCraftingPreviewElement previewStack = map.computeIfAbsent(hash, key -> new ItemCraftingPreviewElement(stack.getStack()));
|
||||||
|
|
||||||
if (previewStack == null) {
|
|
||||||
previewStack = new ItemCraftingPreviewElement(stack.getStack());
|
|
||||||
}
|
|
||||||
|
|
||||||
previewStack.addToCraft(stack.getCount());
|
previewStack.addToCraft(stack.getCount());
|
||||||
|
|
||||||
map.put(hash, previewStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (FluidStack stack : ImmutableList.copyOf(info.getToCraftFluids()).reverse()) {
|
for (FluidStack stack : ImmutableList.copyOf(info.getToCraftFluids()).reverse()) {
|
||||||
int hash = API.instance().getFluidStackHashCode(stack);
|
int hash = API.instance().getFluidStackHashCode(stack);
|
||||||
|
|
||||||
FluidCraftingPreviewElement previewStack = mapFluids.get(hash);
|
FluidCraftingPreviewElement previewStack = mapFluids.computeIfAbsent(hash, key -> new FluidCraftingPreviewElement(stack));
|
||||||
|
|
||||||
if (previewStack == null) {
|
|
||||||
previewStack = new FluidCraftingPreviewElement(stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
previewStack.addToCraft(stack.getAmount());
|
previewStack.addToCraft(stack.getAmount());
|
||||||
|
|
||||||
mapFluids.put(hash, previewStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (StackListEntry<ItemStack> stack : info.getToTake().getStacks()) {
|
for (StackListEntry<ItemStack> stack : info.getToTake().getStacks()) {
|
||||||
int hash = API.instance().getItemStackHashCode(stack.getStack());
|
int hash = API.instance().getItemStackHashCode(stack.getStack());
|
||||||
|
|
||||||
ItemCraftingPreviewElement previewStack = map.get(hash);
|
ItemCraftingPreviewElement previewStack = map.computeIfAbsent(hash, key -> new ItemCraftingPreviewElement(stack.getStack()));
|
||||||
|
|
||||||
if (previewStack == null) {
|
|
||||||
previewStack = new ItemCraftingPreviewElement(stack.getStack());
|
|
||||||
}
|
|
||||||
|
|
||||||
previewStack.addAvailable(stack.getStack().getCount());
|
previewStack.addAvailable(stack.getStack().getCount());
|
||||||
|
|
||||||
map.put(hash, previewStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (StackListEntry<FluidStack> stack : info.getToTakeFluids().getStacks()) {
|
for (StackListEntry<FluidStack> stack : info.getToTakeFluids().getStacks()) {
|
||||||
int hash = API.instance().getFluidStackHashCode(stack.getStack());
|
int hash = API.instance().getFluidStackHashCode(stack.getStack());
|
||||||
|
|
||||||
FluidCraftingPreviewElement previewStack = mapFluids.get(hash);
|
FluidCraftingPreviewElement previewStack = mapFluids.computeIfAbsent(hash, key -> new FluidCraftingPreviewElement(stack.getStack()));
|
||||||
|
|
||||||
if (previewStack == null) {
|
|
||||||
previewStack = new FluidCraftingPreviewElement(stack.getStack());
|
|
||||||
}
|
|
||||||
|
|
||||||
previewStack.addAvailable(stack.getStack().getAmount());
|
previewStack.addAvailable(stack.getStack().getAmount());
|
||||||
|
|
||||||
mapFluids.put(hash, previewStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ICraftingPreviewElement<?>> elements = new ArrayList<>();
|
List<ICraftingPreviewElement<?>> elements = new ArrayList<>();
|
||||||
|
@@ -10,8 +10,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|||||||
public class NetworkListener {
|
public class NetworkListener {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onWorldTick(TickEvent.WorldTickEvent e) {
|
public void onWorldTick(TickEvent.WorldTickEvent e) {
|
||||||
if (!e.world.isRemote()) {
|
if (!e.world.isRemote() && e.phase == TickEvent.Phase.END) {
|
||||||
if (e.phase == TickEvent.Phase.END) {
|
|
||||||
e.world.getProfiler().startSection("network ticking");
|
e.world.getProfiler().startSection("network ticking");
|
||||||
|
|
||||||
for (INetwork network : API.instance().getNetworkManager((ServerWorld) e.world).all()) {
|
for (INetwork network : API.instance().getNetworkManager((ServerWorld) e.world).all()) {
|
||||||
@@ -29,5 +28,4 @@ public class NetworkListener {
|
|||||||
e.world.getProfiler().endSection();
|
e.world.getProfiler().endSection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -100,14 +100,6 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
|||||||
return network.getWorld();
|
return network.getWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dropConflictingBlock(World world, BlockPos pos) {
|
|
||||||
if (!network.getPosition().equals(pos)) {
|
|
||||||
Block.spawnDrops(world.getBlockState(pos), world, pos, world.getTileEntity(pos));
|
|
||||||
|
|
||||||
world.removeBlock(pos, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class Operator implements INetworkNodeVisitor.Operator {
|
private class Operator implements INetworkNodeVisitor.Operator {
|
||||||
private final Set<INetworkNode> foundNodes = Sets.newConcurrentHashSet(); // All scanned nodes
|
private final Set<INetworkNode> foundNodes = Sets.newConcurrentHashSet(); // All scanned nodes
|
||||||
|
|
||||||
@@ -152,6 +144,14 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void dropConflictingBlock(World world, BlockPos pos) {
|
||||||
|
if (!network.getPosition().equals(pos)) {
|
||||||
|
Block.spawnDrops(world.getBlockState(pos), world, pos, world.getTileEntity(pos));
|
||||||
|
|
||||||
|
world.removeBlock(pos, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Action getAction() {
|
public Action getAction() {
|
||||||
return action;
|
return action;
|
||||||
|
Reference in New Issue
Block a user