Merge branch 'master' into 1.16
This commit is contained in:
commit
8f72c3ef8c
6 files changed
+116
-87
No files matched your search
@@ -35,7 +35,7 @@ import static carpet.settings.RuleCategory.CLIENT;
|
||||
@SuppressWarnings("CanBeFinal")
|
||||
public class CarpetSettings
|
||||
{
|
||||
public static final String carpetVersion = "1.3.31+v200616";
|
||||
public static final String carpetVersion = "1.3.32+v200617";
|
||||
public static final Logger LOG = LogManager.getLogger();
|
||||
public static boolean skipGenerationChecks = false;
|
||||
public static boolean impendingFillSkipUpdates = false;
|
||||
|
||||
@@ -123,6 +123,7 @@ import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.EulerAngle;
|
||||
import net.minecraft.util.math.BlockBox;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
@@ -2238,21 +2239,28 @@ public class CarpetExpression
|
||||
return (c_, t_) -> new NumericValue(finalSCount);
|
||||
});
|
||||
|
||||
this.expr.addLazyFunction("volume", 7, (c, t, lv) ->
|
||||
this.expr.addLazyFunction("volume", -1, (c, t, lv) ->
|
||||
{
|
||||
int xi = (int) NumericValue.asNumber(lv.get(0).evalValue(c)).getLong();
|
||||
int yi = (int) NumericValue.asNumber(lv.get(1).evalValue(c)).getLong();
|
||||
int zi = (int) NumericValue.asNumber(lv.get(2).evalValue(c)).getLong();
|
||||
int xj = (int) NumericValue.asNumber(lv.get(3).evalValue(c)).getLong();
|
||||
int yj = (int) NumericValue.asNumber(lv.get(4).evalValue(c)).getLong();
|
||||
int zj = (int) NumericValue.asNumber(lv.get(5).evalValue(c)).getLong();
|
||||
int minx = min(xi, xj);
|
||||
int miny = min(yi, yj);
|
||||
int minz = min(zi, zj);
|
||||
int maxx = max(xi, xj);
|
||||
int maxy = max(yi, yj);
|
||||
int maxz = max(zi, zj);
|
||||
LazyValue expr = lv.get(6);
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
|
||||
BlockArgument pos1Locator = BlockArgument.findIn(cc, lv, 0);
|
||||
BlockArgument pos2Locator = BlockArgument.findIn(cc, lv, pos1Locator.offset);
|
||||
BlockPos pos1 = pos1Locator.block.getPos();
|
||||
BlockPos pos2 = pos2Locator.block.getPos();
|
||||
|
||||
int x1 = pos1.getX();
|
||||
int y1 = pos1.getY();
|
||||
int z1 = pos1.getZ();
|
||||
int x2 = pos2.getX();
|
||||
int y2 = pos2.getY();
|
||||
int z2 = pos2.getZ();
|
||||
int minx = min(x1, x2);
|
||||
int miny = min(y1, y2);
|
||||
int minz = min(z1, z2);
|
||||
int maxx = max(x1, x2);
|
||||
int maxy = max(y1, y2);
|
||||
int maxz = max(z1, z2);
|
||||
LazyValue expr = lv.get(pos2Locator.offset);
|
||||
|
||||
//saving outer scope
|
||||
LazyValue _x = c.getVariable("_x");
|
||||
@@ -2322,57 +2330,63 @@ public class CarpetExpression
|
||||
|
||||
this.expr.addLazyFunction("rect", -1, (c, t, lv)->
|
||||
{
|
||||
if (lv.size() != 3 && lv.size() != 6 && lv.size() != 9)
|
||||
CarpetContext cc = (CarpetContext) c;
|
||||
int cx, cy, cz;
|
||||
int sminx, sminy, sminz;
|
||||
int smaxx, smaxy, smaxz;
|
||||
BlockArgument cposLocator = BlockArgument.findIn(cc, lv, 0);
|
||||
BlockPos cpos = cposLocator.block.getPos();
|
||||
cx = cpos.getX();
|
||||
cy = cpos.getY();
|
||||
cz = cpos.getZ();
|
||||
if (lv.size() > cposLocator.offset)
|
||||
{
|
||||
throw new InternalExpressionException("Rectangular region should be specified with 3, 6, or 9 coordinates");
|
||||
}
|
||||
int cx;
|
||||
int cy;
|
||||
int cz;
|
||||
int sminx;
|
||||
int sminy;
|
||||
int sminz;
|
||||
int smaxx;
|
||||
int smaxy;
|
||||
int smaxz;
|
||||
try
|
||||
{
|
||||
cx = (int)((NumericValue) lv.get(0).evalValue(c)).getLong();
|
||||
cy = (int)((NumericValue) lv.get(1).evalValue(c)).getLong();
|
||||
cz = (int)((NumericValue) lv.get(2).evalValue(c)).getLong();
|
||||
if (lv.size()==3) // only done this way because of stupid Java lambda final reqs
|
||||
Vector3Argument diffLocator = Vector3Argument.findIn(cc, lv, cposLocator.offset);
|
||||
if (diffLocator.fromBlock)
|
||||
{
|
||||
sminx = 1;
|
||||
sminy = 1;
|
||||
sminz = 1;
|
||||
smaxx = 1;
|
||||
smaxy = 1;
|
||||
smaxz = 1;
|
||||
sminx = MathHelper.floor(abs(diffLocator.vec.x - cx));
|
||||
sminy = MathHelper.floor(abs(diffLocator.vec.y - cx));
|
||||
sminz = MathHelper.floor(abs(diffLocator.vec.z - cx));
|
||||
}
|
||||
else if (lv.size()==6)
|
||||
else
|
||||
{
|
||||
sminx = MathHelper.floor(abs(diffLocator.vec.x));
|
||||
sminy = MathHelper.floor(abs(diffLocator.vec.y));
|
||||
sminz = MathHelper.floor(abs(diffLocator.vec.z));
|
||||
}
|
||||
if (lv.size() > diffLocator.offset)
|
||||
{
|
||||
Vector3Argument posDiff = Vector3Argument.findIn(cc, lv, diffLocator.offset);
|
||||
if (posDiff.fromBlock)
|
||||
{
|
||||
smaxx = MathHelper.floor(abs(posDiff.vec.x - cx));
|
||||
smaxy = MathHelper.floor(abs(posDiff.vec.y - cx));
|
||||
smaxz = MathHelper.floor(abs(posDiff.vec.z - cx));
|
||||
}
|
||||
else
|
||||
{
|
||||
smaxx = MathHelper.floor(abs(posDiff.vec.x));
|
||||
smaxy = MathHelper.floor(abs(posDiff.vec.y));
|
||||
smaxz = MathHelper.floor(abs(posDiff.vec.z));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sminx = (int) ((NumericValue) lv.get(3).evalValue(c)).getLong();
|
||||
sminy = (int) ((NumericValue) lv.get(4).evalValue(c)).getLong();
|
||||
sminz = (int) ((NumericValue) lv.get(5).evalValue(c)).getLong();
|
||||
smaxx = sminx;
|
||||
smaxy = sminy;
|
||||
smaxz = sminz;
|
||||
}
|
||||
else // size == 9
|
||||
{
|
||||
sminx = (int) ((NumericValue) lv.get(3).evalValue(c)).getLong();
|
||||
sminy = (int) ((NumericValue) lv.get(4).evalValue(c)).getLong();
|
||||
sminz = (int) ((NumericValue) lv.get(5).evalValue(c)).getLong();
|
||||
smaxx = (int)((NumericValue) lv.get(6).evalValue(c)).getLong();
|
||||
smaxy = (int)((NumericValue) lv.get(7).evalValue(c)).getLong();
|
||||
smaxz = (int)((NumericValue) lv.get(8).evalValue(c)).getLong();
|
||||
}
|
||||
}
|
||||
catch (ClassCastException exc)
|
||||
else
|
||||
{
|
||||
throw new InternalExpressionException("Attempted to pass a non-number to rect");
|
||||
sminx = 1;
|
||||
sminy = 1;
|
||||
sminz = 1;
|
||||
smaxx = 1;
|
||||
smaxy = 1;
|
||||
smaxz = 1;
|
||||
}
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
|
||||
return (c_, t_) -> new LazyListValue()
|
||||
{
|
||||
final int minx = cx-sminx;
|
||||
@@ -2381,6 +2395,7 @@ public class CarpetExpression
|
||||
final int maxx = cx+smaxx;
|
||||
final int maxy = cy+smaxy;
|
||||
final int maxz = cz+smaxz;
|
||||
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
@@ -2440,10 +2455,9 @@ public class CarpetExpression
|
||||
this.expr.addLazyFunction("diamond", -1, (c, t, lv)->
|
||||
{
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
if (lv.size() != 3 && lv.size() != 4 && lv.size() != 5)
|
||||
{
|
||||
throw new InternalExpressionException("'diamond' region should be specified with 3 to 5 coordinates");
|
||||
}
|
||||
|
||||
BlockArgument cposLocator=BlockArgument.findIn((CarpetContext)c,lv,0);
|
||||
BlockPos cpos = cposLocator.block.getPos();
|
||||
|
||||
int cx;
|
||||
int cy;
|
||||
@@ -2452,10 +2466,11 @@ public class CarpetExpression
|
||||
int height;
|
||||
try
|
||||
{
|
||||
cx = (int)((NumericValue) lv.get(0).evalValue(c)).getLong();
|
||||
cy = (int)((NumericValue) lv.get(1).evalValue(c)).getLong();
|
||||
cz = (int)((NumericValue) lv.get(2).evalValue(c)).getLong();
|
||||
if (lv.size()==3)
|
||||
cx = cpos.getX();
|
||||
cy = cpos.getY();
|
||||
cz = cpos.getZ();
|
||||
|
||||
if (lv.size()==cposLocator.offset)
|
||||
{
|
||||
Value retval = ListValue.of(
|
||||
BlockValue.fromCoords(cc, cx, cy-1, cz),
|
||||
@@ -2468,20 +2483,22 @@ public class CarpetExpression
|
||||
);
|
||||
return (_c, _t ) -> retval;
|
||||
}
|
||||
else if (lv.size()==4)
|
||||
else if (lv.size()==1+cposLocator.offset)
|
||||
{
|
||||
width = (int) ((NumericValue) lv.get(3).evalValue(c)).getLong();
|
||||
width = (int) ((NumericValue) lv.get(cposLocator.offset).evalValue(c)).getLong();
|
||||
height = 0;
|
||||
}
|
||||
else // size == 5
|
||||
else if(lv.size()==2+cposLocator.offset)
|
||||
{
|
||||
width = (int) ((NumericValue) lv.get(3).evalValue(c)).getLong();
|
||||
height = (int) ((NumericValue) lv.get(4).evalValue(c)).getLong();
|
||||
width = (int) ((NumericValue) lv.get(cposLocator.offset).evalValue(c)).getLong();
|
||||
height = (int) ((NumericValue) lv.get(cposLocator.offset+1).evalValue(c)).getLong();
|
||||
} else{
|
||||
throw new InternalExpressionException("Incorrect number of arguments for 'diamond'");
|
||||
}
|
||||
}
|
||||
catch (ClassCastException exc)
|
||||
{
|
||||
throw new InternalExpressionException("Attempted to pass a non-number to diamond");
|
||||
throw new InternalExpressionException("Attempted to pass a non-number to 'diamond'");
|
||||
}
|
||||
if (height == 0)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user