refactor access to context data

This commit is contained in:
gnembon committed 2023-01-16 19:01:10 +01:00
1 parent bc31faca21
commit 8dd08d5cb1
15 files changed
+239 -194

No files matched your search

@@ -208,7 +208,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
if (strVal.equals("enderchest"))
{
Value v2 = params.get(1 + offset);
ServerPlayer player = EntityValue.getPlayerByValue(c.s.getServer(), v2);
ServerPlayer player = EntityValue.getPlayerByValue(c.server(), v2);
if (player == null) throw new InternalExpressionException("enderchest inventory requires player argument");
return new InventoryLocator(player, player.blockPosition(), player.getEnderChestInventory(), offset + 2, true);
}
@@ -222,7 +222,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
}
boolean isEnder = strVal.startsWith("enderchest_");
if (isEnder) strVal = strVal.substring(11); // len("enderchest_")
ServerPlayer player = c.s.getServer().getPlayerList().getPlayerByName(strVal);
ServerPlayer player = c.server().getPlayerList().getPlayerByName(strVal);
if (player == null) throw new InternalExpressionException("String description of an inventory should either denote a player or player's enderchest");
return new InventoryLocator(
player,
@@ -251,7 +251,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
BlockPos pos = ((BlockValue) v1).getPos();
if (pos == null)
throw new InternalExpressionException("Block to access inventory needs to be positioned in the world");
Container inv = getInventoryAt(c.s.getLevel(), pos);
Container inv = getInventoryAt(c.level(), pos);
if (inv == null)
return null;
return new InventoryLocator(pos, pos, inv, offset+1);
@@ -263,7 +263,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
NumericValue.asNumber(args.get(0)).getDouble(),
NumericValue.asNumber(args.get(1)).getDouble(),
NumericValue.asNumber(args.get(2)).getDouble());
Container inv = getInventoryAt(c.s.getLevel(), pos);
Container inv = getInventoryAt(c.level(), pos);
if (inv == null)
return null;
return new InventoryLocator(pos, pos, inv, offset+1);
@@ -277,7 +277,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
NumericValue.asNumber(v1).getDouble(),
NumericValue.asNumber(params.get(1 + offset)).getDouble(),
NumericValue.asNumber(params.get(2 + offset)).getDouble());
Container inv = getInventoryAt(c.s.getLevel(), pos);
Container inv = getInventoryAt(c.level(), pos);
if (inv == null)
return null;
return new InventoryLocator(pos, pos, inv, offset + 3);