Added error message like missing upgrade to projector LUA properties

This commit is contained in:
LemADEC 2022-01-30 19:23:08 +01:00
parent 6d1cf48fd1
commit 8698d367c3
2 changed files with 30 additions and 8 deletions

View file

@ -31,7 +31,6 @@ import li.cil.oc.api.network.Visibility;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@ -359,6 +358,7 @@ public abstract class TileEntityAbstractInterfaced extends TileEntityAbstractBas
@Nonnull
protected Object[] computer_getOrSetVector3(@Nonnull final FunctionGet<Vector3> getVector,
@Nonnull final FunctionSetVector<Float> setVector,
@Nonnull final TileEntityAbstractBase.UpgradeSlot upgradeSlot,
final Object[] arguments) {
if ( arguments != null
&& arguments.length > 0
@ -389,7 +389,11 @@ public abstract class TileEntityAbstractInterfaced extends TileEntityAbstractBas
}
}
final Vector3 v3Actual = getVector.apply();
return new Double[] { v3Actual.x, v3Actual.y, v3Actual.z };
if (hasUpgrade(upgradeSlot)) {
return new Double[] { v3Actual.x, v3Actual.y, v3Actual.z };
} else {
return new Object[] { v3Actual.x, v3Actual.y, v3Actual.z, "Missing " + upgradeSlot.itemStack.getDisplayName() };
}
}
protected UUID computer_getUUID(final UUID uuidDefault, @Nonnull final Object[] arguments) {

View file

@ -836,7 +836,12 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
}
public Vector3 getMin() {
return v3Min;
assert EnumForceFieldUpgrade.RANGE.getProjectorUpgradeSlot() != null;
if (hasUpgrade(EnumForceFieldUpgrade.RANGE.getProjectorUpgradeSlot())) {
return v3Min;
} else {
return new Vector3(-1.0D, -1.0D, -1.0D);
}
}
private void setMin(final float x, final float y, final float z) {
@ -844,7 +849,12 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
}
public Vector3 getMax() {
return v3Max;
assert EnumForceFieldUpgrade.RANGE.getProjectorUpgradeSlot() != null;
if (hasUpgrade(EnumForceFieldUpgrade.RANGE.getProjectorUpgradeSlot())) {
return v3Max;
} else {
return new Vector3( 1.0D, 1.0D, 1.0D);
}
}
private void setMax(final float x, final float y, final float z) {
@ -1110,11 +1120,13 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
}
public Object[] min(final Object[] arguments) {
return computer_getOrSetVector3(this::getMin, this::setMin, arguments);
assert EnumForceFieldUpgrade.RANGE.getProjectorUpgradeSlot() != null;
return computer_getOrSetVector3(this::getMin, this::setMin, EnumForceFieldUpgrade.RANGE.getProjectorUpgradeSlot(), arguments);
}
public Object[] max(final Object[] arguments) {
return computer_getOrSetVector3(this::getMax, this::setMax, arguments);
assert EnumForceFieldUpgrade.RANGE.getProjectorUpgradeSlot() != null;
return computer_getOrSetVector3(this::getMax, this::setMax, EnumForceFieldUpgrade.RANGE.getProjectorUpgradeSlot(), arguments);
}
public Object[] rotation(final Object[] arguments) {
@ -1145,11 +1157,17 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
return new Object[] { rotationYaw, rotationPitch, rotationRoll, message };
}
}
return new Float[] { rotationYaw, rotationPitch, rotationRoll };
assert EnumForceFieldUpgrade.ROTATION.getProjectorUpgradeSlot() != null;
if (hasUpgrade(EnumForceFieldUpgrade.ROTATION.getProjectorUpgradeSlot())) {
return new Float[] { rotationYaw, rotationPitch, rotationRoll };
} else {
return new Object[] { 0.0F, 0.0F, 0.0F, "Missing " + EnumForceFieldUpgrade.ROTATION.getProjectorUpgradeSlot().itemStack.getDisplayName() };
}
}
public Object[] translation(final Object[] arguments) {
return computer_getOrSetVector3(this::getTranslation, this::setTranslation, arguments);
assert EnumForceFieldUpgrade.TRANSLATION.getProjectorUpgradeSlot() != null;
return computer_getOrSetVector3(this::getTranslation, this::setTranslation, EnumForceFieldUpgrade.TRANSLATION.getProjectorUpgradeSlot(), arguments);
}
// OpenComputers callback methods