fixes for 22w11a

This commit is contained in:
gnembon committed 2022-03-17 20:21:55 +01:00
1 parent 3e419d1557
commit 302a7b4817
39 files changed
+410 -305

No files matched your search

@@ -775,11 +775,11 @@ public class Auxiliary {
plopData.put(StringValue.of("configured_features"),
ListValue.wrap(registryManager.registryOrThrow(Registry.CONFIGURED_FEATURE_REGISTRY).keySet().stream().sorted().map(ValueConversions::of).collect(Collectors.toList()))
);
plopData.put(StringValue.of("structures"),
ListValue.wrap(Registry.STRUCTURE_FEATURE.keySet().stream().sorted().map(ValueConversions::of).collect(Collectors.toList()))
plopData.put(StringValue.of("structure_types"),
ListValue.wrap(Registry.STRUCTURE_TYPES.keySet().stream().sorted().map(ValueConversions::of).collect(Collectors.toList()))
);
plopData.put(StringValue.of("configured_structures"),
ListValue.wrap(registryManager.registryOrThrow(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY).keySet().stream().sorted().map(ValueConversions::of).collect(Collectors.toList()))
plopData.put(StringValue.of("structures"),
ListValue.wrap(registryManager.registryOrThrow(Registry.STRUCTURE_REGISTRY).keySet().stream().sorted().map(ValueConversions::of).collect(Collectors.toList()))
);
return MapValue.wrap(plopData);
}
@@ -46,6 +46,8 @@ import net.minecraft.core.QuartPos;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.tags.TagKey;
import net.minecraft.world.level.levelgen.structure.Structure;
import net.minecraft.world.level.levelgen.structure.StructureType;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
@@ -111,13 +113,10 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.WorldgenRandom;
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
import net.minecraft.world.level.levelgen.feature.StructureFeature;
import net.minecraft.world.level.levelgen.structure.BoundingBox;
import net.minecraft.world.level.levelgen.structure.StructureStart;
import net.minecraft.world.level.pathfinder.PathComputationType;
@@ -237,11 +236,11 @@ public class WorldAccess {
return (float) num;
}
private static void BooYah(ChunkGenerator generator)
private static void BooYah(final ServerLevel level)
{
synchronized (generator)
synchronized (level)
{
((ChunkGeneratorInterface)generator).initStrongholds();
((ChunkGeneratorInterface)level.getChunkSource().getGenerator()).initStrongholds(level);
}
}
@@ -1285,15 +1284,15 @@ public class WorldAccess {
BlockArgument locator = BlockArgument.findIn(cc, lv, 0);
ServerLevel world = cc.s.getLevel();
BlockPos pos = locator.block.getPos();
Map<ConfiguredStructureFeature<?,?>, LongSet> references = world.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.STRUCTURE_REFERENCES).getAllReferences();
Registry<ConfiguredStructureFeature<?, ?>> reg = cc.s.getServer().registryAccess().registryOrThrow(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY);
Map<Structure, LongSet> references = world.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.STRUCTURE_REFERENCES).getAllReferences();
Registry<Structure> reg = cc.s.getServer().registryAccess().registryOrThrow(Registry.STRUCTURE_REGISTRY);
if (lv.size() == locator.offset)
return ListValue.wrap(references.entrySet().stream().
filter(e -> e.getValue()!= null && !e.getValue().isEmpty()).
map(e -> new StringValue(NBTSerializableValue.nameFromRegistryId(reg.getKey(e.getKey())))).collect(Collectors.toList())
);
String simpleStructureName = lv.get(locator.offset).getString().toLowerCase(Locale.ROOT);
ConfiguredStructureFeature<?,?> structureName = reg.get(InputValidator.identifierOf(simpleStructureName));
Structure structureName = reg.get(InputValidator.identifierOf(simpleStructureName));
if (structureName == null) return Value.NULL;
LongSet structureReferences = references.get(structureName);
if (structureReferences == null || structureReferences.isEmpty()) return ListValue.of();
@@ -1311,13 +1310,13 @@ public class WorldAccess {
ServerLevel world = cc.s.getLevel();
// well, because
BooYah(world.getChunkSource().getGenerator());
BooYah(world);
BlockPos pos = locator.block.getPos();
final List<ConfiguredStructureFeature<?, ?>> structure = new ArrayList<>();
final List<Structure> structure = new ArrayList<>();
boolean needSize = false;
boolean singleOutput = false;
Registry<ConfiguredStructureFeature<?, ?>> reg = cc.s.getServer().registryAccess().registryOrThrow(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY);
Registry<Structure> reg = cc.s.getServer().registryAccess().registryOrThrow(Registry.STRUCTURE_REGISTRY);
if (lv.size() > locator.offset)
{
Value requested = lv.get(locator.offset+0);
@@ -1325,7 +1324,7 @@ public class WorldAccess {
{
String reqString = requested.getString();
var id = InputValidator.identifierOf(reqString);
ConfiguredStructureFeature<?, ?> requestedStructure = reg.get(id);
Structure requestedStructure = reg.get(id);
if (requestedStructure != null)
{
singleOutput = true;
@@ -1333,10 +1332,8 @@ public class WorldAccess {
}
else
{
Registry<StructureFeature<?>> reg1 = cc.s.getServer().registryAccess().registryOrThrow(Registry.STRUCTURE_FEATURE_REGISTRY);
StructureFeature<?> sss = reg1.get(id);
// bad
reg.entrySet().stream().filter(e -> e.getValue().feature==sss).forEach(e -> structure.add(e.getValue()));
StructureType<?> sss = Registry.STRUCTURE_TYPES.get(id);
reg.entrySet().stream().filter(e -> e.getValue().type() ==sss).forEach(e -> structure.add(e.getValue()));
}
if (structure.isEmpty())
{
@@ -1365,7 +1362,7 @@ public class WorldAccess {
return ValueConversions.of(start);
}
Map<Value, Value> ret = new HashMap<>();
for(ConfiguredStructureFeature<?, ?> str: structure)
for(Structure str: structure)
{
StructureStart start;
try
@@ -1392,12 +1389,12 @@ public class WorldAccess {
ServerLevel world = cc.s.getLevel();
BlockPos pos = locator.block.getPos();
Map<ConfiguredStructureFeature<?,?>, StructureStart> structures = world.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.STRUCTURE_STARTS).getAllStarts();
Registry<ConfiguredStructureFeature<?, ?>> reg = cc.s.getServer().registryAccess().registryOrThrow(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY);
Map<Structure, StructureStart> structures = world.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.STRUCTURE_STARTS).getAllStarts();
Registry<Structure> reg = cc.s.getServer().registryAccess().registryOrThrow(Registry.STRUCTURE_REGISTRY);
if (lv.size() == locator.offset)
{
Map<Value, Value> structureList = new HashMap<>();
for (Map.Entry<ConfiguredStructureFeature<?, ?>, StructureStart> entry : structures.entrySet())
for (Map.Entry<Structure, StructureStart> entry : structures.entrySet())
{
StructureStart start = entry.getValue();
if (start == StructureStart.INVALID_START)
@@ -1425,14 +1422,14 @@ public class WorldAccess {
if (lv.size() == locator.offset)
throw new InternalExpressionException("'set_structure requires at least position and a structure name");
String structureName = lv.get(locator.offset).getString().toLowerCase(Locale.ROOT);
ConfiguredStructureFeature<?, ?> configuredStructure = FeatureGenerator.resolveConfiguredStructure(structureName, world, pos);
Structure configuredStructure = FeatureGenerator.resolveConfiguredStructure(structureName, world, pos);
if (configuredStructure == null) throw new ThrowStatement(structureName, Throwables.UNKNOWN_STRUCTURE);
// good 'ol pointer
Value[] result = new Value[]{Value.NULL};
// technically a world modification. Even if we could let it slide, we will still park it
((CarpetContext) c).s.getServer().executeBlocking(() ->
{
Map<ConfiguredStructureFeature<?, ?>, StructureStart> structures = world.getChunk(pos).getAllStarts();
Map<Structure, StructureStart> structures = world.getChunk(pos).getAllStarts();
if (lv.size() == locator.offset + 1)
{
Boolean res = FeatureGenerator.plopGrid(configuredStructure, ((CarpetContext) c).s.getLevel(), locator.block.getPos());
@@ -1443,7 +1440,7 @@ public class WorldAccess {
Value newValue = lv.get(locator.offset+1);
if (newValue.isNull()) // remove structure
{
ConfiguredStructureFeature<?,?> structure = configuredStructure;
Structure structure = configuredStructure;
if (!structures.containsKey(structure))
{
return;
@@ -1457,7 +1454,7 @@ public class WorldAccess {
{
ChunkPos chpos = new ChunkPos(chx, chz);
// getting a chunk will convert it to full, allowing to modify references
Map<ConfiguredStructureFeature<?,?>, LongSet> references =
Map<Structure, LongSet> references =
world.getChunk(chpos.getWorldPosition()).getAllReferences();
if (references.containsKey(structure) && references.get(structure) != null)
references.get(structure).remove(structureChunkPos.toLong());
@@ -1469,7 +1466,7 @@ public class WorldAccess {
});
return result[0]; // preventing from lazy evaluating of the result in case a future completes later
});
/*
expression.addContextFunction("custom_dimension", -1, (c, t, lv) ->
{
if (lv.size() == 0) throw new InternalExpressionException("'custom_dimension' requires at least one argument");
@@ -1496,7 +1493,7 @@ public class WorldAccess {
CarpetServer.settingsManager.notifyPlayersCommandsChanged();
return Value.TRUE;
});
*/
// todo maybe enable chunk blending?
expression.addContextFunction("reset_chunk", -1, (c, t, lv) ->
{
@@ -54,6 +54,7 @@ import java.util.stream.Collectors;
import net.minecraft.ChatFormatting;
import net.minecraft.advancements.Advancement;
import net.minecraft.advancements.critereon.MinMaxBounds;
import net.minecraft.commands.CommandBuildContext;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.commands.arguments.AngleArgument;
@@ -93,6 +94,7 @@ import net.minecraft.commands.synchronization.SuggestionProviders;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
@@ -266,7 +268,7 @@ public abstract class CommandArgument
new VanillaUnconfigurableArgument("uuid", UuidArgument::uuid,
(c, p) -> StringValue.of(UuidArgument.getUuid(c, p).toString()), false
),
new VanillaUnconfigurableArgument("surfacelocation", Vec2Argument::vec2, // vec2
new VanillaUnconfigurableArgument("surfacelocation", () -> Vec2Argument.vec2(), // vec2
(c, p) -> {
Vec2 res = Vec2Argument.getVec2(c, p);
return ListValue.of(NumericValue.of(res.x), NumericValue.of(res.y));
@@ -298,10 +300,10 @@ public abstract class CommandArgument
public static RequiredArgumentBuilder<CommandSourceStack, ?> argumentNode(String param, CarpetScriptHost host) throws CommandSyntaxException
{
CommandArgument arg = getTypeForArgument(param, host);
if (arg.suggestionProvider != null) return argument(param, arg.getArgumentType()).suggests(arg.suggestionProvider);
if (!arg.needsMatching) return argument(param, arg.getArgumentType());
if (arg.suggestionProvider != null) return argument(param, arg.getArgumentType(host)).suggests(arg.suggestionProvider);
if (!arg.needsMatching) return argument(param, arg.getArgumentType(host));
String hostName = host.getName();
return argument(param, arg.getArgumentType()).suggests((ctx, b) -> {
return argument(param, arg.getArgumentType(host)).suggests((ctx, b) -> {
CarpetScriptHost cHost = CarpetServer.scriptServer.modules.get(hostName).retrieveOwnForExecution(ctx.getSource());
return arg.suggest(ctx, b, cHost);
});
@@ -325,7 +327,7 @@ public abstract class CommandArgument
this.needsMatching = suggestFromExamples;
}
protected abstract ArgumentType<?> getArgumentType() throws CommandSyntaxException;
protected abstract ArgumentType<?> getArgumentType(CarpetScriptHost host) throws CommandSyntaxException;
public static Value getValue(CommandContext<CommandSourceStack> context, String param, CarpetScriptHost host) throws CommandSyntaxException
@@ -445,7 +447,7 @@ public abstract class CommandArgument
}
@Override
public ArgumentType<?> getArgumentType()
public ArgumentType<?> getArgumentType(CarpetScriptHost host)
{
return StringArgumentType.string();
}
@@ -490,7 +492,7 @@ public abstract class CommandArgument
{
private WordArgument() { super(); suffix = "term"; examples = StringArgumentType.StringType.SINGLE_WORD.getExamples(); }
@Override
public ArgumentType<?> getArgumentType() { return StringArgumentType.word(); }
public ArgumentType<?> getArgumentType(CarpetScriptHost host) { return StringArgumentType.word(); }
@Override
protected Supplier<CommandArgument> factory() { return WordArgument::new; }
}
@@ -499,7 +501,7 @@ public abstract class CommandArgument
{
private GreedyStringArgument() { super();suffix = "text"; examples = StringArgumentType.StringType.GREEDY_PHRASE.getExamples(); }
@Override
public ArgumentType<?> getArgumentType() { return StringArgumentType.greedyString(); }
public ArgumentType<?> getArgumentType(CarpetScriptHost host) { return StringArgumentType.greedyString(); }
@Override
protected Supplier<CommandArgument> factory() { return GreedyStringArgument::new; }
}
@@ -514,7 +516,7 @@ public abstract class CommandArgument
}
@Override
public ArgumentType<?> getArgumentType()
public ArgumentType<?> getArgumentType(CarpetScriptHost host)
{
return net.minecraft.commands.arguments.coordinates.BlockPosArgument.blockPos();
}
@@ -552,7 +554,7 @@ public abstract class CommandArgument
blockCentered = true;
}
@Override
protected ArgumentType<?> getArgumentType()
protected ArgumentType<?> getArgumentType(CarpetScriptHost host)
{
return Vec3Argument.vec3(blockCentered);
}
@@ -589,7 +591,7 @@ public abstract class CommandArgument
single = false;
}
@Override
protected ArgumentType<?> getArgumentType()
protected ArgumentType<?> getArgumentType(CarpetScriptHost host)
{
if (onlyFans)
{
@@ -636,7 +638,7 @@ public abstract class CommandArgument
single = false;
}
@Override
protected ArgumentType<?> getArgumentType()
protected ArgumentType<?> getArgumentType(CarpetScriptHost host)
{
return GameProfileArgument.gameProfile();
}
@@ -677,7 +679,7 @@ public abstract class CommandArgument
suggestionProvider = ScoreHolderArgument.SUGGEST_SCORE_HOLDERS;
}
@Override
protected ArgumentType<?> getArgumentType()
protected ArgumentType<?> getArgumentType(CarpetScriptHost host)
{
return single?ScoreHolderArgument.scoreHolder():ScoreHolderArgument.scoreHolders();
}
@@ -716,7 +718,7 @@ public abstract class CommandArgument
mapRequired = true;
}
@Override
protected ArgumentType<?> getArgumentType()
protected ArgumentType<?> getArgumentType(CarpetScriptHost host)
{
return mapRequired?CompoundTagArgument.compoundTag(): NbtTagArgument.nbtTag();
}
@@ -754,7 +756,7 @@ public abstract class CommandArgument
}
@Override
protected ArgumentType<?> getArgumentType()
protected ArgumentType<?> getArgumentType(CarpetScriptHost host)
{
return ResourceLocationArgument.id();
}
@@ -799,7 +801,7 @@ public abstract class CommandArgument
}
@Override
public ArgumentType<?> getArgumentType()
public ArgumentType<?> getArgumentType(CarpetScriptHost host)
{
if (min != null)
{
@@ -850,7 +852,7 @@ public abstract class CommandArgument
}
@Override
public ArgumentType<?> getArgumentType()
public ArgumentType<?> getArgumentType(CarpetScriptHost host)
{
if (min != null)
{
@@ -944,7 +946,7 @@ public abstract class CommandArgument
}
@Override
protected ArgumentType<?> getArgumentType() throws CommandSyntaxException
protected ArgumentType<?> getArgumentType(CarpetScriptHost host) throws CommandSyntaxException
{
return net.minecraft.commands.arguments.SlotArgument.slot();
}
@@ -998,11 +1000,19 @@ public abstract class CommandArgument
ArgumentType<?> get() throws CommandSyntaxException;
}
@FunctionalInterface
private interface ArgumentProviderEx
{
ArgumentType<?> get(CommandBuildContext regAccess) throws CommandSyntaxException;
}
public static class VanillaUnconfigurableArgument extends CommandArgument
{
private final ArgumentProvider argumentTypeSupplier;
private final ArgumentProviderEx argumentTypeSupplierEx;
private final ValueExtractor valueExtractor;
private final boolean providesExamples;
public VanillaUnconfigurableArgument(
String suffix,
ArgumentProvider argumentTypeSupplier,
@@ -1022,6 +1032,7 @@ public abstract class CommandArgument
this.providesExamples = suggestFromExamples;
this.argumentTypeSupplier = argumentTypeSupplier;
this.valueExtractor = valueExtractor;
this.argumentTypeSupplierEx = null;
}
public VanillaUnconfigurableArgument(
String suffix,
@@ -1035,12 +1046,38 @@ public abstract class CommandArgument
this.providesExamples = false;
this.argumentTypeSupplier = argumentTypeSupplier;
this.valueExtractor = valueExtractor;
this.argumentTypeSupplierEx = null;
}
public VanillaUnconfigurableArgument(
String suffix,
ArgumentProviderEx argumentTypeSupplier,
ValueExtractor valueExtractor,
boolean suggestFromExamples
)
{
super(suffix, null, suggestFromExamples);
try
{
final CommandBuildContext context = new CommandBuildContext(RegistryAccess.BUILTIN.get());
context.missingTagAccessPolicy(CommandBuildContext.MissingTagAccessPolicy.RETURN_EMPTY);
this.examples = argumentTypeSupplier.get(context).getExamples();
}
catch (CommandSyntaxException e)
{
this.examples = Collections.emptyList();
}
this.providesExamples = suggestFromExamples;
this.argumentTypeSupplierEx = argumentTypeSupplier;
this.valueExtractor = valueExtractor;
this.argumentTypeSupplier = null;
}
@Override
protected ArgumentType<?> getArgumentType() throws CommandSyntaxException
protected ArgumentType<?> getArgumentType(CarpetScriptHost host) throws CommandSyntaxException
{
return argumentTypeSupplier.get();
if (argumentTypeSupplier != null) return argumentTypeSupplier.get();
CommandBuildContext registryAccess = new CommandBuildContext(host.getScriptServer().server.registryAccess());
return argumentTypeSupplierEx.get(registryAccess);
}
@Override
@@ -1052,7 +1089,8 @@ public abstract class CommandArgument
@Override
protected Supplier<CommandArgument> factory()
{
return () -> new VanillaUnconfigurableArgument(getTypeSuffix(), argumentTypeSupplier, valueExtractor, providesExamples);
if (argumentTypeSupplier != null) return () -> new VanillaUnconfigurableArgument(getTypeSuffix(), argumentTypeSupplier, valueExtractor, providesExamples);
return () -> new VanillaUnconfigurableArgument(getTypeSuffix(), argumentTypeSupplierEx, valueExtractor, providesExamples);
}
}
}
@@ -8,12 +8,11 @@ import carpet.script.value.StringValue;
import carpet.script.value.Value;
import carpet.script.value.ValueConversions;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.BiFunction;
import java.util.stream.Collectors;
import net.minecraft.core.Holder;
import net.minecraft.core.HolderSet;
import net.minecraft.core.Registry;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.biome.Biome;
@@ -25,7 +24,12 @@ public class BiomeInfo
public final static Map<String, BiFunction<ServerLevel, Biome, Value>> biomeFeatures = new HashMap<String, BiFunction<ServerLevel, Biome, Value>>(){{
//put("top_material", (w, b) -> new BlockValue( b.getGenerationSettings(). getSurfaceConfig().getTopMaterial(), null, null));
//put("under_material", (w, b) -> new BlockValue( b.getGenerationSettings().getSurfaceConfig().getUnderMaterial(), null, null));
put("category", (w, b) -> StringValue.of(Biome.getBiomeCategory(Holder.direct(b)).getName()));
//put("category", (w, b) -> StringValue.of(Biome.getBiomeCategory(Holder.direct(b)).getName()));
put("biome_tags", (w, b) -> {
Holder<Biome> direct = Holder.direct(b);
return ListValue.wrap(w.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getTags().filter(p -> p.getSecond().contains(direct)).map(p -> p.getFirst().location()).map(ValueConversions::of).collect(Collectors.toList()));
});
put("temperature", (w, b) -> NumericValue.of(b.getBaseTemperature()));
put("fog_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().getFogColor()));
put("foliage_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().getFoliageColorOverride().orElse(4764952))); // client Biome.getDefaultFoliageColor
@@ -72,7 +72,7 @@ public class WorldTools
catch (IOException ignored) { }
return true;
}
/*
public static boolean createWorld(MinecraftServer server, String worldKey, Long seed)
{
ResourceLocation worldId = new ResourceLocation(worldKey);
@@ -137,7 +137,7 @@ public class WorldTools
overWorld.getWorldBorder().addListener(new BorderChangeListener.DelegateBorderChangeListener(serverWorld.getWorldBorder()));
((MinecraftServerInterface) server).getCMWorlds().put(customWorld, serverWorld);
return true;
}
}*/
public static void forceChunkUpdate(BlockPos pos, ServerLevel world)
{
@@ -18,6 +18,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis;
import net.minecraft.core.GlobalPos;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.Registry;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.StringTag;
@@ -59,13 +60,13 @@ public class BlockValue extends Value
{
BlockValue bv = bvCache.get(str);
if (bv != null) return bv;
BlockStateParser blockstateparser = (new BlockStateParser(new StringReader(str), false)).parse(true);
if (blockstateparser.getState() != null)
BlockStateParser.BlockResult foo = BlockStateParser.parseForBlock(HolderLookup.forRegistry(Registry.BLOCK), new StringReader(str), true );
if (foo.blockState() != null)
{
CompoundTag bd = blockstateparser.getNbt();
CompoundTag bd = foo.nbt();
if (bd == null)
bd = new CompoundTag();
bv = new BlockValue(blockstateparser.getState(), null, null, bd );
bv = new BlockValue(foo.blockState(), null, null, bd );
if (bvCache.size()>10000)
bvCache.clear();
bvCache.put(str, bv);
@@ -22,6 +22,9 @@ import net.minecraft.commands.arguments.NbtPathArgument;
import net.minecraft.commands.arguments.item.ItemInput;
import net.minecraft.commands.arguments.item.ItemParser;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.Registry;
import net.minecraft.nbt.CollectionTag;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.EndTag;
@@ -301,17 +304,17 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
if (customTag == null)
return res;
else
return new ItemInput(res.getItem(), customTag);
return new ItemInput(Holder.direct(res.getItem()), customTag);
ItemParser.ItemResult parser = ItemParser.parseForItem(HolderLookup.forRegistry(Registry.ITEM), new StringReader(itemString));
res = new ItemInput(parser.item(), parser.nbt());
ItemParser parser = (new ItemParser(new StringReader(itemString), false)).parse();
res = new ItemInput(parser.getItem(), parser.getNbt());
itemCache.put(itemString, res);
if (itemCache.size()>64000)
itemCache.clear();
if (customTag == null)
return res;
else
return new ItemInput(res.getItem(), customTag);
return new ItemInput(Holder.direct(res.getItem()), customTag);
}
catch (CommandSyntaxException e)
{