This commit is contained in:
gnembon committed 2021-04-02 18:38:55 -03:00
1 parent 3756ca9f86
commit 5dd2a12aa7
20 files changed
+61 -79

No files matched your search

@@ -15,11 +15,11 @@ 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.class_6067;
import net.minecraft.command.argument.ItemStackArgument;
import net.minecraft.command.argument.ItemStringReader;
import net.minecraft.command.argument.NbtPathArgumentType;
import net.minecraft.entity.Entity;
import net.minecraft.entity.InventoryOwner;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.passive.MerchantEntity;
@@ -226,8 +226,8 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
Entity e = ((EntityValue) v1).getEntity();
if (e instanceof PlayerEntity) inv = ((PlayerEntity) e).getInventory();
else if (e instanceof Inventory) inv = (Inventory) e;
else if (e instanceof class_6067) inv = ((class_6067) e).method_35199(); // getInentory // now covers pillagers
else if (e instanceof InventoryBearerInterface) inv = ((InventoryBearerInterface)e).getCMInventory();
else if (e instanceof InventoryOwner) inv = ((InventoryOwner) e).getInventory();
else if (e instanceof InventoryBearerInterface) inv = ((InventoryBearerInterface)e).getCMInventory(); // horse only
else if (e instanceof LivingEntity) return new InventoryLocator(e, e.getBlockPos(), new EquipmentInventory((MobEntity) e), offset+1);
if (inv == null)
return null;
@@ -302,27 +302,32 @@ public class ValueConversions
);
}
public static Value of(BlockBox box)
{
return ListValue.of(
ListValue.fromTriple(box.getMinX(), box.getMinY(), box.getMinZ()),
ListValue.fromTriple(box.getMaxX(), box.getMaxY(), box.getMaxZ())
);
}
public static Value of(StructureStart<?> structure)
{
if (structure == null || structure == StructureStart.DEFAULT) return Value.NULL;
BlockBox boundingBox = structure.setBoundingBoxFromChildren();
if (boundingBox.method_35417() < boundingBox.method_35420() || boundingBox.method_35418() < boundingBox.method_35415() || boundingBox.method_35419() < boundingBox.method_35416()) return Value.NULL;
if (boundingBox.getMaxX() < boundingBox.getMinX() || boundingBox.getMaxY() < boundingBox.getMinY() || boundingBox.getMaxZ() < boundingBox.getMinZ()) return Value.NULL;
Map<Value, Value> ret = new HashMap<>();
ret.put(new StringValue("box"), ListValue.of(
ListValue.fromTriple(boundingBox.method_35420(), boundingBox.method_35415(), boundingBox.method_35416()),
ListValue.fromTriple(boundingBox.method_35417(), boundingBox.method_35418(), boundingBox.method_35419())
));
ret.put(new StringValue("box"), of(boundingBox));
List<Value> pieces = new ArrayList<>();
for (StructurePiece piece : structure.getChildren())
{
BlockBox box = piece.getBoundingBox();
if (box.method_35417() >= box.method_35420() && box.method_35418() >= box.method_35415() && box.method_35419() >= box.method_35416())
if (box.getMaxX() >= box.getMinX() && box.getMaxY() >= box.getMinY() && box.getMaxZ() >= box.getMinZ())
{
pieces.add(ListValue.of(
new StringValue(NBTSerializableValue.nameFromRegistryId(Registry.STRUCTURE_PIECE.getId(piece.getType()))),
(piece.getFacing() == null) ? Value.NULL : new StringValue(piece.getFacing().getName()),
ListValue.fromTriple(box.method_35420(), box.method_35415(), box.method_35416()),
ListValue.fromTriple(box.method_35417(), box.method_35418(), box.method_35419())
ListValue.fromTriple(box.getMinX(), box.getMinY(), box.getMinZ()),
ListValue.fromTriple(box.getMaxX(), box.getMaxY(), box.getMaxZ())
));
}
}