Migrated some API calls
This commit is contained in:
parent
c11fca74a5
commit
daa4a2b4af
56 changed files with 172 additions and 167 deletions
|
@ -2,7 +2,7 @@ package org.betterx.bclib.util;
|
|||
|
||||
import org.betterx.bclib.BCLib;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.GsonHelper;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
@ -21,7 +21,7 @@ public class ItemUtil {
|
|||
throw new IllegalStateException("Stack can't be null!");
|
||||
}
|
||||
Item item = stack.getItem();
|
||||
return Registry.ITEM.getKey(item) + ":" + stack.getCount();
|
||||
return BuiltInRegistries.ITEM.getKey(item) + ":" + stack.getCount();
|
||||
} catch (Exception ex) {
|
||||
BCLib.LOGGER.error("ItemStack serialization error!", ex);
|
||||
}
|
||||
|
@ -38,13 +38,13 @@ public class ItemUtil {
|
|||
if (parts.length < 2) return null;
|
||||
if (parts.length == 2) {
|
||||
ResourceLocation itemId = new ResourceLocation(stackString);
|
||||
Item item = Registry.ITEM.getOptional(itemId).orElseThrow(() -> {
|
||||
Item item = BuiltInRegistries.ITEM.getOptional(itemId).orElseThrow(() -> {
|
||||
return new IllegalStateException("Output item " + itemId + " does not exists!");
|
||||
});
|
||||
return new ItemStack(item);
|
||||
}
|
||||
ResourceLocation itemId = new ResourceLocation(parts[0], parts[1]);
|
||||
Item item = Registry.ITEM.getOptional(itemId).orElseThrow(() -> {
|
||||
Item item = BuiltInRegistries.ITEM.getOptional(itemId).orElseThrow(() -> {
|
||||
return new IllegalStateException("Output item " + itemId + " does not exists!");
|
||||
});
|
||||
return new ItemStack(item, Integer.valueOf(parts[2]));
|
||||
|
@ -61,7 +61,7 @@ public class ItemUtil {
|
|||
throw new IllegalStateException("Invalid JsonObject. Entry 'item' does not exists!");
|
||||
}
|
||||
ResourceLocation itemId = new ResourceLocation(GsonHelper.getAsString(recipe, "item"));
|
||||
Item item = Registry.ITEM.getOptional(itemId).orElseThrow(() -> {
|
||||
Item item = BuiltInRegistries.ITEM.getOptional(itemId).orElseThrow(() -> {
|
||||
return new IllegalStateException("Output item " + itemId + " does not exists!");
|
||||
});
|
||||
int count = GsonHelper.getAsInt(recipe, "count", 1);
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package org.betterx.bclib.util;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
public class RecipeHelper {
|
||||
public static boolean exists(ItemLike item) {
|
||||
if (item instanceof Block) {
|
||||
return Registry.BLOCK.getKey((Block) item) != Registry.BLOCK.getDefaultKey();
|
||||
return BuiltInRegistries.BLOCK.getKey((Block) item) != BuiltInRegistries.BLOCK.getDefaultKey();
|
||||
} else {
|
||||
return Registry.ITEM.getKey(item.asItem()) != Registry.ITEM.getDefaultKey();
|
||||
return BuiltInRegistries.ITEM.getKey(item.asItem()) != BuiltInRegistries.ITEM.getDefaultKey();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@ package org.betterx.bclib.util;
|
|||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -69,7 +69,7 @@ public class StructureHelper {
|
|||
CompoundTag nbttagcompound = NbtIo.readCompressed(stream);
|
||||
|
||||
StructureTemplate template = new StructureTemplate();
|
||||
template.load(HolderLookup.forRegistry(Registry.BLOCK), nbttagcompound);
|
||||
template.load(HolderLookup.forRegistry(BuiltInRegistries.BLOCK), nbttagcompound);
|
||||
|
||||
return template;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.betterx.bclib.util;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.data.BuiltinRegistries;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
@ -37,8 +37,8 @@ public class TranslationHelper {
|
|||
? new JsonObject()
|
||||
: gson.fromJson(new InputStreamReader(inputStream), JsonObject.class);
|
||||
|
||||
Registry.BLOCK.forEach(block -> {
|
||||
if (Registry.BLOCK.getKey(block).getNamespace().equals(modID)) {
|
||||
BuiltInRegistries.BLOCK.forEach(block -> {
|
||||
if (BuiltInRegistries.BLOCK.getKey(block).getNamespace().equals(modID)) {
|
||||
String name = block.getName().getString();
|
||||
if (!translation.has(name)) {
|
||||
missingNames.add(name);
|
||||
|
@ -46,8 +46,8 @@ public class TranslationHelper {
|
|||
}
|
||||
});
|
||||
|
||||
Registry.ITEM.forEach(item -> {
|
||||
if (Registry.ITEM.getKey(item).getNamespace().equals(modID)) {
|
||||
BuiltInRegistries.ITEM.forEach(item -> {
|
||||
if (BuiltInRegistries.ITEM.getKey(item).getNamespace().equals(modID)) {
|
||||
String name = item.getDescription().getString();
|
||||
if (!translation.has(name)) {
|
||||
missingNames.add(name);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue