Merge branch 'master' into 1.16
This commit is contained in:
commit
bba9f4e88d
5 files changed
+55
-6
No files matched your search
+10
-2
@@ -431,9 +431,16 @@ $);
|
|||||||
Allows to add the results of two expressions. If the operands resolve to numbers, the result is arithmetic operation.
|
Allows to add the results of two expressions. If the operands resolve to numbers, the result is arithmetic operation.
|
||||||
In case of strings, adding or subtracting from a string results in string concatenation and removal of substrings
|
In case of strings, adding or subtracting from a string results in string concatenation and removal of substrings
|
||||||
from that string. Multiplication of strings and numbers results in repeating the string N times and division results
|
from that string. Multiplication of strings and numbers results in repeating the string N times and division results
|
||||||
in taking the first k'th part of the string, so that `str*n/n ~ str` In case first operand is a list, either it
|
in taking the first k'th part of the string, so that `str*n/n ~ str`
|
||||||
|
|
||||||
|
In case first operand is a list, either it
|
||||||
results in a new list with all elements modified one by one with the other operand, or if the operand is a list
|
results in a new list with all elements modified one by one with the other operand, or if the operand is a list
|
||||||
with the same number of items - element-wise addition/subtraction
|
with the same number of items - element-wise addition/subtraction. This prioritize treating lists as value containers
|
||||||
|
to lists treated as vectors.
|
||||||
|
|
||||||
|
Addition with maps (`{}` or `m()`) results in a new map with keys from both maps added, if both operands are maps,
|
||||||
|
adding elements of the right argument to the keys, of left map, or just adding the right value as a new key
|
||||||
|
in the output map.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
@@ -447,6 +454,7 @@ Examples:
|
|||||||
'foofoofoo'-'o' => 'fff'
|
'foofoofoo'-'o' => 'fff'
|
||||||
l(1,2,3)+1 => l(2,3,4)
|
l(1,2,3)+1 => l(2,3,4)
|
||||||
b = l(100,63,100); b+l(10,0,10) => l(110,63,110)
|
b = l(100,63,100); b+l(10,0,10) => l(110,63,110)
|
||||||
|
{'a' -> 1} + {'b' -> 2} => {'a' -> 1, 'b' -> 2}
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
### `Just Operators % ^`
|
### `Just Operators % ^`
|
||||||
|
|||||||
@@ -110,9 +110,16 @@ $);
|
|||||||
Allows to add the results of two expressions. If the operands resolve to numbers, the result is arithmetic operation.
|
Allows to add the results of two expressions. If the operands resolve to numbers, the result is arithmetic operation.
|
||||||
In case of strings, adding or subtracting from a string results in string concatenation and removal of substrings
|
In case of strings, adding or subtracting from a string results in string concatenation and removal of substrings
|
||||||
from that string. Multiplication of strings and numbers results in repeating the string N times and division results
|
from that string. Multiplication of strings and numbers results in repeating the string N times and division results
|
||||||
in taking the first k'th part of the string, so that `str*n/n ~ str` In case first operand is a list, either it
|
in taking the first k'th part of the string, so that `str*n/n ~ str`
|
||||||
|
|
||||||
|
In case first operand is a list, either it
|
||||||
results in a new list with all elements modified one by one with the other operand, or if the operand is a list
|
results in a new list with all elements modified one by one with the other operand, or if the operand is a list
|
||||||
with the same number of items - element-wise addition/subtraction
|
with the same number of items - element-wise addition/subtraction. This prioritize treating lists as value containers
|
||||||
|
to lists treated as vectors.
|
||||||
|
|
||||||
|
Addition with maps (`{}` or `m()`) results in a new map with keys from both maps added, if both operands are maps,
|
||||||
|
adding elements of the right argument to the keys, of left map, or just adding the right value as a new key
|
||||||
|
in the output map.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
@@ -126,6 +133,7 @@ Examples:
|
|||||||
'foofoofoo'-'o' => 'fff'
|
'foofoofoo'-'o' => 'fff'
|
||||||
l(1,2,3)+1 => l(2,3,4)
|
l(1,2,3)+1 => l(2,3,4)
|
||||||
b = l(100,63,100); b+l(10,0,10) => l(110,63,110)
|
b = l(100,63,100); b+l(10,0,10) => l(110,63,110)
|
||||||
|
{'a' -> 1} + {'b' -> 2} => {'a' -> 1, 'b' -> 2}
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
### `Just Operators % ^`
|
### `Just Operators % ^`
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ public class PlayerCommand
|
|||||||
.then(literal("west").executes(manipulation(ap -> ap.look(Direction.WEST))))
|
.then(literal("west").executes(manipulation(ap -> ap.look(Direction.WEST))))
|
||||||
.then(literal("up").executes(manipulation(ap -> ap.look(Direction.UP))))
|
.then(literal("up").executes(manipulation(ap -> ap.look(Direction.UP))))
|
||||||
.then(literal("down").executes(manipulation(ap -> ap.look(Direction.DOWN))))
|
.then(literal("down").executes(manipulation(ap -> ap.look(Direction.DOWN))))
|
||||||
|
.then(literal("at").then(argument("position", Vec3ArgumentType.vec3()).executes(PlayerCommand::lookAt)))
|
||||||
.then(argument("direction", RotationArgumentType.rotation())
|
.then(argument("direction", RotationArgumentType.rotation())
|
||||||
.executes(c -> manipulate(c, ap -> ap.look(RotationArgumentType.getRotation(c, "direction").toAbsoluteRotation(c.getSource())))))
|
.executes(c -> manipulate(c, ap -> ap.look(RotationArgumentType.getRotation(c, "direction").toAbsoluteRotation(c.getSource())))))
|
||||||
).then(literal("turn")
|
).then(literal("turn")
|
||||||
@@ -206,6 +207,15 @@ public class PlayerCommand
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int lookAt(CommandContext<ServerCommandSource> context)
|
||||||
|
{
|
||||||
|
return manipulate(context, ap -> {
|
||||||
|
try {
|
||||||
|
ap.lookAt(Vec3ArgumentType.getVec3(context, "position"));
|
||||||
|
} catch (CommandSyntaxException ignored) {}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
interface SupplierWithCommandSyntaxException<T>
|
interface SupplierWithCommandSyntaxException<T>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package carpet.helpers;
|
|||||||
|
|
||||||
import carpet.fakes.ServerPlayerEntityInterface;
|
import carpet.fakes.ServerPlayerEntityInterface;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.command.arguments.EntityAnchorArgumentType;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.passive.HorseBaseEntity;
|
import net.minecraft.entity.passive.HorseBaseEntity;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
@@ -127,6 +128,12 @@ public class EntityPlayerActionPack
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EntityPlayerActionPack lookAt(Vec3d position)
|
||||||
|
{
|
||||||
|
player.lookAt(EntityAnchorArgumentType.EntityAnchor.EYES, position);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public EntityPlayerActionPack turn(float yaw, float pitch)
|
public EntityPlayerActionPack turn(float yaw, float pitch)
|
||||||
{
|
{
|
||||||
return look(player.yaw + yaw, player.pitch + pitch);
|
return look(player.yaw + yaw, player.pitch + pitch);
|
||||||
|
|||||||
@@ -97,8 +97,24 @@ public class MapValue extends AbstractListValue implements ContainerValueInterfa
|
|||||||
@Override
|
@Override
|
||||||
public Value add(Value o)
|
public Value add(Value o)
|
||||||
{
|
{
|
||||||
append(o);
|
Map<Value, Value> newItems = new HashMap<>(map);
|
||||||
return this;
|
if (o instanceof MapValue)
|
||||||
|
{
|
||||||
|
newItems.putAll(((MapValue) o).map);
|
||||||
|
}
|
||||||
|
else if (o instanceof AbstractListValue)
|
||||||
|
{
|
||||||
|
Iterator<Value> it = ((AbstractListValue) o).iterator();
|
||||||
|
while (it.hasNext())
|
||||||
|
{
|
||||||
|
newItems.put(it.next(), Value.NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newItems.put(o, Value.NULL);
|
||||||
|
}
|
||||||
|
return MapValue.wrap(newItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in new issue
Block a user