1.4.87 for 22w44a
This commit is contained in:
1 parent
c51f59c799
commit
4be362e58b
20 files changed
+236
-185
No files matched your search
@@ -18,8 +18,8 @@ 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.core.RegistryAccess;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.StringTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
@@ -54,13 +54,13 @@ public class BlockValue extends Value
|
||||
}
|
||||
|
||||
private static final Map<String, BlockValue> bvCache= new HashMap<>();
|
||||
public static BlockValue fromString(String str)
|
||||
public static BlockValue fromString(String str, RegistryAccess regs)
|
||||
{
|
||||
try
|
||||
{
|
||||
BlockValue bv = bvCache.get(str);
|
||||
BlockValue bv = bvCache.get(str); // [SCARY SHIT] persistent caches over server reloads
|
||||
if (bv != null) return bv;
|
||||
BlockStateParser.BlockResult foo = BlockStateParser.parseForBlock(HolderLookup.forRegistry(Registry.BLOCK), new StringReader(str), true );
|
||||
BlockStateParser.BlockResult foo = BlockStateParser.parseForBlock(regs.lookupOrThrow(Registry.BLOCK_REGISTRY), new StringReader(str), true );
|
||||
if (foo.blockState() != null)
|
||||
{
|
||||
CompoundTag bd = foo.nbt();
|
||||
|
||||
@@ -1691,7 +1691,7 @@ public class EntityValue extends Value
|
||||
|
||||
});
|
||||
put("item", (e, v) -> {
|
||||
ItemStack item=ValueConversions.getItemStackFromValue(v, true);
|
||||
ItemStack item=ValueConversions.getItemStackFromValue(v, true, e.level.registryAccess());
|
||||
if(e instanceof ItemEntity itementity)
|
||||
itementity.setItem(item);
|
||||
if(e instanceof ItemFrame itemframe)
|
||||
|
||||
@@ -23,8 +23,8 @@ 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.core.RegistryAccess;
|
||||
import net.minecraft.nbt.CollectionTag;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.EndTag;
|
||||
@@ -290,22 +290,22 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
|
||||
|
||||
private static final Map<String,ItemInput> itemCache = new HashMap<>();
|
||||
|
||||
public static ItemInput parseItem(String itemString)
|
||||
public static ItemInput parseItem(String itemString, RegistryAccess regs)
|
||||
{
|
||||
return parseItem(itemString, null);
|
||||
return parseItem(itemString, null, regs);
|
||||
}
|
||||
|
||||
public static ItemInput parseItem(String itemString, CompoundTag customTag)
|
||||
public static ItemInput parseItem(String itemString, CompoundTag customTag, RegistryAccess regs)
|
||||
{
|
||||
try
|
||||
{
|
||||
ItemInput res = itemCache.get(itemString);
|
||||
ItemInput res = itemCache.get(itemString); // [SCARY SHIT] persistent caches over server reloads
|
||||
if (res != null)
|
||||
if (customTag == null)
|
||||
return res;
|
||||
else
|
||||
return new ItemInput(Holder.direct(res.getItem()), customTag);
|
||||
ItemParser.ItemResult parser = ItemParser.parseForItem(HolderLookup.forRegistry(Registry.ITEM), new StringReader(itemString));
|
||||
ItemParser.ItemResult parser = ItemParser.parseForItem(regs.lookupOrThrow(Registry.ITEM_REGISTRY), new StringReader(itemString));
|
||||
res = new ItemInput(parser.item(), parser.nbt());
|
||||
|
||||
itemCache.put(itemString, res);
|
||||
|
||||
@@ -413,7 +413,7 @@ public class ValueConversions
|
||||
);
|
||||
}
|
||||
|
||||
public static ItemStack getItemStackFromValue(Value value, boolean withCount)
|
||||
public static ItemStack getItemStackFromValue(Value value, boolean withCount, RegistryAccess regs)
|
||||
{
|
||||
if (value.isNull())
|
||||
{
|
||||
@@ -444,7 +444,7 @@ public class ValueConversions
|
||||
{
|
||||
name = value.getString();
|
||||
}
|
||||
ItemInput itemInput = NBTSerializableValue.parseItem(name, nbtTag);
|
||||
ItemInput itemInput = NBTSerializableValue.parseItem(name, nbtTag, regs);
|
||||
try
|
||||
{
|
||||
return itemInput.createItemStack(count,false);
|
||||
|
||||
Reference in new issue
Block a user