This commit is contained in:
gnembon committed 2024-02-29 11:05:15 +01:00
1 parent 2dd8674ea6
commit 4e57eecf2d
37 files changed
+534 -481

No files matched your search

@@ -8,14 +8,12 @@ import carpet.script.utils.Colors;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import net.minecraft.advancements.critereon.MinMaxBounds;
import net.minecraft.commands.arguments.item.ItemInput;
import net.minecraft.core.BlockPos;
import net.minecraft.core.GlobalPos;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess;
import net.minecraft.core.Vec3i;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceKey;
@@ -58,8 +56,6 @@ import java.util.UUID;
import java.util.function.Predicate;
import java.util.stream.StreamSupport;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import javax.annotation.Nullable;
public class ValueConversions
@@ -97,22 +93,12 @@ public class ValueConversions
);
}
@Deprecated
public static Value of(ItemStack stack)
{
return stack == null || stack.isEmpty() ? Value.NULL : ListValue.of(
of(BuiltInRegistries.ITEM.getKey(stack.getItem())),
new NumericValue(stack.getCount()),
NBTSerializableValue.fromStack(stack)
);
}
public static Value of(ItemStack stack, RegistryAccess regs)
{
return stack == null || stack.isEmpty() ? Value.NULL : ListValue.of(
of(regs.registryOrThrow(Registries.ITEM).getKey(stack.getItem())),
new NumericValue(stack.getCount()),
NBTSerializableValue.fromStack(stack)
NBTSerializableValue.fromStack(stack, regs)
);
}
@@ -503,22 +489,9 @@ public class ValueConversions
{
name = value.getString();
}
ItemInput itemInput = NBTSerializableValue.parseItem(name, nbtTag, regs);
try
{
return itemInput.createItemStack(count, false);
}
catch (CommandSyntaxException cse)
{
if (!withCount)
{
throw new IllegalStateException("Unexpected exception while creating item stack of " + name + ". All items should be able to stack to one", cse);
}
else
{
throw new ThrowStatement(count + " stack size of " + name, Throwables.UNKNOWN_ITEM);
}
}
ItemStack itemInput = NBTSerializableValue.parseItem(name, nbtTag, regs);
itemInput.setCount(count);
return itemInput;
}
public static Value guess(ServerLevel serverWorld, Object o)