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

+2 -2
View File
@@ -5,9 +5,9 @@ org.gradle.jvmargs=-Xmx1G
# check these on https://fabricmc.net/use # check these on https://fabricmc.net/use
# or better: https://modmuss50.me/fabric.html # or better: https://modmuss50.me/fabric.html
minecraft_version=21w11a minecraft_version=21w11a
yarn_mappings=21w11a+build.2 yarn_mappings=21w11a+build.20
loader_version=0.11.3 loader_version=0.11.3
fabric_version=0.32.2+1.17 fabric_version=0.32.5+1.17
# Mod Properties # Mod Properties
mod_version = 1.4.30 mod_version = 1.4.30
@@ -13,7 +13,7 @@ import net.minecraft.entity.mob.MobEntity;
import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.command.argument.BlockPosArgumentType; import net.minecraft.command.argument.BlockPosArgumentType;
import net.minecraft.command.argument.EntitySummonArgumentType; import net.minecraft.command.argument.EntitySummonArgumentType;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import static net.minecraft.server.command.CommandManager.argument; import static net.minecraft.server.command.CommandManager.argument;
@@ -46,7 +46,7 @@ public class PerimeterInfoCommand
private static int perimeterDiagnose(ServerCommandSource source, BlockPos pos, String mobId) private static int perimeterDiagnose(ServerCommandSource source, BlockPos pos, String mobId)
{ {
CompoundTag nbttagcompound = new CompoundTag(); NbtCompound nbttagcompound = new NbtCompound();
MobEntity entityliving = null; MobEntity entityliving = null;
if (mobId != null) if (mobId != null)
{ {
@@ -3,7 +3,7 @@ package carpet.fakes;
import carpet.script.value.Value; import carpet.script.value.Value;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.tag.Tag; import net.minecraft.tag.Tag;
import java.util.Map; import java.util.Map;
@@ -13,5 +13,5 @@ public interface BlockPredicateInterface
BlockState getCMBlockState(); BlockState getCMBlockState();
Tag<Block> getCMBlockTag(); Tag<Block> getCMBlockTag();
Map<Value, Value> getCMProperties(); Map<Value, Value> getCMProperties();
CompoundTag getCMDataTag(); NbtCompound getCMDataTag();
} }
@@ -1,8 +1,8 @@
package carpet.fakes; package carpet.fakes;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
public interface BlockStateArgumentInterface public interface BlockStateArgumentInterface
{ {
CompoundTag getCMTag(); NbtCompound getCMTag();
} }
@@ -1,11 +1,11 @@
package carpet.helpers; package carpet.helpers;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
public class InventoryHelper public class InventoryHelper
{ {
// From nbt/Tag.java createTag() // From nbt/NbtElement.java createTag()
public static final int TAG_END = 0; public static final int TAG_END = 0;
public static final int TAG_BYTE = 1; public static final int TAG_BYTE = 1;
public static final int TAG_SHORT = 2; public static final int TAG_SHORT = 2;
@@ -23,12 +23,12 @@ public class InventoryHelper
public static boolean cleanUpShulkerBoxTag(ItemStack stack) public static boolean cleanUpShulkerBoxTag(ItemStack stack)
{ {
boolean changed = false; boolean changed = false;
CompoundTag tag = stack.getTag(); NbtCompound tag = stack.getTag();
if (tag == null || !tag.contains("BlockEntityTag", TAG_COMPOUND)) if (tag == null || !tag.contains("BlockEntityTag", TAG_COMPOUND))
return false; return false;
CompoundTag bet = tag.getCompound("BlockEntityTag"); NbtCompound bet = tag.getCompound("BlockEntityTag");
if (bet.contains("Items", TAG_LIST) && bet.getList("Items", TAG_COMPOUND).isEmpty()) if (bet.contains("Items", TAG_LIST) && bet.getList("Items", TAG_COMPOUND).isEmpty())
{ {
bet.remove("Items"); bet.remove("Items");
@@ -50,12 +50,12 @@ public class InventoryHelper
public static boolean shulkerBoxHasItems(ItemStack stack) public static boolean shulkerBoxHasItems(ItemStack stack)
{ {
CompoundTag tag = stack.getTag(); NbtCompound tag = stack.getTag();
if (tag == null || !tag.contains("BlockEntityTag", TAG_COMPOUND)) if (tag == null || !tag.contains("BlockEntityTag", TAG_COMPOUND))
return false; return false;
CompoundTag bet = tag.getCompound("BlockEntityTag"); NbtCompound bet = tag.getCompound("BlockEntityTag");
return bet.contains("Items", TAG_LIST) && !bet.getList("Items", TAG_COMPOUND).isEmpty(); return bet.contains("Items", TAG_LIST) && !bet.getList("Items", TAG_COMPOUND).isEmpty();
} }
} }
@@ -9,6 +9,8 @@ import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(BaseRangeDecorator.class) @Mixin(BaseRangeDecorator.class)
public class BaseRangeDecorator_cleanLogsMixin { public class BaseRangeDecorator_cleanLogsMixin {
@SuppressWarnings("UnresolvedMixinReference")
@Redirect(method = "getY(Lnet/minecraft/world/gen/decorator/DecoratorContext;Ljava/util/Random;Lnet/minecraft/world/gen/decorator/RangeDecoratorConfig;I)I", @Redirect(method = "getY(Lnet/minecraft/world/gen/decorator/DecoratorContext;Ljava/util/Random;Lnet/minecraft/world/gen/decorator/RangeDecoratorConfig;I)I",
at = @At(value = "INVOKE", target = "Lorg/apache/logging/log4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V") at = @At(value = "INVOKE", target = "Lorg/apache/logging/log4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V")
) )
@@ -2,7 +2,7 @@ package carpet.mixins;
import carpet.fakes.BlockStateArgumentInterface; import carpet.fakes.BlockStateArgumentInterface;
import net.minecraft.command.argument.BlockStateArgument; import net.minecraft.command.argument.BlockStateArgument;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@@ -11,10 +11,10 @@ import org.spongepowered.asm.mixin.Shadow;
@Mixin(BlockStateArgument.class) @Mixin(BlockStateArgument.class)
public class BlockStateArgument_scarpetMixin implements BlockStateArgumentInterface public class BlockStateArgument_scarpetMixin implements BlockStateArgumentInterface
{ {
@Shadow @Final private @Nullable CompoundTag data; @Shadow @Final private @Nullable NbtCompound data;
@Override @Override
public CompoundTag getCMTag() public NbtCompound getCMTag()
{ {
return data; return data;
} }
@@ -8,7 +8,7 @@ import net.minecraft.entity.SpawnReason;
import net.minecraft.entity.mob.ElderGuardianEntity; import net.minecraft.entity.mob.ElderGuardianEntity;
import net.minecraft.entity.mob.GuardianEntity; import net.minecraft.entity.mob.GuardianEntity;
import net.minecraft.entity.mob.HostileEntity; import net.minecraft.entity.mob.HostileEntity;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.World; import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@@ -28,7 +28,7 @@ public abstract class GuardianEntityMixin extends HostileEntity
{ {
ElderGuardianEntity elderGuardian = new ElderGuardianEntity(EntityType.ELDER_GUARDIAN ,this.world); ElderGuardianEntity elderGuardian = new ElderGuardianEntity(EntityType.ELDER_GUARDIAN ,this.world);
elderGuardian.refreshPositionAndAngles(this.getX(), this.getY(), this.getZ(), this.yaw, this.pitch); elderGuardian.refreshPositionAndAngles(this.getX(), this.getY(), this.getZ(), this.yaw, this.pitch);
elderGuardian.initialize(serverWorld ,this.world.getLocalDifficulty(elderGuardian.getBlockPos()), SpawnReason.CONVERSION, (EntityData)null, (CompoundTag)null); elderGuardian.initialize(serverWorld ,this.world.getLocalDifficulty(elderGuardian.getBlockPos()), SpawnReason.CONVERSION, (EntityData)null, (NbtCompound)null);
elderGuardian.setAiDisabled(this.isAiDisabled()); elderGuardian.setAiDisabled(this.isAiDisabled());
if (this.hasCustomName()) if (this.hasCustomName())
@@ -10,7 +10,7 @@ import net.minecraft.block.Blocks;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.block.entity.PistonBlockEntity; import net.minecraft.block.entity.PistonBlockEntity;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@@ -128,25 +128,25 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple
} }
@Inject(method = "readNbt", at = @At(value = "TAIL")) @Inject(method = "readNbt", at = @At(value = "TAIL"))
private void onFromTag(CompoundTag compoundTag_1, CallbackInfo ci) private void onFromTag(NbtCompound NbtCompound_1, CallbackInfo ci)
{ {
if (CarpetSettings.movableBlockEntities && compoundTag_1.contains("carriedTileEntityCM", 10)) if (CarpetSettings.movableBlockEntities && NbtCompound_1.contains("carriedTileEntityCM", 10))
{ {
if (this.pushedBlock.getBlock() instanceof BlockEntityProvider) if (this.pushedBlock.getBlock() instanceof BlockEntityProvider)
this.carriedBlockEntity = ((BlockEntityProvider) (this.pushedBlock.getBlock())).createBlockEntity(pos, pushedBlock);// this.world); this.carriedBlockEntity = ((BlockEntityProvider) (this.pushedBlock.getBlock())).createBlockEntity(pos, pushedBlock);// this.world);
if (carriedBlockEntity != null) //Can actually be null, as BlockPistonMoving.createNewTileEntity(...) returns null if (carriedBlockEntity != null) //Can actually be null, as BlockPistonMoving.createNewTileEntity(...) returns null
this.carriedBlockEntity.readNbt(compoundTag_1.getCompound("carriedTileEntityCM")); this.carriedBlockEntity.readNbt(NbtCompound_1.getCompound("carriedTileEntityCM"));
setCarriedBlockEntity(carriedBlockEntity); setCarriedBlockEntity(carriedBlockEntity);
} }
} }
@Inject(method = "writeNbt", at = @At(value = "RETURN", shift = At.Shift.BEFORE)) @Inject(method = "writeNbt", at = @At(value = "RETURN", shift = At.Shift.BEFORE))
private void onToTag(CompoundTag compoundTag_1, CallbackInfoReturnable<CompoundTag> cir) private void onToTag(NbtCompound NbtCompound_1, CallbackInfoReturnable<NbtCompound> cir)
{ {
if (CarpetSettings.movableBlockEntities && this.carriedBlockEntity != null) if (CarpetSettings.movableBlockEntities && this.carriedBlockEntity != null)
{ {
//Leave name "carriedTileEntityCM" instead of "carriedBlockEntityCM" for upgrade compatibility with 1.13.2 movable TE //Leave name "carriedTileEntityCM" instead of "carriedBlockEntityCM" for upgrade compatibility with 1.13.2 movable TE
compoundTag_1.put("carriedTileEntityCM", this.carriedBlockEntity.writeNbt(new CompoundTag())); NbtCompound_1.put("carriedTileEntityCM", this.carriedBlockEntity.writeNbt(new NbtCompound()));
} }
} }
} }
@@ -41,7 +41,7 @@ public abstract class PistonHandler_customStickyMixin
@Shadow protected abstract boolean tryMove(BlockPos blockPos_1, Direction direction_1); @Shadow protected abstract boolean tryMove(BlockPos blockPos_1, Direction direction_1);
@Shadow private static boolean isBlockSticky(BlockState block_1) { return false; } @Shadow private static boolean isBlockSticky(BlockState block_1) { return false; }
@Shadow private static boolean isAdjacentBlockStuck(BlockState block, BlockState block2) {return false;} @Shadow private static boolean isAdjacentBlockStuck(BlockState block, BlockState block2) {return false;}
@Shadow protected abstract boolean canMoveAdjacentBlock(BlockPos pos); @Shadow protected abstract boolean tryMoveAdjacentBlock(BlockPos pos);
// collects information about sticking block when backtracking. // collects information about sticking block when backtracking.
private BlockPos currentPos; private BlockPos currentPos;
@@ -169,7 +169,7 @@ public abstract class PistonHandler_customStickyMixin
BlockState chainState = world.getBlockState(pos); BlockState chainState = world.getBlockState(pos);
// chain is sideways // chain is sideways
if (chainState.getBlock() == Blocks.CHAIN && !isChainOnAxis(chainState, motionDirection) if (chainState.getBlock() == Blocks.CHAIN && !isChainOnAxis(chainState, motionDirection)
&& !this.canMoveAdjacentBlock(pos)) && !this.tryMoveAdjacentBlock(pos))
{ {
cir.setReturnValue(false); cir.setReturnValue(false);
} }
@@ -217,7 +217,7 @@ public abstract class PistonHandler_customStickyMixin
if (CarpetSettings.doChainStone) if (CarpetSettings.doChainStone)
{ {
BlockState chainState = world.getBlockState(blockPos3); BlockState chainState = world.getBlockState(blockPos3);
if (chainState.getBlock() == Blocks.CHAIN && !isChainOnAxis(chainState, motionDirection) && !canMoveAdjacentBlock(blockPos3)) if (chainState.getBlock() == Blocks.CHAIN && !isChainOnAxis(chainState, motionDirection) && !tryMoveAdjacentBlock(blockPos3))
{ {
cir.setReturnValue(false); cir.setReturnValue(false);
} }
@@ -228,7 +228,7 @@ public abstract class PistonHandler_customStickyMixin
/** /**
* Custom movement of blocks stuck to the sides of blocks other than slimeblocks like chains * Custom movement of blocks stuck to the sides of blocks other than slimeblocks like chains
*/ */
@Inject(method = "canMoveAdjacentBlock", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true, at = @At( @Inject(method = "tryMoveAdjacentBlock", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true, at = @At(
value = "INVOKE", value = "INVOKE",
target = "Lnet/minecraft/block/piston/PistonHandler;isAdjacentBlockStuck(Lnet/minecraft/block/BlockState;Lnet/minecraft/block/BlockState;)Z", target = "Lnet/minecraft/block/piston/PistonHandler;isAdjacentBlockStuck(Lnet/minecraft/block/BlockState;Lnet/minecraft/block/BlockState;)Z",
shift = At.Shift.BEFORE shift = At.Shift.BEFORE
@@ -264,7 +264,7 @@ public abstract class PistonHandler_customStickyMixin
* @param block2 * @param block2
* @return * @return
*/ */
@Redirect(method = "canMoveAdjacentBlock", at = @At( @Redirect(method = "tryMoveAdjacentBlock", at = @At(
value = "INVOKE", value = "INVOKE",
target = "Lnet/minecraft/block/piston/PistonHandler;isAdjacentBlockStuck(Lnet/minecraft/block/BlockState;Lnet/minecraft/block/BlockState;)Z") target = "Lnet/minecraft/block/piston/PistonHandler;isAdjacentBlockStuck(Lnet/minecraft/block/BlockState;Lnet/minecraft/block/BlockState;)Z")
) )
@@ -6,7 +6,7 @@ import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.player.PlayerAbilities; import net.minecraft.entity.player.PlayerAbilities;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.world.World; import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@@ -24,15 +24,15 @@ public abstract class PlayerEntity_parrotMixin extends LivingEntity
@Shadow protected abstract void dropShoulderEntities(); @Shadow protected abstract void dropShoulderEntities();
@Shadow public abstract CompoundTag getShoulderEntityLeft(); @Shadow public abstract NbtCompound getShoulderEntityLeft();
@Shadow protected abstract void setShoulderEntityLeft(CompoundTag compoundTag_1); @Shadow protected abstract void setShoulderEntityLeft(NbtCompound NbtCompound_1);
@Shadow protected abstract void setShoulderEntityRight(CompoundTag compoundTag_1); @Shadow protected abstract void setShoulderEntityRight(NbtCompound NbtCompound_1);
@Shadow public abstract CompoundTag getShoulderEntityRight(); @Shadow public abstract NbtCompound getShoulderEntityRight();
@Shadow protected abstract void dropShoulderEntity(CompoundTag entityNbt); @Shadow protected abstract void dropShoulderEntity(NbtCompound entityNbt);
protected PlayerEntity_parrotMixin(EntityType<? extends LivingEntity> entityType_1, World world_1) protected PlayerEntity_parrotMixin(EntityType<? extends LivingEntity> entityType_1, World world_1)
{ {
@@ -47,7 +47,7 @@ public abstract class PlayerEntity_parrotMixin extends LivingEntity
} }
@Inject(method = "tickMovement", at = @At(value = "INVOKE", shift = At.Shift.AFTER, ordinal = 1, @Inject(method = "tickMovement", at = @At(value = "INVOKE", shift = At.Shift.AFTER, ordinal = 1,
target = "Lnet/minecraft/entity/player/PlayerEntity;updateShoulderEntity(Lnet/minecraft/nbt/CompoundTag;)V")) target = "Lnet/minecraft/entity/player/PlayerEntity;updateShoulderEntity(Lnet/minecraft/nbt/NbtCompound;)V"))
private void onTickMovement(CallbackInfo ci) private void onTickMovement(CallbackInfo ci)
{ {
boolean parrots_will_drop = !CarpetSettings.persistentParrots || this.abilities.invulnerable; boolean parrots_will_drop = !CarpetSettings.persistentParrots || this.abilities.invulnerable;
@@ -67,13 +67,13 @@ public abstract class PlayerEntity_parrotMixin extends LivingEntity
protected void dismount_left() protected void dismount_left()
{ {
dropShoulderEntity(this.getShoulderEntityLeft()); dropShoulderEntity(this.getShoulderEntityLeft());
this.setShoulderEntityLeft(new CompoundTag()); this.setShoulderEntityLeft(new NbtCompound());
} }
protected void dismount_right() protected void dismount_right()
{ {
dropShoulderEntity(this.getShoulderEntityRight()); dropShoulderEntity(this.getShoulderEntityRight());
this.setShoulderEntityRight(new CompoundTag()); this.setShoulderEntityRight(new NbtCompound());
} }
@Inject(method = "damage", at = @At(value = "INVOKE", shift = At.Shift.BEFORE, @Inject(method = "damage", at = @At(value = "INVOKE", shift = At.Shift.BEFORE,
@@ -1,7 +1,7 @@
package carpet.mixins; package carpet.mixins;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.ClientConnection; import net.minecraft.network.ClientConnection;
import net.minecraft.text.TranslatableText; import net.minecraft.text.TranslatableText;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
@@ -31,7 +31,7 @@ public abstract class PlayerManager_fakePlayersMixin
private MinecraftServer server; private MinecraftServer server;
@Inject(method = "loadPlayerData", at = @At(value = "RETURN", shift = At.Shift.BEFORE)) @Inject(method = "loadPlayerData", at = @At(value = "RETURN", shift = At.Shift.BEFORE))
private void fixStartingPos(ServerPlayerEntity serverPlayerEntity_1, CallbackInfoReturnable<CompoundTag> cir) private void fixStartingPos(ServerPlayerEntity serverPlayerEntity_1, CallbackInfoReturnable<NbtCompound> cir)
{ {
if (serverPlayerEntity_1 instanceof EntityPlayerMPFake) if (serverPlayerEntity_1 instanceof EntityPlayerMPFake)
{ {
@@ -13,7 +13,7 @@ import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnReason; import net.minecraft.entity.SpawnReason;
import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.tag.BlockTags; import net.minecraft.tag.BlockTags;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@@ -175,9 +175,9 @@ public class SpawnHelperMixin
@Redirect(method = "spawnEntitiesInChunk(Lnet/minecraft/entity/SpawnGroup;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/world/chunk/Chunk;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/SpawnHelper$Checker;Lnet/minecraft/world/SpawnHelper$Runner;)V", at = @At( @Redirect(method = "spawnEntitiesInChunk(Lnet/minecraft/entity/SpawnGroup;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/world/chunk/Chunk;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/SpawnHelper$Checker;Lnet/minecraft/world/SpawnHelper$Runner;)V", at = @At(
value = "INVOKE", value = "INVOKE",
target = "Lnet/minecraft/entity/mob/MobEntity;initialize(Lnet/minecraft/world/ServerWorldAccess;Lnet/minecraft/world/LocalDifficulty;Lnet/minecraft/entity/SpawnReason;Lnet/minecraft/entity/EntityData;Lnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/entity/EntityData;" target = "Lnet/minecraft/entity/mob/MobEntity;initialize(Lnet/minecraft/world/ServerWorldAccess;Lnet/minecraft/world/LocalDifficulty;Lnet/minecraft/entity/SpawnReason;Lnet/minecraft/entity/EntityData;Lnet/minecraft/nbt/NbtCompound;)Lnet/minecraft/entity/EntityData;"
)) ))
private static EntityData spawnEntity(MobEntity mobEntity, ServerWorldAccess serverWorldAccess, LocalDifficulty difficulty, SpawnReason spawnReason, EntityData entityData, CompoundTag entityTag) private static EntityData spawnEntity(MobEntity mobEntity, ServerWorldAccess serverWorldAccess, LocalDifficulty difficulty, SpawnReason spawnReason, EntityData entityData, NbtCompound entityTag)
{ {
if (!SpawnReporter.mock_spawns) // WorldAccess if (!SpawnReporter.mock_spawns) // WorldAccess
return mobEntity.initialize(serverWorldAccess, difficulty, spawnReason, entityData, entityTag); return mobEntity.initialize(serverWorldAccess, difficulty, spawnReason, entityData, entityTag);
@@ -6,7 +6,7 @@ import carpet.script.value.Value;
import carpet.script.value.ValueConversions; import carpet.script.value.ValueConversions;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.state.property.Property; import net.minecraft.state.property.Property;
import net.minecraft.tag.Tag; import net.minecraft.tag.Tag;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
@@ -23,7 +23,7 @@ public class StatePredicate_scarpetMixin implements BlockPredicateInterface
@Shadow @Final private BlockState state; @Shadow @Final private BlockState state;
@Shadow @Final /*@Nullable*/ private CompoundTag nbt; @Shadow @Final /*@Nullable*/ private NbtCompound nbt;
@Shadow @Final private Set<Property<?>> properties; @Shadow @Final private Set<Property<?>> properties;
@@ -50,7 +50,7 @@ public class StatePredicate_scarpetMixin implements BlockPredicateInterface
} }
@Override @Override
public CompoundTag getCMDataTag() public NbtCompound getCMDataTag()
{ {
return nbt; return nbt;
} }
@@ -5,7 +5,7 @@ import carpet.script.value.StringValue;
import carpet.script.value.Value; import carpet.script.value.Value;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.tag.Tag; import net.minecraft.tag.Tag;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@@ -21,7 +21,7 @@ public class TagPredicate_scarpetMixin implements BlockPredicateInterface
@Shadow @Final private Map<String, String> properties; @Shadow @Final private Map<String, String> properties;
@Shadow @Final /*@Nullable*/ private CompoundTag nbt; @Shadow @Final /*@Nullable*/ private NbtCompound nbt;
@Override @Override
public BlockState getCMBlockState() public BlockState getCMBlockState()
@@ -45,7 +45,7 @@ public class TagPredicate_scarpetMixin implements BlockPredicateInterface
} }
@Override @Override
public CompoundTag getCMDataTag() public NbtCompound getCMDataTag()
{ {
return nbt; return nbt;
} }
@@ -4,9 +4,9 @@ import carpet.CarpetServer;
import carpet.CarpetSettings; import carpet.CarpetSettings;
import carpet.script.utils.ShapesRenderer; import carpet.script.utils.ShapesRenderer;
import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.NbtList;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.NbtElement;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
@@ -64,16 +64,16 @@ public class CarpetClient
return true; return true;
} }
public static void onClientCommand(Tag t) public static void onClientCommand(NbtElement t)
{ {
CarpetSettings.LOG.info("Server Response:"); CarpetSettings.LOG.info("Server Response:");
CompoundTag tag = (CompoundTag)t; NbtCompound tag = (NbtCompound)t;
CarpetSettings.LOG.info(" - id: "+tag.getString("id")); CarpetSettings.LOG.info(" - id: "+tag.getString("id"));
CarpetSettings.LOG.info(" - code: "+tag.getInt("code")); CarpetSettings.LOG.info(" - code: "+tag.getInt("code"));
if (tag.contains("error")) CarpetSettings.LOG.warn(" - error: "+tag.getString("error")); if (tag.contains("error")) CarpetSettings.LOG.warn(" - error: "+tag.getString("error"));
if (tag.contains("output")) if (tag.contains("output"))
{ {
ListTag outputTag = (ListTag) tag.get("output"); NbtList outputTag = (NbtList) tag.get("output");
for (int i = 0; i < outputTag.size(); i++) for (int i = 0; i < outputTag.size(); i++)
CarpetSettings.LOG.info(" - response: " + Text.Serializer.fromJson(outputTag.getString(i)).getString()); CarpetSettings.LOG.info(" - response: " + Text.Serializer.fromJson(outputTag.getString(i)).getString());
} }
@@ -8,11 +8,11 @@ import carpet.settings.ParsedRule;
import carpet.settings.SettingsManager; import carpet.settings.SettingsManager;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.nbt.AbstractNumberTag; import net.minecraft.nbt.AbstractNbtNumber;
import net.minecraft.nbt.ByteTag; import net.minecraft.nbt.NbtByte;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.NbtList;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.NbtElement;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket; import net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket;
@@ -22,14 +22,14 @@ import java.util.function.BiConsumer;
public class ClientNetworkHandler public class ClientNetworkHandler
{ {
private static Map<String, BiConsumer<ClientPlayerEntity, Tag>> dataHandlers = new HashMap<String, BiConsumer<ClientPlayerEntity, Tag>>(); private static Map<String, BiConsumer<ClientPlayerEntity, NbtElement>> dataHandlers = new HashMap<String, BiConsumer<ClientPlayerEntity, NbtElement>>();
static static
{ {
dataHandlers.put("Rules", (p, t) -> { dataHandlers.put("Rules", (p, t) -> {
CompoundTag ruleset = (CompoundTag)t; NbtCompound ruleset = (NbtCompound)t;
for (String ruleKey: ruleset.getKeys()) for (String ruleKey: ruleset.getKeys())
{ {
CompoundTag ruleNBT = (CompoundTag) ruleset.get(ruleKey); NbtCompound ruleNBT = (NbtCompound) ruleset.get(ruleKey);
SettingsManager manager = null; SettingsManager manager = null;
String ruleName; String ruleName;
if (ruleNBT.contains("Manager")) if (ruleNBT.contains("Manager"))
@@ -65,22 +65,22 @@ public class ClientNetworkHandler
} }
} }
}); });
dataHandlers.put("TickRate", (p, t) -> TickSpeed.tickrate(((AbstractNumberTag)t).getFloat(), false)); dataHandlers.put("TickRate", (p, t) -> TickSpeed.tickrate(((AbstractNbtNumber)t).floatValue(), false));
dataHandlers.put("TickingState", (p, t) -> { dataHandlers.put("TickingState", (p, t) -> {
CompoundTag tickingState = (CompoundTag)t; NbtCompound tickingState = (NbtCompound)t;
TickSpeed.setFrozenState(tickingState.getBoolean("is_paused"), tickingState.getBoolean("deepFreeze")); TickSpeed.setFrozenState(tickingState.getBoolean("is_paused"), tickingState.getBoolean("deepFreeze"));
}); });
dataHandlers.put("SuperHotState", (p, t) -> { dataHandlers.put("SuperHotState", (p, t) -> {
TickSpeed.is_superHot = ((ByteTag) t).equals(ByteTag.ONE); TickSpeed.is_superHot = ((NbtByte) t).equals(NbtByte.ONE);
}); });
dataHandlers.put("TickPlayerActiveTimeout", (p, t) -> TickSpeed.player_active_timeout = ((AbstractNumberTag)t).getInt()); dataHandlers.put("TickPlayerActiveTimeout", (p, t) -> TickSpeed.player_active_timeout = ((AbstractNbtNumber)t).intValue());
dataHandlers.put("scShape", (p, t) -> { // deprecated dataHandlers.put("scShape", (p, t) -> { // deprecated
if (CarpetClient.shapes != null) if (CarpetClient.shapes != null)
CarpetClient.shapes.addShape((CompoundTag)t); CarpetClient.shapes.addShape((NbtCompound)t);
}); });
dataHandlers.put("scShapes", (p, t) -> { dataHandlers.put("scShapes", (p, t) -> {
if (CarpetClient.shapes != null) if (CarpetClient.shapes != null)
CarpetClient.shapes.addShapes((ListTag) t); CarpetClient.shapes.addShapes((NbtList) t);
}); });
dataHandlers.put("clientCommand", (p, t) -> { dataHandlers.put("clientCommand", (p, t) -> {
CarpetClient.onClientCommand(t); CarpetClient.onClientCommand(t);
@@ -129,7 +129,7 @@ public class ClientNetworkHandler
private static void onSyncData(PacketByteBuf data, ClientPlayerEntity player) private static void onSyncData(PacketByteBuf data, ClientPlayerEntity player)
{ {
CompoundTag compound = data.readCompoundTag(); NbtCompound compound = data.readCompoundTag();
if (compound == null) return; if (compound == null) return;
for (String key: compound.getKeys()) for (String key: compound.getKeys())
{ {
@@ -142,10 +142,10 @@ public class ClientNetworkHandler
public static void clientCommand(String command) public static void clientCommand(String command)
{ {
CompoundTag tag = new CompoundTag(); NbtCompound tag = new NbtCompound();
tag.putString("id", command); tag.putString("id", command);
tag.putString("command", command); tag.putString("command", command);
CompoundTag outer = new CompoundTag(); NbtCompound outer = new NbtCompound();
outer.put("clientCommand", tag); outer.put("clientCommand", tag);
CarpetClient.getPlayer().networkHandler.sendPacket(new CustomPayloadC2SPacket( CarpetClient.getPlayer().networkHandler.sendPacket(new CustomPayloadC2SPacket(
CarpetClient.CARPET_CHANNEL, CarpetClient.CARPET_CHANNEL,
@@ -6,10 +6,10 @@ import carpet.helpers.TickSpeed;
import carpet.settings.ParsedRule; import carpet.settings.ParsedRule;
import carpet.settings.SettingsManager; import carpet.settings.SettingsManager;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.NbtList;
import net.minecraft.nbt.StringTag; import net.minecraft.nbt.NbtString;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.NbtElement;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket; import net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket;
import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.command.ServerCommandSource;
@@ -31,9 +31,9 @@ public class ServerNetworkHandler
private static Map<ServerPlayerEntity, String> remoteCarpetPlayers = new HashMap<>(); private static Map<ServerPlayerEntity, String> remoteCarpetPlayers = new HashMap<>();
private static Set<ServerPlayerEntity> validCarpetPlayers = new HashSet<>(); private static Set<ServerPlayerEntity> validCarpetPlayers = new HashSet<>();
private static Map<String, BiConsumer<ServerPlayerEntity, Tag>> dataHandlers = new HashMap<String, BiConsumer<ServerPlayerEntity, Tag>>(){{ private static Map<String, BiConsumer<ServerPlayerEntity, NbtElement>> dataHandlers = new HashMap<String, BiConsumer<ServerPlayerEntity, NbtElement>>(){{
put("clientCommand", (p, t) -> { put("clientCommand", (p, t) -> {
handleClientCommand(p, (CompoundTag)t); handleClientCommand(p, (NbtCompound)t);
}); });
}}; }};
@@ -88,7 +88,7 @@ public class ServerNetworkHandler
playerEntity.networkHandler.sendPacket(new CustomPayloadS2CPacket(CarpetClient.CARPET_CHANNEL, data.build() )); playerEntity.networkHandler.sendPacket(new CustomPayloadS2CPacket(CarpetClient.CARPET_CHANNEL, data.build() ));
} }
private static void handleClientCommand(ServerPlayerEntity player, CompoundTag commandData) private static void handleClientCommand(ServerPlayerEntity player, NbtCompound commandData)
{ {
String command = commandData.getString("command"); String command = commandData.getString("command");
String id = commandData.getString("id"); String id = commandData.getString("id");
@@ -121,12 +121,12 @@ public class ServerNetworkHandler
command command
); );
}; };
CompoundTag result = new CompoundTag(); NbtCompound result = new NbtCompound();
result.putString("id", id); result.putString("id", id);
result.putInt("code", resultCode); result.putInt("code", resultCode);
if (error[0] != null) result.putString("error", error[0]); if (error[0] != null) result.putString("error", error[0]);
ListTag outputResult = new ListTag(); NbtList outputResult = new NbtList();
for (Text line: output) outputResult.add(StringTag.of(Text.Serializer.toJson(line))); for (Text line: output) outputResult.add(NbtString.of(Text.Serializer.toJson(line)));
if (!output.isEmpty()) result.put("output", outputResult); if (!output.isEmpty()) result.put("output", outputResult);
player.networkHandler.sendPacket(new CustomPayloadS2CPacket( player.networkHandler.sendPacket(new CustomPayloadS2CPacket(
CarpetClient.CARPET_CHANNEL, CarpetClient.CARPET_CHANNEL,
@@ -138,7 +138,7 @@ public class ServerNetworkHandler
private static void onClientData(ServerPlayerEntity player, PacketByteBuf data) private static void onClientData(ServerPlayerEntity player, PacketByteBuf data)
{ {
CompoundTag compound = data.readCompoundTag(); NbtCompound compound = data.readCompoundTag();
if (compound == null) return; if (compound == null) return;
for (String key: compound.getKeys()) for (String key: compound.getKeys())
{ {
@@ -209,7 +209,7 @@ public class ServerNetworkHandler
} }
} }
public static void broadcastCustomCommand(String command, Tag data) public static void broadcastCustomCommand(String command, NbtElement data)
{ {
if (CarpetSettings.superSecretSetting) return; if (CarpetSettings.superSecretSetting) return;
for (ServerPlayerEntity player : validCarpetPlayers) for (ServerPlayerEntity player : validCarpetPlayers)
@@ -221,7 +221,7 @@ public class ServerNetworkHandler
} }
} }
public static void sendCustomCommand(ServerPlayerEntity player, String command, Tag data) public static void sendCustomCommand(ServerPlayerEntity player, String command, NbtElement data)
{ {
if (isValidCarpetPlayer(player)) if (isValidCarpetPlayer(player))
{ {
@@ -262,14 +262,14 @@ public class ServerNetworkHandler
private static class DataBuilder private static class DataBuilder
{ {
private CompoundTag tag; private NbtCompound tag;
private static DataBuilder create() private static DataBuilder create()
{ {
return new DataBuilder(); return new DataBuilder();
} }
private DataBuilder() private DataBuilder()
{ {
tag = new CompoundTag(); tag = new NbtCompound();
} }
private DataBuilder withTickRate() private DataBuilder withTickRate()
{ {
@@ -278,7 +278,7 @@ public class ServerNetworkHandler
} }
private DataBuilder withFrozenState() private DataBuilder withFrozenState()
{ {
CompoundTag tickingState = new CompoundTag(); NbtCompound tickingState = new NbtCompound();
tickingState.putBoolean("is_paused", TickSpeed.isPaused()); tickingState.putBoolean("is_paused", TickSpeed.isPaused());
tickingState.putBoolean("deepFreeze", TickSpeed.deeplyFrozen()); tickingState.putBoolean("deepFreeze", TickSpeed.deeplyFrozen());
tag.put("TickingState", tickingState); tag.put("TickingState", tickingState);
@@ -296,16 +296,16 @@ public class ServerNetworkHandler
} }
private DataBuilder withRule(ParsedRule<?> rule) private DataBuilder withRule(ParsedRule<?> rule)
{ {
CompoundTag rules = (CompoundTag) tag.get("Rules"); NbtCompound rules = (NbtCompound) tag.get("Rules");
if (rules == null) if (rules == null)
{ {
rules = new CompoundTag(); rules = new NbtCompound();
tag.put("Rules", rules); tag.put("Rules", rules);
} }
String identifier = rule.settingsManager.getIdentifier(); String identifier = rule.settingsManager.getIdentifier();
String key = rule.name; String key = rule.name;
while (rules.contains(key)) { key = key+"2";} while (rules.contains(key)) { key = key+"2";}
CompoundTag ruleNBT = new CompoundTag(); NbtCompound ruleNBT = new NbtCompound();
ruleNBT.putString("Value", rule.getAsString()); ruleNBT.putString("Value", rule.getAsString());
ruleNBT.putString("Manager",identifier); ruleNBT.putString("Manager",identifier);
ruleNBT.putString("Rule",rule.name); ruleNBT.putString("Rule",rule.name);
@@ -313,7 +313,7 @@ public class ServerNetworkHandler
return this; return this;
} }
public DataBuilder withCustomNbt(String key, Tag value) public DataBuilder withCustomNbt(String key, NbtElement value)
{ {
tag.put(key, value); tag.put(key, value);
return this; return this;
@@ -29,7 +29,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.NbtElement;
import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
@@ -60,7 +60,7 @@ public class CarpetScriptHost extends ScriptHost
private final CarpetScriptServer scriptServer; private final CarpetScriptServer scriptServer;
ServerCommandSource responsibleSource; ServerCommandSource responsibleSource;
private Tag globalState; private NbtElement globalState;
private int saveTimeout; private int saveTimeout;
public boolean persistenceRequired; public boolean persistenceRequired;
@@ -789,12 +789,12 @@ public class CarpetScriptHost extends ScriptHost
Module.saveData(main, globalState); Module.saveData(main, globalState);
} }
private Tag loadState() private NbtElement loadState()
{ {
return Module.getData(main); return Module.getData(main);
} }
public Tag readFileTag(FileArgument fdesc) public NbtElement readFileTag(FileArgument fdesc)
{ {
if (getName() == null && !fdesc.isShared) return null; if (getName() == null && !fdesc.isShared) return null;
if (fdesc.resource != null) if (fdesc.resource != null)
@@ -804,7 +804,7 @@ public class CarpetScriptHost extends ScriptHost
return ((CarpetScriptHost)parent).globalState; return ((CarpetScriptHost)parent).globalState;
} }
public boolean writeTagFile(Tag tag, FileArgument fdesc) public boolean writeTagFile(NbtElement tag, FileArgument fdesc)
{ {
if (getName() == null && !fdesc.isShared) return false; // if belongs to an app, cannot be default host. if (getName() == null && !fdesc.isShared) return false; // if belongs to an app, cannot be default host.
+13 -13
View File
@@ -51,11 +51,11 @@ import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.decoration.ArmorStandEntity; import net.minecraft.entity.decoration.ArmorStandEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtHelper; import net.minecraft.nbt.NbtHelper;
import net.minecraft.nbt.NbtOps; import net.minecraft.nbt.NbtOps;
import net.minecraft.nbt.StringTag; import net.minecraft.nbt.NbtString;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.NbtElement;
import net.minecraft.network.Packet; import net.minecraft.network.Packet;
import net.minecraft.network.packet.s2c.play.ClearTitleS2CPacket; import net.minecraft.network.packet.s2c.play.ClearTitleS2CPacket;
import net.minecraft.network.packet.s2c.play.OverlayMessageS2CPacket; import net.minecraft.network.packet.s2c.play.OverlayMessageS2CPacket;
@@ -459,7 +459,7 @@ public class Auxiliary {
expression.addLazyFunction("escape_nbt", 1, (c, t, lv) -> { expression.addLazyFunction("escape_nbt", 1, (c, t, lv) -> {
Value v = lv.get(0).evalValue(c); Value v = lv.get(0).evalValue(c);
String string = v.getString(); String string = v.getString();
Value ret = new StringValue(StringTag.escape(string)); Value ret = new StringValue(NbtString.escape(string));
return (cc, tt) -> ret; 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 (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(1).isNull()) return Value.TRUE;
if (lv.get(0).isNull()) return Value.FALSE; if (lv.get(0).isNull()) return Value.FALSE;
Tag source = ((NBTSerializableValue)(NBTSerializableValue.fromValue(lv.get(0)))).getTag(); NbtElement source = ((NBTSerializableValue)(NBTSerializableValue.fromValue(lv.get(0)))).getTag();
Tag match = ((NBTSerializableValue)(NBTSerializableValue.fromValue(lv.get(1)))).getTag(); NbtElement match = ((NBTSerializableValue)(NBTSerializableValue.fromValue(lv.get(1)))).getTag();
return new NumericValue(NbtHelper.matches(match, source, numParam == 2 || lv.get(2).getBoolean())); 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"); if (argSize==0 || argSize > 2) throw new InternalExpressionException("'encode_nbt' requires 1 or 2 parameters");
Value v = lv.get(0).evalValue(c); Value v = lv.get(0).evalValue(c);
boolean force = (argSize > 1) && lv.get(1).evalValue(c).getBoolean(); boolean force = (argSize > 1) && lv.get(1).evalValue(c).getBoolean();
Tag tag; NbtElement tag;
try try
{ {
tag = v.toTag(force); tag = v.toTag(force);
@@ -877,7 +877,7 @@ public class Auxiliary {
Value retVal; Value retVal;
if (fdesc.type == FileArgument.Type.NBT) 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; if (state == null) return LazyValue.NULL;
retVal = new NBTSerializableValue(state); retVal = new NBTSerializableValue(state);
} }
@@ -916,7 +916,7 @@ public class Auxiliary {
NBTSerializableValue tagValue = (val instanceof NBTSerializableValue) NBTSerializableValue tagValue = (val instanceof NBTSerializableValue)
? (NBTSerializableValue) val ? (NBTSerializableValue) val
: new NBTSerializableValue(val.getString()); : new NBTSerializableValue(val.getString());
Tag tag = tagValue.getTag(); NbtElement tag = tagValue.getTag();
success = ((CarpetScriptHost) c.host).writeTagFile(tag, fdesc); success = ((CarpetScriptHost) c.host).writeTagFile(tag, fdesc);
} }
else if (fdesc.type == FileArgument.Type.JSON) 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(); boolean shared = lv.size() > 1 && lv.get(1).evalValue(c).getBoolean();
fdesc = new FileArgument(resource, FileArgument.Type.NBT, null, false, shared, FileArgument.Reason.READ); 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) if (state == null)
return (cc, tt) -> Value.NULL; return (cc, tt) -> Value.NULL;
Value retVal = new NBTSerializableValue(state); Value retVal = new NBTSerializableValue(state);
@@ -986,7 +986,7 @@ public class Auxiliary {
NBTSerializableValue tagValue = (val instanceof NBTSerializableValue) NBTSerializableValue tagValue = (val instanceof NBTSerializableValue)
? (NBTSerializableValue) val ? (NBTSerializableValue) val
: new NBTSerializableValue(val.getString()); : new NBTSerializableValue(val.getString());
Tag tag = tagValue.getTag(); NbtElement tag = tagValue.getTag();
boolean success = ((CarpetScriptHost) c.host).writeTagFile(tag, fdesc); boolean success = ((CarpetScriptHost) c.host).writeTagFile(tag, fdesc);
return success?LazyValue.TRUE:LazyValue.FALSE; return success?LazyValue.TRUE:LazyValue.FALSE;
}); });
@@ -1074,7 +1074,7 @@ public class Auxiliary {
return (_c, _t) -> ret; return (_c, _t) -> ret;
} }
String key = lv.get(0).evalValue(c).getString(); 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) { if (lv.size() == 2) {
Value nbt = lv.get(1).evalValue(c); Value nbt = lv.get(1).evalValue(c);
NBTSerializableValue new_nbt = (nbt instanceof NBTSerializableValue) ? (NBTSerializableValue) nbt 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 //not sure its needed, but doesn't seem to have a negative effect and might be used in some custom shtuff
serverRM.loadRegistryTags(); 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); SaveProperties saveProperties = session.readLevelProperties(registryOps, dataPackSettings2);
if (saveProperties == null) return LazyValue.NULL; if (saveProperties == null) return LazyValue.NULL;
//session.backupLevelDataFile(server.getRegistryManager(), saveProperties); // no need //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.SpawnReason;
import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.player.PlayerEntity; 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.predicate.entity.EntityPredicates;
import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
@@ -140,7 +140,7 @@ public class Entities {
Vector3Argument position = Vector3Argument.findIn(cc, lv, 1); Vector3Argument position = Vector3Argument.findIn(cc, lv, 1);
if (position.fromBlock) if (position.fromBlock)
position.vec = position.vec.subtract(0, 0.5, 0); position.vec = position.vec.subtract(0, 0.5, 0);
CompoundTag tag = new CompoundTag(); NbtCompound tag = new NbtCompound();
boolean hasTag = false; boolean hasTag = false;
if (lv.size() > position.offset) if (lv.size() > position.offset)
{ {
@@ -25,7 +25,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.Items; 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.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket;
import net.minecraft.recipe.AbstractCookingRecipe; import net.minecraft.recipe.AbstractCookingRecipe;
import net.minecraft.recipe.CuttingRecipe; import net.minecraft.recipe.CuttingRecipe;
@@ -35,6 +35,7 @@ import net.minecraft.recipe.ShapedRecipe;
import net.minecraft.recipe.ShapelessRecipe; import net.minecraft.recipe.ShapelessRecipe;
import net.minecraft.recipe.SpecialCraftingRecipe; import net.minecraft.recipe.SpecialCraftingRecipe;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.tag.Tag;
import net.minecraft.tag.TagManager; import net.minecraft.tag.TagManager;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.InvalidIdentifierException; import net.minecraft.util.InvalidIdentifierException;
@@ -97,7 +98,7 @@ public class Inventories {
return (_c, _t) -> ret; return (_c, _t) -> ret;
} }
String tag = lv.get(1).evalValue(c).getString(); 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; if (itemTag == null) return LazyValue.NULL;
return itemTag.contains(item)?LazyValue.TRUE:LazyValue.FALSE; return itemTag.contains(item)?LazyValue.TRUE:LazyValue.FALSE;
}); });
@@ -277,7 +278,7 @@ public class Inventories {
syncPlayerInventory(inventoryLocator, slot); syncPlayerInventory(inventoryLocator, slot);
return (_c, _t) -> ListValue.fromItemStack(previousStack); return (_c, _t) -> ListValue.fromItemStack(previousStack);
} }
CompoundTag nbt = null; // skipping one argument NbtCompound nbt = null; // skipping one argument
if (lv.size() > inventoryLocator.offset+3) if (lv.size() > inventoryLocator.offset+3)
{ {
Value nbtValue = lv.get(inventoryLocator.offset+3).evalValue(c); 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.ShearsItem;
import net.minecraft.item.SwordItem; import net.minecraft.item.SwordItem;
import net.minecraft.item.TridentItem; import net.minecraft.item.TridentItem;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.NbtElement;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ChunkTicket; import net.minecraft.server.world.ChunkTicket;
import net.minecraft.server.world.ChunkTicketType; import net.minecraft.server.world.ChunkTicketType;
@@ -70,6 +70,7 @@ import net.minecraft.sound.SoundCategory;
import net.minecraft.state.StateManager; import net.minecraft.state.StateManager;
import net.minecraft.state.property.Property; import net.minecraft.state.property.Property;
import net.minecraft.structure.StructureStart; import net.minecraft.structure.StructureStart;
import net.minecraft.tag.Tag;
import net.minecraft.tag.TagManager; import net.minecraft.tag.TagManager;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.Clearable; import net.minecraft.util.Clearable;
@@ -289,7 +290,7 @@ public class WorldAccess {
{ {
throw new InternalExpressionException("Block requires at least one parameter"); 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) if (tag == null)
return (c_, t_) -> Value.NULL; return (c_, t_) -> Value.NULL;
Value retval = new NBTSerializableValue(tag); Value retval = new NBTSerializableValue(tag);
@@ -756,7 +757,7 @@ public class WorldAccess {
BlockArgument sourceLocator = BlockArgument.findIn(cc, lv, targetLocator.offset, true); BlockArgument sourceLocator = BlockArgument.findIn(cc, lv, targetLocator.offset, true);
BlockState sourceBlockState = sourceLocator.block.getBlockState(); BlockState sourceBlockState = sourceLocator.block.getBlockState();
BlockState targetBlockState = world.getBlockState(targetLocator.block.getPos()); BlockState targetBlockState = world.getBlockState(targetLocator.block.getPos());
CompoundTag data = null; NbtCompound data = null;
if (lv.size() > sourceLocator.offset) if (lv.size() > sourceLocator.offset)
{ {
List<Value> args = new ArrayList<>(); List<Value> args = new ArrayList<>();
@@ -815,7 +816,7 @@ public class WorldAccess {
} }
if (data == null) data = sourceLocator.block.getData(); if (data == null) data = sourceLocator.block.getData();
CompoundTag finalData = data; NbtCompound finalData = data;
if (sourceBlockState == targetBlockState && data == null) if (sourceBlockState == targetBlockState && data == null)
return (c_, t_) -> Value.FALSE; return (c_, t_) -> Value.FALSE;
@@ -831,7 +832,7 @@ public class WorldAccess {
BlockEntity be = world.getBlockEntity(targetPos); BlockEntity be = world.getBlockEntity(targetPos);
if (be != null) if (be != null)
{ {
CompoundTag destTag = finalData.copy(); NbtCompound destTag = finalData.copy();
destTag.putInt("x", targetPos.getX()); destTag.putInt("x", targetPos.getX());
destTag.putInt("y", targetPos.getY()); destTag.putInt("y", targetPos.getY());
destTag.putInt("z", targetPos.getZ()); destTag.putInt("z", targetPos.getZ());
@@ -875,7 +876,7 @@ public class WorldAccess {
.orElseThrow(() -> new ThrowStatement(itemString, Throwables.UNKNOWN_ITEM)); .orElseThrow(() -> new ThrowStatement(itemString, Throwables.UNKNOWN_ITEM));
} }
} }
CompoundTag tag = null; NbtCompound tag = null;
if (lv.size() > locator.offset+1) if (lv.size() > locator.offset+1)
{ {
if (!playerBreak) throw new InternalExpressionException("tag is not necessary with 'destroy' with no item"); 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; return (c_, t_) -> Value.TRUE;
if (toolBroke) if (toolBroke)
return LazyValue.NULL; return LazyValue.NULL;
Tag outtag = tool.getTag(); NbtElement outtag = tool.getTag();
if (outtag == null) if (outtag == null)
return LazyValue.TRUE; return LazyValue.TRUE;
Value ret = new NBTSerializableValue(() -> outtag); Value ret = new NBTSerializableValue(() -> outtag);
@@ -1130,7 +1131,7 @@ public class WorldAccess {
return (_c, _t) -> ret; return (_c, _t) -> ret;
} }
String tag = lv.get(blockLocator.offset).evalValue(c).getString(); 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; if (blockTag == null) return LazyValue.NULL;
return blockLocator.block.getBlockState().isIn(blockTag)?LazyValue.TRUE:LazyValue.FALSE; return blockLocator.block.getBlockState().isIn(blockTag)?LazyValue.TRUE:LazyValue.FALSE;
}); });
@@ -1354,7 +1355,7 @@ public class WorldAccess {
return; return;
} }
StructureStart<?> start = structures.get(structure); 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(); BlockBox box = start.getBoundingBox();
for (int chx = box.minX / 16; chx <= box.maxX / 16; chx++) for (int chx = box.minX / 16; chx <= box.maxX / 16; chx++)
{ {
@@ -15,11 +15,11 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonParseException; import com.google.gson.JsonParseException;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonReader;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtIo; import net.minecraft.nbt.NbtIo;
import net.minecraft.nbt.NbtTagSizeTracker; import net.minecraft.nbt.NbtTagSizeTracker;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.NbtElement;
import net.minecraft.nbt.TagReaders; import net.minecraft.nbt.NbtTypes;
import net.minecraft.util.WorldSavePath; import net.minecraft.util.WorldSavePath;
import net.minecraft.util.crash.CrashException; import net.minecraft.util.crash.CrashException;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
@@ -302,7 +302,7 @@ public class FileArgument
return true; return true;
} }
public Tag getNbtData(Module module) // aka getData public NbtElement getNbtData(Module module) // aka getData
{ {
try { synchronized (writeIOSync) { try { synchronized (writeIOSync) {
Path dataFile = toPath(module); Path dataFile = toPath(module);
@@ -316,7 +316,7 @@ public class FileArgument
//copied private method from net.minecraft.nbt.NbtIo.read() //copied private method from net.minecraft.nbt.NbtIo.read()
// to read non-compound tags - these won't be compressed // to read non-compound tags - these won't be compressed
public static Tag readTag(Path path) public static NbtElement readTag(Path path)
{ {
try try
{ {
@@ -346,7 +346,7 @@ public class FileArgument
else else
{ {
dataInput_1.readUTF(); dataInput_1.readUTF();
return TagReaders.of(byte_1).read(dataInput_1, 0, NbtTagSizeTracker.EMPTY); return NbtTypes.byId(byte_1).read(dataInput_1, 0, NbtTagSizeTracker.EMPTY);
} }
} }
catch (IOException ignored) catch (IOException ignored)
@@ -361,7 +361,7 @@ public class FileArgument
} }
} }
public boolean saveNbtData(Module module, Tag tag) // aka saveData public boolean saveNbtData(Module module, NbtElement tag) // aka saveData
{ {
try { synchronized (writeIOSync) { try { synchronized (writeIOSync) {
Path dataFile = toPath(module); Path dataFile = toPath(module);
@@ -376,7 +376,7 @@ public class FileArgument
} }
//copied private method from net.minecraft.nbt.NbtIo.write() and client method safe_write //copied private method from net.minecraft.nbt.NbtIo.write() and client method safe_write
public static boolean writeTagDisk(Tag tag_1, Path path, boolean zipped) public static boolean writeTagDisk(NbtElement tag_1, Path path, boolean zipped)
{ {
Path original = path; Path original = path;
try try
@@ -387,9 +387,9 @@ public class FileArgument
Files.deleteIfExists(path); Files.deleteIfExists(path);
} }
if (tag_1 instanceof CompoundTag) if (tag_1 instanceof NbtCompound)
{ {
NbtIo.writeCompressed((CompoundTag) tag_1, Files.newOutputStream(path)); NbtIo.writeCompressed((NbtCompound) tag_1, Files.newOutputStream(path));
} }
else else
{ {
@@ -2,7 +2,7 @@ package carpet.script.bundled;
import carpet.CarpetServer; import carpet.CarpetServer;
import carpet.script.argument.FileArgument; import carpet.script.argument.FileArgument;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.NbtElement;
import net.minecraft.util.WorldSavePath; import net.minecraft.util.WorldSavePath;
import java.nio.file.Files; import java.nio.file.Files;
@@ -14,7 +14,7 @@ public abstract class Module
public abstract String getCode(); public abstract String getCode();
public abstract boolean isLibrary(); public abstract boolean isLibrary();
public static Tag getData(Module module) public static NbtElement getData(Module module)
{ {
Path dataFile = resolveResource(module); Path dataFile = resolveResource(module);
if (dataFile == null) return null; if (dataFile == null) return null;
@@ -22,7 +22,7 @@ public abstract class Module
synchronized (FileArgument.writeIOSync) { return FileArgument.readTag(dataFile); } synchronized (FileArgument.writeIOSync) { return FileArgument.readTag(dataFile); }
} }
public static void saveData(Module module, Tag globalState) public static void saveData(Module module, NbtElement globalState)
{ {
Path dataFile = resolveResource(module); Path dataFile = resolveResource(module);
if (dataFile == null) return; if (dataFile == null) return;
@@ -22,14 +22,14 @@ import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.command.argument.ParticleEffectArgumentType; import net.minecraft.command.argument.ParticleEffectArgumentType;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.nbt.ByteTag; import net.minecraft.nbt.NbtByte;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.DoubleTag; import net.minecraft.nbt.NbtDouble;
import net.minecraft.nbt.FloatTag; import net.minecraft.nbt.NbtFloat;
import net.minecraft.nbt.IntTag; import net.minecraft.nbt.NbtInt;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.NbtList;
import net.minecraft.nbt.StringTag; import net.minecraft.nbt.NbtString;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.NbtElement;
import net.minecraft.particle.ParticleEffect; import net.minecraft.particle.ParticleEffect;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
@@ -123,7 +123,7 @@ public class ShapeDispatcher
if (!clientPlayers.isEmpty()) if (!clientPlayers.isEmpty())
{ {
ListTag tag = new ListTag(); NbtList tag = new NbtList();
int tagcount = 0; int tagcount = 0;
for (Pair<ExpiringShape, Map<String, Value>> s : shapes) for (Pair<ExpiringShape, Map<String, Value>> s : shapes)
{ {
@@ -131,12 +131,12 @@ public class ShapeDispatcher
if (tagcount++>1000) if (tagcount++>1000)
{ {
tagcount = 0; tagcount = 0;
Tag finalTag = tag; NbtElement finalTag = tag;
clientPlayers.forEach( p -> ServerNetworkHandler.sendCustomCommand(p, "scShapes", finalTag)); clientPlayers.forEach( p -> ServerNetworkHandler.sendCustomCommand(p, "scShapes", finalTag));
tag = new ListTag(); tag = new NbtList();
} }
} }
Tag finalTag = tag; NbtElement finalTag = tag;
if (tag.size() > 0) clientPlayers.forEach( p -> ServerNetworkHandler.sendCustomCommand(p, "scShapes", finalTag)); if (tag.size() > 0) clientPlayers.forEach( p -> ServerNetworkHandler.sendCustomCommand(p, "scShapes", finalTag));
} }
if (!alternativePlayers.isEmpty()) if (!alternativePlayers.isEmpty())
@@ -194,7 +194,7 @@ public class ShapeDispatcher
} }
// client // client
public static ExpiringShape fromTag(CompoundTag tag) public static ExpiringShape fromTag(NbtCompound tag)
{ {
Map<String, Value> options = new HashMap<>(); Map<String, Value> options = new HashMap<>();
for (String key : tag.getKeys()) for (String key : tag.getKeys())
@@ -265,11 +265,11 @@ public class ShapeDispatcher
protected ExpiringShape() { } protected ExpiringShape() { }
public static CompoundTag toTag(Map<String, Value> params) public static NbtCompound toTag(Map<String, Value> params)
{ {
CompoundTag tag = new CompoundTag(); NbtCompound tag = new NbtCompound();
params.forEach((k, v) -> { params.forEach((k, v) -> {
Tag valTag = Param.of.get(k).toTag(v); NbtElement valTag = Param.of.get(k).toTag(v);
if (valTag != null) tag.put(k, valTag); if (valTag != null) tag.put(k, valTag);
}); });
return tag; return tag;
@@ -890,9 +890,9 @@ public class ShapeDispatcher
this.id = id; this.id = id;
} }
public abstract Tag toTag(Value value); //validates value, returning null if not necessary to keep it and serialize public abstract NbtElement toTag(Value value); //validates value, returning null if not necessary to keep it and serialize
public abstract Value validate(Map<String, Value> options, CarpetContext cc, Value value); // makes sure the value is proper public abstract Value validate(Map<String, Value> options, CarpetContext cc, Value value); // makes sure the value is proper
public abstract Value decode(Tag tag); public abstract Value decode(NbtElement tag);
} }
public abstract static class StringParam extends Param public abstract static class StringParam extends Param
@@ -900,8 +900,8 @@ public class ShapeDispatcher
protected StringParam(String id) { super(id); } protected StringParam(String id) { super(id); }
@Override @Override
public Tag toTag(Value value) { return StringTag.of(value.getString()); } public NbtElement toTag(Value value) { return NbtString.of(value.getString()); }
public Value decode(Tag tag) { return new StringValue(tag.asString()); } public Value decode(NbtElement tag) { return new StringValue(tag.asString()); }
} }
public static class TextParam extends StringParam public static class TextParam extends StringParam
{ {
@@ -931,15 +931,15 @@ public class ShapeDispatcher
} }
@Override @Override
public Tag toTag(Value value) public NbtElement toTag(Value value)
{ {
if (!(value instanceof FormattedTextValue)) if (!(value instanceof FormattedTextValue))
value = new FormattedTextValue(new LiteralText(value.getString())); value = new FormattedTextValue(new LiteralText(value.getString()));
return StringTag.of(((FormattedTextValue)value).serialize()); return NbtString.of(((FormattedTextValue)value).serialize());
} }
@Override @Override
public Value decode(Tag tag) public Value decode(NbtElement tag)
{ {
return FormattedTextValue.deserialize(tag.asString()); return FormattedTextValue.deserialize(tag.asString());
} }
@@ -1004,24 +1004,24 @@ public class ShapeDispatcher
} }
@Override @Override
public Tag toTag(Value value) public NbtElement toTag(Value value)
{ {
return ByteTag.of(value.getBoolean()); return NbtByte.of(value.getBoolean());
} }
@Override @Override
public Value decode(Tag tag) public Value decode(NbtElement tag)
{ {
return new NumericValue(((ByteTag) tag).getByte() > 0); return new NumericValue(((NbtByte) tag).byteValue() > 0);
} }
} }
public static class FloatParam extends NumericParam public static class FloatParam extends NumericParam
{ {
protected FloatParam(String id) { super(id); } protected FloatParam(String id) { super(id); }
@Override @Override
public Value decode(Tag tag) { return new NumericValue(((FloatTag)tag).getFloat()); } public Value decode(NbtElement tag) { return new NumericValue(((NbtFloat)tag).floatValue()); }
@Override @Override
public Tag toTag(Value value) { return FloatTag.of(NumericValue.asNumber(value, id).getFloat()); } public NbtElement toTag(Value value) { return NbtFloat.of(NumericValue.asNumber(value, id).getFloat()); }
} }
public static abstract class PositiveParam extends NumericParam public static abstract class PositiveParam extends NumericParam
@@ -1038,27 +1038,27 @@ public class ShapeDispatcher
{ {
protected PositiveFloatParam(String id) { super(id); } protected PositiveFloatParam(String id) { super(id); }
@Override @Override
public Value decode(Tag tag) { return new NumericValue(((FloatTag)tag).getFloat()); } public Value decode(NbtElement tag) { return new NumericValue(((NbtFloat)tag).floatValue()); }
@Override @Override
public Tag toTag(Value value) { return FloatTag.of(NumericValue.asNumber(value, id).getFloat()); } public NbtElement toTag(Value value) { return NbtFloat.of(NumericValue.asNumber(value, id).getFloat()); }
} }
public static class PositiveIntParam extends PositiveParam public static class PositiveIntParam extends PositiveParam
{ {
protected PositiveIntParam(String id) { super(id); } protected PositiveIntParam(String id) { super(id); }
@Override @Override
public Value decode(Tag tag) { return new NumericValue(((IntTag)tag).getInt()); } public Value decode(NbtElement tag) { return new NumericValue(((NbtInt)tag).intValue()); }
@Override @Override
public Tag toTag(Value value) { return IntTag.of(NumericValue.asNumber(value, id).getInt()); } public NbtElement toTag(Value value) { return NbtInt.of(NumericValue.asNumber(value, id).getInt()); }
} }
public static class NonNegativeIntParam extends NumericParam public static class NonNegativeIntParam extends NumericParam
{ {
protected NonNegativeIntParam(String id) { super(id); } protected NonNegativeIntParam(String id) { super(id); }
@Override @Override
public Value decode(Tag tag) { return new NumericValue(((IntTag)tag).getInt()); } public Value decode(NbtElement tag) { return new NumericValue(((NbtInt)tag).intValue()); }
@Override @Override
public Tag toTag(Value value) { return IntTag.of(NumericValue.asNumber(value, id).getInt()); } public NbtElement toTag(Value value) { return NbtInt.of(NumericValue.asNumber(value, id).getInt()); }
@Override public Value validate(Map<String, Value> options, CarpetContext cc, Value value) @Override public Value validate(Map<String, Value> options, CarpetContext cc, Value value)
{ {
Value ret = super.validate(options, cc, value); Value ret = super.validate(options, cc, value);
@@ -1070,9 +1070,9 @@ public class ShapeDispatcher
{ {
protected NonNegativeFloatParam(String id) { super(id); } protected NonNegativeFloatParam(String id) { super(id); }
@Override @Override
public Value decode(Tag tag) { return new NumericValue(((FloatTag)tag).getFloat()); } public Value decode(NbtElement tag) { return new NumericValue(((NbtFloat)tag).floatValue()); }
@Override @Override
public Tag toTag(Value value) { return FloatTag.of(NumericValue.asNumber(value, id).getFloat()); } public NbtElement toTag(Value value) { return NbtFloat.of(NumericValue.asNumber(value, id).getFloat()); }
@Override public Value validate(Map<String, Value> options, CarpetContext cc, Value value) @Override public Value validate(Map<String, Value> options, CarpetContext cc, Value value)
{ {
Value ret = super.validate(options, cc, value); Value ret = super.validate(options, cc, value);
@@ -1137,9 +1137,9 @@ public class ShapeDispatcher
throw new InternalExpressionException("'"+p.id+"' requires a triple, block or entity to indicate position"); throw new InternalExpressionException("'"+p.id+"' requires a triple, block or entity to indicate position");
} }
public Value decode(Tag tag) public Value decode(NbtElement tag)
{ {
ListTag ctag = (ListTag)tag; NbtList ctag = (NbtList)tag;
return ListValue.of( return ListValue.of(
new NumericValue(ctag.getDouble(0)), new NumericValue(ctag.getDouble(0)),
new NumericValue(ctag.getDouble(1)), new NumericValue(ctag.getDouble(1)),
@@ -1147,13 +1147,13 @@ public class ShapeDispatcher
); );
} }
@Override @Override
public Tag toTag(Value value) public NbtElement toTag(Value value)
{ {
List<Value> lv = ((ListValue)value).getItems(); List<Value> lv = ((ListValue)value).getItems();
ListTag tag = new ListTag(); NbtList tag = new NbtList();
tag.add(DoubleTag.of(NumericValue.asNumber(lv.get(0), "x").getDouble())); tag.add(NbtDouble.of(NumericValue.asNumber(lv.get(0), "x").getDouble()));
tag.add(DoubleTag.of(NumericValue.asNumber(lv.get(1), "y").getDouble())); tag.add(NbtDouble.of(NumericValue.asNumber(lv.get(1), "y").getDouble()));
tag.add(DoubleTag.of(NumericValue.asNumber(lv.get(2), "z").getDouble())); tag.add(NbtDouble.of(NumericValue.asNumber(lv.get(2), "z").getDouble()));
return tag; return tag;
} }
} }
@@ -1175,13 +1175,13 @@ public class ShapeDispatcher
return ListValue.wrap(points); return ListValue.wrap(points);
} }
public Value decode(Tag tag) public Value decode(NbtElement tag)
{ {
ListTag ltag = (ListTag)tag; NbtList ltag = (NbtList)tag;
List<Value> points = new ArrayList<>(); List<Value> points = new ArrayList<>();
for (int i=0, ll = ltag.size(); i<ll; i++) for (int i=0, ll = ltag.size(); i<ll; i++)
{ {
ListTag ptag = ltag.getList(i); NbtList ptag = ltag.getList(i);
points.add(ListValue.of( points.add(ListValue.of(
new NumericValue(ptag.getDouble(0)), new NumericValue(ptag.getDouble(0)),
new NumericValue(ptag.getDouble(1)), new NumericValue(ptag.getDouble(1)),
@@ -1191,17 +1191,17 @@ public class ShapeDispatcher
return ListValue.wrap(points); return ListValue.wrap(points);
} }
@Override @Override
public Tag toTag(Value pointsValue) public NbtElement toTag(Value pointsValue)
{ {
List<Value> lv = ((ListValue)pointsValue).getItems(); List<Value> lv = ((ListValue)pointsValue).getItems();
ListTag ltag = new ListTag(); NbtList ltag = new NbtList();
for (Value value : lv) for (Value value : lv)
{ {
List<Value> coords = ((ListValue)value).getItems(); List<Value> coords = ((ListValue)value).getItems();
ListTag tag = new ListTag(); NbtList tag = new NbtList();
tag.add(DoubleTag.of(NumericValue.asNumber(lv.get(0), "x").getDouble())); tag.add(NbtDouble.of(NumericValue.asNumber(lv.get(0), "x").getDouble()));
tag.add(DoubleTag.of(NumericValue.asNumber(lv.get(1), "y").getDouble())); tag.add(NbtDouble.of(NumericValue.asNumber(lv.get(1), "y").getDouble()));
tag.add(DoubleTag.of(NumericValue.asNumber(lv.get(2), "z").getDouble())); tag.add(NbtDouble.of(NumericValue.asNumber(lv.get(2), "z").getDouble()));
ltag.add(tag); ltag.add(tag);
} }
return ltag; return ltag;
@@ -1216,9 +1216,9 @@ public class ShapeDispatcher
super(id); super(id);
} }
public Value decode(Tag tag) { return new NumericValue(((IntTag)tag).getInt()); } public Value decode(NbtElement tag) { return new NumericValue(((NbtInt)tag).intValue()); }
@Override @Override
public Tag toTag(Value value) { return IntTag.of(NumericValue.asNumber(value, id).getInt()); } public NbtElement toTag(Value value) { return NbtInt.of(NumericValue.asNumber(value, id).getInt()); }
} }
public static class EntityParam extends Param public static class EntityParam extends Param
@@ -1227,9 +1227,9 @@ public class ShapeDispatcher
protected EntityParam(String id) { super(id); } protected EntityParam(String id) { super(id); }
@Override @Override
public Tag toTag(Value value) public NbtElement toTag(Value value)
{ {
return IntTag.of(NumericValue.asNumber(value, id).getInt()); return NbtInt.of(NumericValue.asNumber(value, id).getInt());
} }
@Override @Override
@@ -1242,7 +1242,7 @@ public class ShapeDispatcher
return new NumericValue(player.getId()); return new NumericValue(player.getId());
} }
public Value decode(Tag tag) { return new NumericValue(((IntTag)tag).getInt()); } public Value decode(NbtElement tag) { return new NumericValue(((NbtInt)tag).intValue()); }
} }
private static boolean isStraight(Vec3d from, Vec3d to, double density) private static boolean isStraight(Vec3d from, Vec3d to, double density)
@@ -14,8 +14,8 @@ import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.world.ClientWorld; import net.minecraft.client.world.ClientWorld;
import net.minecraft.client.render.VertexFormats; import net.minecraft.client.render.VertexFormats;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.NbtList;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
@@ -60,7 +60,7 @@ public class ShapesRenderer
long currentTime = client.world.getTime(); long currentTime = client.world.getTime();
RenderSystem.disableTexture(); RenderSystem.disableTexture();
RenderSystem.enableDepthTest(); RenderSystem.enableDepthTest();
RenderSystem.setShader(GameRenderer::method_34540); RenderSystem.setShader(GameRenderer::getPositionColorShader);
RenderSystem.depthFunc(515); RenderSystem.depthFunc(515);
RenderSystem.enableBlend(); RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc(); RenderSystem.defaultBlendFunc();
@@ -122,7 +122,7 @@ public class ShapesRenderer
RenderSystem.enableTexture(); RenderSystem.enableTexture();
} }
public void addShapes(ListTag tag) public void addShapes(NbtList tag)
{ {
for (int i=0, count = tag.size(); i < count; i++) for (int i=0, count = tag.size(); i < count; i++)
{ {
@@ -130,7 +130,7 @@ public class ShapesRenderer
} }
} }
public void addShape(CompoundTag tag) public void addShape(NbtCompound tag)
{ {
ShapeDispatcher.ExpiringShape shape = ShapeDispatcher.fromTag(tag); ShapeDispatcher.ExpiringShape shape = ShapeDispatcher.fromTag(tag);
if (shape == null) return; if (shape == null) return;
@@ -13,9 +13,9 @@ import net.minecraft.command.argument.BlockArgumentParser;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.item.ItemPlacementContext; import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.StringTag; import net.minecraft.nbt.NbtString;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.NbtElement;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.state.property.Property; import net.minecraft.state.property.Property;
import net.minecraft.util.dynamic.GlobalPos; import net.minecraft.util.dynamic.GlobalPos;
@@ -45,7 +45,7 @@ public class BlockValue extends Value
private BlockState blockState; private BlockState blockState;
private final BlockPos pos; private final BlockPos pos;
private final ServerWorld world; private final ServerWorld world;
private CompoundTag data; private NbtCompound data;
public static BlockValue fromCoords(CarpetContext c, int x, int y, int z) public static BlockValue fromCoords(CarpetContext c, int x, int y, int z)
{ {
@@ -63,9 +63,9 @@ public class BlockValue extends Value
BlockArgumentParser blockstateparser = (new BlockArgumentParser(new StringReader(str), false)).parse(true); BlockArgumentParser blockstateparser = (new BlockArgumentParser(new StringReader(str), false)).parse(true);
if (blockstateparser.getBlockState() != null) if (blockstateparser.getBlockState() != null)
{ {
CompoundTag bd = blockstateparser.getNbtData(); NbtCompound bd = blockstateparser.getNbtData();
if (bd == null) if (bd == null)
bd = new CompoundTag(); bd = new NbtCompound();
bv = new BlockValue(blockstateparser.getBlockState(), null, null, bd ); bv = new BlockValue(blockstateparser.getBlockState(), null, null, bd );
if (bvCache.size()>10000) if (bvCache.size()>10000)
bvCache.clear(); bvCache.clear();
@@ -107,7 +107,7 @@ public class BlockValue extends Value
} }
public CompoundTag getData() public NbtCompound getData()
{ {
if (data != null) if (data != null)
{ {
@@ -118,7 +118,7 @@ public class BlockValue extends Value
if (world != null && pos != null) if (world != null && pos != null)
{ {
BlockEntity be = getBlockEntity(world, pos); BlockEntity be = getBlockEntity(world, pos);
CompoundTag tag = new CompoundTag(); NbtCompound tag = new NbtCompound();
if (be == null) if (be == null)
{ {
data = tag; data = tag;
@@ -139,7 +139,7 @@ public class BlockValue extends Value
data = null; data = null;
} }
public BlockValue(BlockState state, ServerWorld world, BlockPos position, CompoundTag nbt) public BlockValue(BlockState state, ServerWorld world, BlockPos position, NbtCompound nbt)
{ {
this.world = world; this.world = world;
blockState = state; blockState = state;
@@ -188,26 +188,26 @@ public class BlockValue extends Value
public ServerWorld getWorld() { return world;} public ServerWorld getWorld() { return world;}
@Override @Override
public Tag toTag(boolean force) public NbtElement toTag(boolean force)
{ {
if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this); if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this);
// follows falling block convertion // follows falling block convertion
CompoundTag tag = new CompoundTag(); NbtCompound tag = new NbtCompound();
CompoundTag state = new CompoundTag(); NbtCompound state = new NbtCompound();
BlockState s = getBlockState(); BlockState s = getBlockState();
state.put("Name", StringTag.of(Registry.BLOCK.getId(s.getBlock()).toString())); state.put("Name", NbtString.of(Registry.BLOCK.getId(s.getBlock()).toString()));
Collection<Property<?>> properties = s.getProperties(); Collection<Property<?>> properties = s.getProperties();
if (!properties.isEmpty()) if (!properties.isEmpty())
{ {
CompoundTag props = new CompoundTag(); NbtCompound props = new NbtCompound();
for (Property<?> p: properties) for (Property<?> p: properties)
{ {
props.put(p.getName(), StringTag.of(s.get(p).toString().toLowerCase(Locale.ROOT))); props.put(p.getName(), NbtString.of(s.get(p).toString().toLowerCase(Locale.ROOT)));
} }
state.put("Properties", props); state.put("Properties", props);
} }
tag.put("BlockState", state); tag.put("BlockState", state);
CompoundTag dataTag = getData(); NbtCompound dataTag = getData();
if (dataTag != null) if (dataTag != null)
{ {
tag.put("TileEntityData", dataTag); tag.put("TileEntityData", dataTag);
@@ -2,8 +2,8 @@ package carpet.script.value;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive; import com.google.gson.JsonPrimitive;
import net.minecraft.nbt.ByteTag; import net.minecraft.nbt.NbtByte;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.NbtElement;
public class BooleanValue extends NumericValue public class BooleanValue extends NumericValue
{ {
@@ -47,8 +47,8 @@ public class BooleanValue extends NumericValue
} }
@Override @Override
public Tag toTag(boolean force) { public NbtElement toTag(boolean force) {
return ByteTag.of(boolValue); return NbtByte.of(boolValue);
} }
@Override @Override
@@ -27,8 +27,8 @@ import net.minecraft.entity.ai.brain.MemoryModuleType;
import net.minecraft.entity.ai.pathing.Path; import net.minecraft.entity.ai.pathing.Path;
import net.minecraft.entity.projectile.ProjectileEntity; import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.entity.vehicle.AbstractMinecartEntity; import net.minecraft.entity.vehicle.AbstractMinecartEntity;
import net.minecraft.nbt.StringTag; import net.minecraft.nbt.NbtString;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.NbtElement;
import net.minecraft.network.packet.s2c.play.EntityPassengersSetS2CPacket; import net.minecraft.network.packet.s2c.play.EntityPassengersSetS2CPacket;
import net.minecraft.network.packet.s2c.play.EntityPositionS2CPacket; import net.minecraft.network.packet.s2c.play.EntityPositionS2CPacket;
import net.minecraft.network.packet.s2c.play.ExperienceBarUpdateS2CPacket; import net.minecraft.network.packet.s2c.play.ExperienceBarUpdateS2CPacket;
@@ -49,12 +49,13 @@ import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.mob.PathAwareEntity; import net.minecraft.entity.mob.PathAwareEntity;
import net.minecraft.entity.passive.PassiveEntity; import net.minecraft.entity.passive.PassiveEntity;
import net.minecraft.entity.player.PlayerEntity; 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.predicate.entity.EntityPredicates;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.tag.Tag;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.TypeFilter; import net.minecraft.util.TypeFilter;
@@ -241,7 +242,7 @@ public class EntityValue extends Value
positive = false; positive = false;
who = who.substring(1); who = who.substring(1);
} }
net.minecraft.tag.Tag<EntityType<?>> eTag = server.getTagManager().getOrCreateTagGroup(Registry.ENTITY_TYPE_KEY).getTag(new Identifier(who)); Tag<EntityType<?>> eTag = server.getTagManager().getOrCreateTagGroup(Registry.ENTITY_TYPE_KEY).getTag(new Identifier(who));
if (eTag == null) throw new InternalExpressionException(who+" is not a valid entity descriptor"); if (eTag == null) throw new InternalExpressionException(who+" is not a valid entity descriptor");
if (positive) if (positive)
{ {
@@ -450,7 +451,7 @@ public class EntityValue extends Value
put("has_scoreboard_tag", (e, a) -> new NumericValue(e.getScoreboardTags().contains(a.getString()))); put("has_scoreboard_tag", (e, a) -> new NumericValue(e.getScoreboardTags().contains(a.getString())));
put("has_entity_tag", (e, a) -> { put("has_entity_tag", (e, a) -> {
net.minecraft.tag.Tag<EntityType<?>> tag = e.getServer().getTagManager().getOrCreateTagGroup(Registry.ENTITY_TYPE_KEY).getTag(new Identifier(a.getString())); Tag<EntityType<?>> tag = e.getServer().getTagManager().getOrCreateTagGroup(Registry.ENTITY_TYPE_KEY).getTag(new Identifier(a.getString()));
if (tag == null) return Value.NULL; if (tag == null) return Value.NULL;
return new NumericValue(e.getType().isIn(tag)); return new NumericValue(e.getType().isIn(tag));
}); });
@@ -841,7 +842,7 @@ public class EntityValue extends Value
}); });
put("nbt",(e, a) -> { put("nbt",(e, a) -> {
CompoundTag nbttagcompound = e.writeNbt((new CompoundTag())); NbtCompound nbttagcompound = e.writeNbt((new NbtCompound()));
if (a==null) if (a==null)
return new NBTSerializableValue(nbttagcompound); return new NBTSerializableValue(nbttagcompound);
return new NBTSerializableValue(nbttagcompound).get(a); return new NBTSerializableValue(nbttagcompound).get(a);
@@ -1470,7 +1471,7 @@ public class EntityValue extends Value
Value tagValue = NBTSerializableValue.fromValue(v); Value tagValue = NBTSerializableValue.fromValue(v);
if (tagValue instanceof NBTSerializableValue) if (tagValue instanceof NBTSerializableValue)
{ {
CompoundTag nbttagcompound = e.writeNbt((new CompoundTag())); NbtCompound nbttagcompound = e.writeNbt((new NbtCompound()));
nbttagcompound.copyFrom(((NBTSerializableValue) tagValue).getCompoundTag()); nbttagcompound.copyFrom(((NBTSerializableValue) tagValue).getCompoundTag());
e.readNbt(nbttagcompound); e.readNbt(nbttagcompound);
e.setUuid(uUID); e.setUuid(uUID);
@@ -1493,12 +1494,12 @@ public class EntityValue extends Value
} }
@Override @Override
public Tag toTag(boolean force) public NbtElement toTag(boolean force)
{ {
if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this); if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this);
CompoundTag tag = new CompoundTag(); NbtCompound tag = new NbtCompound();
tag.put("Data", getEntity().writeNbt( new CompoundTag())); tag.put("Data", getEntity().writeNbt( new NbtCompound()));
tag.put("Name", StringTag.of(Registry.ENTITY_TYPE.getId(getEntity().getType()).toString())); tag.put("Name", NbtString.of(Registry.ENTITY_TYPE.getId(getEntity().getType()).toString()));
return tag; return tag;
} }
} }
@@ -1,7 +1,7 @@
package carpet.script.value; package carpet.script.value;
import net.minecraft.nbt.StringTag; import net.minecraft.nbt.NbtString;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.NbtElement;
import net.minecraft.text.BaseText; import net.minecraft.text.BaseText;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
import net.minecraft.text.Text; import net.minecraft.text.Text;
@@ -70,10 +70,10 @@ public class FormattedTextValue extends StringValue
} }
@Override @Override
public Tag toTag(boolean force) public NbtElement toTag(boolean force)
{ {
if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this); if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this);
return StringTag.of(Text.Serializer.toJson(text)); return NbtString.of(Text.Serializer.toJson(text));
} }
@Override @Override
@@ -1,6 +1,6 @@
package carpet.script.value; package carpet.script.value;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.NbtElement;
public abstract class FrameworkValue extends Value public abstract class FrameworkValue extends Value
{ {
@@ -29,7 +29,7 @@ public abstract class FrameworkValue extends Value
} }
@Override @Override
public Tag toTag(boolean force) public NbtElement toTag(boolean force)
{ {
throw new UnsupportedOperationException("Scarpet language component cannot be serialized to the tag"); throw new UnsupportedOperationException("Scarpet language component cannot be serialized to the tag");
} }
@@ -1,7 +1,7 @@
package carpet.script.value; package carpet.script.value;
import carpet.script.exception.InternalExpressionException; import carpet.script.exception.InternalExpressionException;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.NbtElement;
public class FunctionAnnotationValue extends Value public class FunctionAnnotationValue extends Value
{ {
@@ -35,7 +35,7 @@ public class FunctionAnnotationValue extends Value
} }
@Override @Override
public Tag toTag(boolean force) public NbtElement toTag(boolean force)
{ {
throw new UnsupportedOperationException("Global value cannot be serialized to the tag"); throw new UnsupportedOperationException("Global value cannot be serialized to the tag");
} }
@@ -12,8 +12,8 @@ import carpet.script.exception.ExpressionException;
import carpet.script.exception.InternalExpressionException; import carpet.script.exception.InternalExpressionException;
import carpet.script.exception.ReturnStatement; import carpet.script.exception.ReturnStatement;
import carpet.script.exception.ThrowStatement; import carpet.script.exception.ThrowStatement;
import net.minecraft.nbt.StringTag; import net.minecraft.nbt.NbtString;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.NbtElement;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@@ -246,10 +246,10 @@ public class FunctionValue extends Value implements Fluff.ILazyFunction
public String getVarArgs() {return varArgs; } public String getVarArgs() {return varArgs; }
@Override @Override
public Tag toTag(boolean force) public NbtElement toTag(boolean force)
{ {
if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this); if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this);
return StringTag.of(getString()); return NbtString.of(getString());
} }
public void assertArgsOk(List<?> list, Consumer<Boolean> feedback) public void assertArgsOk(List<?> list, Consumer<Boolean> feedback)
@@ -1,8 +1,8 @@
package carpet.script.value; package carpet.script.value;
import carpet.script.exception.InternalExpressionException; import carpet.script.exception.InternalExpressionException;
import net.minecraft.nbt.StringTag; import net.minecraft.nbt.NbtString;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.NbtElement;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
@@ -199,9 +199,9 @@ public abstract class LazyListValue extends AbstractListValue implements Iterato
} }
@Override @Override
public Tag toTag(boolean force) public NbtElement toTag(boolean force)
{ {
if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this); if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this);
return StringTag.of(getString()); return NbtString.of(getString());
} }
} }
@@ -5,14 +5,14 @@ import carpet.script.exception.InternalExpressionException;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.AbstractNumberTag; import net.minecraft.nbt.AbstractNbtNumber;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.DoubleTag; import net.minecraft.nbt.NbtDouble;
import net.minecraft.nbt.IntTag; import net.minecraft.nbt.NbtInt;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.NbtList;
import net.minecraft.nbt.LongTag; import net.minecraft.nbt.NbtLong;
import net.minecraft.nbt.StringTag; import net.minecraft.nbt.NbtString;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.NbtElement;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@@ -481,31 +481,31 @@ public class ListValue extends AbstractListValue implements ContainerValueInterf
LIST, LIST,
MAP, MAP,
STRING; STRING;
private static TagTypeCompat getType(Tag tag) private static TagTypeCompat getType(NbtElement tag)
{ {
if (tag instanceof IntTag) return INT; if (tag instanceof NbtInt) return INT;
if (tag instanceof LongTag) return LONG; if (tag instanceof NbtLong) return LONG;
if (tag instanceof DoubleTag) return DBL; if (tag instanceof NbtDouble) return DBL;
if (tag instanceof ListTag) return LIST; if (tag instanceof NbtList) return LIST;
if (tag instanceof CompoundTag) return MAP; if (tag instanceof NbtCompound) return MAP;
return STRING; return STRING;
} }
} }
@Override @Override
public Tag toTag(boolean force) public NbtElement toTag(boolean force)
{ {
int argSize = items.size(); int argSize = items.size();
if (argSize == 0) return new ListTag(); if (argSize == 0) return new NbtList();
ListTag tag = new ListTag(); NbtList tag = new NbtList();
if (argSize ==1) if (argSize ==1)
{ {
tag.add(items.get(0).toTag(force)); tag.add(items.get(0).toTag(force));
return tag; return tag;
} }
// figuring out the types // figuring out the types
List<Tag> tags= new ArrayList<>(); List<NbtElement> tags= new ArrayList<>();
items.forEach(v -> tags.add(v.toTag(force))); items.forEach(v -> tags.add(v.toTag(force)));
Set<TagTypeCompat> cases = EnumSet.noneOf(TagTypeCompat.class); Set<TagTypeCompat> cases = EnumSet.noneOf(TagTypeCompat.class);
tags.forEach(t -> cases.add(TagTypeCompat.getType(t))); tags.forEach(t -> cases.add(TagTypeCompat.getType(t)));
@@ -519,17 +519,17 @@ public class ListValue extends AbstractListValue implements ContainerValueInterf
|| cases.contains(TagTypeCompat.STRING)) // incompatible types || cases.contains(TagTypeCompat.STRING)) // incompatible types
{ {
if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this); if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this);
tags.forEach(t -> tag.add(StringTag.of(t.asString()))); tags.forEach(t -> tag.add(NbtString.of(t.asString())));
return tag; return tag;
} }
// only numbers / mixed types // only numbers / mixed types
if (cases.contains(TagTypeCompat.DBL)) if (cases.contains(TagTypeCompat.DBL))
{ {
tags.forEach(t -> tag.add(DoubleTag.of(((AbstractNumberTag)t).getDouble()))); tags.forEach(t -> tag.add(NbtDouble.of(((AbstractNbtNumber)t).doubleValue())));
} }
else else
{ {
tags.forEach(t -> tag.add(LongTag.of(((AbstractNumberTag)t).getLong()))); tags.forEach(t -> tag.add(NbtLong.of(((AbstractNbtNumber)t).longValue())));
} }
return tag; return tag;
} }
@@ -3,8 +3,8 @@ package carpet.script.value;
import carpet.script.exception.InternalExpressionException; import carpet.script.exception.InternalExpressionException;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.NbtElement;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@@ -254,9 +254,9 @@ public class MapValue extends AbstractListValue implements ContainerValueInterfa
} }
@Override @Override
public Tag toTag(boolean force) public NbtElement toTag(boolean force)
{ {
CompoundTag tag = new CompoundTag() ; NbtCompound tag = new NbtCompound() ;
map.forEach( (k, v) -> map.forEach( (k, v) ->
{ {
if (!force && !(k instanceof StringValue)) throw new NBTSerializableValue.IncompatibleTypeException(k); if (!force && !(k instanceof StringValue)) throw new NBTSerializableValue.IncompatibleTypeException(k);
@@ -25,13 +25,13 @@ import net.minecraft.entity.passive.VillagerEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Inventory; import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.AbstractListTag; import net.minecraft.nbt.AbstractNbtList;
import net.minecraft.nbt.AbstractNumberTag; import net.minecraft.nbt.AbstractNbtNumber;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.NbtList;
import net.minecraft.nbt.StringNbtReader; import net.minecraft.nbt.StringNbtReader;
import net.minecraft.nbt.StringTag; import net.minecraft.nbt.NbtString;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.NbtElement;
import net.minecraft.predicate.entity.EntityPredicates; import net.minecraft.predicate.entity.EntityPredicates;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
@@ -53,8 +53,8 @@ import java.util.stream.Collectors;
public class NBTSerializableValue extends Value implements ContainerValueInterface public class NBTSerializableValue extends Value implements ContainerValueInterface
{ {
private String nbtString = null; private String nbtString = null;
private Tag nbtTag = null; private NbtElement nbtTag = null;
private Supplier<Tag> nbtSupplier = null; private Supplier<NbtElement> nbtSupplier = null;
private boolean owned = false; private boolean owned = false;
private NBTSerializableValue() {} private NBTSerializableValue() {}
@@ -65,7 +65,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
{ {
try try
{ {
return (new StringNbtReader(new StringReader(nbtString))).parseTag(); return (new StringNbtReader(new StringReader(nbtString))).parseElement();
} }
catch (CommandSyntaxException e) catch (CommandSyntaxException e)
{ {
@@ -75,13 +75,13 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
owned = true; owned = true;
} }
public NBTSerializableValue(Tag tag) public NBTSerializableValue(NbtElement tag)
{ {
nbtTag = tag; nbtTag = tag;
owned = true; owned = true;
} }
public NBTSerializableValue(Supplier<Tag> tagSupplier) public NBTSerializableValue(Supplier<NbtElement> tagSupplier)
{ {
nbtSupplier = tagSupplier; nbtSupplier = tagSupplier;
} }
@@ -108,10 +108,10 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
public static NBTSerializableValue parseString(String nbtString, boolean fail) public static NBTSerializableValue parseString(String nbtString, boolean fail)
{ {
Tag tag; NbtElement tag;
try try
{ {
tag = (new StringNbtReader(new StringReader(nbtString))).parseTag(); tag = (new StringNbtReader(new StringReader(nbtString))).parseElement();
} }
catch (CommandSyntaxException e) catch (CommandSyntaxException e)
{ {
@@ -276,7 +276,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
return parseItem(itemString, null); return parseItem(itemString, null);
} }
public static ItemStackArgument parseItem(String itemString, CompoundTag customTag) public static ItemStackArgument parseItem(String itemString, NbtCompound customTag)
{ {
try try
{ {
@@ -313,12 +313,12 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
return slot; return slot;
} }
private static Value decodeTag(Tag t) private static Value decodeTag(NbtElement t)
{ {
if (t instanceof CompoundTag) if (t instanceof NbtCompound)
return new NBTSerializableValue(() -> t); return new NBTSerializableValue(() -> t);
if (t instanceof AbstractNumberTag) if (t instanceof AbstractNbtNumber)
return new NumericValue(((AbstractNumberTag) t).getDouble()); return new NumericValue(((AbstractNbtNumber) t).doubleValue());
// more can be done here // more can be done here
return new StringValue(t.asString()); return new StringValue(t.asString());
} }
@@ -338,35 +338,35 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
} }
private static Value decodeTagDeep(Tag t) private static Value decodeTagDeep(NbtElement t)
{ {
if (t instanceof CompoundTag) if (t instanceof NbtCompound)
{ {
Map<Value, Value> pairs = new HashMap<>(); Map<Value, Value> pairs = new HashMap<>();
CompoundTag ctag = (CompoundTag)t; NbtCompound ctag = (NbtCompound)t;
for (String key: ctag.getKeys()) for (String key: ctag.getKeys())
{ {
pairs.put(new StringValue(key), decodeTagDeep(ctag.get(key))); pairs.put(new StringValue(key), decodeTagDeep(ctag.get(key)));
} }
return MapValue.wrap(pairs); return MapValue.wrap(pairs);
} }
if (t instanceof AbstractListTag) if (t instanceof AbstractNbtList)
{ {
List<Value> elems = new ArrayList<>(); List<Value> elems = new ArrayList<>();
AbstractListTag<? extends Tag> ltag = (AbstractListTag<? extends Tag>)t; AbstractNbtList<? extends NbtElement> ltag = (AbstractNbtList<? extends NbtElement>)t;
for (Tag elem: ltag) for (NbtElement elem: ltag)
{ {
elems.add(decodeTagDeep(elem)); elems.add(decodeTagDeep(elem));
} }
return ListValue.wrap(elems); return ListValue.wrap(elems);
} }
if (t instanceof AbstractNumberTag) if (t instanceof AbstractNbtNumber)
return new NumericValue(((AbstractNumberTag) t).getDouble()); return new NumericValue(((AbstractNbtNumber) t).doubleValue());
// more can be done here // more can be done here
return new StringValue(t.asString()); return new StringValue(t.asString());
} }
public Tag getTag() public NbtElement getTag()
{ {
if (nbtTag == null) if (nbtTag == null)
nbtTag = nbtSupplier.get(); nbtTag = nbtSupplier.get();
@@ -392,24 +392,24 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
@Override @Override
public boolean getBoolean() public boolean getBoolean()
{ {
Tag tag = getTag(); NbtElement tag = getTag();
if (tag instanceof CompoundTag) if (tag instanceof NbtCompound)
return !((CompoundTag) tag).isEmpty(); return !((NbtCompound) tag).isEmpty();
if (tag instanceof AbstractListTag) if (tag instanceof AbstractNbtList)
return ((AbstractListTag) tag).isEmpty(); return ((AbstractNbtList) tag).isEmpty();
if (tag instanceof AbstractNumberTag) if (tag instanceof AbstractNbtNumber)
return ((AbstractNumberTag) tag).getDouble()!=0.0; return ((AbstractNbtNumber) tag).doubleValue()!=0.0;
if (tag instanceof StringTag) if (tag instanceof NbtString)
return tag.asString().isEmpty(); return tag.asString().isEmpty();
return true; return true;
} }
public CompoundTag getCompoundTag() public NbtCompound getCompoundTag()
{ {
try try
{ {
ensureOwnership(); ensureOwnership();
return (CompoundTag) getTag(); return (NbtCompound) getTag();
} }
catch (ClassCastException e) catch (ClassCastException e)
{ {
@@ -429,7 +429,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
/// WIP /// WIP
ensureOwnership(); ensureOwnership();
NbtPathArgumentType.NbtPath path = cachePath(where.getString()); NbtPathArgumentType.NbtPath path = cachePath(where.getString());
Tag tagToInsert = value instanceof NBTSerializableValue ? NbtElement tagToInsert = value instanceof NBTSerializableValue ?
((NBTSerializableValue) value).getTag() : ((NBTSerializableValue) value).getTag() :
new NBTSerializableValue(value.getString()).getTag(); new NBTSerializableValue(value.getString()).getTag();
boolean modifiedTag; boolean modifiedTag;
@@ -459,17 +459,17 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
private boolean modify_insert(int index, NbtPathArgumentType.NbtPath nbtPath, Tag newElement) private boolean modify_insert(int index, NbtPathArgumentType.NbtPath nbtPath, NbtElement newElement)
{ {
return modify_insert(index, nbtPath, newElement, this.getTag()); return modify_insert(index, nbtPath, newElement, this.getTag());
} }
private boolean modify_insert(int index, NbtPathArgumentType.NbtPath nbtPath, Tag newElement, Tag currentTag) private boolean modify_insert(int index, NbtPathArgumentType.NbtPath nbtPath, NbtElement newElement, NbtElement currentTag)
{ {
Collection<Tag> targets; Collection<NbtElement> targets;
try try
{ {
targets = nbtPath.getOrInit(currentTag, ListTag::new); targets = nbtPath.getOrInit(currentTag, NbtList::new);
} }
catch (CommandSyntaxException e) catch (CommandSyntaxException e)
{ {
@@ -477,16 +477,16 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
} }
boolean modified = false; boolean modified = false;
for (Tag target : targets) for (NbtElement target : targets)
{ {
if (!(target instanceof AbstractListTag)) if (!(target instanceof AbstractNbtList))
{ {
continue; continue;
} }
try try
{ {
AbstractListTag<?> targetList = (AbstractListTag) target; AbstractNbtList<?> targetList = (AbstractNbtList) target;
if (!targetList.addTag(index < 0 ? targetList.size() + index + 1 : index, newElement.copy())) if (!targetList.addElement(index < 0 ? targetList.size() + index + 1 : index, newElement.copy()))
return false; return false;
modified = true; modified = true;
} }
@@ -498,22 +498,22 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
} }
private boolean modify_merge(NbtPathArgumentType.NbtPath nbtPath, Tag replacement) //nbtPathArgumentType$NbtPath_1, list_1) private boolean modify_merge(NbtPathArgumentType.NbtPath nbtPath, NbtElement replacement) //nbtPathArgumentType$NbtPath_1, list_1)
{ {
if (!(replacement instanceof CompoundTag)) if (!(replacement instanceof NbtCompound))
{ {
return false; return false;
} }
Tag ownTag = getTag(); NbtElement ownTag = getTag();
try try
{ {
for (Tag target : nbtPath.getOrInit(ownTag, CompoundTag::new)) for (NbtElement target : nbtPath.getOrInit(ownTag, NbtCompound::new))
{ {
if (!(target instanceof CompoundTag)) if (!(target instanceof NbtCompound))
{ {
continue; continue;
} }
((CompoundTag) target).copyFrom((CompoundTag) replacement); ((NbtCompound) target).copyFrom((NbtCompound) replacement);
} }
} }
catch (CommandSyntaxException ignored) catch (CommandSyntaxException ignored)
@@ -523,9 +523,9 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
return true; return true;
} }
private boolean modify_replace(NbtPathArgumentType.NbtPath nbtPath, Tag replacement) //nbtPathArgumentType$NbtPath_1, list_1) private boolean modify_replace(NbtPathArgumentType.NbtPath nbtPath, NbtElement replacement) //nbtPathArgumentType$NbtPath_1, list_1)
{ {
Tag tag = getTag(); NbtElement tag = getTag();
String pathText = nbtPath.toString(); String pathText = nbtPath.toString();
if (pathText.endsWith("]")) // workaround for array replacement or item in the array replacement if (pathText.endsWith("]")) // workaround for array replacement or item in the array replacement
{ {
@@ -572,7 +572,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
NbtPathArgumentType.NbtPath path = cachePath(value.getString()); NbtPathArgumentType.NbtPath path = cachePath(value.getString());
try try
{ {
List<Tag> tags = path.get(getTag()); List<NbtElement> tags = path.get(getTag());
if (tags.size()==0) if (tags.size()==0)
return Value.NULL; return Value.NULL;
if (tags.size()==1) if (tags.size()==1)
@@ -669,7 +669,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
@Override @Override
public Tag toTag(boolean force) public NbtElement toTag(boolean force)
{ {
if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this); if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this);
ensureOwnership(); ensureOwnership();
@@ -4,8 +4,8 @@ import java.util.ArrayList;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonNull; import com.google.gson.JsonNull;
import net.minecraft.nbt.StringTag; import net.minecraft.nbt.NbtString;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.NbtElement;
public class NullValue extends NumericValue // TODO check nonsingleton code public class NullValue extends NumericValue // TODO check nonsingleton code
{ {
@@ -80,10 +80,10 @@ public class NullValue extends NumericValue // TODO check nonsingleton code
} }
@Override @Override
public Tag toTag(boolean force) public NbtElement toTag(boolean force)
{ {
if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this); if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this);
return StringTag.of("null"); return NbtString.of("null");
} }
@Override @Override
@@ -3,10 +3,10 @@ package carpet.script.value;
import carpet.script.exception.InternalExpressionException; import carpet.script.exception.InternalExpressionException;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive; import com.google.gson.JsonPrimitive;
import net.minecraft.nbt.DoubleTag; import net.minecraft.nbt.NbtDouble;
import net.minecraft.nbt.IntTag; import net.minecraft.nbt.NbtInt;
import net.minecraft.nbt.LongTag; import net.minecraft.nbt.NbtLong;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.NbtElement;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
@@ -271,20 +271,20 @@ public class NumericValue extends Value
} }
@Override @Override
public Tag toTag(boolean force) public NbtElement toTag(boolean force)
{ {
if (longValue != null) if (longValue != null)
return LongTag.of(longValue); return NbtLong.of(longValue);
long lv = getLong(); long lv = getLong();
if (value == (double)lv) if (value == (double)lv)
{ {
if (abs(value) < Integer.MAX_VALUE-2) if (abs(value) < Integer.MAX_VALUE-2)
return IntTag.of((int)lv); return NbtInt.of((int)lv);
return LongTag.of(getLong()); return NbtLong.of(getLong());
} }
else else
{ {
return DoubleTag.of(value); return NbtDouble.of(value);
} }
} }
@@ -1,7 +1,7 @@
package carpet.script.value; package carpet.script.value;
import net.minecraft.nbt.StringTag; import net.minecraft.nbt.NbtString;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.NbtElement;
public class StringValue extends Value public class StringValue extends Value
{ {
@@ -43,8 +43,8 @@ public class StringValue extends Value
} }
@Override @Override
public Tag toTag(boolean force) public NbtElement toTag(boolean force)
{ {
return StringTag.of(str); return NbtString.of(str);
} }
} }
@@ -6,7 +6,7 @@ import carpet.script.Tokenizer;
import carpet.script.exception.ExitStatement; import carpet.script.exception.ExitStatement;
import carpet.script.exception.ExpressionException; import carpet.script.exception.ExpressionException;
import carpet.script.exception.InternalExpressionException; import carpet.script.exception.InternalExpressionException;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.NbtElement;
import java.util.List; import java.util.List;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@@ -117,7 +117,7 @@ public class ThreadValue extends Value
} }
@Override @Override
public Tag toTag(boolean force) public NbtElement toTag(boolean force)
{ {
if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this); if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this);
return getValue().toTag(true); return getValue().toTag(true);
+2 -2
View File
@@ -3,7 +3,7 @@ package carpet.script.value;
import carpet.script.exception.InternalExpressionException; import carpet.script.exception.InternalExpressionException;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive; import com.google.gson.JsonPrimitive;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.NbtElement;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@@ -251,7 +251,7 @@ public abstract class Value implements Comparable<Value>, Cloneable
} }
} }
public abstract Tag toTag(boolean force); public abstract NbtElement toTag(boolean force);
public JsonElement toJson() public JsonElement toJson()
{ {