Migrated some API calls
This commit is contained in:
parent
c11fca74a5
commit
daa4a2b4af
56 changed files with 172 additions and 167 deletions
|
@ -11,7 +11,7 @@ import com.mojang.serialization.Encoder;
|
|||
import com.mojang.serialization.JsonOps;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.data.BuiltinRegistries;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.data.CachedOutput;
|
||||
import net.minecraft.data.DataProvider;
|
||||
import net.minecraft.data.PackOutput;
|
||||
|
@ -60,7 +60,7 @@ public class BCLibDatagen implements DataGeneratorEntrypoint {
|
|||
|
||||
@Override
|
||||
public CompletableFuture<?> run(CachedOutput cachedOutput) {
|
||||
RegistryAccess.Frozen registryAccess = BuiltinRegistries.createAccess();
|
||||
RegistryAccess.Frozen registryAccess = BuiltInRegistries.createAccess();
|
||||
RegistryOps<JsonElement> dynamicOps = RegistryOps.create(JsonOps.INSTANCE, registryAccess);
|
||||
final List<CompletableFuture<?>> futures = new ArrayList<>();
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ import org.betterx.bclib.api.v2.levelgen.LevelGenUtil;
|
|||
import org.betterx.bclib.config.Configs;
|
||||
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.data.BuiltinRegistries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtOps;
|
||||
import net.minecraft.nbt.Tag;
|
||||
|
|
|
@ -21,7 +21,6 @@ import org.betterx.worlds.together.tag.v3.MineableTags;
|
|||
import org.betterx.worlds.together.tag.v3.TagManager;
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
@ -56,7 +55,7 @@ public class PostInitAPI {
|
|||
* @param isClient {@code boolean}, {@code true} for client, {@code false} for server.
|
||||
*/
|
||||
public static void postInit(boolean isClient) {
|
||||
Registry.BLOCK.forEach(block -> {
|
||||
BuiltInRegistries.BLOCK.forEach(block -> {
|
||||
processBlockCommon(block);
|
||||
if (isClient) {
|
||||
processBlockClient(block);
|
||||
|
@ -64,7 +63,7 @@ public class PostInitAPI {
|
|||
});
|
||||
|
||||
|
||||
Registry.ITEM.forEach(item -> {
|
||||
BuiltInRegistries.ITEM.forEach(item -> {
|
||||
processItemCommon(item);
|
||||
});
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import org.betterx.bclib.items.complex.EquipmentSet;
|
|||
|
||||
import net.minecraft.advancements.*;
|
||||
import net.minecraft.advancements.critereon.*;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.data.recipes.RecipeBuilder;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
|
@ -148,11 +147,11 @@ public class AdvancementManager {
|
|||
}
|
||||
|
||||
public static Builder create(ItemStack icon, AdvancementType type, Consumer<DisplayBuilder> displayAdapter) {
|
||||
var id = Registry.ITEM.getKey(icon.getItem());
|
||||
var id = BuiltInRegistries.ITEM.getKey(icon.getItem());
|
||||
boolean canBuild = true;
|
||||
if (id == null || icon.is(Items.AIR)) {
|
||||
canBuild = false;
|
||||
id = Registry.ITEM.getDefaultKey();
|
||||
id = BuiltInRegistries.ITEM.getDefaultKey();
|
||||
}
|
||||
|
||||
String baseName = "advancements." + id.getNamespace() + "." + id.getPath() + ".";
|
||||
|
@ -214,7 +213,7 @@ public class AdvancementManager {
|
|||
if (icon == null) {
|
||||
canBuild = false;
|
||||
} else {
|
||||
var id = Registry.ITEM.getKey(icon.getItem());
|
||||
var id = BuiltInRegistries.ITEM.getKey(icon.getItem());
|
||||
if (id == null) {
|
||||
canBuild = false;
|
||||
}
|
||||
|
@ -231,7 +230,7 @@ public class AdvancementManager {
|
|||
public Builder awardRecipe(ItemLike... items) {
|
||||
var rewardBuilder = startReward();
|
||||
for (ItemLike item : items) {
|
||||
var id = Registry.ITEM.getKey(item.asItem());
|
||||
var id = BuiltInRegistries.ITEM.getKey(item.asItem());
|
||||
if (id == null) continue;
|
||||
rewardBuilder.addRecipe(id);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import com.mojang.serialization.Codec;
|
|||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.data.BuiltinRegistries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.KeyDispatchDataCodec;
|
||||
|
|
|
@ -10,7 +10,6 @@ import net.minecraft.core.Holder;
|
|||
import net.minecraft.core.MappedRegistry;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.data.BuiltinRegistries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.KeyDispatchDataCodec;
|
||||
|
|
|
@ -16,7 +16,8 @@ import net.minecraft.core.BlockPos;
|
|||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.HolderSet;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.data.BuiltinRegistries;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.BiomeTags;
|
||||
|
@ -63,7 +64,7 @@ public class BiomeAPI {
|
|||
* @return {@link BCLBiome}
|
||||
*/
|
||||
public static BCLBiome registerBuiltinBiomeAndOverrideIntendedDimension(BCLBiome bclbiome, BiomeType dim) {
|
||||
return registerBiomeAndOverrideIntendedDimension(bclbiome, dim, BuiltinRegistries.BIOME);
|
||||
return registerBiomeAndOverrideIntendedDimension(bclbiome, dim, Registries.BIOME);
|
||||
}
|
||||
|
||||
static BCLBiome registerBiomeAndOverrideIntendedDimension(
|
||||
|
@ -472,7 +473,7 @@ public class BiomeAPI {
|
|||
Optional<ResourceKey<Biome>> key = InternalBiomeAPI.biomeRegistry.getResourceKey(biome);
|
||||
if (key.isPresent()) return key.get();
|
||||
}
|
||||
return BuiltinRegistries.BIOME
|
||||
return BuiltInRegistries.BIOME
|
||||
.getResourceKey(biome)
|
||||
.orElseGet(null);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import org.betterx.bclib.mixin.common.BiomeGenerationSettingsAccessor;
|
|||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.data.BuiltinRegistries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
|
|
@ -5,7 +5,6 @@ import org.betterx.bclib.mixin.common.StructuresAccessor;
|
|||
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.minecraft.core.*;
|
||||
import net.minecraft.data.BuiltinRegistries;
|
||||
import net.minecraft.data.worldgen.StructureSets;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.betterx.bclib.api.v2.levelgen.structures;
|
|||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
|
@ -120,7 +120,7 @@ public class StructureWorld {
|
|||
BlockState[] states = new BlockState[map2.size()];
|
||||
for (int i = 0; i < states.length; i++) {
|
||||
states[i] = NbtUtils.readBlockState(
|
||||
HolderLookup.forRegistry(Registry.BLOCK),
|
||||
HolderLookup.forRegistry(BuiltInRegistries.BLOCK),
|
||||
(CompoundTag) map2.get(i)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.betterx.bclib.util.Triple;
|
|||
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.data.BuiltinRegistries;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.random.SimpleWeightedRandomList;
|
||||
import net.minecraft.util.valueproviders.ConstantInt;
|
||||
|
@ -211,8 +211,8 @@ public abstract class BCLFeatureBuilder<F extends Feature<FC>, FC extends Featur
|
|||
ResourceLocation id,
|
||||
ConfiguredFeature<FC, F> cFeature
|
||||
) {
|
||||
return (Holder<ConfiguredFeature<FC, F>>) (Object) BuiltinRegistries.register(
|
||||
BuiltinRegistries.CONFIGURED_FEATURE,
|
||||
return (Holder<ConfiguredFeature<FC, F>>) (Object) BuiltInRegistries.register(
|
||||
BuiltInRegistries.CONFIGURED_FEATURE,
|
||||
id,
|
||||
cFeature
|
||||
);
|
||||
|
@ -671,7 +671,7 @@ public abstract class BCLFeatureBuilder<F extends Feature<FC>, FC extends Featur
|
|||
// is meant to prevent that...
|
||||
if (NoneFeatureConfiguration.NONE != null)
|
||||
return (FC) NoneFeatureConfiguration.NONE;
|
||||
|
||||
|
||||
return (FC) NoneFeatureConfiguration.INSTANCE;
|
||||
}
|
||||
return configuration;
|
||||
|
|
|
@ -3,7 +3,7 @@ package org.betterx.bclib.blocks;
|
|||
import org.betterx.bclib.client.models.BasePatterns;
|
||||
import org.betterx.bclib.client.models.PatternsHelper;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import java.util.Optional;
|
||||
|
@ -15,7 +15,7 @@ public class BaseBarkBlock extends BaseRotatedPillarBlock {
|
|||
|
||||
@Override
|
||||
protected Optional<String> createBlockPattern(ResourceLocation blockId) {
|
||||
blockId = Registry.BLOCK.getKey(this);
|
||||
blockId = BuiltInRegistries.BLOCK.getKey(this);
|
||||
return PatternsHelper.createJson(BasePatterns.BLOCK_BASE, replacePath(blockId));
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import org.betterx.bclib.interfaces.BlockModelProvider;
|
|||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.BlockModelRotation;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -51,7 +51,7 @@ public abstract class BaseButtonBlock extends ButtonBlock implements BlockModelP
|
|||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public BlockModel getItemModel(ResourceLocation blockId) {
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
ResourceLocation parentId = BuiltInRegistries.BLOCK.getKey(parent);
|
||||
Optional<String> pattern = PatternsHelper.createJson(BasePatterns.ITEM_BUTTON, parentId);
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public abstract class BaseButtonBlock extends ButtonBlock implements BlockModelP
|
|||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
ResourceLocation parentId = BuiltInRegistries.BLOCK.getKey(parent);
|
||||
Optional<String> pattern = blockState.getValue(POWERED)
|
||||
? PatternsHelper.createJson(
|
||||
BasePatterns.BLOCK_BUTTON_PRESSED,
|
||||
|
|
|
@ -8,7 +8,7 @@ import org.betterx.bclib.registry.BaseBlockEntities;
|
|||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
@ -55,7 +55,7 @@ public class BaseChestBlock extends ChestBlock implements BlockModelProvider {
|
|||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
ResourceLocation parentId = BuiltInRegistries.BLOCK.getKey(parent);
|
||||
return ModelsHelper.createBlockEmpty(parentId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import org.betterx.bclib.interfaces.BlockModelProvider;
|
|||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.BlockModelRotation;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
@ -42,7 +42,7 @@ public class BaseFenceBlock extends FenceBlock implements BlockModelProvider {
|
|||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public BlockModel getItemModel(ResourceLocation blockId) {
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
ResourceLocation parentId = BuiltInRegistries.BLOCK.getKey(parent);
|
||||
Optional<String> pattern = PatternsHelper.createJson(BasePatterns.ITEM_FENCE, parentId);
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public class BaseFenceBlock extends FenceBlock implements BlockModelProvider {
|
|||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
ResourceLocation parentId = BuiltInRegistries.BLOCK.getKey(parent);
|
||||
String path = blockId.getPath();
|
||||
Optional<String> pattern = Optional.empty();
|
||||
if (path.endsWith("_post")) {
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.betterx.bclib.interfaces.BlockModelProvider;
|
|||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -50,7 +50,7 @@ public class BaseGateBlock extends FenceGateBlock implements BlockModelProvider
|
|||
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
boolean inWall = blockState.getValue(IN_WALL);
|
||||
boolean isOpen = blockState.getValue(OPEN);
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
ResourceLocation parentId = BuiltInRegistries.BLOCK.getKey(parent);
|
||||
Optional<String> pattern;
|
||||
if (inWall) {
|
||||
pattern = isOpen
|
||||
|
|
|
@ -11,7 +11,7 @@ import net.minecraft.client.renderer.block.model.BlockModel;
|
|||
import net.minecraft.client.resources.model.BlockModelRotation;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
@ -45,7 +45,7 @@ public class BaseMetalBarsBlock extends IronBarsBlock implements BlockModelProvi
|
|||
}
|
||||
|
||||
public Optional<String> getModelString(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
ResourceLocation blockId = BuiltInRegistries.BLOCK.getKey(this);
|
||||
if (block.contains("item")) {
|
||||
return PatternsHelper.createJson(BasePatterns.ITEM_BLOCK, blockId);
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ public class BaseMetalBarsBlock extends IronBarsBlock implements BlockModelProvi
|
|||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
ResourceLocation thisId = Registry.BLOCK.getKey(this);
|
||||
ResourceLocation thisId = BuiltInRegistries.BLOCK.getKey(this);
|
||||
String path = blockId.getPath();
|
||||
Optional<String> pattern = Optional.empty();
|
||||
if (path.endsWith("_post")) {
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.betterx.bclib.client.models.PatternsHelper;
|
|||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
|
@ -78,7 +78,7 @@ public class BasePathBlock extends BaseBlockNotFull {
|
|||
@Environment(EnvType.CLIENT)
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
String name = blockId.getPath();
|
||||
ResourceLocation bottomId = Registry.BLOCK.getKey(baseBlock);
|
||||
ResourceLocation bottomId = BuiltInRegistries.BLOCK.getKey(baseBlock);
|
||||
String bottom = bottomId.getNamespace() + ":block/" + bottomId.getPath();
|
||||
Map<String, String> textures = Maps.newHashMap();
|
||||
textures.put("%modid%", blockId.getNamespace());
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.betterx.bclib.interfaces.BlockModelProvider;
|
|||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -51,7 +51,7 @@ public class BasePressurePlateBlock extends PressurePlateBlock implements BlockM
|
|||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
ResourceLocation parentId = BuiltInRegistries.BLOCK.getKey(parent);
|
||||
Optional<String> pattern;
|
||||
if (blockState.getValue(POWERED)) {
|
||||
pattern = PatternsHelper.createJson(BasePatterns.BLOCK_PLATE_DOWN, parentId);
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.betterx.bclib.util.BlocksHelper;
|
|||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.protocol.game.ClientboundOpenSignEditorPacket;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
@ -163,7 +163,7 @@ public class BaseSignBlock extends SignBlock implements BlockModelProvider, Cust
|
|||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
ResourceLocation parentId = BuiltInRegistries.BLOCK.getKey(parent);
|
||||
return ModelsHelper.createBlockEmpty(parentId);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.betterx.bclib.interfaces.CustomItemProvider;
|
|||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.BlockModelRotation;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
@ -59,7 +59,7 @@ public class BaseSlabBlock extends SlabBlock implements BlockModelProvider, Cust
|
|||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
ResourceLocation parentId = BuiltInRegistries.BLOCK.getKey(parent);
|
||||
Optional<String> pattern;
|
||||
if (blockState.getValue(TYPE) == SlabType.DOUBLE) {
|
||||
pattern = PatternsHelper.createBlockSimple(parentId);
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.betterx.bclib.interfaces.CustomItemProvider;
|
|||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.BlockModelRotation;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
@ -59,7 +59,7 @@ public class BaseStairsBlock extends StairBlock implements BlockModelProvider, C
|
|||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
ResourceLocation parentId = BuiltInRegistries.BLOCK.getKey(parent);
|
||||
Optional<String> pattern = PatternsHelper.createJson(switch (blockState.getValue(SHAPE)) {
|
||||
case STRAIGHT -> BasePatterns.BLOCK_STAIR;
|
||||
case INNER_LEFT, INNER_RIGHT -> BasePatterns.BLOCK_STAIR_INNER;
|
||||
|
|
|
@ -11,7 +11,7 @@ import net.minecraft.client.renderer.block.model.BlockModel;
|
|||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
@ -138,7 +138,7 @@ public class BaseTerrainBlock extends BaseBlock {
|
|||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
ResourceLocation baseId = Registry.BLOCK.getKey(getBaseBlock());
|
||||
ResourceLocation baseId = BuiltInRegistries.BLOCK.getKey(getBaseBlock());
|
||||
String modId = blockId.getNamespace();
|
||||
String path = blockId.getPath();
|
||||
String bottom = baseId.getNamespace() + ":block/" + baseId.getPath();
|
||||
|
|
|
@ -8,7 +8,7 @@ import org.betterx.bclib.interfaces.BlockModelProvider;
|
|||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.BlockModelRotation;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
@ -43,7 +43,7 @@ public class BaseWallBlock extends WallBlock implements BlockModelProvider {
|
|||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public BlockModel getItemModel(ResourceLocation blockId) {
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
ResourceLocation parentId = BuiltInRegistries.BLOCK.getKey(parent);
|
||||
Optional<String> pattern = PatternsHelper.createJson(BasePatterns.ITEM_WALL, parentId);
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class BaseWallBlock extends WallBlock implements BlockModelProvider {
|
|||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
ResourceLocation parentId = BuiltInRegistries.BLOCK.getKey(parent);
|
||||
String path = blockId.getPath();
|
||||
Optional<String> pattern = Optional.empty();
|
||||
if (path.endsWith("_post")) {
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.betterx.bclib.interfaces.BlockModelProvider;
|
|||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -56,7 +56,7 @@ public class BaseWeightedPlateBlock extends WeightedPressurePlateBlock implement
|
|||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
ResourceLocation parentId = BuiltInRegistries.BLOCK.getKey(parent);
|
||||
Optional<String> pattern;
|
||||
if (blockState.getValue(POWER) > 0) {
|
||||
pattern = PatternsHelper.createJson(BasePatterns.BLOCK_PLATE_DOWN, parentId);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.betterx.bclib.blocks;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.util.FormattedCharSequence;
|
||||
import net.minecraft.world.item.Tiers;
|
||||
|
@ -31,7 +31,7 @@ public class LeveledAnvilBlock extends BaseAnvilBlock {
|
|||
}
|
||||
|
||||
public static List<Block> getAnvils() {
|
||||
return Registry.BLOCK
|
||||
return BuiltInRegistries.BLOCK
|
||||
.stream()
|
||||
.filter(b -> b instanceof LeveledAnvilBlock || b == Blocks.ANVIL)
|
||||
.toList();
|
||||
|
|
|
@ -9,7 +9,6 @@ import net.minecraft.client.renderer.block.model.BlockModel;
|
|||
import net.minecraft.client.renderer.block.model.multipart.MultiPart;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
@ -32,38 +31,44 @@ public class CustomModelBakery {
|
|||
}
|
||||
|
||||
public void loadCustomModels(ResourceManager resourceManager) {
|
||||
Registry.BLOCK.stream().parallel().filter(block -> block instanceof BlockModelProvider).forEach(block -> {
|
||||
ResourceLocation blockID = Registry.BLOCK.getKey(block);
|
||||
ResourceLocation storageID = new ResourceLocation(
|
||||
blockID.getNamespace(),
|
||||
"blockstates/" + blockID.getPath() + ".json"
|
||||
);
|
||||
if (resourceManager.getResource(storageID).isEmpty()) {
|
||||
addBlockModel(blockID, block);
|
||||
}
|
||||
storageID = new ResourceLocation(blockID.getNamespace(), "models/item/" + blockID.getPath() + ".json");
|
||||
if (resourceManager.getResource(storageID).isEmpty()) {
|
||||
addItemModel(blockID, (ItemModelProvider) block);
|
||||
}
|
||||
});
|
||||
BuiltInRegistries.BLOCK.stream()
|
||||
.parallel()
|
||||
.filter(block -> block instanceof BlockModelProvider)
|
||||
.forEach(block -> {
|
||||
ResourceLocation blockID = BuiltInRegistries.BLOCK.getKey(block);
|
||||
ResourceLocation storageID = new ResourceLocation(
|
||||
blockID.getNamespace(),
|
||||
"blockstates/" + blockID.getPath() + ".json"
|
||||
);
|
||||
if (resourceManager.getResource(storageID).isEmpty()) {
|
||||
addBlockModel(blockID, block);
|
||||
}
|
||||
storageID = new ResourceLocation(
|
||||
blockID.getNamespace(),
|
||||
"models/item/" + blockID.getPath() + ".json"
|
||||
);
|
||||
if (resourceManager.getResource(storageID).isEmpty()) {
|
||||
addItemModel(blockID, (ItemModelProvider) block);
|
||||
}
|
||||
});
|
||||
|
||||
Registry.ITEM.stream()
|
||||
.parallel()
|
||||
.filter(item -> item instanceof ItemModelProvider || RecordItemModelProvider.has(item))
|
||||
.forEach(item -> {
|
||||
ResourceLocation registryID = Registry.ITEM.getKey(item);
|
||||
ResourceLocation storageID = new ResourceLocation(
|
||||
registryID.getNamespace(),
|
||||
"models/item/" + registryID.getPath() + ".json"
|
||||
);
|
||||
final ItemModelProvider provider = (item instanceof ItemModelProvider)
|
||||
? (ItemModelProvider) item
|
||||
: RecordItemModelProvider.get(item);
|
||||
BuiltInRegistries.ITEM.stream()
|
||||
.parallel()
|
||||
.filter(item -> item instanceof ItemModelProvider || RecordItemModelProvider.has(item))
|
||||
.forEach(item -> {
|
||||
ResourceLocation registryID = BuiltInRegistries.ITEM.getKey(item);
|
||||
ResourceLocation storageID = new ResourceLocation(
|
||||
registryID.getNamespace(),
|
||||
"models/item/" + registryID.getPath() + ".json"
|
||||
);
|
||||
final ItemModelProvider provider = (item instanceof ItemModelProvider)
|
||||
? (ItemModelProvider) item
|
||||
: RecordItemModelProvider.get(item);
|
||||
|
||||
if (resourceManager.getResource(storageID).isEmpty()) {
|
||||
addItemModel(registryID, provider);
|
||||
}
|
||||
});
|
||||
if (resourceManager.getResource(storageID).isEmpty()) {
|
||||
addItemModel(registryID, provider);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addBlockModel(ResourceLocation blockID, Block block) {
|
||||
|
|
|
@ -13,7 +13,6 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
|||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.client.renderer.blockentity.BrightnessCombiner;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.*;
|
||||
|
@ -165,7 +164,7 @@ public class BaseChestBlockEntityRenderer implements BlockEntityRenderer<BaseChe
|
|||
}
|
||||
|
||||
public static void registerRenderLayer(Block block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(block);
|
||||
ResourceLocation blockId = BuiltInRegistries.BLOCK.getKey(block);
|
||||
String modId = blockId.getNamespace();
|
||||
String path = blockId.getPath();
|
||||
LAYERS.put(
|
||||
|
|
|
@ -18,7 +18,6 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
|||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.client.renderer.blockentity.SignRenderer;
|
||||
import net.minecraft.client.resources.model.Material;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.FormattedCharSequence;
|
||||
import net.minecraft.util.Mth;
|
||||
|
@ -181,7 +180,7 @@ public class BaseSignBlockEntityRenderer implements BlockEntityRenderer<BaseSign
|
|||
}
|
||||
|
||||
public static void registerRenderLayer(Block block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(block);
|
||||
ResourceLocation blockId = BuiltInRegistries.BLOCK.getKey(block);
|
||||
RenderType layer = RenderType.entitySolid(new ResourceLocation(
|
||||
blockId.getNamespace(),
|
||||
"textures/entity/sign/" + blockId.getPath() + ".png"
|
||||
|
|
|
@ -5,7 +5,8 @@ import org.betterx.worlds.together.tag.v3.TagManager;
|
|||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.data.BuiltinRegistries;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
|
@ -38,15 +39,15 @@ public abstract class ModIntegration {
|
|||
}
|
||||
|
||||
public ResourceKey<PlacedFeature> getFeatureKey(String name) {
|
||||
return ResourceKey.create(Registry.PLACED_FEATURE_REGISTRY, getID(name));
|
||||
return ResourceKey.create(Registries.PLACED_FEATURE, getID(name));
|
||||
}
|
||||
|
||||
public Block getBlock(String name) {
|
||||
return Registry.BLOCK.get(getID(name));
|
||||
return BuiltInRegistries.BLOCK.get(getID(name));
|
||||
}
|
||||
|
||||
public Item getItem(String name) {
|
||||
return Registry.ITEM.get(getID(name));
|
||||
return BuiltInRegistries.ITEM.get(getID(name));
|
||||
}
|
||||
|
||||
public BlockState getDefaultState(String name) {
|
||||
|
@ -63,11 +64,11 @@ public abstract class ModIntegration {
|
|||
|
||||
|
||||
public ConfiguredFeature<?, ?> getConfiguredFeature(String name) {
|
||||
return BuiltinRegistries.CONFIGURED_FEATURE.get(getID(name));
|
||||
return BuiltInRegistries.CONFIGURED_FEATURE.get(getID(name));
|
||||
}
|
||||
|
||||
public Holder<Biome> getBiome(String name) {
|
||||
return BuiltinRegistries.BIOME.getHolder(getKey(name)).orElseThrow();
|
||||
return BuiltInRegistries.BIOME.getHolder(getKey(name)).orElseThrow();
|
||||
}
|
||||
|
||||
public Class<?> getClass(String path) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
@ -18,7 +17,7 @@ public interface SurvivesOnTags extends SurvivesOnSpecialGround {
|
|||
default String getSurvivableBlocksString() {
|
||||
return getSurvivableTags()
|
||||
.stream()
|
||||
.map(tag -> Registry.BLOCK.getTag(tag))
|
||||
.map(tag -> BuiltInRegistries.BLOCK.getTag(tag))
|
||||
.filter(named -> named.isPresent())
|
||||
.map(named -> named.get())
|
||||
.flatMap(named -> named.stream())
|
||||
|
|
|
@ -5,7 +5,6 @@ import org.betterx.bclib.interfaces.BlockModelProvider;
|
|||
import org.betterx.bclib.interfaces.ItemModelProvider;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
|
@ -73,7 +72,7 @@ public class BaseAnvilItem extends BlockItem implements ItemModelProvider {
|
|||
@Environment(EnvType.CLIENT)
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
Block anvilBlock = getBlock();
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(anvilBlock);
|
||||
ResourceLocation blockId = BuiltInRegistries.BLOCK.getKey(anvilBlock);
|
||||
return ((BlockModelProvider) anvilBlock).getBlockModel(blockId, anvilBlock.defaultBlockState());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import net.minecraft.client.color.block.BlockColors;
|
|||
import net.minecraft.client.color.item.ItemColors;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.main.GameConfig;
|
||||
import net.minecraft.core.Registry;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
@ -36,7 +35,7 @@ public abstract class MinecraftMixin {
|
|||
|
||||
@Inject(method = "<init>*", at = @At("TAIL"))
|
||||
private void bclib_onMCInit(GameConfig args, CallbackInfo info) {
|
||||
Registry.BLOCK.forEach(block -> {
|
||||
BuiltInRegistries.BLOCK.forEach(block -> {
|
||||
if (block instanceof CustomColorProvider provider) {
|
||||
blockColors.register(provider.getProvider(), block);
|
||||
itemColors.register(provider.getItemProvider(), block.asItem());
|
||||
|
|
|
@ -6,7 +6,7 @@ import com.mojang.serialization.Lifecycle;
|
|||
import net.minecraft.core.MappedRegistry;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.WritableRegistry;
|
||||
import net.minecraft.data.BuiltinRegistries;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
@ -15,13 +15,13 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(BuiltinRegistries.class)
|
||||
@Mixin(BuiltInRegistries.class)
|
||||
public abstract class BuiltinRegistriesMixin {
|
||||
@Shadow
|
||||
protected static <T, R extends WritableRegistry<T>> R internalRegister(
|
||||
ResourceKey<? extends Registry<T>> resourceKey,
|
||||
R writableRegistry,
|
||||
BuiltinRegistries.RegistryBootstrap<T> registryBootstrap,
|
||||
BuiltInRegistries.RegistryBootstrap<T> registryBootstrap,
|
||||
Lifecycle lifecycle
|
||||
) {
|
||||
throw new RuntimeException("Shadowed Call");
|
||||
|
|
|
@ -3,7 +3,6 @@ package org.betterx.bclib.recipes;
|
|||
import org.betterx.bclib.api.v2.advancement.AdvancementManager;
|
||||
|
||||
import net.minecraft.advancements.RequirementsStrategy;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.ArmorItem;
|
||||
|
@ -105,8 +104,8 @@ public class AbstractAdvancementRecipe {
|
|||
String name = "has_" + (nameCounter++) + "_" +
|
||||
Arrays.stream(items)
|
||||
.map(block -> (block instanceof Block)
|
||||
? Registry.BLOCK.getKey((Block) block)
|
||||
: Registry.ITEM.getKey((Item) block))
|
||||
? BuiltInRegistries.BLOCK.getKey((Block) block)
|
||||
: BuiltInRegistries.ITEM.getKey((Item) block))
|
||||
.filter(id -> id != null)
|
||||
.map(id -> id.getPath())
|
||||
.collect(Collectors.joining("_"));
|
||||
|
|
|
@ -209,10 +209,10 @@ public class AnvilRecipe implements Recipe<Container>, UnknownReceipBookCategory
|
|||
@Override
|
||||
public NonNullList<Ingredient> getIngredients() {
|
||||
NonNullList<Ingredient> defaultedList = NonNullList.create();
|
||||
defaultedList.add(Ingredient.of(Registry.ITEM.stream()
|
||||
.filter(AnvilRecipe::isHammer)
|
||||
.filter(this::canUse)
|
||||
.map(ItemStack::new))
|
||||
defaultedList.add(Ingredient.of(BuiltInRegistries.ITEM.stream()
|
||||
.filter(AnvilRecipe::isHammer)
|
||||
.filter(this::canUse)
|
||||
.map(ItemStack::new))
|
||||
);
|
||||
defaultedList.add(input);
|
||||
return defaultedList;
|
||||
|
|
|
@ -117,9 +117,9 @@ public class BCLRecipeManager {
|
|||
|
||||
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 item != Items.AIR && Registry.ITEM.getKey(item.asItem()) != Registry.ITEM.getDefaultKey();
|
||||
return item != Items.AIR && BuiltInRegistries.ITEM.getKey(item.asItem()) != BuiltInRegistries.ITEM.getDefaultKey();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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