its a doozie

This commit is contained in:
gnembon committed 2021-03-24 10:35:52 -03:00
1 parent 365892b9ca
commit ab553187c5
43 files changed
+356 -351

No files matched your search

+13 -13
View File
@@ -51,11 +51,11 @@ import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.decoration.ArmorStandEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtHelper;
import net.minecraft.nbt.NbtOps;
import net.minecraft.nbt.StringTag;
import net.minecraft.nbt.Tag;
import net.minecraft.nbt.NbtString;
import net.minecraft.nbt.NbtElement;
import net.minecraft.network.Packet;
import net.minecraft.network.packet.s2c.play.ClearTitleS2CPacket;
import net.minecraft.network.packet.s2c.play.OverlayMessageS2CPacket;
@@ -459,7 +459,7 @@ public class Auxiliary {
expression.addLazyFunction("escape_nbt", 1, (c, t, lv) -> {
Value v = lv.get(0).evalValue(c);
String string = v.getString();
Value ret = new StringValue(StringTag.escape(string));
Value ret = new StringValue(NbtString.escape(string));
return (cc, tt) -> ret;
});
@@ -482,8 +482,8 @@ public class Auxiliary {
if (numParam != 2 && numParam != 3) throw new InternalExpressionException("'tag_matches' requires 2 or 3 arguments");
if (lv.get(1).isNull()) return Value.TRUE;
if (lv.get(0).isNull()) return Value.FALSE;
Tag source = ((NBTSerializableValue)(NBTSerializableValue.fromValue(lv.get(0)))).getTag();
Tag match = ((NBTSerializableValue)(NBTSerializableValue.fromValue(lv.get(1)))).getTag();
NbtElement source = ((NBTSerializableValue)(NBTSerializableValue.fromValue(lv.get(0)))).getTag();
NbtElement match = ((NBTSerializableValue)(NBTSerializableValue.fromValue(lv.get(1)))).getTag();
return new NumericValue(NbtHelper.matches(match, source, numParam == 2 || lv.get(2).getBoolean()));
});
@@ -492,7 +492,7 @@ public class Auxiliary {
if (argSize==0 || argSize > 2) throw new InternalExpressionException("'encode_nbt' requires 1 or 2 parameters");
Value v = lv.get(0).evalValue(c);
boolean force = (argSize > 1) && lv.get(1).evalValue(c).getBoolean();
Tag tag;
NbtElement tag;
try
{
tag = v.toTag(force);
@@ -877,7 +877,7 @@ public class Auxiliary {
Value retVal;
if (fdesc.type == FileArgument.Type.NBT)
{
Tag state = ((CarpetScriptHost) c.host).readFileTag(fdesc);
NbtElement state = ((CarpetScriptHost) c.host).readFileTag(fdesc);
if (state == null) return LazyValue.NULL;
retVal = new NBTSerializableValue(state);
}
@@ -916,7 +916,7 @@ public class Auxiliary {
NBTSerializableValue tagValue = (val instanceof NBTSerializableValue)
? (NBTSerializableValue) val
: new NBTSerializableValue(val.getString());
Tag tag = tagValue.getTag();
NbtElement tag = tagValue.getTag();
success = ((CarpetScriptHost) c.host).writeTagFile(tag, fdesc);
}
else if (fdesc.type == FileArgument.Type.JSON)
@@ -963,7 +963,7 @@ public class Auxiliary {
boolean shared = lv.size() > 1 && lv.get(1).evalValue(c).getBoolean();
fdesc = new FileArgument(resource, FileArgument.Type.NBT, null, false, shared, FileArgument.Reason.READ);
}
Tag state = ((CarpetScriptHost) c.host).readFileTag(fdesc);
NbtElement state = ((CarpetScriptHost) c.host).readFileTag(fdesc);
if (state == null)
return (cc, tt) -> Value.NULL;
Value retVal = new NBTSerializableValue(state);
@@ -986,7 +986,7 @@ public class Auxiliary {
NBTSerializableValue tagValue = (val instanceof NBTSerializableValue)
? (NBTSerializableValue) val
: new NBTSerializableValue(val.getString());
Tag tag = tagValue.getTag();
NbtElement tag = tagValue.getTag();
boolean success = ((CarpetScriptHost) c.host).writeTagFile(tag, fdesc);
return success?LazyValue.TRUE:LazyValue.FALSE;
});
@@ -1074,7 +1074,7 @@ public class Auxiliary {
return (_c, _t) -> ret;
}
String key = lv.get(0).evalValue(c).getString();
CompoundTag old_nbt = storage.get(new Identifier(key));
NbtCompound old_nbt = storage.get(new Identifier(key));
if (lv.size() == 2) {
Value nbt = lv.get(1).evalValue(c);
NBTSerializableValue new_nbt = (nbt instanceof NBTSerializableValue) ? (NBTSerializableValue) nbt
@@ -1170,7 +1170,7 @@ public class Auxiliary {
//not sure its needed, but doesn't seem to have a negative effect and might be used in some custom shtuff
serverRM.loadRegistryTags();
RegistryOps<Tag> registryOps = RegistryOps.of(NbtOps.INSTANCE, serverRM.getResourceManager(), (DynamicRegistryManager.Impl) server.getRegistryManager());
RegistryOps<NbtElement> registryOps = RegistryOps.of(NbtOps.INSTANCE, serverRM.getResourceManager(), (DynamicRegistryManager.Impl) server.getRegistryManager());
SaveProperties saveProperties = session.readLevelProperties(registryOps, dataPackSettings2);
if (saveProperties == null) return LazyValue.NULL;
//session.backupLevelDataFile(server.getRegistryManager(), saveProperties); // no need
@@ -21,7 +21,7 @@ import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnReason;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.predicate.entity.EntityPredicates;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
@@ -140,7 +140,7 @@ public class Entities {
Vector3Argument position = Vector3Argument.findIn(cc, lv, 1);
if (position.fromBlock)
position.vec = position.vec.subtract(0, 0.5, 0);
CompoundTag tag = new CompoundTag();
NbtCompound tag = new NbtCompound();
boolean hasTag = false;
if (lv.size() > position.offset)
{
@@ -25,7 +25,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket;
import net.minecraft.recipe.AbstractCookingRecipe;
import net.minecraft.recipe.CuttingRecipe;
@@ -35,6 +35,7 @@ import net.minecraft.recipe.ShapedRecipe;
import net.minecraft.recipe.ShapelessRecipe;
import net.minecraft.recipe.SpecialCraftingRecipe;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.tag.Tag;
import net.minecraft.tag.TagManager;
import net.minecraft.util.Identifier;
import net.minecraft.util.InvalidIdentifierException;
@@ -97,7 +98,7 @@ public class Inventories {
return (_c, _t) -> ret;
}
String tag = lv.get(1).evalValue(c).getString();
net.minecraft.tag.Tag<Item> itemTag = tagManager.getOrCreateTagGroup(Registry.ITEM_KEY).getTag(new Identifier(tag));
Tag<Item> itemTag = tagManager.getOrCreateTagGroup(Registry.ITEM_KEY).getTag(new Identifier(tag));
if (itemTag == null) return LazyValue.NULL;
return itemTag.contains(item)?LazyValue.TRUE:LazyValue.FALSE;
});
@@ -277,7 +278,7 @@ public class Inventories {
syncPlayerInventory(inventoryLocator, slot);
return (_c, _t) -> ListValue.fromItemStack(previousStack);
}
CompoundTag nbt = null; // skipping one argument
NbtCompound nbt = null; // skipping one argument
if (lv.size() > inventoryLocator.offset+3)
{
Value nbtValue = lv.get(inventoryLocator.offset+3).evalValue(c);
@@ -59,8 +59,8 @@ import net.minecraft.item.MiningToolItem;
import net.minecraft.item.ShearsItem;
import net.minecraft.item.SwordItem;
import net.minecraft.item.TridentItem;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ChunkTicket;
import net.minecraft.server.world.ChunkTicketType;
@@ -70,6 +70,7 @@ import net.minecraft.sound.SoundCategory;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.Property;
import net.minecraft.structure.StructureStart;
import net.minecraft.tag.Tag;
import net.minecraft.tag.TagManager;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Clearable;
@@ -289,7 +290,7 @@ public class WorldAccess {
{
throw new InternalExpressionException("Block requires at least one parameter");
}
CompoundTag tag = BlockArgument.findIn(cc, lv, 0, true).block.getData();
NbtCompound tag = BlockArgument.findIn(cc, lv, 0, true).block.getData();
if (tag == null)
return (c_, t_) -> Value.NULL;
Value retval = new NBTSerializableValue(tag);
@@ -756,7 +757,7 @@ public class WorldAccess {
BlockArgument sourceLocator = BlockArgument.findIn(cc, lv, targetLocator.offset, true);
BlockState sourceBlockState = sourceLocator.block.getBlockState();
BlockState targetBlockState = world.getBlockState(targetLocator.block.getPos());
CompoundTag data = null;
NbtCompound data = null;
if (lv.size() > sourceLocator.offset)
{
List<Value> args = new ArrayList<>();
@@ -815,7 +816,7 @@ public class WorldAccess {
}
if (data == null) data = sourceLocator.block.getData();
CompoundTag finalData = data;
NbtCompound finalData = data;
if (sourceBlockState == targetBlockState && data == null)
return (c_, t_) -> Value.FALSE;
@@ -831,7 +832,7 @@ public class WorldAccess {
BlockEntity be = world.getBlockEntity(targetPos);
if (be != null)
{
CompoundTag destTag = finalData.copy();
NbtCompound destTag = finalData.copy();
destTag.putInt("x", targetPos.getX());
destTag.putInt("y", targetPos.getY());
destTag.putInt("z", targetPos.getZ());
@@ -875,7 +876,7 @@ public class WorldAccess {
.orElseThrow(() -> new ThrowStatement(itemString, Throwables.UNKNOWN_ITEM));
}
}
CompoundTag tag = null;
NbtCompound tag = null;
if (lv.size() > locator.offset+1)
{
if (!playerBreak) throw new InternalExpressionException("tag is not necessary with 'destroy' with no item");
@@ -937,7 +938,7 @@ public class WorldAccess {
return (c_, t_) -> Value.TRUE;
if (toolBroke)
return LazyValue.NULL;
Tag outtag = tool.getTag();
NbtElement outtag = tool.getTag();
if (outtag == null)
return LazyValue.TRUE;
Value ret = new NBTSerializableValue(() -> outtag);
@@ -1130,7 +1131,7 @@ public class WorldAccess {
return (_c, _t) -> ret;
}
String tag = lv.get(blockLocator.offset).evalValue(c).getString();
net.minecraft.tag.Tag<Block> blockTag = tagManager.getOrCreateTagGroup(Registry.BLOCK_KEY).getTag(new Identifier(tag));
Tag<Block> blockTag = tagManager.getOrCreateTagGroup(Registry.BLOCK_KEY).getTag(new Identifier(tag));
if (blockTag == null) return LazyValue.NULL;
return blockLocator.block.getBlockState().isIn(blockTag)?LazyValue.TRUE:LazyValue.FALSE;
});
@@ -1354,7 +1355,7 @@ public class WorldAccess {
return;
}
StructureStart<?> start = structures.get(structure);
ChunkPos structureChunkPos = start.method_34000(); // new ChunkPos(start.getChunkX(), start.getChunkZ());
ChunkPos structureChunkPos = start.getPos(); // new ChunkPos(start.getChunkX(), start.getChunkZ());
BlockBox box = start.getBoundingBox();
for (int chx = box.minX / 16; chx <= box.maxX / 16; chx++)
{