From 2b3f3768717a457662e7605de7b4cc0d4e5a68bc Mon Sep 17 00:00:00 2001 From: altrisi Date: Mon, 24 May 2021 12:00:55 +0200 Subject: [PATCH] Replace usages of deprecated ListValue::fromItemStack and remove it --- src/main/java/carpet/script/CarpetEventServer.java | 12 ++++++------ src/main/java/carpet/script/value/EntityValue.java | 4 ++-- src/main/java/carpet/script/value/ListValue.java | 7 ------- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/main/java/carpet/script/CarpetEventServer.java b/src/main/java/carpet/script/CarpetEventServer.java index 4534d667..baae0119 100644 --- a/src/main/java/carpet/script/CarpetEventServer.java +++ b/src/main/java/carpet/script/CarpetEventServer.java @@ -479,7 +479,7 @@ public class CarpetEventServer //ItemStack itemstack = player.getStackInHand(enumhand); return Arrays.asList( new EntityValue(player), - ListValue.fromItemStack(itemstack), + ValueConversions.of(itemstack), StringValue.of(enumhand == Hand.MAIN_HAND ? "mainhand" : "offhand") ); }, player::getCommandSource); @@ -513,7 +513,7 @@ public class CarpetEventServer Vec3d vec3d = hitRes.getPos().subtract(blockpos.getX(), blockpos.getY(), blockpos.getZ()); return Arrays.asList( new EntityValue(player), - ListValue.fromItemStack(itemstack), + ValueConversions.of(itemstack), StringValue.of(enumhand == Hand.MAIN_HAND ? "mainhand" : "offhand"), new BlockValue(null, player.getServerWorld(), blockpos), StringValue.of(enumfacing.getName()), @@ -557,7 +557,7 @@ public class CarpetEventServer { handler.call( () -> Arrays.asList( new EntityValue(player), - ListValue.fromItemStack(itemstack), + ValueConversions.of(itemstack), StringValue.of(enumhand == Hand.MAIN_HAND ? "mainhand" : "offhand"), new BlockValue(null, player.getServerWorld(), pos) ), player::getCommandSource); @@ -602,7 +602,7 @@ public class CarpetEventServer { @Override public void onItemAction(ServerPlayerEntity player, Hand enumhand, ItemStack itemstack) { - handler.call( () -> Arrays.asList(new EntityValue(player), ListValue.fromItemStack(itemstack)), player::getCommandSource); + handler.call( () -> Arrays.asList(new EntityValue(player), ValueConversions.of(itemstack)), player::getCommandSource); } }; @@ -656,7 +656,7 @@ public class CarpetEventServer handler.call( () -> Arrays.asList( new EntityValue(player), - ListValue.fromItemStack(itemstack), + ValueConversions.of(itemstack), StringValue.of(enumhand == Hand.MAIN_HAND ? "mainhand" : "offhand") ), player::getCommandSource); } @@ -670,7 +670,7 @@ public class CarpetEventServer handler.call( () -> Arrays.asList( new EntityValue(player), - ListValue.fromItemStack(itemstack), + ValueConversions.of(itemstack), new StringValue(enumhand == Hand.MAIN_HAND ? "mainhand" : "offhand") ), player::getCommandSource); } diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index bf125311..f5520774 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -486,7 +486,7 @@ public class EntityValue extends Value put("age", (e, a) -> new NumericValue(e.age)); put("breeding_age", (e, a) -> e instanceof PassiveEntity?new NumericValue(((PassiveEntity) e).getBreedingAge()):Value.NULL); put("despawn_timer", (e, a) -> e instanceof LivingEntity?new NumericValue(((LivingEntity) e).getDespawnCounter()):Value.NULL); - put("item", (e, a) -> (e instanceof ItemEntity)?ListValue.fromItemStack(((ItemEntity) e).getStack()):Value.NULL); + put("item", (e, a) -> (e instanceof ItemEntity)?ValueConversions.of(((ItemEntity) e).getStack()):Value.NULL); put("count", (e, a) -> (e instanceof ItemEntity)?new NumericValue(((ItemEntity) e).getStack().getCount()):Value.NULL); put("pickup_delay", (e, a) -> (e instanceof ItemEntity)?new NumericValue(((ItemEntityInterface) e).getPickupDelayCM()):Value.NULL); put("portal_cooldown", (e , a) ->new NumericValue(((EntityInterface)e).getPortalTimer())); @@ -734,7 +734,7 @@ public class EntityValue extends Value if (where == null) throw new InternalExpressionException("Unknown inventory slot: "+a.getString()); if (e instanceof LivingEntity) - return ListValue.fromItemStack(((LivingEntity)e).getEquippedStack(where)); + return ValueConversions.of(((LivingEntity)e).getEquippedStack(where)); return Value.NULL; }); diff --git a/src/main/java/carpet/script/value/ListValue.java b/src/main/java/carpet/script/value/ListValue.java index 36766093..886019d4 100644 --- a/src/main/java/carpet/script/value/ListValue.java +++ b/src/main/java/carpet/script/value/ListValue.java @@ -4,7 +4,6 @@ import carpet.script.LazyValue; import carpet.script.exception.InternalExpressionException; import com.google.gson.JsonArray; import com.google.gson.JsonElement; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.AbstractNumberTag; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.DoubleTag; @@ -75,12 +74,6 @@ public class ListValue extends AbstractListValue implements ContainerValueInterf items = list; } - @Deprecated - public static Value fromItemStack(ItemStack itemstack) - { - return ValueConversions.of(itemstack); - } - public static Value fromTriple(double a, double b, double c) { return ListValue.of(new NumericValue(a), new NumericValue(b), new NumericValue(c));