Merge branch 'master' into 1.15
This commit is contained in:
commit
671cad22bb
7 files changed
+52
-17
No files matched your search
@@ -2,7 +2,6 @@ package carpet.script.value;
|
||||
|
||||
import carpet.script.Context;
|
||||
import carpet.script.Expression;
|
||||
import carpet.script.ExpressionInspector;
|
||||
import carpet.script.Fluff;
|
||||
import carpet.script.LazyValue;
|
||||
import carpet.script.Tokenizer;
|
||||
@@ -14,9 +13,11 @@ import carpet.script.exception.InternalExpressionException;
|
||||
import carpet.script.exception.ReturnStatement;
|
||||
import carpet.script.exception.ThrowStatement;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class FunctionValue extends Value implements Fluff.ILazyFunction
|
||||
{
|
||||
@@ -57,6 +58,16 @@ public class FunctionValue extends Value implements Fluff.ILazyFunction
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrettyString()
|
||||
{
|
||||
List<String> stringArgs= new ArrayList<>(args);
|
||||
if (outerState != null)
|
||||
stringArgs.addAll(outerState.entrySet().stream().map(e ->
|
||||
"outer("+e.getKey()+") = "+e.getValue().evalValue(null).getPrettyString()).collect(Collectors.toList()));
|
||||
return (name.equals("_")?"<lambda>":name) +"("+String.join(", ",stringArgs)+")";
|
||||
}
|
||||
|
||||
public String fullName() {return expression.module == null?name:name+"["+expression.module.getName()+"]";}
|
||||
|
||||
@Override
|
||||
@@ -107,6 +118,12 @@ public class FunctionValue extends Value implements Fluff.ILazyFunction
|
||||
throw new InternalExpressionException("Function value has no numeric value");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeString()
|
||||
{
|
||||
return "function";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Value slice(long from, long to)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,6 @@ import net.minecraft.block.ChestBlock;
|
||||
import net.minecraft.block.InventoryProvider;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.ChestBlockEntity;
|
||||
import net.minecraft.block.entity.HopperBlockEntity;
|
||||
import net.minecraft.command.arguments.ItemStackArgument;
|
||||
import net.minecraft.command.arguments.ItemStringReader;
|
||||
import net.minecraft.command.arguments.NbtPathArgumentType;
|
||||
@@ -32,7 +31,6 @@ import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@@ -201,6 +199,17 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
|
||||
return null;
|
||||
return new InventoryLocator(pos, pos, inv, offset + 1);
|
||||
}
|
||||
else if (v1.getString().equalsIgnoreCase("enderchest"))
|
||||
{
|
||||
Value v2 = params.get(1 + offset).evalValue(c);
|
||||
if (!(v2 instanceof EntityValue) || !(((EntityValue) v2).getEntity() instanceof PlayerEntity))
|
||||
{
|
||||
throw new InternalExpressionException("enderchest inventory requires player argument");
|
||||
}
|
||||
PlayerEntity e = (PlayerEntity)((EntityValue) v2).getEntity();
|
||||
inv = e.getEnderChestInventory();
|
||||
return new InventoryLocator(e, e.getBlockPos(), inv, offset + 2, true);
|
||||
}
|
||||
BlockPos pos = new BlockPos(
|
||||
NumericValue.asNumber(v1).getDouble(),
|
||||
NumericValue.asNumber(params.get(1 + offset).evalValue(c)).getDouble(),
|
||||
@@ -516,12 +525,19 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
|
||||
public BlockPos position;
|
||||
public Inventory inventory;
|
||||
public int offset;
|
||||
public boolean isEnder;
|
||||
InventoryLocator(Object owner, BlockPos pos, Inventory i, int o)
|
||||
{
|
||||
this(owner, pos, i, o, false);
|
||||
}
|
||||
|
||||
InventoryLocator(Object owner, BlockPos pos, Inventory i, int o, boolean isEnder)
|
||||
{
|
||||
this.owner = owner;
|
||||
position = pos;
|
||||
inventory = i;
|
||||
offset = o;
|
||||
this.isEnder = isEnder;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public class NumericValue extends Value
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.format("%.3f..", getDouble());
|
||||
return String.format("%.1f..", getDouble());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user