More SonarQube fixes.
This commit is contained in:
@@ -21,6 +21,8 @@ import net.minecraft.world.World;
|
|||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class DetectorNetworkNode extends NetworkNode implements IComparable, IType {
|
public class DetectorNetworkNode extends NetworkNode implements IComparable, IType {
|
||||||
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "detector");
|
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "detector");
|
||||||
|
|
||||||
@@ -114,7 +116,7 @@ public class DetectorNetworkNode extends NetworkNode implements IComparable, ITy
|
|||||||
this.powered = powered;
|
this.powered = powered;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isPowered(Integer size) {
|
private boolean isPowered(@Nullable Integer size) {
|
||||||
if (size != null) {
|
if (size != null) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case MODE_UNDER:
|
case MODE_UNDER:
|
||||||
@@ -123,18 +125,16 @@ public class DetectorNetworkNode extends NetworkNode implements IComparable, ITy
|
|||||||
return size == amount;
|
return size == amount;
|
||||||
case MODE_ABOVE:
|
case MODE_ABOVE:
|
||||||
return size > amount;
|
return size > amount;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (mode == MODE_UNDER && amount != 0) {
|
if (mode == MODE_UNDER && amount != 0) {
|
||||||
return true;
|
return true;
|
||||||
} else if (mode == MODE_EQUAL && amount == 0) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return mode == MODE_EQUAL && amount == 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -201,13 +201,14 @@ public class DiskManipulatorNetworkNode extends NetworkNode implements IComparab
|
|||||||
}
|
}
|
||||||
|
|
||||||
// In Extract mode, we just need to check if the disk is full or not.
|
// In Extract mode, we just need to check if the disk is full or not.
|
||||||
if (ioMode == IO_MODE_EXTRACT)
|
if (ioMode == IO_MODE_EXTRACT) {
|
||||||
if (storage.getStored() == storage.getCapacity()) {
|
if (storage.getStored() == storage.getCapacity()) {
|
||||||
moveDriveToOutput(slot);
|
moveDriveToOutput(slot);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<ItemStack> stacks = new ArrayList<>(storage.getStacks());
|
List<ItemStack> stacks = new ArrayList<>(storage.getStacks());
|
||||||
|
|
||||||
@@ -298,13 +299,14 @@ public class DiskManipulatorNetworkNode extends NetworkNode implements IComparab
|
|||||||
}
|
}
|
||||||
|
|
||||||
//In Extract mode, we just need to check if the disk is full or not.
|
//In Extract mode, we just need to check if the disk is full or not.
|
||||||
if (ioMode == IO_MODE_EXTRACT)
|
if (ioMode == IO_MODE_EXTRACT) {
|
||||||
if (storage.getStored() == storage.getCapacity()) {
|
if (storage.getStored() == storage.getCapacity()) {
|
||||||
moveDriveToOutput(slot);
|
moveDriveToOutput(slot);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<FluidStack> stacks = new ArrayList<>(storage.getStacks());
|
List<FluidStack> stacks = new ArrayList<>(storage.getStacks());
|
||||||
|
|
||||||
|
@@ -4,13 +4,13 @@ import com.refinedmods.refinedstorage.api.network.security.ISecurityCard;
|
|||||||
import com.refinedmods.refinedstorage.api.network.security.Permission;
|
import com.refinedmods.refinedstorage.api.network.security.Permission;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.HashMap;
|
import java.util.EnumMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class SecurityCard implements ISecurityCard {
|
public class SecurityCard implements ISecurityCard {
|
||||||
private final UUID owner;
|
private final UUID owner;
|
||||||
private final Map<Permission, Boolean> permissions = new HashMap<>();
|
private final Map<Permission, Boolean> permissions = new EnumMap<>(Permission.class);
|
||||||
|
|
||||||
public SecurityCard(@Nullable UUID owner) {
|
public SecurityCard(@Nullable UUID owner) {
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
|
@@ -66,7 +66,6 @@ public class DiskDriveBakedModel extends DelegateBakedModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final IBakedModel base;
|
|
||||||
private final IBakedModel disk;
|
private final IBakedModel disk;
|
||||||
private final IBakedModel diskNearCapacity;
|
private final IBakedModel diskNearCapacity;
|
||||||
private final IBakedModel diskFull;
|
private final IBakedModel diskFull;
|
||||||
@@ -80,7 +79,8 @@ public class DiskDriveBakedModel extends DelegateBakedModel {
|
|||||||
|
|
||||||
List<BakedQuad> quads = new ArrayList<>(QuadTransformer.getTransformedQuads(base, facing, null, key.state, key.random, key.side));
|
List<BakedQuad> quads = new ArrayList<>(QuadTransformer.getTransformedQuads(base, facing, null, key.state, key.random, key.side));
|
||||||
|
|
||||||
int x = 0, y = 0;
|
int x = 0;
|
||||||
|
int y = 0;
|
||||||
for (int i = 0; i < 8; ++i) {
|
for (int i = 0; i < 8; ++i) {
|
||||||
if (key.diskState[i] != DiskState.NONE) {
|
if (key.diskState[i] != DiskState.NONE) {
|
||||||
IBakedModel diskModel = getDiskModel(key.diskState[i]);
|
IBakedModel diskModel = getDiskModel(key.diskState[i]);
|
||||||
@@ -113,7 +113,6 @@ public class DiskDriveBakedModel extends DelegateBakedModel {
|
|||||||
IBakedModel diskDisconnected) {
|
IBakedModel diskDisconnected) {
|
||||||
super(base);
|
super(base);
|
||||||
|
|
||||||
this.base = base;
|
|
||||||
this.disk = disk;
|
this.disk = disk;
|
||||||
this.diskNearCapacity = diskNearCapacity;
|
this.diskNearCapacity = diskNearCapacity;
|
||||||
this.diskFull = diskFull;
|
this.diskFull = diskFull;
|
||||||
|
@@ -91,7 +91,8 @@ public class DiskManipulatorBakedModel extends DelegateBakedModel {
|
|||||||
key.side
|
key.side
|
||||||
));
|
));
|
||||||
|
|
||||||
int x = 0, y = 0;
|
int x = 0;
|
||||||
|
int y = 0;
|
||||||
for (int i = 0; i < 6; ++i) {
|
for (int i = 0; i < 6; ++i) {
|
||||||
if (key.diskState[i] != DiskState.NONE) {
|
if (key.diskState[i] != DiskState.NONE) {
|
||||||
IBakedModel diskModel = getDiskModel(key.diskState[i]);
|
IBakedModel diskModel = getDiskModel(key.diskState[i]);
|
||||||
|
@@ -110,11 +110,7 @@ public class FullbrightBakedModel extends DelegateBakedModel {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!state.equals(cacheKey.state)) {
|
return state.equals(cacheKey.state);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -116,14 +116,79 @@ public class CraftingPreviewScreen extends BaseScreen<Container> {
|
|||||||
|
|
||||||
float scale = Minecraft.getInstance().getForceUnicodeFont() ? 1F : 0.5F;
|
float scale = Minecraft.getInstance().getForceUnicodeFont() ? 1F : 0.5F;
|
||||||
|
|
||||||
if (getErrorType() != null) {
|
CalculationResultType errorType = getErrorType();
|
||||||
|
if (errorType != null) {
|
||||||
|
renderError(matrixStack, x, y, scale, errorType);
|
||||||
|
} else {
|
||||||
|
renderPreview(matrixStack, mouseX, mouseY, x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderPreview(MatrixStack matrixStack, int mouseX, int mouseY, int x, int y) {
|
||||||
|
int slot = scrollbar != null ? (scrollbar.getOffset() * 3) : 0;
|
||||||
|
|
||||||
|
RenderHelper.setupGui3DDiffuseLighting();
|
||||||
|
RenderSystem.enableDepthTest();
|
||||||
|
|
||||||
|
this.hoveringStack = null;
|
||||||
|
this.hoveringFluid = null;
|
||||||
|
|
||||||
|
for (int i = 0; i < 3 * 5; ++i) {
|
||||||
|
if (slot < stacks.size()) {
|
||||||
|
renderElement(matrixStack, mouseX, mouseY, x, y, stacks.get(slot));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((i + 1) % 3 == 0) {
|
||||||
|
x = 7;
|
||||||
|
y += 30;
|
||||||
|
} else {
|
||||||
|
x += 74;
|
||||||
|
}
|
||||||
|
|
||||||
|
slot++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderElement(MatrixStack matrixStack, int mouseX, int mouseY, int x, int y, ICraftingPreviewElement<?> element) {
|
||||||
|
element.draw(matrixStack, x, y + 5, drawers);
|
||||||
|
|
||||||
|
if (RenderUtils.inBounds(x + 5, y + 7, 16, 16, mouseX, mouseY)) {
|
||||||
|
this.hoveringStack = element.getId().equals(ItemCraftingPreviewElement.ID) ? (ItemStack) element.getElement() : null;
|
||||||
|
|
||||||
|
if (this.hoveringStack == null) {
|
||||||
|
this.hoveringFluid = element.getId().equals(FluidCraftingPreviewElement.ID) ? (FluidStack) element.getElement() : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderError(MatrixStack matrixStack, int x, int y, float scale, CalculationResultType errorType) {
|
||||||
matrixStack.push();
|
matrixStack.push();
|
||||||
matrixStack.scale(scale, scale, 1);
|
matrixStack.scale(scale, scale, 1);
|
||||||
|
|
||||||
renderString(matrixStack, RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 11, scale), I18n.format("gui.refinedstorage.crafting_preview.error"));
|
renderString(matrixStack, RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 11, scale), I18n.format("gui.refinedstorage.crafting_preview.error"));
|
||||||
|
|
||||||
switch (getErrorType()) {
|
switch (errorType) {
|
||||||
case RECURSIVE: {
|
case RECURSIVE:
|
||||||
|
renderRecursiveError(matrixStack, x, y, scale);
|
||||||
|
break;
|
||||||
|
case OK:
|
||||||
|
case MISSING:
|
||||||
|
case NO_PATTERN:
|
||||||
|
break;
|
||||||
|
case TOO_COMPLEX:
|
||||||
|
renderTooComplexError(matrixStack, x, y, scale);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
matrixStack.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderTooComplexError(MatrixStack matrixStack, int x, int y, float scale) {
|
||||||
|
renderString(matrixStack, RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 21, scale), I18n.format("gui.refinedstorage.crafting_preview.error.too_complex.0"));
|
||||||
|
renderString(matrixStack, RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 31, scale), I18n.format("gui.refinedstorage.crafting_preview.error.too_complex.1"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderRecursiveError(MatrixStack matrixStack, int x, int y, float scale) {
|
||||||
renderString(matrixStack, RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 21, scale), I18n.format("gui.refinedstorage.crafting_preview.error.recursive.0"));
|
renderString(matrixStack, RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 21, scale), I18n.format("gui.refinedstorage.crafting_preview.error.recursive.0"));
|
||||||
renderString(matrixStack, RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 31, scale), I18n.format("gui.refinedstorage.crafting_preview.error.recursive.1"));
|
renderString(matrixStack, RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 31, scale), I18n.format("gui.refinedstorage.crafting_preview.error.recursive.1"));
|
||||||
renderString(matrixStack, RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 41, scale), I18n.format("gui.refinedstorage.crafting_preview.error.recursive.2"));
|
renderString(matrixStack, RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 41, scale), I18n.format("gui.refinedstorage.crafting_preview.error.recursive.2"));
|
||||||
@@ -149,52 +214,6 @@ public class CraftingPreviewScreen extends BaseScreen<Container> {
|
|||||||
yy += 17;
|
yy += 17;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TOO_COMPLEX: {
|
|
||||||
renderString(matrixStack, RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 21, scale), I18n.format("gui.refinedstorage.crafting_preview.error.too_complex.0"));
|
|
||||||
renderString(matrixStack, RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 31, scale), I18n.format("gui.refinedstorage.crafting_preview.error.too_complex.1"));
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
matrixStack.pop();
|
|
||||||
} else {
|
|
||||||
int slot = scrollbar != null ? (scrollbar.getOffset() * 3) : 0;
|
|
||||||
|
|
||||||
RenderHelper.setupGui3DDiffuseLighting();
|
|
||||||
RenderSystem.enableDepthTest();
|
|
||||||
|
|
||||||
this.hoveringStack = null;
|
|
||||||
this.hoveringFluid = null;
|
|
||||||
|
|
||||||
for (int i = 0; i < 3 * 5; ++i) {
|
|
||||||
if (slot < stacks.size()) {
|
|
||||||
ICraftingPreviewElement<?> stack = stacks.get(slot);
|
|
||||||
|
|
||||||
stack.draw(matrixStack, x, y + 5, drawers);
|
|
||||||
|
|
||||||
if (RenderUtils.inBounds(x + 5, y + 7, 16, 16, mouseX, mouseY)) {
|
|
||||||
this.hoveringStack = stack.getId().equals(ItemCraftingPreviewElement.ID) ? (ItemStack) stack.getElement() : null;
|
|
||||||
|
|
||||||
if (this.hoveringStack == null) {
|
|
||||||
this.hoveringFluid = stack.getId().equals(FluidCraftingPreviewElement.ID) ? (FluidStack) stack.getElement() : null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((i + 1) % 3 == 0) {
|
|
||||||
x = 7;
|
|
||||||
y += 30;
|
|
||||||
} else {
|
|
||||||
x += 74;
|
|
||||||
}
|
|
||||||
|
|
||||||
slot++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -7,27 +7,27 @@ import net.minecraft.client.resources.I18n;
|
|||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
|
||||||
public class FilterTypeSideButton extends SideButton {
|
public class FilterTypeSideButton extends SideButton {
|
||||||
private final FilterScreen screen;
|
private final FilterScreen filterScreen;
|
||||||
|
|
||||||
public FilterTypeSideButton(FilterScreen screen) {
|
public FilterTypeSideButton(FilterScreen filterScreen) {
|
||||||
super(screen);
|
super(filterScreen);
|
||||||
|
|
||||||
this.screen = screen;
|
this.filterScreen = filterScreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTooltip() {
|
public String getTooltip() {
|
||||||
return I18n.format("sidebutton.refinedstorage.type") + "\n" + TextFormatting.GRAY + I18n.format("sidebutton.refinedstorage.type." + screen.getType());
|
return I18n.format("sidebutton.refinedstorage.type") + "\n" + TextFormatting.GRAY + I18n.format("sidebutton.refinedstorage.type." + filterScreen.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderButtonIcon(MatrixStack matrixStack, int x, int y) {
|
protected void renderButtonIcon(MatrixStack matrixStack, int x, int y) {
|
||||||
screen.blit(matrixStack, x, y, 16 * screen.getType(), 128, 16, 16);
|
filterScreen.blit(matrixStack, x, y, 16 * filterScreen.getType(), 128, 16, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPress() {
|
public void onPress() {
|
||||||
screen.setType(screen.getType() == IType.ITEMS ? IType.FLUIDS : IType.ITEMS);
|
filterScreen.setType(filterScreen.getType() == IType.ITEMS ? IType.FLUIDS : IType.ITEMS);
|
||||||
screen.sendUpdate();
|
filterScreen.sendUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user