diff --git a/src/main/java/carpet/script/CarpetEventServer.java b/src/main/java/carpet/script/CarpetEventServer.java index 28d76232..461dde8f 100644 --- a/src/main/java/carpet/script/CarpetEventServer.java +++ b/src/main/java/carpet/script/CarpetEventServer.java @@ -292,11 +292,7 @@ public class CarpetEventServer ItemStack itemstack = player.getStackInHand(enumhand); return Arrays.asList( ((c, t) -> new EntityValue(player)), - ((c, t) -> ListValue.of( - new StringValue(Registry.ITEM.getId(itemstack.getItem()).getPath()), - new NumericValue(itemstack.getCount()), - new StringValue(itemstack.toTag(new CompoundTag()).toString()) - )), + ((c, t) -> ListValue.fromItemStack(itemstack)), ((c, t) -> new StringValue(enumhand == Hand.MAIN_HAND ? "mainhand" : "offhand")) ); }, player::getCommandSource); @@ -321,11 +317,7 @@ public class CarpetEventServer Vec3d vec3d = hitRes.getPos().subtract(blockpos.getX(), blockpos.getY(), blockpos.getZ()); return Arrays.asList( ((c, t) -> new EntityValue(player)), - ((c, t) -> ListValue.of( - new StringValue(Registry.ITEM.getId(itemstack.getItem()).getPath()), - new NumericValue(itemstack.getCount()), - new StringValue(itemstack.toTag(new CompoundTag()).toString()) - )), + ((c, t) -> ListValue.fromItemStack(itemstack)), ((c, t) -> new StringValue(enumhand == Hand.MAIN_HAND ? "mainhand" : "offhand")), ((c, t) -> new BlockValue(null, player.world, blockpos)), ((c, t) -> new StringValue(enumfacing.getName())), diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index 664ef537..dc7ffb71 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -215,7 +215,7 @@ public class EntityValue extends Value put("width", (e, a) -> new NumericValue(e.getDimensions(EntityPose.STANDING).width)); put("eye_height", (e, a) -> new NumericValue(e.getEyeHeight(EntityPose.STANDING))); put("age", (e, a) -> new NumericValue(e.age)); - put("item", (e, a) -> (e instanceof ItemEntity)?new StringValue(((ItemEntity) e).getStack().getName().getString()):Value.NULL); + put("item", (e, a) -> (e instanceof ItemEntity)?ListValue.fromItemStack(((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).getPickupDelay()):Value.NULL); // ItemEntity -> despawn timer via ssGetAge