diff --git a/README.md b/README.md index 404e1347..814d89b5 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,33 @@ [![](https://jitpack.io/v/paulevsGitch/BCLib.svg)](https://jitpack.io/#paulevsGitch/BCLib) # BCLib -BCLib is a library mod for BetterX team mods, developed for Fabric, MC 1.16.4+ +BCLib is a library mod for BetterX team mods, developed for Fabric, MC 1.16.5 ## Features: ### API: +* Simple Mod Integration API; * Structure Features API; +* World Data API; * Bonemeal API; * Features API; * Biome API; -* Tag API; +* Tag API. ### Libs: * Spline library (simple); +* Recipe manager; * Noise library; * Math library; -* SDF library; +* SDF library. ### Helpers And Utils: * Custom surface builders; * Translation helper; * Weighted list; -* Block helper; +* Block helper. + +### Rendering: +* Procedural block models (from paterns or from code); +* Block render layer interface. ## Importing: * Clone repo diff --git a/bclib_banner.png b/bclib_banner.png new file mode 100644 index 00000000..a57ca1bf Binary files /dev/null and b/bclib_banner.png differ diff --git a/build.gradle b/build.gradle index 843c4bb2..9d232758 100644 --- a/build.gradle +++ b/build.gradle @@ -7,12 +7,12 @@ buildscript { plugins { id 'idea' id 'eclipse' - id 'fabric-loom' version '0.7-SNAPSHOT' + id 'fabric-loom' version '0.8-SNAPSHOT' id 'maven-publish' } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +sourceCompatibility = JavaVersion.VERSION_16 +targetCompatibility = JavaVersion.VERSION_16 archivesBaseName = project.archives_base_name version = project.mod_version @@ -20,7 +20,7 @@ group = project.maven_group repositories { maven { url "https://maven.dblsaiko.net/" } - maven { url "http://server.bbkr.space:8081/artifactory/libs-release/" } + maven { url "https://server.bbkr.space:8081/artifactory/libs-release/" } maven { url "https://maven.fabricmc.net/" } maven { url 'https://maven.blamejared.com' } maven { url "https://maven.shedaniel.me/" } @@ -33,7 +33,7 @@ dependencies { modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - useApi "vazkii.patchouli:Patchouli:1.16.4-${project.patchouli_version}" + //useApi "vazkii.patchouli:Patchouli:1.16.4-${project.patchouli_version}" } def useOptional(String dep) { @@ -65,6 +65,7 @@ def useApi(String dep) { processResources { inputs.property "version", project.version + duplicatesStrategy = 'EXCLUDE' from(sourceSets.main.resources.srcDirs) { include "fabric.mod.json" diff --git a/gradle.properties b/gradle.properties index d84688e6..f0252152 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,16 +3,16 @@ org.gradle.jvmargs=-Xmx2G # Fabric Properties # check these on https://fabricmc.net/use -minecraft_version=1.16.5 -yarn_mappings=6 -loader_version=0.11.3 +minecraft_version= 1.17 +yarn_mappings= 6 +loader_version= 0.11.6 # Mod Properties -mod_version = 0.1.30 +mod_version = 0.2.0 maven_group = ru.bclib archives_base_name = bclib # Dependencies # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api patchouli_version = 50-FABRIC -fabric_version = 0.32.9+1.16 +fabric_version = 0.36.0+1.17 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 442d9132..f371643e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/ru/bclib/BCLib.java b/src/main/java/ru/bclib/BCLib.java index 3c8bc3b9..e3bbee16 100644 --- a/src/main/java/ru/bclib/BCLib.java +++ b/src/main/java/ru/bclib/BCLib.java @@ -5,6 +5,8 @@ import net.fabricmc.api.ModInitializer; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.resources.ResourceLocation; import ru.bclib.api.TagAPI; +import ru.bclib.config.Configs; +import ru.bclib.recipes.CraftingRecipes; import ru.bclib.registry.BaseBlockEntities; import ru.bclib.registry.BaseRegistry; import ru.bclib.util.Logger; @@ -20,6 +22,8 @@ public class BCLib implements ModInitializer { BaseBlockEntities.register(); BCLSurfaceBuilders.register(); TagAPI.init(); + CraftingRecipes.init(); + Configs.save(); } public static boolean isDevEnvironment() { diff --git a/src/main/java/ru/bclib/api/BiomeAPI.java b/src/main/java/ru/bclib/api/BiomeAPI.java index f311c862..0a1cb7b5 100644 --- a/src/main/java/ru/bclib/api/BiomeAPI.java +++ b/src/main/java/ru/bclib/api/BiomeAPI.java @@ -41,7 +41,7 @@ public class BiomeAPI { } public static void registerBiome(BCLBiome biome) { - if (!BuiltinRegistries.BIOME.containsKey(biome.getID())) { + if (BuiltinRegistries.BIOME.get(biome.getID()) == null) { Registry.register(BuiltinRegistries.BIOME, biome.getID(), biome.getBiome()); } ID_MAP.put(biome.getID(), biome); @@ -91,6 +91,9 @@ public class BiomeAPI { * @return {@link BCLBiome} or {@code BiomeAPI.EMPTY_BIOME}. */ public static BCLBiome getFromBiome(Biome biome) { + if (biomeRegistry == null) { + return EMPTY_BIOME; + } return ID_MAP.getOrDefault(biomeRegistry.getKey(biome), EMPTY_BIOME); } diff --git a/src/main/java/ru/bclib/api/DataFixerAPI.java b/src/main/java/ru/bclib/api/DataFixerAPI.java index 559fc7d5..cf644539 100644 --- a/src/main/java/ru/bclib/api/DataFixerAPI.java +++ b/src/main/java/ru/bclib/api/DataFixerAPI.java @@ -33,9 +33,11 @@ public class DataFixerAPI { Collection mods = FabricLoader.getInstance().getAllMods(); for (ModContainer mod: mods) { String name = mod.getMetadata().getId(); + int preVersion = WorldDataAPI.getIntModVersion(name); int version = getModVersion(mod.getMetadata().getVersion().toString()); - if (version > 0) { - shoudFix |= FIX_VERSIONS.getOrDefault(name, version) < version; + if (version > preVersion) { + int fixVersion = FIX_VERSIONS.getOrDefault(name, version); + shoudFix |= fixVersion < version && fixVersion >= preVersion; } }; if (!shoudFix) { diff --git a/src/main/java/ru/bclib/api/ModIntegrationAPI.java b/src/main/java/ru/bclib/api/ModIntegrationAPI.java new file mode 100644 index 00000000..eff311dc --- /dev/null +++ b/src/main/java/ru/bclib/api/ModIntegrationAPI.java @@ -0,0 +1,40 @@ +package ru.bclib.api; + +import java.util.List; + +import com.google.common.collect.Lists; + +import ru.bclib.integration.ModIntegration; + +public class ModIntegrationAPI { + private static final List INTEGRATIONS = Lists.newArrayList(); + + /** + * Registers mod integration + * @param integration + * @return + */ + public static ModIntegration register(ModIntegration integration) { + INTEGRATIONS.add(integration); + return integration; + } + + /** + * Get all registered mod integrations. + * @return {@link List} of {@link ModIntegration}. + */ + public static List getIntegrations() { + return INTEGRATIONS; + } + + /** + * Initialize all integrations, only for internal usage. + */ + public static void registerAll() { + INTEGRATIONS.forEach(integration -> { + if (integration.modIsInstalled()) { + integration.init(); + } + }); + } +} diff --git a/src/main/java/ru/bclib/api/WorldDataAPI.java b/src/main/java/ru/bclib/api/WorldDataAPI.java index af8a6afa..6927c9ed 100644 --- a/src/main/java/ru/bclib/api/WorldDataAPI.java +++ b/src/main/java/ru/bclib/api/WorldDataAPI.java @@ -4,10 +4,13 @@ import java.io.File; import java.io.IOException; import java.util.List; import java.util.Map; +import java.util.Optional; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import net.fabricmc.loader.api.FabricLoader; +import net.fabricmc.loader.api.ModContainer; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtIo; import ru.bclib.BCLib; @@ -20,8 +23,9 @@ public class WorldDataAPI { public static void load(File dataDir) { WorldDataAPI.dataDir = dataDir; MODS.stream().parallel().forEach(modID -> { - File file = new File(dataDir, modID); + File file = new File(dataDir, modID + ".nbt"); CompoundTag root = new CompoundTag(); + TAGS.put(modID, root); if (file.exists()) { try { root = NbtIo.readCompressed(file); @@ -30,7 +34,19 @@ public class WorldDataAPI { BCLib.LOGGER.error("World data loading failed", e); } } - TAGS.put(modID, root); + else { + Optional optional = FabricLoader.getInstance().getModContainer(modID); + if (optional.isPresent()) { + ModContainer modContainer = optional.get(); + if (BCLib.isDevEnvironment()) { + root.putString("version", "63.63.63"); + } + else { + root.putString("version", modContainer.getMetadata().getVersion().toString()); + } + saveFile(modID); + } + } }); } @@ -77,6 +93,10 @@ public class WorldDataAPI { return tag; } + /** + * Forces mod cache file to be saved. + * @param modID {@link String} mod ID. + */ public static void saveFile(String modID) { try { NbtIo.writeCompressed(getRootTag(modID), new File(dataDir, modID + ".nbt")); @@ -85,4 +105,20 @@ public class WorldDataAPI { BCLib.LOGGER.error("World data saving failed", e); } } + + /** + * Get stored mod version (only for mods with registered cache). + * @return {@link String} mod version. + */ + public static String getModVersion(String modID) { + return getRootTag(modID).getString("version"); + } + + /** + * Get stored mod version as integer (only for mods with registered cache). + * @return {@code int} mod version. + */ + public static int getIntModVersion(String modID) { + return DataFixerAPI.getModVersion(getModVersion(modID)); + } } diff --git a/src/main/java/ru/bclib/blockentities/BaseBarrelBlockEntity.java b/src/main/java/ru/bclib/blockentities/BaseBarrelBlockEntity.java index 488a86eb..c181a7a7 100644 --- a/src/main/java/ru/bclib/blockentities/BaseBarrelBlockEntity.java +++ b/src/main/java/ru/bclib/blockentities/BaseBarrelBlockEntity.java @@ -1,5 +1,6 @@ package ru.bclib.blockentities; +import net.minecraft.core.BlockPos; import net.minecraft.core.NonNullList; import net.minecraft.core.Vec3i; import net.minecraft.nbt.CompoundTag; @@ -26,13 +27,13 @@ public class BaseBarrelBlockEntity extends RandomizableContainerBlockEntity { private NonNullList inventory; private int viewerCount; - private BaseBarrelBlockEntity(BlockEntityType type) { - super(type); + private BaseBarrelBlockEntity(BlockEntityType type, BlockPos blockPos, BlockState blockState) { + super(type, blockPos, blockState); this.inventory = NonNullList.withSize(27, ItemStack.EMPTY); } - public BaseBarrelBlockEntity() { - this(BaseBlockEntities.BARREL); + public BaseBarrelBlockEntity(BlockPos blockPos, BlockState blockState) { + this(BaseBlockEntities.BARREL, blockPos, blockState); } public CompoundTag save(CompoundTag tag) { @@ -44,8 +45,8 @@ public class BaseBarrelBlockEntity extends RandomizableContainerBlockEntity { return tag; } - public void load(BlockState state, CompoundTag tag) { - super.load(state, tag); + public void load(CompoundTag tag) { + super.load(tag); this.inventory = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); if (!this.tryLoadLootTable(tag)) { ContainerHelper.loadAllItems(tag, this.inventory); @@ -97,10 +98,7 @@ public class BaseBarrelBlockEntity extends RandomizableContainerBlockEntity { public void tick() { if (level != null) { - int x = worldPosition.getX(); - int y = worldPosition.getY(); - int z = worldPosition.getZ(); - viewerCount = ChestBlockEntity.getOpenCount(level, this, x, y, z); + viewerCount = ChestBlockEntity.getOpenCount(level, worldPosition); if (viewerCount > 0) { scheduleUpdate(); } else { diff --git a/src/main/java/ru/bclib/blockentities/BaseChestBlockEntity.java b/src/main/java/ru/bclib/blockentities/BaseChestBlockEntity.java index 2d1ed5d4..97581739 100644 --- a/src/main/java/ru/bclib/blockentities/BaseChestBlockEntity.java +++ b/src/main/java/ru/bclib/blockentities/BaseChestBlockEntity.java @@ -1,10 +1,12 @@ package ru.bclib.blockentities; +import net.minecraft.core.BlockPos; import net.minecraft.world.level.block.entity.ChestBlockEntity; +import net.minecraft.world.level.block.state.BlockState; import ru.bclib.registry.BaseBlockEntities; public class BaseChestBlockEntity extends ChestBlockEntity { - public BaseChestBlockEntity() { - super(BaseBlockEntities.CHEST); + public BaseChestBlockEntity(BlockPos blockPos, BlockState blockState) { + super(BaseBlockEntities.CHEST, blockPos, blockState); } } diff --git a/src/main/java/ru/bclib/blockentities/BaseFurnaceBlockEntity.java b/src/main/java/ru/bclib/blockentities/BaseFurnaceBlockEntity.java index 7413bd7c..fa681007 100644 --- a/src/main/java/ru/bclib/blockentities/BaseFurnaceBlockEntity.java +++ b/src/main/java/ru/bclib/blockentities/BaseFurnaceBlockEntity.java @@ -1,5 +1,6 @@ package ru.bclib.blockentities; +import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.world.entity.player.Inventory; @@ -7,11 +8,12 @@ import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.FurnaceMenu; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity; +import net.minecraft.world.level.block.state.BlockState; import ru.bclib.registry.BaseBlockEntities; public class BaseFurnaceBlockEntity extends AbstractFurnaceBlockEntity { - public BaseFurnaceBlockEntity() { - super(BaseBlockEntities.FURNACE, RecipeType.SMELTING); + public BaseFurnaceBlockEntity(BlockPos blockPos, BlockState blockState) { + super(BaseBlockEntities.FURNACE, blockPos, blockState, RecipeType.SMELTING); } protected Component getDefaultName() { diff --git a/src/main/java/ru/bclib/blockentities/BaseSignBlockEntity.java b/src/main/java/ru/bclib/blockentities/BaseSignBlockEntity.java index 90bf2a21..64a9b75f 100644 --- a/src/main/java/ru/bclib/blockentities/BaseSignBlockEntity.java +++ b/src/main/java/ru/bclib/blockentities/BaseSignBlockEntity.java @@ -1,12 +1,14 @@ package ru.bclib.blockentities; +import net.minecraft.core.BlockPos; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.SignBlockEntity; +import net.minecraft.world.level.block.state.BlockState; import ru.bclib.registry.BaseBlockEntities; public class BaseSignBlockEntity extends SignBlockEntity { - public BaseSignBlockEntity() { - super(); + public BaseSignBlockEntity(BlockPos blockPos, BlockState blockState) { + super(blockPos, blockState); } @Override diff --git a/src/main/java/ru/bclib/blockentities/DynamicBlockEntityType.java b/src/main/java/ru/bclib/blockentities/DynamicBlockEntityType.java index 0b476594..2f992c86 100644 --- a/src/main/java/ru/bclib/blockentities/DynamicBlockEntityType.java +++ b/src/main/java/ru/bclib/blockentities/DynamicBlockEntityType.java @@ -6,24 +6,40 @@ import java.util.function.Supplier; import com.google.common.collect.Sets; +import net.minecraft.core.BlockPos; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; +import org.jetbrains.annotations.Nullable; public class DynamicBlockEntityType extends BlockEntityType { private final Set validBlocks = Sets.newHashSet(); + private final BlockEntitySupplier factory; - public DynamicBlockEntityType(Supplier supplier) { - super(supplier, Collections.emptySet(), null); + public DynamicBlockEntityType(BlockEntitySupplier supplier) { + super(null, Collections.emptySet(), null); + this.factory = supplier; } @Override - public boolean isValid(Block block) { - return validBlocks.contains(block); + @Nullable public T create(BlockPos blockPos, BlockState blockState) { + return factory.create(blockPos, blockState); + } + + @Override + public boolean isValid(BlockState blockState) { + return validBlocks.contains(blockState.getBlock()); } public void registerBlock(Block block) { validBlocks.add(block); } + + @FunctionalInterface + public + interface BlockEntitySupplier { + T create(BlockPos blockPos, BlockState blockState); + } } diff --git a/src/main/java/ru/bclib/blocks/BaseAnvilBlock.java b/src/main/java/ru/bclib/blocks/BaseAnvilBlock.java index 4abac5be..5dafc0d5 100644 --- a/src/main/java/ru/bclib/blocks/BaseAnvilBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseAnvilBlock.java @@ -1,7 +1,16 @@ package ru.bclib.blocks; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import org.jetbrains.annotations.Nullable; + import com.google.common.collect.Lists; import com.google.common.collect.Maps; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.resources.model.UnbakedModel; @@ -16,22 +25,17 @@ import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.IntegerProperty; import net.minecraft.world.level.material.MaterialColor; import net.minecraft.world.level.storage.loot.LootContext; -import org.jetbrains.annotations.Nullable; import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.BlockModelProvider; import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.PatternsHelper; import ru.bclib.items.BaseAnvilItem; -import java.util.List; -import java.util.Map; -import java.util.Optional; - public abstract class BaseAnvilBlock extends AnvilBlock implements BlockModelProvider { public static final IntegerProperty DESTRUCTION = BlockProperties.DESTRUCTION; public BaseAnvilBlock(MaterialColor color) { - super(FabricBlockSettings.copyOf(Blocks.ANVIL).materialColor(color)); + super(FabricBlockSettings.copyOf(Blocks.ANVIL).mapColor(color)); } @Override @@ -39,8 +43,9 @@ public abstract class BaseAnvilBlock extends AnvilBlock implements BlockModelPro super.createBlockStateDefinition(builder); builder.add(DESTRUCTION); } - + @Override + @SuppressWarnings("deprecation") public List getDrops(BlockState state, LootContext.Builder builder) { ItemStack dropStack = new ItemStack(this); int destruction = state.getValue(DESTRUCTION); @@ -60,11 +65,13 @@ public abstract class BaseAnvilBlock extends AnvilBlock implements BlockModelPro public abstract Item asItem(); @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation blockId) { return getBlockModel(blockId, defaultBlockState()); } @Override + @Environment(EnvType.CLIENT) public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { int destruction = blockState.getValue(DESTRUCTION); String name = blockId.getPath(); @@ -77,6 +84,7 @@ public abstract class BaseAnvilBlock extends AnvilBlock implements BlockModelPro } @Override + @Environment(EnvType.CLIENT) public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map modelCache) { int destruction = blockState.getValue(DESTRUCTION); String modId = stateId.getNamespace(); diff --git a/src/main/java/ru/bclib/blocks/BaseAttachedBlock.java b/src/main/java/ru/bclib/blocks/BaseAttachedBlock.java index 9d021fd0..ecf12d48 100644 --- a/src/main/java/ru/bclib/blocks/BaseAttachedBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseAttachedBlock.java @@ -16,12 +16,13 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.DirectionProperty; import ru.bclib.util.BlocksHelper; +@SuppressWarnings("deprecation") public abstract class BaseAttachedBlock extends BaseBlockNotFull { public static final DirectionProperty FACING = BlockStateProperties.FACING; public BaseAttachedBlock(Properties settings) { super(settings); - this.registerDefaultState(this.defaultBlockState().setValue(FACING, Direction.UP)); + registerDefaultState(defaultBlockState().setValue(FACING, Direction.UP)); } @Override @@ -31,7 +32,7 @@ public abstract class BaseAttachedBlock extends BaseBlockNotFull { @Override public BlockState getStateForPlacement(BlockPlaceContext ctx) { - BlockState blockState = this.defaultBlockState(); + BlockState blockState = defaultBlockState(); LevelReader worldView = ctx.getLevel(); BlockPos blockPos = ctx.getClickedPos(); Direction[] directions = ctx.getNearestLookingDirections(); @@ -47,7 +48,7 @@ public abstract class BaseAttachedBlock extends BaseBlockNotFull { @Override public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { - Direction direction = (Direction) state.getValue(FACING); + Direction direction = state.getValue(FACING); BlockPos blockPos = pos.relative(direction.getOpposite()); return canSupportCenter(world, blockPos, direction) || world.getBlockState(blockPos).is(BlockTags.LEAVES); } diff --git a/src/main/java/ru/bclib/blocks/BaseBarrelBlock.java b/src/main/java/ru/bclib/blocks/BaseBarrelBlock.java index 2a2de39d..b36f8843 100644 --- a/src/main/java/ru/bclib/blocks/BaseBarrelBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseBarrelBlock.java @@ -7,6 +7,8 @@ import java.util.Random; import org.jetbrains.annotations.Nullable; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.resources.model.BlockModelRotation; @@ -44,11 +46,12 @@ public class BaseBarrelBlock extends BarrelBlock implements BlockModelProvider { } @Override - public BlockEntity newBlockEntity(BlockGetter world) { - return BaseBlockEntities.BARREL.create(); + public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) { + return BaseBlockEntities.BARREL.create(blockPos, blockState); } @Override + @SuppressWarnings("deprecation") public List getDrops(BlockState state, LootContext.Builder builder) { List drop = super.getDrops(state, builder); drop.add(new ItemStack(this.asItem())); @@ -97,11 +100,13 @@ public class BaseBarrelBlock extends BarrelBlock implements BlockModelProvider { } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation blockId) { return getBlockModel(blockId, defaultBlockState()); } @Override + @Environment(EnvType.CLIENT) public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { Optional pattern; if (blockState.getValue(OPEN)) { @@ -113,6 +118,7 @@ public class BaseBarrelBlock extends BarrelBlock implements BlockModelProvider { } @Override + @Environment(EnvType.CLIENT) public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map modelCache) { String open = blockState.getValue(OPEN) ? "_open" : ""; ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), @@ -125,8 +131,8 @@ public class BaseBarrelBlock extends BarrelBlock implements BlockModelProvider { case EAST: rotation = BlockModelRotation.X90_Y90; break; case SOUTH: rotation = BlockModelRotation.X90_Y180; break; case WEST: rotation = BlockModelRotation.X90_Y270; break; - case DOWN: - default: rotation = BlockModelRotation.X180_Y0; break; + case DOWN: rotation = BlockModelRotation.X180_Y0; break; + default: break; } return ModelsHelper.createMultiVariant(modelId, rotation.getRotation(), false); } diff --git a/src/main/java/ru/bclib/blocks/BaseBlock.java b/src/main/java/ru/bclib/blocks/BaseBlock.java index 274261a5..97878a79 100644 --- a/src/main/java/ru/bclib/blocks/BaseBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseBlock.java @@ -17,6 +17,7 @@ public class BaseBlock extends Block implements BlockModelProvider { } @Override + @SuppressWarnings("deprecation") public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } diff --git a/src/main/java/ru/bclib/blocks/BaseBlockWithEntity.java b/src/main/java/ru/bclib/blocks/BaseBlockWithEntity.java index fa731e03..718a58f7 100644 --- a/src/main/java/ru/bclib/blocks/BaseBlockWithEntity.java +++ b/src/main/java/ru/bclib/blocks/BaseBlockWithEntity.java @@ -3,6 +3,7 @@ package ru.bclib.blocks; import java.util.Collections; import java.util.List; +import net.minecraft.core.BlockPos; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.block.BaseEntityBlock; @@ -16,11 +17,12 @@ public class BaseBlockWithEntity extends BaseEntityBlock { } @Override - public BlockEntity newBlockEntity(BlockGetter world) { + public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) { return null; } - + @Override + @SuppressWarnings("deprecation") public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } diff --git a/src/main/java/ru/bclib/blocks/BaseBookshelfBlock.java b/src/main/java/ru/bclib/blocks/BaseBookshelfBlock.java index 98907016..a1b68b1d 100644 --- a/src/main/java/ru/bclib/blocks/BaseBookshelfBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseBookshelfBlock.java @@ -6,6 +6,8 @@ import java.util.Optional; import org.jetbrains.annotations.Nullable; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.resources.ResourceLocation; @@ -39,6 +41,7 @@ public class BaseBookshelfBlock extends BaseBlock { } @Override + @Environment(EnvType.CLIENT) public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { Optional pattern = PatternsHelper.createJson(BasePatterns.BLOCK_BOOKSHELF, replacePath(blockId)); return ModelsHelper.fromPattern(pattern); diff --git a/src/main/java/ru/bclib/blocks/BaseButtonBlock.java b/src/main/java/ru/bclib/blocks/BaseButtonBlock.java index 7a0a2143..5f8642ce 100644 --- a/src/main/java/ru/bclib/blocks/BaseButtonBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseButtonBlock.java @@ -7,6 +7,8 @@ import java.util.Optional; import org.jetbrains.annotations.Nullable; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.resources.model.BlockModelRotation; import net.minecraft.client.resources.model.UnbakedModel; @@ -33,11 +35,13 @@ public abstract class BaseButtonBlock extends ButtonBlock implements BlockModelP } @Override + @SuppressWarnings("deprecation") public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation blockId) { ResourceLocation parentId = Registry.BLOCK.getKey(parent); Optional pattern = PatternsHelper.createJson(BasePatterns.ITEM_BUTTON, parentId); @@ -45,6 +49,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); Optional pattern = blockState.getValue(POWERED) ? @@ -54,6 +59,7 @@ public abstract class BaseButtonBlock extends ButtonBlock implements BlockModelP } @Override + @Environment(EnvType.CLIENT) public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map modelCache) { String powered = blockState.getValue(POWERED) ? "_powered" : ""; ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), diff --git a/src/main/java/ru/bclib/blocks/BaseChainBlock.java b/src/main/java/ru/bclib/blocks/BaseChainBlock.java index e23827f8..c2a14fe3 100644 --- a/src/main/java/ru/bclib/blocks/BaseChainBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseChainBlock.java @@ -7,6 +7,8 @@ import java.util.Optional; import org.jetbrains.annotations.Nullable; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.resources.model.UnbakedModel; @@ -22,31 +24,35 @@ import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.BlockModelProvider; import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.PatternsHelper; -import ru.bclib.client.render.ERenderLayer; +import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.interfaces.IRenderTyped; public class BaseChainBlock extends ChainBlock implements BlockModelProvider, IRenderTyped { public BaseChainBlock(MaterialColor color) { - super(FabricBlockSettings.copyOf(Blocks.CHAIN).materialColor(color)); + super(FabricBlockSettings.copyOf(Blocks.CHAIN).mapColor(color)); } - + @Override + @SuppressWarnings("deprecation") public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation blockId) { return ModelsHelper.createItemModel(blockId); } @Override + @Environment(EnvType.CLIENT) public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { Optional pattern = PatternsHelper.createJson(BasePatterns.BLOCK_CHAIN, blockId); return ModelsHelper.fromPattern(pattern); } @Override + @Environment(EnvType.CLIENT) public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map modelCache) { Direction.Axis axis = blockState.getValue(AXIS); ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), @@ -56,7 +62,7 @@ public class BaseChainBlock extends ChainBlock implements BlockModelProvider, IR } @Override - public ERenderLayer getRenderLayer() { - return ERenderLayer.CUTOUT; + public BCLRenderLayer getRenderLayer() { + return BCLRenderLayer.CUTOUT; } } diff --git a/src/main/java/ru/bclib/blocks/BaseChestBlock.java b/src/main/java/ru/bclib/blocks/BaseChestBlock.java index 2f8f02b2..2b89b5d2 100644 --- a/src/main/java/ru/bclib/blocks/BaseChestBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseChestBlock.java @@ -3,8 +3,11 @@ package ru.bclib.blocks; import java.util.List; import java.util.Optional; +import net.minecraft.core.BlockPos; import org.jetbrains.annotations.Nullable; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.core.Registry; @@ -31,12 +34,12 @@ public class BaseChestBlock extends ChestBlock implements BlockModelProvider { } @Override - public BlockEntity newBlockEntity(BlockGetter world) - { - return BaseBlockEntities.CHEST.create(); + public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) { + return BaseBlockEntities.CHEST.create(blockPos, blockState); } - + @Override + @SuppressWarnings("deprecation") public List getDrops(BlockState state, LootContext.Builder builder) { List drop = super.getDrops(state, builder); @@ -45,12 +48,14 @@ public class BaseChestBlock extends ChestBlock implements BlockModelProvider { } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation blockId) { Optional pattern = PatternsHelper.createJson(BasePatterns.ITEM_CHEST, blockId); return ModelsHelper.fromPattern(pattern); } @Override + @Environment(EnvType.CLIENT) public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) { ResourceLocation parentId = Registry.BLOCK.getKey(parent); return ModelsHelper.createBlockEmpty(parentId); diff --git a/src/main/java/ru/bclib/blocks/BaseComposterBlock.java b/src/main/java/ru/bclib/blocks/BaseComposterBlock.java index 40fcd847..faecc6e5 100644 --- a/src/main/java/ru/bclib/blocks/BaseComposterBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseComposterBlock.java @@ -7,6 +7,8 @@ import java.util.Optional; import org.jetbrains.annotations.Nullable; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.resources.model.UnbakedModel; @@ -26,24 +28,28 @@ public class BaseComposterBlock extends ComposterBlock implements BlockModelProv public BaseComposterBlock(Block source) { super(FabricBlockSettings.copyOf(source)); } - + @Override + @SuppressWarnings("deprecation") public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this.asItem())); } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation resourceLocation) { return getBlockModel(resourceLocation, defaultBlockState()); } @Override + @Environment(EnvType.CLIENT) public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { Optional pattern = PatternsHelper.createJson(BasePatterns.BLOCK_COMPOSTER, blockId); return ModelsHelper.fromPattern(pattern); } @Override + @Environment(EnvType.CLIENT) public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map modelCache) { ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath()); registerBlockModel(stateId, modelId, blockState, modelCache); diff --git a/src/main/java/ru/bclib/blocks/BaseCraftingTableBlock.java b/src/main/java/ru/bclib/blocks/BaseCraftingTableBlock.java index e36b2374..570758fe 100644 --- a/src/main/java/ru/bclib/blocks/BaseCraftingTableBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseCraftingTableBlock.java @@ -7,6 +7,8 @@ import java.util.Optional; import org.jetbrains.annotations.Nullable; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.resources.ResourceLocation; @@ -26,16 +28,19 @@ public class BaseCraftingTableBlock extends CraftingTableBlock implements BlockM } @Override + @SuppressWarnings("deprecation") public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this.asItem())); } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation resourceLocation) { return getBlockModel(resourceLocation, defaultBlockState()); } @Override + @Environment(EnvType.CLIENT) public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { String blockName = blockId.getPath(); Optional pattern = PatternsHelper.createJson(BasePatterns.BLOCK_SIDED, new HashMap() { diff --git a/src/main/java/ru/bclib/blocks/BaseCropBlock.java b/src/main/java/ru/bclib/blocks/BaseCropBlock.java index 703ffaab..e395d338 100644 --- a/src/main/java/ru/bclib/blocks/BaseCropBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseCropBlock.java @@ -106,8 +106,9 @@ public class BaseCropBlock extends BasePlantBlock { public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) { return state.getValue(AGE) < 3; } - + @Override + @SuppressWarnings("deprecation") public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) { super.tick(state, world, pos, random); if (isBonemealSuccess(world, random, pos, state) && random.nextInt(8) == 0) { diff --git a/src/main/java/ru/bclib/blocks/BaseDoorBlock.java b/src/main/java/ru/bclib/blocks/BaseDoorBlock.java index 3afa466c..1c2c6245 100644 --- a/src/main/java/ru/bclib/blocks/BaseDoorBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseDoorBlock.java @@ -7,6 +7,8 @@ import java.util.Optional; import org.jetbrains.annotations.Nullable; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.resources.model.BlockModelRotation; @@ -25,7 +27,7 @@ import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.BlockModelProvider; import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.PatternsHelper; -import ru.bclib.client.render.ERenderLayer; +import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.interfaces.IRenderTyped; public class BaseDoorBlock extends DoorBlock implements IRenderTyped, BlockModelProvider { @@ -34,6 +36,7 @@ public class BaseDoorBlock extends DoorBlock implements IRenderTyped, BlockModel } @Override + @SuppressWarnings("deprecation") public List getDrops(BlockState state, LootContext.Builder builder) { if (state.getValue(HALF) == DoubleBlockHalf.LOWER) return Collections.singletonList(new ItemStack(this.asItem())); @@ -42,11 +45,12 @@ public class BaseDoorBlock extends DoorBlock implements IRenderTyped, BlockModel } @Override - public ERenderLayer getRenderLayer() { - return ERenderLayer.CUTOUT; + public BCLRenderLayer getRenderLayer() { + return BCLRenderLayer.CUTOUT; } @Override + @Environment(EnvType.CLIENT) public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) { DoorType doorType = getDoorType(blockState); Optional pattern = PatternsHelper.createJson(BasePatterns.BLOCK_DOOR_BOTTOM, resourceLocation); @@ -66,6 +70,7 @@ public class BaseDoorBlock extends DoorBlock implements IRenderTyped, BlockModel } @Override + @Environment(EnvType.CLIENT) public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map modelCache) { Direction facing = blockState.getValue(FACING); DoorType doorType = getDoorType(blockState); diff --git a/src/main/java/ru/bclib/blocks/BaseDoublePlantBlock.java b/src/main/java/ru/bclib/blocks/BaseDoublePlantBlock.java index 38817356..73f0ed6c 100644 --- a/src/main/java/ru/bclib/blocks/BaseDoublePlantBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseDoublePlantBlock.java @@ -34,10 +34,11 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; -import ru.bclib.client.render.ERenderLayer; +import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.interfaces.IRenderTyped; import ru.bclib.util.BlocksHelper; +@SuppressWarnings("deprecation") public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements IRenderTyped, BonemealableBlock { private static final VoxelShape SHAPE = Block.box(4, 2, 4, 12, 16, 12); public static final IntegerProperty ROTATION = BlockProperties.ROTATION; @@ -110,7 +111,7 @@ public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements I } ItemStack tool = builder.getParameter(LootContextParams.TOOL); - if (tool != null && tool.getItem().is(FabricToolTags.SHEARS) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { + if (tool != null && FabricToolTags.SHEARS.contains(tool.getItem()) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { return Lists.newArrayList(new ItemStack(this)); } else { @@ -119,8 +120,8 @@ public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements I } @Override - public ERenderLayer getRenderLayer() { - return ERenderLayer.CUTOUT; + public BCLRenderLayer getRenderLayer() { + return BCLRenderLayer.CUTOUT; } @Override diff --git a/src/main/java/ru/bclib/blocks/BaseFenceBlock.java b/src/main/java/ru/bclib/blocks/BaseFenceBlock.java index 0948de06..85adff6e 100644 --- a/src/main/java/ru/bclib/blocks/BaseFenceBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseFenceBlock.java @@ -7,6 +7,8 @@ import java.util.Optional; import org.jetbrains.annotations.Nullable; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.resources.model.BlockModelRotation; @@ -33,11 +35,13 @@ public class BaseFenceBlock extends FenceBlock implements BlockModelProvider { } @Override + @SuppressWarnings("deprecation") public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation blockId) { ResourceLocation parentId = Registry.BLOCK.getKey(parent); Optional pattern = PatternsHelper.createJson(BasePatterns.ITEM_FENCE, parentId); @@ -45,6 +49,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); String path = blockId.getPath(); @@ -59,6 +64,7 @@ public class BaseFenceBlock extends FenceBlock implements BlockModelProvider { } @Override + @Environment(EnvType.CLIENT) public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map modelCache) { ResourceLocation postId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath() + "_post"); diff --git a/src/main/java/ru/bclib/blocks/BaseFurnaceBlock.java b/src/main/java/ru/bclib/blocks/BaseFurnaceBlock.java index 9bdf4b76..925a3e45 100644 --- a/src/main/java/ru/bclib/blocks/BaseFurnaceBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseFurnaceBlock.java @@ -1,14 +1,9 @@ package ru.bclib.blocks; -import java.util.List; -import java.util.Map; -import java.util.Optional; - -import org.jetbrains.annotations.Nullable; - import com.google.common.collect.Lists; import com.google.common.collect.Maps; - +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.resources.model.UnbakedModel; @@ -18,21 +13,29 @@ import net.minecraft.stats.Stats; import net.minecraft.world.MenuProvider; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.FurnaceBlock; +import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity; import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityTicker; +import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import org.jetbrains.annotations.Nullable; import ru.bclib.blockentities.BaseFurnaceBlockEntity; import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.BlockModelProvider; import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.PatternsHelper; -import ru.bclib.client.render.ERenderLayer; +import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.interfaces.IRenderTyped; +import ru.bclib.registry.BaseBlockEntities; + +import java.util.List; +import java.util.Map; +import java.util.Optional; public class BaseFurnaceBlock extends FurnaceBlock implements BlockModelProvider, IRenderTyped { public BaseFurnaceBlock(Block source) { @@ -40,8 +43,8 @@ public class BaseFurnaceBlock extends FurnaceBlock implements BlockModelProvider } @Override - public BlockEntity newBlockEntity(BlockGetter world) { - return new BaseFurnaceBlockEntity(); + public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) { + return new BaseFurnaceBlockEntity(blockPos, blockState); } @Override @@ -54,6 +57,7 @@ public class BaseFurnaceBlock extends FurnaceBlock implements BlockModelProvider } @Override + @Environment(EnvType.CLIENT) public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { String blockName = blockId.getPath(); Map textures = Maps.newHashMap(); @@ -73,11 +77,13 @@ public class BaseFurnaceBlock extends FurnaceBlock implements BlockModelProvider } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation resourceLocation) { return getBlockModel(resourceLocation, defaultBlockState()); } @Override + @Environment(EnvType.CLIENT) public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map modelCache) { String lit = blockState.getValue(LIT) ? "_lit" : ""; ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), @@ -87,11 +93,12 @@ public class BaseFurnaceBlock extends FurnaceBlock implements BlockModelProvider } @Override - public ERenderLayer getRenderLayer() { - return ERenderLayer.CUTOUT; + public BCLRenderLayer getRenderLayer() { + return BCLRenderLayer.CUTOUT; } - + @Override + @SuppressWarnings("deprecation") public List getDrops(BlockState state, LootContext.Builder builder) { List drop = Lists.newArrayList(new ItemStack(this)); BlockEntity blockEntity = builder.getOptionalParameter(LootContextParams.BLOCK_ENTITY); @@ -103,4 +110,15 @@ public class BaseFurnaceBlock extends FurnaceBlock implements BlockModelProvider } return drop; } + + @Override + @Nullable + public BlockEntityTicker getTicker(Level level, BlockState blockState, BlockEntityType blockEntityType) { + return createFurnaceTicker(level, blockEntityType, BaseBlockEntities.FURNACE); + } + + @Nullable + protected static BlockEntityTicker createFurnaceTicker(Level level, BlockEntityType blockEntityType, BlockEntityType blockEntityType2) { + return level.isClientSide ? null : createTickerHelper(blockEntityType, blockEntityType2, AbstractFurnaceBlockEntity::serverTick); + } } diff --git a/src/main/java/ru/bclib/blocks/BaseGateBlock.java b/src/main/java/ru/bclib/blocks/BaseGateBlock.java index 8e811ce4..d765ca2d 100644 --- a/src/main/java/ru/bclib/blocks/BaseGateBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseGateBlock.java @@ -7,6 +7,8 @@ import java.util.Optional; import org.jetbrains.annotations.Nullable; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.resources.model.UnbakedModel; @@ -31,16 +33,19 @@ public class BaseGateBlock extends FenceGateBlock implements BlockModelProvider } @Override + @SuppressWarnings("deprecation") public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation resourceLocation) { return getBlockModel(resourceLocation, defaultBlockState()); } @Override + @Environment(EnvType.CLIENT) public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { boolean inWall = blockState.getValue(IN_WALL); boolean isOpen = blockState.getValue(OPEN); @@ -57,6 +62,7 @@ public class BaseGateBlock extends FenceGateBlock implements BlockModelProvider } @Override + @Environment(EnvType.CLIENT) public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map modelCache) { boolean inWall = blockState.getValue(IN_WALL); boolean isOpen = blockState.getValue(OPEN); diff --git a/src/main/java/ru/bclib/blocks/BaseLadderBlock.java b/src/main/java/ru/bclib/blocks/BaseLadderBlock.java index 17fdbec0..93939d8f 100644 --- a/src/main/java/ru/bclib/blocks/BaseLadderBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseLadderBlock.java @@ -5,6 +5,8 @@ import java.util.Optional; import org.jetbrains.annotations.Nullable; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.resources.model.UnbakedModel; @@ -33,10 +35,11 @@ import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.BlockModelProvider; import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.PatternsHelper; -import ru.bclib.client.render.ERenderLayer; +import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.interfaces.IRenderTyped; import ru.bclib.util.BlocksHelper; +@SuppressWarnings("deprecation") public class BaseLadderBlock extends BaseBlockNotFull implements IRenderTyped, BlockModelProvider { public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING; public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; @@ -55,17 +58,14 @@ public class BaseLadderBlock extends BaseBlockNotFull implements IRenderTyped, B stateManager.add(WATERLOGGED); } + @Override public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { - switch (state.getValue(FACING)) { - case SOUTH: - return SOUTH_SHAPE; - case WEST: - return WEST_SHAPE; - case EAST: - return EAST_SHAPE; - default: - return NORTH_SHAPE; - } + return switch (state.getValue(FACING)) { + case SOUTH -> SOUTH_SHAPE; + case WEST -> WEST_SHAPE; + case EAST -> EAST_SHAPE; + default -> NORTH_SHAPE; + }; } private boolean canPlaceOn(BlockGetter world, BlockPos pos, Direction side) { @@ -76,7 +76,7 @@ public class BaseLadderBlock extends BaseBlockNotFull implements IRenderTyped, B @Override public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { Direction direction = state.getValue(FACING); - return this.canPlaceOn(world, pos.relative(direction.getOpposite()), direction); + return canPlaceOn(world, pos.relative(direction.getOpposite()), direction); } @Override @@ -137,22 +137,25 @@ public class BaseLadderBlock extends BaseBlockNotFull implements IRenderTyped, B } @Override - public ERenderLayer getRenderLayer() { - return ERenderLayer.CUTOUT; + public BCLRenderLayer getRenderLayer() { + return BCLRenderLayer.CUTOUT; } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation blockId) { return ModelsHelper.createBlockItem(blockId); } @Override + @Environment(EnvType.CLIENT) public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { Optional pattern = PatternsHelper.createJson(BasePatterns.BLOCK_LADDER, blockId); return ModelsHelper.fromPattern(pattern); } @Override + @Environment(EnvType.CLIENT) public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map modelCache) { ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath()); registerBlockModel(stateId, modelId, blockState, modelCache); diff --git a/src/main/java/ru/bclib/blocks/BaseLeavesBlock.java b/src/main/java/ru/bclib/blocks/BaseLeavesBlock.java index 4d0652da..4e644f8e 100644 --- a/src/main/java/ru/bclib/blocks/BaseLeavesBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseLeavesBlock.java @@ -20,7 +20,7 @@ import net.minecraft.world.level.material.MaterialColor; import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import ru.bclib.client.models.BlockModelProvider; -import ru.bclib.client.render.ERenderLayer; +import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.interfaces.IRenderTyped; import ru.bclib.util.MHelper; @@ -29,7 +29,7 @@ public class BaseLeavesBlock extends LeavesBlock implements BlockModelProvider, public BaseLeavesBlock(Block sapling, MaterialColor color) { super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES) - .materialColor(color) + .mapColor(color) .breakByTool(FabricToolTags.HOES) .breakByTool(FabricToolTags.SHEARS) .breakByHand(true) @@ -41,7 +41,7 @@ public class BaseLeavesBlock extends LeavesBlock implements BlockModelProvider, public BaseLeavesBlock(Block sapling, MaterialColor color, int light) { super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES) - .materialColor(color) + .mapColor(color) .luminance(light) .breakByTool(FabricToolTags.HOES) .breakByTool(FabricToolTags.SHEARS) @@ -52,15 +52,16 @@ public class BaseLeavesBlock extends LeavesBlock implements BlockModelProvider, } @Override - public ERenderLayer getRenderLayer() { - return ERenderLayer.CUTOUT; + public BCLRenderLayer getRenderLayer() { + return BCLRenderLayer.CUTOUT; } - + @Override + @SuppressWarnings("deprecation") public List getDrops(BlockState state, LootContext.Builder builder) { ItemStack tool = builder.getParameter(LootContextParams.TOOL); if (tool != null) { - if (tool.getItem().is(FabricToolTags.SHEARS) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { + if (FabricToolTags.SHEARS.contains(tool.getItem()) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { return Collections.singletonList(new ItemStack(this)); } int fortune = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.BLOCK_FORTUNE, tool); diff --git a/src/main/java/ru/bclib/blocks/BaseMetalBarsBlock.java b/src/main/java/ru/bclib/blocks/BaseMetalBarsBlock.java index 5a612ac0..d4ecb9bf 100644 --- a/src/main/java/ru/bclib/blocks/BaseMetalBarsBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseMetalBarsBlock.java @@ -25,7 +25,7 @@ import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.BlockModelProvider; import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.PatternsHelper; -import ru.bclib.client.render.ERenderLayer; +import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.interfaces.IRenderTyped; public class BaseMetalBarsBlock extends IronBarsBlock implements BlockModelProvider, IRenderTyped { @@ -34,6 +34,7 @@ public class BaseMetalBarsBlock extends IronBarsBlock implements BlockModelProvi } @Override + @SuppressWarnings("deprecation") public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } @@ -52,11 +53,13 @@ public class BaseMetalBarsBlock extends IronBarsBlock implements BlockModelProvi } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation resourceLocation) { return ModelsHelper.createBlockItem(resourceLocation); } @Override + @Environment(EnvType.CLIENT) public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { ResourceLocation thisId = Registry.BLOCK.getKey(this); String path = blockId.getPath(); @@ -71,6 +74,7 @@ public class BaseMetalBarsBlock extends IronBarsBlock implements BlockModelProvi } @Override + @Environment(EnvType.CLIENT) public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map modelCache) { ResourceLocation postId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath() + "_post"); @@ -96,14 +100,14 @@ public class BaseMetalBarsBlock extends IronBarsBlock implements BlockModelProvi @Environment(EnvType.CLIENT) public boolean skipRendering(BlockState state, BlockState stateFrom, Direction direction) { - if (direction.getAxis().isVertical() && stateFrom.getBlock().is(this) && !stateFrom.equals(state)) { + if (direction.getAxis().isVertical() && stateFrom.getBlock() == this && !stateFrom.equals(state)) { return false; } return super.skipRendering(state, stateFrom, direction); } @Override - public ERenderLayer getRenderLayer() { - return ERenderLayer.CUTOUT; + public BCLRenderLayer getRenderLayer() { + return BCLRenderLayer.CUTOUT; } } diff --git a/src/main/java/ru/bclib/blocks/BaseOreBlock.java b/src/main/java/ru/bclib/blocks/BaseOreBlock.java index 5d5cc847..9f0bfaf2 100644 --- a/src/main/java/ru/bclib/blocks/BaseOreBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseOreBlock.java @@ -8,6 +8,7 @@ import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; +import net.minecraft.util.valueproviders.UniformInt; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.enchantment.EnchantmentHelper; @@ -26,26 +27,20 @@ public class BaseOreBlock extends OreBlock implements BlockModelProvider { private final Item dropItem; private final int minCount; private final int maxCount; - private final int experience; public BaseOreBlock(Item drop, int minCount, int maxCount, int experience) { super(FabricBlockSettings.of(Material.STONE, MaterialColor.SAND) .hardness(3F) .resistance(9F) .requiresCorrectToolForDrops() - .sound(SoundType.STONE)); + .sound(SoundType.STONE), UniformInt.of(1, experience)); this.dropItem = drop; this.minCount = minCount; this.maxCount = maxCount; - this.experience = experience; - } - - @Override - protected int xpOnDrop(Random random) { - return this.experience > 0 ? random.nextInt(experience) + 1 : 0; } @Override + @SuppressWarnings("deprecation") public List getDrops(BlockState state, LootContext.Builder builder) { ItemStack tool = builder.getParameter(LootContextParams.TOOL); if (tool != null && tool.isCorrectToolForDrops(state)) { diff --git a/src/main/java/ru/bclib/blocks/BasePathBlock.java b/src/main/java/ru/bclib/blocks/BasePathBlock.java index 76695951..75060542 100644 --- a/src/main/java/ru/bclib/blocks/BasePathBlock.java +++ b/src/main/java/ru/bclib/blocks/BasePathBlock.java @@ -9,6 +9,8 @@ import org.jetbrains.annotations.Nullable; import com.google.common.collect.Maps; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.resources.model.UnbakedModel; @@ -66,11 +68,13 @@ public class BasePathBlock extends BaseBlockNotFull { } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation blockId) { return getBlockModel(blockId, defaultBlockState()); } @Override + @Environment(EnvType.CLIENT) public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { String name = blockId.getPath(); ResourceLocation bottomId = Registry.BLOCK.getKey(baseBlock); @@ -85,6 +89,7 @@ public class BasePathBlock extends BaseBlockNotFull { } @Override + @Environment(EnvType.CLIENT) public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map modelCache) { ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath()); registerBlockModel(stateId, modelId, blockState, modelCache); diff --git a/src/main/java/ru/bclib/blocks/BasePlantBlock.java b/src/main/java/ru/bclib/blocks/BasePlantBlock.java index 9180a4b0..b3181e9d 100644 --- a/src/main/java/ru/bclib/blocks/BasePlantBlock.java +++ b/src/main/java/ru/bclib/blocks/BasePlantBlock.java @@ -30,9 +30,10 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; -import ru.bclib.client.render.ERenderLayer; +import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.interfaces.IRenderTyped; +@SuppressWarnings("deprecation") public abstract class BasePlantBlock extends BaseBlockNotFull implements IRenderTyped, BonemealableBlock { private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 14, 12); @@ -97,7 +98,7 @@ public abstract class BasePlantBlock extends BaseBlockNotFull implements IRender @Override public List getDrops(BlockState state, LootContext.Builder builder) { ItemStack tool = builder.getParameter(LootContextParams.TOOL); - if (tool != null && tool.getItem().is(FabricToolTags.SHEARS) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { + if (tool != null && FabricToolTags.SHEARS.contains(tool.getItem()) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { return Lists.newArrayList(new ItemStack(this)); } else { @@ -106,8 +107,8 @@ public abstract class BasePlantBlock extends BaseBlockNotFull implements IRender } @Override - public ERenderLayer getRenderLayer() { - return ERenderLayer.CUTOUT; + public BCLRenderLayer getRenderLayer() { + return BCLRenderLayer.CUTOUT; } @Override diff --git a/src/main/java/ru/bclib/blocks/BasePlantWithAgeBlock.java b/src/main/java/ru/bclib/blocks/BasePlantWithAgeBlock.java index a8c31d54..e78a0189 100644 --- a/src/main/java/ru/bclib/blocks/BasePlantWithAgeBlock.java +++ b/src/main/java/ru/bclib/blocks/BasePlantWithAgeBlock.java @@ -53,8 +53,9 @@ public abstract class BasePlantWithAgeBlock extends BasePlantBlock { public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) { return true; } - + @Override + @SuppressWarnings("deprecation") public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) { super.tick(state, world, pos, random); if (random.nextInt(8) == 0) { diff --git a/src/main/java/ru/bclib/blocks/BasePressurePlateBlock.java b/src/main/java/ru/bclib/blocks/BasePressurePlateBlock.java index 6f08b05b..9cd483f4 100644 --- a/src/main/java/ru/bclib/blocks/BasePressurePlateBlock.java +++ b/src/main/java/ru/bclib/blocks/BasePressurePlateBlock.java @@ -7,6 +7,8 @@ import java.util.Optional; import org.jetbrains.annotations.Nullable; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.resources.model.UnbakedModel; @@ -31,16 +33,19 @@ public class BasePressurePlateBlock extends PressurePlateBlock implements BlockM } @Override + @SuppressWarnings("deprecation") public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation resourceLocation) { return getBlockModel(resourceLocation, defaultBlockState()); } @Override + @Environment(EnvType.CLIENT) public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) { ResourceLocation parentId = Registry.BLOCK.getKey(parent); Optional pattern; @@ -53,6 +58,7 @@ public class BasePressurePlateBlock extends PressurePlateBlock implements BlockM } @Override + @Environment(EnvType.CLIENT) public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map modelCache) { String state = blockState.getValue(POWERED) ? "_down" : "_up"; ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), diff --git a/src/main/java/ru/bclib/blocks/BaseRotatedPillarBlock.java b/src/main/java/ru/bclib/blocks/BaseRotatedPillarBlock.java index 0a7e72fb..e5d3af50 100644 --- a/src/main/java/ru/bclib/blocks/BaseRotatedPillarBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseRotatedPillarBlock.java @@ -7,6 +7,8 @@ import java.util.Optional; import org.jetbrains.annotations.Nullable; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.resources.model.UnbakedModel; @@ -28,27 +30,30 @@ public class BaseRotatedPillarBlock extends RotatedPillarBlock implements BlockM public BaseRotatedPillarBlock(Block block) { super(FabricBlockSettings.copyOf(block)); } - + @Override + @SuppressWarnings("deprecation") public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation blockId) { return getBlockModel(blockId, defaultBlockState()); } @Override + @Environment(EnvType.CLIENT) public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { Optional pattern = createBlockPattern(blockId); return ModelsHelper.fromPattern(pattern); } @Override + @Environment(EnvType.CLIENT) public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map modelCache) { - ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), - "block/" + stateId.getPath()); + ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath()); registerBlockModel(stateId, modelId, blockState, modelCache); return ModelsHelper.createRotatedModel(modelId, blockState.getValue(AXIS)); } diff --git a/src/main/java/ru/bclib/blocks/BaseSignBlock.java b/src/main/java/ru/bclib/blocks/BaseSignBlock.java index f762f22d..5eeb16a0 100644 --- a/src/main/java/ru/bclib/blocks/BaseSignBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseSignBlock.java @@ -5,6 +5,8 @@ import java.util.List; import org.jetbrains.annotations.Nullable; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.core.BlockPos; @@ -46,6 +48,7 @@ import ru.bclib.client.models.ModelsHelper; import ru.bclib.interfaces.ISpetialItem; import ru.bclib.util.BlocksHelper; +@SuppressWarnings("deprecation") public class BaseSignBlock extends SignBlock implements BlockModelProvider, ISpetialItem { public static final IntegerProperty ROTATION = BlockStateProperties.ROTATION_16; public static final BooleanProperty FLOOR = BooleanProperty.create("floor"); @@ -75,8 +78,8 @@ public class BaseSignBlock extends SignBlock implements BlockModelProvider, ISpe } @Override - public BlockEntity newBlockEntity(BlockGetter world) { - return new BaseSignBlockEntity(); + public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) { + return new BaseSignBlockEntity(blockPos, blockState); } @Override @@ -85,7 +88,7 @@ public class BaseSignBlock extends SignBlock implements BlockModelProvider, ISpe BaseSignBlockEntity sign = (BaseSignBlockEntity) world.getBlockEntity(pos); if (sign != null) { if (!world.isClientSide) { - sign.setAllowedPlayerEditor((Player) placer); + sign.setAllowedPlayerEditor(placer.getUUID()); ((ServerPlayer) placer).connection.send(new ClientboundOpenSignEditorPacket(pos)); } else { sign.setEditable(true); @@ -146,6 +149,7 @@ public class BaseSignBlock extends SignBlock implements BlockModelProvider, ISpe } @Override + @Environment(EnvType.CLIENT) public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) { ResourceLocation parentId = Registry.BLOCK.getKey(parent); return ModelsHelper.createBlockEmpty(parentId); @@ -166,12 +170,6 @@ public class BaseSignBlock extends SignBlock implements BlockModelProvider, ISpe return Collections.singletonList(new ItemStack(this)); } - @Override - public Fluid takeLiquid(LevelAccessor world, BlockPos pos, BlockState state) { - // TODO Auto-generated method stub - return super.takeLiquid(world, pos, state); - } - @Override public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) { // TODO Auto-generated method stub diff --git a/src/main/java/ru/bclib/blocks/BaseSlabBlock.java b/src/main/java/ru/bclib/blocks/BaseSlabBlock.java index 357ecd58..73c2e109 100644 --- a/src/main/java/ru/bclib/blocks/BaseSlabBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseSlabBlock.java @@ -7,6 +7,8 @@ import java.util.Optional; import org.jetbrains.annotations.Nullable; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.resources.model.BlockModelRotation; @@ -33,23 +35,32 @@ public class BaseSlabBlock extends SlabBlock implements BlockModelProvider { } @Override + @SuppressWarnings("deprecation") public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation resourceLocation) { return getBlockModel(resourceLocation, defaultBlockState()); } @Override + @Environment(EnvType.CLIENT) public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { ResourceLocation parentId = Registry.BLOCK.getKey(parent); - Optional pattern = PatternsHelper.createJson(BasePatterns.BLOCK_SLAB, parentId); + Optional pattern; + if (blockState.getValue(TYPE) == SlabType.DOUBLE) { + pattern = PatternsHelper.createBlockSimple(parentId); + } else { + pattern = PatternsHelper.createJson(BasePatterns.BLOCK_SLAB, parentId); + } return ModelsHelper.fromPattern(pattern); } @Override + @Environment(EnvType.CLIENT) public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map modelCache) { SlabType type = blockState.getValue(TYPE); ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), diff --git a/src/main/java/ru/bclib/blocks/BaseStairsBlock.java b/src/main/java/ru/bclib/blocks/BaseStairsBlock.java index 49eb833c..2f057e78 100644 --- a/src/main/java/ru/bclib/blocks/BaseStairsBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseStairsBlock.java @@ -7,6 +7,8 @@ import java.util.Optional; import org.jetbrains.annotations.Nullable; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.resources.model.BlockModelRotation; @@ -35,16 +37,19 @@ public class BaseStairsBlock extends StairBlock implements BlockModelProvider { } @Override + @SuppressWarnings("deprecation") public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation resourceLocation) { return getBlockModel(resourceLocation, defaultBlockState()); } @Override + @Environment(EnvType.CLIENT) public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { ResourceLocation parentId = Registry.BLOCK.getKey(parent); Optional pattern = Optional.empty(); @@ -65,6 +70,7 @@ public class BaseStairsBlock extends StairBlock implements BlockModelProvider { } @Override + @Environment(EnvType.CLIENT) public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map modelCache) { String state; StairsShape shape = blockState.getValue(SHAPE); diff --git a/src/main/java/ru/bclib/blocks/BaseStripableLogBlock.java b/src/main/java/ru/bclib/blocks/BaseStripableLogBlock.java index f956e04d..a552e9fc 100644 --- a/src/main/java/ru/bclib/blocks/BaseStripableLogBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseStripableLogBlock.java @@ -20,13 +20,14 @@ public class BaseStripableLogBlock extends BaseRotatedPillarBlock { private final Block striped; public BaseStripableLogBlock(MaterialColor color, Block striped) { - super(FabricBlockSettings.copyOf(striped).materialColor(color)); + super(FabricBlockSettings.copyOf(striped).mapColor(color)); this.striped = striped; } @Override + @SuppressWarnings("deprecation") public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { - if (player.getMainHandItem().getItem().is(FabricToolTags.AXES)) { + if (FabricToolTags.AXES.contains(player.getMainHandItem().getItem())) { world.playSound(player, pos, SoundEvents.AXE_STRIP, SoundSource.BLOCKS, 1.0F, 1.0F); if (!world.isClientSide) { world.setBlock(pos, striped.defaultBlockState().setValue(RotatedPillarBlock.AXIS, state.getValue(RotatedPillarBlock.AXIS)), 11); diff --git a/src/main/java/ru/bclib/blocks/BaseTerrainBlock.java b/src/main/java/ru/bclib/blocks/BaseTerrainBlock.java index ff79bb93..fd0537c1 100644 --- a/src/main/java/ru/bclib/blocks/BaseTerrainBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseTerrainBlock.java @@ -10,6 +10,8 @@ import org.jetbrains.annotations.Nullable; import com.google.common.collect.Maps; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.minecraft.client.renderer.block.model.BlockModel; @@ -65,7 +67,7 @@ public class BaseTerrainBlock extends BaseBlock { @Override public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { - if (pathBlock != null && player.getMainHandItem().getItem().is(FabricToolTags.SHOVELS)) { + if (pathBlock != null && FabricToolTags.SHOVELS.contains(player.getMainHandItem().getItem())) { world.playSound(player, pos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F); if (!world.isClientSide) { world.setBlockAndUpdate(pos, pathBlock.defaultBlockState()); @@ -110,11 +112,13 @@ public class BaseTerrainBlock extends BaseBlock { } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation blockId) { return getBlockModel(blockId, defaultBlockState()); } @Override + @Environment(EnvType.CLIENT) public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { ResourceLocation baseId = Registry.BLOCK.getKey(baseBlock); String modId = blockId.getNamespace(); @@ -129,6 +133,7 @@ public class BaseTerrainBlock extends BaseBlock { } @Override + @Environment(EnvType.CLIENT) public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map modelCache) { ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath()); registerBlockModel(stateId, modelId, blockState, modelCache); diff --git a/src/main/java/ru/bclib/blocks/BaseTrapdoorBlock.java b/src/main/java/ru/bclib/blocks/BaseTrapdoorBlock.java index 1121a1f4..b0167f0e 100644 --- a/src/main/java/ru/bclib/blocks/BaseTrapdoorBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseTrapdoorBlock.java @@ -8,6 +8,8 @@ import java.util.Optional; import org.jetbrains.annotations.Nullable; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.resources.model.BlockModelRotation; @@ -23,7 +25,7 @@ import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.BlockModelProvider; import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.PatternsHelper; -import ru.bclib.client.render.ERenderLayer; +import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.interfaces.IRenderTyped; public class BaseTrapdoorBlock extends TrapDoorBlock implements IRenderTyped, BlockModelProvider { @@ -32,21 +34,24 @@ public class BaseTrapdoorBlock extends TrapDoorBlock implements IRenderTyped, Bl } @Override + @SuppressWarnings("deprecation") public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } @Override - public ERenderLayer getRenderLayer() { - return ERenderLayer.CUTOUT; + public BCLRenderLayer getRenderLayer() { + return BCLRenderLayer.CUTOUT; } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation resourceLocation) { return getBlockModel(resourceLocation, defaultBlockState()); } @Override + @Environment(EnvType.CLIENT) public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) { String name = resourceLocation.getPath(); Optional pattern = PatternsHelper.createJson(BasePatterns.BLOCK_TRAPDOOR, new HashMap() { @@ -61,6 +66,7 @@ public class BaseTrapdoorBlock extends TrapDoorBlock implements IRenderTyped, Bl } @Override + @Environment(EnvType.CLIENT) public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map modelCache) { ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath()); registerBlockModel(stateId, modelId, blockState, modelCache); diff --git a/src/main/java/ru/bclib/blocks/BaseUnderwaterWallPlantBlock.java b/src/main/java/ru/bclib/blocks/BaseUnderwaterWallPlantBlock.java index 5ef38d66..2254146b 100644 --- a/src/main/java/ru/bclib/blocks/BaseUnderwaterWallPlantBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseUnderwaterWallPlantBlock.java @@ -48,6 +48,7 @@ public abstract class BaseUnderwaterWallPlantBlock extends BaseWallPlantBlock im } @Override + @SuppressWarnings("deprecation") public FluidState getFluidState(BlockState state) { return Fluids.WATER.getSource(false); } diff --git a/src/main/java/ru/bclib/blocks/BaseVineBlock.java b/src/main/java/ru/bclib/blocks/BaseVineBlock.java index 46da7f0b..108dc183 100644 --- a/src/main/java/ru/bclib/blocks/BaseVineBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseVineBlock.java @@ -33,10 +33,11 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; import ru.bclib.blocks.BlockProperties.TripleShape; -import ru.bclib.client.render.ERenderLayer; +import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.interfaces.IRenderTyped; import ru.bclib.util.BlocksHelper; +@SuppressWarnings("deprecation") public class BaseVineBlock extends BaseBlockNotFull implements IRenderTyped, BonemealableBlock { public static final EnumProperty SHAPE = BlockProperties.TRIPLE_SHAPE; private static final VoxelShape VOXEL_SHAPE = Block.box(2, 0, 2, 14, 16, 14); @@ -106,7 +107,7 @@ public class BaseVineBlock extends BaseBlockNotFull implements IRenderTyped, Bon @Override public List getDrops(BlockState state, LootContext.Builder builder) { ItemStack tool = builder.getParameter(LootContextParams.TOOL); - if (tool != null && tool.getItem().is(FabricToolTags.SHEARS) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { + if (tool != null && FabricToolTags.SHEARS.contains(tool.getItem()) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { return Lists.newArrayList(new ItemStack(this)); } else { @@ -115,8 +116,8 @@ public class BaseVineBlock extends BaseBlockNotFull implements IRenderTyped, Bon } @Override - public ERenderLayer getRenderLayer() { - return ERenderLayer.CUTOUT; + public BCLRenderLayer getRenderLayer() { + return BCLRenderLayer.CUTOUT; } @Override diff --git a/src/main/java/ru/bclib/blocks/BaseWallBlock.java b/src/main/java/ru/bclib/blocks/BaseWallBlock.java index a88c82c8..031f4d31 100644 --- a/src/main/java/ru/bclib/blocks/BaseWallBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseWallBlock.java @@ -7,6 +7,8 @@ import java.util.Optional; import org.jetbrains.annotations.Nullable; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.resources.model.BlockModelRotation; @@ -34,11 +36,13 @@ public class BaseWallBlock extends WallBlock implements BlockModelProvider { } @Override + @SuppressWarnings("deprecation") public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation blockId) { ResourceLocation parentId = Registry.BLOCK.getKey(parent); Optional pattern = PatternsHelper.createJson(BasePatterns.ITEM_WALL, parentId); @@ -46,6 +50,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); String path = blockId.getPath(); @@ -63,6 +68,7 @@ public class BaseWallBlock extends WallBlock implements BlockModelProvider { } @Override + @Environment(EnvType.CLIENT) public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map modelCache) { ResourceLocation postId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath() + "_post"); diff --git a/src/main/java/ru/bclib/blocks/BaseWallPlantBlock.java b/src/main/java/ru/bclib/blocks/BaseWallPlantBlock.java index d833e3fc..9adb0c91 100644 --- a/src/main/java/ru/bclib/blocks/BaseWallPlantBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseWallPlantBlock.java @@ -113,11 +113,13 @@ public abstract class BaseWallPlantBlock extends BasePlantBlock { } @Override + @SuppressWarnings("deprecation") public BlockState rotate(BlockState state, Rotation rotation) { return BlocksHelper.rotateHorizontal(state, rotation, FACING); } @Override + @SuppressWarnings("deprecation") public BlockState mirror(BlockState state, Mirror mirror) { return BlocksHelper.mirrorHorizontal(state, mirror, FACING); } diff --git a/src/main/java/ru/bclib/blocks/BaseWeightedPlateBlock.java b/src/main/java/ru/bclib/blocks/BaseWeightedPlateBlock.java index a1616678..28bbe68e 100644 --- a/src/main/java/ru/bclib/blocks/BaseWeightedPlateBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseWeightedPlateBlock.java @@ -7,6 +7,8 @@ import java.util.Optional; import org.jetbrains.annotations.Nullable; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.resources.model.UnbakedModel; @@ -31,16 +33,19 @@ public class BaseWeightedPlateBlock extends WeightedPressurePlateBlock implement } @Override + @SuppressWarnings("deprecation") public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation resourceLocation) { return getBlockModel(resourceLocation, defaultBlockState()); } @Override + @Environment(EnvType.CLIENT) public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) { ResourceLocation parentId = Registry.BLOCK.getKey(parent); Optional pattern; @@ -53,6 +58,7 @@ public class BaseWeightedPlateBlock extends WeightedPressurePlateBlock implement } @Override + @Environment(EnvType.CLIENT) public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map modelCache) { String state = blockState.getValue(POWER) > 0 ? "_down" : "_up"; ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), diff --git a/src/main/java/ru/bclib/blocks/FeatureSaplingBlock.java b/src/main/java/ru/bclib/blocks/FeatureSaplingBlock.java index 387c3d24..38548c2f 100644 --- a/src/main/java/ru/bclib/blocks/FeatureSaplingBlock.java +++ b/src/main/java/ru/bclib/blocks/FeatureSaplingBlock.java @@ -5,8 +5,11 @@ import java.util.List; import java.util.Optional; import java.util.Random; +import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; import org.jetbrains.annotations.Nullable; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.core.BlockPos; @@ -31,9 +34,10 @@ import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.BlockModelProvider; import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.PatternsHelper; -import ru.bclib.client.render.ERenderLayer; +import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.interfaces.IRenderTyped; +@SuppressWarnings("deprecation") public abstract class FeatureSaplingBlock extends SaplingBlock implements IRenderTyped, BlockModelProvider { private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 14, 12); @@ -83,7 +87,8 @@ public abstract class FeatureSaplingBlock extends SaplingBlock implements IRende @Override public void advanceTree(ServerLevel world, BlockPos pos, BlockState blockState, Random random) { - getFeature().place(world, world.getChunkSource().getGenerator(), random, pos, null); + FeaturePlaceContext context = new FeaturePlaceContext(world, world.getChunkSource().getGenerator(), random, pos, null); + getFeature().place(context); } @Override @@ -100,16 +105,18 @@ public abstract class FeatureSaplingBlock extends SaplingBlock implements IRende } @Override - public ERenderLayer getRenderLayer() { - return ERenderLayer.CUTOUT; + public BCLRenderLayer getRenderLayer() { + return BCLRenderLayer.CUTOUT; } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation resourceLocation) { return ModelsHelper.createBlockItem(resourceLocation); } @Override + @Environment(EnvType.CLIENT) public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) { Optional pattern = PatternsHelper.createJson(BasePatterns.BLOCK_CROSS, resourceLocation); return ModelsHelper.fromPattern(pattern); diff --git a/src/main/java/ru/bclib/blocks/SimpleLeavesBlock.java b/src/main/java/ru/bclib/blocks/SimpleLeavesBlock.java index 4de8acf2..ac46338c 100644 --- a/src/main/java/ru/bclib/blocks/SimpleLeavesBlock.java +++ b/src/main/java/ru/bclib/blocks/SimpleLeavesBlock.java @@ -4,14 +4,14 @@ import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.MaterialColor; -import ru.bclib.client.render.ERenderLayer; +import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.interfaces.IRenderTyped; public class SimpleLeavesBlock extends BaseBlockNotFull implements IRenderTyped { public SimpleLeavesBlock(MaterialColor color) { super(FabricBlockSettings.of(Material.LEAVES) .strength(0.2F) - .materialColor(color) + .mapColor(color) .sound(SoundType.GRASS) .noOcclusion() .isValidSpawn((state, world, pos, type) -> false) @@ -22,7 +22,7 @@ public class SimpleLeavesBlock extends BaseBlockNotFull implements IRenderTyped public SimpleLeavesBlock(MaterialColor color, int light) { super(FabricBlockSettings.of(Material.LEAVES) .luminance(light) - .materialColor(color) + .mapColor(color) .strength(0.2F) .sound(SoundType.GRASS) .noOcclusion() @@ -32,7 +32,7 @@ public class SimpleLeavesBlock extends BaseBlockNotFull implements IRenderTyped } @Override - public ERenderLayer getRenderLayer() { - return ERenderLayer.CUTOUT; + public BCLRenderLayer getRenderLayer() { + return BCLRenderLayer.CUTOUT; } } \ No newline at end of file diff --git a/src/main/java/ru/bclib/blocks/StalactiteBlock.java b/src/main/java/ru/bclib/blocks/StalactiteBlock.java index a77c3832..50401565 100644 --- a/src/main/java/ru/bclib/blocks/StalactiteBlock.java +++ b/src/main/java/ru/bclib/blocks/StalactiteBlock.java @@ -5,6 +5,8 @@ import java.util.Optional; import org.jetbrains.annotations.Nullable; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.resources.model.BlockModelRotation; @@ -38,9 +40,10 @@ import net.minecraft.world.phys.shapes.VoxelShape; import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.PatternsHelper; -import ru.bclib.client.render.ERenderLayer; +import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.interfaces.IRenderTyped; +@SuppressWarnings("deprecation") public class StalactiteBlock extends BaseBlockNotFull implements SimpleWaterloggedBlock, LiquidBlockContainer, IRenderTyped { public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; public static final BooleanProperty IS_FLOOR = BlockProperties.IS_FLOOR; @@ -200,12 +203,14 @@ public class StalactiteBlock extends BaseBlockNotFull implements SimpleWaterlogg } @Override + @Environment(EnvType.CLIENT) public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) { Optional pattern = PatternsHelper.createJson(BasePatterns.BLOCK_CROSS_SHADED, resourceLocation); return ModelsHelper.fromPattern(pattern); } @Override + @Environment(EnvType.CLIENT) public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map modelCache) { BlockModelRotation rotation = blockState.getValue(IS_FLOOR) ? BlockModelRotation.X0_Y0 : BlockModelRotation.X180_Y0; ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), @@ -230,8 +235,8 @@ public class StalactiteBlock extends BaseBlockNotFull implements SimpleWaterlogg } @Override - public ERenderLayer getRenderLayer() { - return ERenderLayer.CUTOUT; + public BCLRenderLayer getRenderLayer() { + return BCLRenderLayer.CUTOUT; } static { diff --git a/src/main/java/ru/bclib/blocks/StripableBarkBlock.java b/src/main/java/ru/bclib/blocks/StripableBarkBlock.java index c86c792a..d0195177 100644 --- a/src/main/java/ru/bclib/blocks/StripableBarkBlock.java +++ b/src/main/java/ru/bclib/blocks/StripableBarkBlock.java @@ -20,13 +20,14 @@ public class StripableBarkBlock extends BaseBarkBlock { private final Block striped; public StripableBarkBlock(MaterialColor color, Block striped) { - super(FabricBlockSettings.copyOf(striped).materialColor(color)); + super(FabricBlockSettings.copyOf(striped).mapColor(color)); this.striped = striped; } @Override + @SuppressWarnings("deprecation") public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { - if (player.getMainHandItem().getItem().is(FabricToolTags.AXES)) { + if (FabricToolTags.AXES.contains(player.getMainHandItem().getItem())) { world.playSound(player, pos, SoundEvents.AXE_STRIP, SoundSource.BLOCKS, 1.0F, 1.0F); if (!world.isClientSide) { world.setBlock(pos, striped.defaultBlockState().setValue(RotatedPillarBlock.AXIS, state.getValue(RotatedPillarBlock.AXIS)), 11); diff --git a/src/main/java/ru/bclib/blocks/TripleTerrainBlock.java b/src/main/java/ru/bclib/blocks/TripleTerrainBlock.java index 07956146..252ec776 100644 --- a/src/main/java/ru/bclib/blocks/TripleTerrainBlock.java +++ b/src/main/java/ru/bclib/blocks/TripleTerrainBlock.java @@ -10,6 +10,8 @@ import org.jetbrains.annotations.Nullable; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.MultiVariant; import net.minecraft.client.renderer.block.model.Variant; @@ -109,11 +111,13 @@ public class TripleTerrainBlock extends BaseTerrainBlock { } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation blockId) { return getBlockModel(blockId, defaultBlockState()); } @Override + @Environment(EnvType.CLIENT) public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { String path = blockId.getPath(); Optional pattern; @@ -131,6 +135,7 @@ public class TripleTerrainBlock extends BaseTerrainBlock { } @Override + @Environment(EnvType.CLIENT) public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map modelCache) { boolean isMiddle = isMiddle(blockState); String middle = isMiddle ? "_middle" : ""; diff --git a/src/main/java/ru/bclib/blocks/UnderwaterPlantBlock.java b/src/main/java/ru/bclib/blocks/UnderwaterPlantBlock.java index 113c481e..4d168107 100644 --- a/src/main/java/ru/bclib/blocks/UnderwaterPlantBlock.java +++ b/src/main/java/ru/bclib/blocks/UnderwaterPlantBlock.java @@ -34,9 +34,10 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; -import ru.bclib.client.render.ERenderLayer; +import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.interfaces.IRenderTyped; +@SuppressWarnings("deprecation") public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements IRenderTyped, BonemealableBlock, LiquidBlockContainer { private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 14, 12); @@ -95,7 +96,7 @@ public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements I @Override public List getDrops(BlockState state, LootContext.Builder builder) { ItemStack tool = builder.getParameter(LootContextParams.TOOL); - if (tool != null && tool.getItem().is(FabricToolTags.SHEARS) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { + if (tool != null && FabricToolTags.SHEARS.contains(tool.getItem()) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { return Lists.newArrayList(new ItemStack(this)); } else { @@ -104,8 +105,8 @@ public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements I } @Override - public ERenderLayer getRenderLayer() { - return ERenderLayer.CUTOUT; + public BCLRenderLayer getRenderLayer() { + return BCLRenderLayer.CUTOUT; } @Override diff --git a/src/main/java/ru/bclib/blocks/UnderwaterPlantWithAgeBlock.java b/src/main/java/ru/bclib/blocks/UnderwaterPlantWithAgeBlock.java index fb7870b8..8b6499a2 100644 --- a/src/main/java/ru/bclib/blocks/UnderwaterPlantWithAgeBlock.java +++ b/src/main/java/ru/bclib/blocks/UnderwaterPlantWithAgeBlock.java @@ -47,6 +47,7 @@ public abstract class UnderwaterPlantWithAgeBlock extends UnderwaterPlantBlock { } @Override + @SuppressWarnings("deprecation") public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) { super.tick(state, world, pos, random); if (isBonemealSuccess(world, random, pos, state)) { diff --git a/src/main/java/ru/bclib/blocks/UpDownPlantBlock.java b/src/main/java/ru/bclib/blocks/UpDownPlantBlock.java index 95a7d2f7..0773a45b 100644 --- a/src/main/java/ru/bclib/blocks/UpDownPlantBlock.java +++ b/src/main/java/ru/bclib/blocks/UpDownPlantBlock.java @@ -26,9 +26,10 @@ import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; -import ru.bclib.client.render.ERenderLayer; +import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.interfaces.IRenderTyped; +@SuppressWarnings("deprecation") public abstract class UpDownPlantBlock extends BaseBlockNotFull implements IRenderTyped { private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 16, 12); @@ -71,7 +72,7 @@ public abstract class UpDownPlantBlock extends BaseBlockNotFull implements IRend @Override public List getDrops(BlockState state, LootContext.Builder builder) { ItemStack tool = builder.getParameter(LootContextParams.TOOL); - if (tool != null && tool.getItem().is(FabricToolTags.SHEARS) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { + if (tool != null && FabricToolTags.SHEARS.contains(tool.getItem()) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { return Lists.newArrayList(new ItemStack(this)); } else { @@ -80,8 +81,8 @@ public abstract class UpDownPlantBlock extends BaseBlockNotFull implements IRend } @Override - public ERenderLayer getRenderLayer() { - return ERenderLayer.CUTOUT; + public BCLRenderLayer getRenderLayer() { + return BCLRenderLayer.CUTOUT; } @Override diff --git a/src/main/java/ru/bclib/client/BCLibClient.java b/src/main/java/ru/bclib/client/BCLibClient.java index ada4ab03..5b6249d6 100644 --- a/src/main/java/ru/bclib/client/BCLibClient.java +++ b/src/main/java/ru/bclib/client/BCLibClient.java @@ -1,11 +1,33 @@ package ru.bclib.client; import net.fabricmc.api.ClientModInitializer; +import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.core.Registry; +import ru.bclib.api.ModIntegrationAPI; +import ru.bclib.client.render.BCLRenderLayer; +import ru.bclib.interfaces.IRenderTyped; import ru.bclib.registry.BaseBlockEntityRenders; public class BCLibClient implements ClientModInitializer { @Override public void onInitializeClient() { + ModIntegrationAPI.registerAll(); BaseBlockEntityRenders.register(); + registerRenderLayers(); + } + + private void registerRenderLayers() { + RenderType cutout = RenderType.cutout(); + RenderType translucent = RenderType.translucent(); + Registry.BLOCK.forEach(block -> { + if (block instanceof IRenderTyped) { + BCLRenderLayer layer = ((IRenderTyped) block).getRenderLayer(); + if (layer == BCLRenderLayer.CUTOUT) + BlockRenderLayerMap.INSTANCE.putBlock(block, cutout); + else if (layer == BCLRenderLayer.TRANSLUCENT) + BlockRenderLayerMap.INSTANCE.putBlock(block, translucent); + } + }); } } diff --git a/src/main/java/ru/bclib/client/gui/BlockSignEditScreen.java b/src/main/java/ru/bclib/client/gui/BlockSignEditScreen.java index 25be05c9..89954126 100644 --- a/src/main/java/ru/bclib/client/gui/BlockSignEditScreen.java +++ b/src/main/java/ru/bclib/client/gui/BlockSignEditScreen.java @@ -1,7 +1,5 @@ package ru.bclib.client.gui; -import java.util.Arrays; - import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.Lighting; import com.mojang.blaze3d.systems.RenderSystem; @@ -11,8 +9,8 @@ import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.Tesselator; import com.mojang.blaze3d.vertex.VertexConsumer; +import com.mojang.blaze3d.vertex.VertexFormat; import com.mojang.math.Matrix4f; - import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.Util; @@ -20,22 +18,25 @@ import net.minecraft.client.gui.GuiComponent; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.font.TextFieldHelper; import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.model.geom.ModelLayers; import net.minecraft.client.multiplayer.ClientPacketListener; import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.blockentity.SignRenderer.SignModel; +import net.minecraft.client.renderer.blockentity.SignRenderer; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.network.protocol.game.ServerboundSignUpdatePacket; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.WoodType; import ru.bclib.blockentities.BaseSignBlockEntity; import ru.bclib.blocks.BaseSignBlock; import ru.bclib.client.render.BaseSignBlockEntityRenderer; +import java.util.Arrays; + @Environment(EnvType.CLIENT) public class BlockSignEditScreen extends Screen { - private final SignModel model = new SignModel(); private final BaseSignBlockEntity sign; private int ticksSinceOpened; private int currentRow; @@ -43,6 +44,7 @@ public class BlockSignEditScreen extends Screen { private final String[] text = (String[]) Util.make(new String[4], (strings) -> { Arrays.fill(strings, ""); }); + private SignRenderer.SignModel model; public BlockSignEditScreen(BaseSignBlockEntity sign) { super(new TranslatableComponent("sign.edit")); @@ -50,8 +52,11 @@ public class BlockSignEditScreen extends Screen { } protected void init() { + //set up a default model + model = new SignRenderer.SignModel(this.minecraft.getEntityModels().bakeLayer(ModelLayers.createSignModelName(WoodType.OAK))); + minecraft.keyboardHandler.setSendRepeatsToGui(true); - this.addButton(new Button(this.width / 2 - 100, this.height / 4 + 120, 200, 20, CommonComponents.GUI_DONE, + this.addRenderableWidget(new Button(this.width / 2 - 100, this.height / 4 + 120, 200, 20, CommonComponents.GUI_DONE, (buttonWidget) -> { this.finishEditing(); })); @@ -80,7 +85,7 @@ public class BlockSignEditScreen extends Screen { public void tick() { ++this.ticksSinceOpened; - if (!this.sign.getType().isValid(this.sign.getBlockState().getBlock())) { + if (!this.sign.getType().isValid(this.sign.getBlockState())) { this.finishEditing(); } } @@ -135,7 +140,7 @@ public class BlockSignEditScreen extends Screen { matrices.scale(0.6666667F, -0.6666667F, -0.6666667F); MultiBufferSource.BufferSource immediate = minecraft.renderBuffers().bufferSource(); VertexConsumer vertexConsumer = BaseSignBlockEntityRenderer.getConsumer(immediate, blockState.getBlock()); - model.sign.render(matrices, vertexConsumer, 15728880, OverlayTexture.NO_OVERLAY); + model.root.getChild("sign").render(matrices, vertexConsumer, 15728880, OverlayTexture.NO_OVERLAY); if (bl) { model.stick.render(matrices, vertexConsumer, 15728880, OverlayTexture.NO_OVERLAY); @@ -206,7 +211,7 @@ public class BlockSignEditScreen extends Screen { RenderSystem.disableTexture(); RenderSystem.enableColorLogicOp(); RenderSystem.logicOp(GlStateManager.LogicOp.OR_REVERSE); - bufferBuilder.begin(7, DefaultVertexFormat.POSITION_COLOR); + bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); float var32 = (float) x; bufferBuilder.vertex(matrix4f, var32, (float) (l + 9), 0.0F).color(0, 0, 255, 255).endVertex(); var32 = (float) y; diff --git a/src/main/java/ru/bclib/client/models/BaseChestBlockModel.java b/src/main/java/ru/bclib/client/models/BaseChestBlockModel.java new file mode 100644 index 00000000..ec5bf62d --- /dev/null +++ b/src/main/java/ru/bclib/client/models/BaseChestBlockModel.java @@ -0,0 +1,91 @@ +package ru.bclib.client.models; + +import net.minecraft.client.model.geom.ModelPart; +import net.minecraft.client.model.geom.PartPose; +import net.minecraft.client.model.geom.builders.*; + +public class BaseChestBlockModel { + public final ModelPart partA; + public final ModelPart partC; + public final ModelPart partB; + public final ModelPart partRightA; + public final ModelPart partRightC; + public final ModelPart partRightB; + public final ModelPart partLeftA; + public final ModelPart partLeftC; + public final ModelPart partLeftB; + + public static LayerDefinition getTexturedModelData() { + MeshDefinition modelData = new MeshDefinition(); + PartDefinition modelPartData = modelData.getRoot(); + CubeDeformation deformation_partC = new CubeDeformation(0.0f); + modelPartData.addOrReplaceChild("partC", CubeListBuilder.create() + .texOffs(0, 19) + .addBox(1.0f, 0.0f, 1.0f, 14.0f, 9.0f, 14.0f, deformation_partC), + PartPose.ZERO); + + CubeDeformation deformation_partA = new CubeDeformation(0.0f); + modelPartData.addOrReplaceChild("partA", CubeListBuilder.create() + .texOffs(0, 0) + .addBox(1.0f, 0.0f, 0.0f, 14.0f, 5.0f, 14.0f, deformation_partA), + PartPose.offset(0.0f, 9.0f, 1.0f)); + + CubeDeformation deformation_partB = new CubeDeformation(0.0f); + modelPartData.addOrReplaceChild("partB", CubeListBuilder.create() + .texOffs(0, 0) + .addBox(7.0f, -1.0f, 15.0f, 2.0f, 4.0f, 1.0f, deformation_partB), + PartPose.offset(0.0f, 8.0f, 0.0f)); + + CubeDeformation deformation_partRightC = new CubeDeformation(0.0f); + modelPartData.addOrReplaceChild("partRightC", CubeListBuilder.create() + .texOffs(0, 19) + .addBox(1.0f, 0.0f, 1.0f, 15.0f, 9.0f, 14.0f, deformation_partRightC), + PartPose.ZERO); + + CubeDeformation deformation_partRightA = new CubeDeformation(0.0f); + modelPartData.addOrReplaceChild("partRightA", CubeListBuilder.create() + .texOffs(0, 0) + .addBox(1.0f, 0.0f, 0.0f, 15.0f, 5.0f, 14.0f, deformation_partRightA), + PartPose.offset(0.0f, 9.0f, 1.0f)); + + CubeDeformation deformation_partRightB = new CubeDeformation(0.0f); + PartDefinition partRightB = modelPartData.addOrReplaceChild("partRightB", CubeListBuilder.create() + .texOffs(0, 0) + .addBox(15.0f, -1.0f, 15.0f, 1.0f, 4.0f, 1.0f, deformation_partRightB), + PartPose.offset(0.0f, 8.0f, 0.0f)); + + CubeDeformation deformation_partLeftC = new CubeDeformation(0.0f); + modelPartData.addOrReplaceChild("partLeftC", CubeListBuilder.create() + .texOffs(0, 19) + .addBox(0.0f, 0.0f, 1.0f, 15.0f, 9.0f, 14.0f, deformation_partLeftC), + PartPose.ZERO); + + CubeDeformation deformation_partLeftA = new CubeDeformation(0.0f); + modelPartData.addOrReplaceChild("partLeftA", CubeListBuilder.create() + .texOffs(0, 0) + .addBox(0.0f, 0.0f, 0.0f, 15.0f, 5.0f, 14.0f, deformation_partLeftA), + PartPose.offset(0.0f, 9.0f, 1.0f)); + + CubeDeformation deformation_partLeftB = new CubeDeformation(0.0f); + modelPartData.addOrReplaceChild("partLeftB", CubeListBuilder.create() + .texOffs(0, 0) + .addBox(0.0f, -1.0f, 15.0f, 1.0f, 4.0f, 1.0f, deformation_partLeftB), + PartPose.offset(0.0f, 8.0f, 0.0f)); + + return LayerDefinition.create(modelData, 64, 64); + } + + public BaseChestBlockModel(ModelPart modelPart) { + super(); + + partC = modelPart.getChild("partC"); + partA = modelPart.getChild("partA"); + partB = modelPart.getChild("partB"); + partRightC = modelPart.getChild("partRightC"); + partRightA = modelPart.getChild("partRightA"); + partRightB = modelPart.getChild("partRightB"); + partLeftC = modelPart.getChild("partLeftC"); + partLeftA = modelPart.getChild("partLeftA"); + partLeftB = modelPart.getChild("partLeftB"); + } +} diff --git a/src/main/java/ru/bclib/client/models/BlockModelProvider.java b/src/main/java/ru/bclib/client/models/BlockModelProvider.java index f4bb00b1..e139a923 100644 --- a/src/main/java/ru/bclib/client/models/BlockModelProvider.java +++ b/src/main/java/ru/bclib/client/models/BlockModelProvider.java @@ -7,6 +7,8 @@ import java.util.Optional; import org.jetbrains.annotations.Nullable; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.resources.ResourceLocation; @@ -14,17 +16,20 @@ import net.minecraft.world.level.block.state.BlockState; import ru.bclib.BCLib; public interface BlockModelProvider extends ItemModelProvider { + @Environment(EnvType.CLIENT) default @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) { Optional pattern = PatternsHelper.createBlockSimple(resourceLocation); return ModelsHelper.fromPattern(pattern); } + @Environment(EnvType.CLIENT) default UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map modelCache) { ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath()); registerBlockModel(stateId, modelId, blockState, modelCache); return ModelsHelper.createBlockSimple(modelId); } + @Environment(EnvType.CLIENT) default void registerBlockModel(ResourceLocation stateId, ResourceLocation modelId, BlockState blockState, Map modelCache) { if (!modelCache.containsKey(modelId)) { BlockModel model = getBlockModel(stateId, blockState); diff --git a/src/main/java/ru/bclib/client/models/ItemModelProvider.java b/src/main/java/ru/bclib/client/models/ItemModelProvider.java index 7374bd80..50930e6c 100644 --- a/src/main/java/ru/bclib/client/models/ItemModelProvider.java +++ b/src/main/java/ru/bclib/client/models/ItemModelProvider.java @@ -1,9 +1,12 @@ package ru.bclib.client.models; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.resources.ResourceLocation; public interface ItemModelProvider { + @Environment(EnvType.CLIENT) default BlockModel getItemModel(ResourceLocation resourceLocation) { return ModelsHelper.createItemModel(resourceLocation); } diff --git a/src/main/java/ru/bclib/client/models/ModelsHelper.java b/src/main/java/ru/bclib/client/models/ModelsHelper.java index 637b8a3f..f7bdec4d 100644 --- a/src/main/java/ru/bclib/client/models/ModelsHelper.java +++ b/src/main/java/ru/bclib/client/models/ModelsHelper.java @@ -67,7 +67,8 @@ public class ModelsHelper { BlockModelRotation rotation = BlockModelRotation.X0_Y0; switch (axis) { case X: rotation = BlockModelRotation.X90_Y90; break; - case Z: default: rotation = BlockModelRotation.X90_Y0; break; + case Z: rotation = BlockModelRotation.X90_Y0; break; + default: break; } return createMultiVariant(resourceLocation, rotation.getRotation(), false); } diff --git a/src/main/java/ru/bclib/client/render/ERenderLayer.java b/src/main/java/ru/bclib/client/render/BCLRenderLayer.java similarity index 66% rename from src/main/java/ru/bclib/client/render/ERenderLayer.java rename to src/main/java/ru/bclib/client/render/BCLRenderLayer.java index cf0d637d..3846d7d6 100644 --- a/src/main/java/ru/bclib/client/render/ERenderLayer.java +++ b/src/main/java/ru/bclib/client/render/BCLRenderLayer.java @@ -1,6 +1,6 @@ package ru.bclib.client.render; -public enum ERenderLayer { +public enum BCLRenderLayer { CUTOUT, TRANSLUCENT; } diff --git a/src/main/java/ru/bclib/client/render/BaseChestBlockEntityRenderer.java b/src/main/java/ru/bclib/client/render/BaseChestBlockEntityRenderer.java index 3626e902..96d59f04 100644 --- a/src/main/java/ru/bclib/client/render/BaseChestBlockEntityRenderer.java +++ b/src/main/java/ru/bclib/client/render/BaseChestBlockEntityRenderer.java @@ -1,12 +1,9 @@ package ru.bclib.client.render; -import java.util.HashMap; - import com.google.common.collect.Maps; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Vector3f; - import it.unimi.dsi.fastutil.floats.Float2FloatFunction; import it.unimi.dsi.fastutil.ints.Int2IntFunction; import net.fabricmc.api.EnvType; @@ -14,27 +11,25 @@ import net.fabricmc.api.Environment; import net.minecraft.client.model.geom.ModelPart; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; 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.AbstractChestBlock; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.ChestBlock; -import net.minecraft.world.level.block.DoubleBlockCombiner; +import net.minecraft.world.level.block.*; import net.minecraft.world.level.block.DoubleBlockCombiner.NeighborCombineResult; import net.minecraft.world.level.block.entity.ChestBlockEntity; -import net.minecraft.world.level.block.entity.LidBlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.ChestType; import ru.bclib.blockentities.BaseChestBlockEntity; +import ru.bclib.client.models.BaseChestBlockModel; + +import java.util.HashMap; @Environment(EnvType.CLIENT) -public class BaseChestBlockEntityRenderer extends BlockEntityRenderer { +public class BaseChestBlockEntityRenderer implements BlockEntityRenderer { private static final HashMap LAYERS = Maps.newHashMap(); private static final RenderType[] defaultLayer; @@ -42,53 +37,17 @@ public class BaseChestBlockEntityRenderer extends BlockEntityRenderer abstractChestBlock = (AbstractChestBlock) block; @@ -107,7 +66,7 @@ public class BaseChestBlockEntityRenderer extends BlockEntityRenderer layers[ID_LEFT]; + case RIGHT -> layers[ID_RIGHT]; + default -> layers[ID_NORMAL]; + }; } public static VertexConsumer getConsumer(MultiBufferSource provider, Block block, ChestType chestType) { diff --git a/src/main/java/ru/bclib/client/render/BaseSignBlockEntityRenderer.java b/src/main/java/ru/bclib/client/render/BaseSignBlockEntityRenderer.java index 6ef7e419..6d26f1d6 100644 --- a/src/main/java/ru/bclib/client/render/BaseSignBlockEntityRenderer.java +++ b/src/main/java/ru/bclib/client/render/BaseSignBlockEntityRenderer.java @@ -1,68 +1,84 @@ package ru.bclib.client.render; -import java.util.HashMap; -import java.util.List; - import com.google.common.collect.Maps; import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Vector3f; - +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; +import net.minecraft.client.model.geom.ModelLayers; +import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.Sheets; -import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; 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.renderer.blockentity.SignRenderer.SignModel; 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; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.item.DyeColor; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.SignBlock; import net.minecraft.world.level.block.StandingSignBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.WoodType; +import net.minecraft.world.phys.Vec3; import ru.bclib.blockentities.BaseSignBlockEntity; import ru.bclib.blocks.BaseSignBlock; -public class BaseSignBlockEntityRenderer extends BlockEntityRenderer { +import java.util.HashMap; +import java.util.List; + +public class BaseSignBlockEntityRenderer implements BlockEntityRenderer { private static final HashMap LAYERS = Maps.newHashMap(); private static final RenderType defaultLayer; - private final SignModel model = new SignRenderer.SignModel(); + private final Font font; + private final SignRenderer.SignModel model; - public BaseSignBlockEntityRenderer(BlockEntityRenderDispatcher dispatcher) { - super(dispatcher); + + private static final int OUTLINE_RENDER_DISTANCE = Mth.square(16); + + public BaseSignBlockEntityRenderer(BlockEntityRendererProvider.Context ctx) { + super(); + this.font = ctx.getFont(); + + //set up a default model + model = new SignRenderer.SignModel(ctx.bakeLayer(ModelLayers.createSignModelName(WoodType.OAK))); } public void render(BaseSignBlockEntity signBlockEntity, float tickDelta, PoseStack matrixStack, MultiBufferSource provider, int light, int overlay) { BlockState state = signBlockEntity.getBlockState(); + matrixStack.pushPose(); + matrixStack.translate(0.5D, 0.5D, 0.5D); float angle = -((float) (state.getValue(StandingSignBlock.ROTATION) * 360) / 16.0F); BlockState blockState = signBlockEntity.getBlockState(); if (blockState.getValue(BaseSignBlock.FLOOR)) { matrixStack.mulPose(Vector3f.YP.rotationDegrees(angle)); - this.model.stick.visible = true; + model.stick.visible = true; } else { matrixStack.mulPose(Vector3f.YP.rotationDegrees(angle + 180)); matrixStack.translate(0.0D, -0.3125D, -0.4375D); - this.model.stick.visible = false; + model.stick.visible = false; } matrixStack.pushPose(); matrixStack.scale(0.6666667F, -0.6666667F, -0.6666667F); VertexConsumer vertexConsumer = getConsumer(provider, state.getBlock()); - model.sign.render(matrixStack, vertexConsumer, light, overlay); - model.stick.render(matrixStack, vertexConsumer, light, overlay); + + model.root.render(matrixStack, vertexConsumer, light, overlay); + //model.stick.render(matrixStack, vertexConsumer, light, overlay); matrixStack.popPose(); - Font textRenderer = renderer.getFont(); + //Font textRenderer = renderer.getFont(); matrixStack.translate(0.0D, 0.3333333432674408D, 0.046666666865348816D); matrixStack.scale(0.010416667F, -0.010416667F, 0.010416667F); int m = signBlockEntity.getColor().getTextColor(); @@ -71,21 +87,59 @@ public class BaseSignBlockEntityRenderer extends BlockEntityRenderer { + List list = this.font.split(component, 90); + return list.isEmpty() ? FormattedCharSequence.EMPTY : (FormattedCharSequence) list.get(0); + }); + int drawColor; + boolean drawOutlined; + int drawLight; + if (signBlockEntity.hasGlowingText()) { + drawColor = signBlockEntity.getColor().getTextColor(); + drawOutlined = isOutlineVisible(signBlockEntity, drawColor); + drawLight = 15728880; + } else { + drawColor = m; + drawOutlined = false; + drawLight = light; + } + for (int s = 0; s < 4; ++s) { - FormattedCharSequence orderedText = signBlockEntity.getRenderMessage(s, (text) -> { - List list = textRenderer.split(text, 90); - return list.isEmpty() ? FormattedCharSequence.EMPTY : list.get(0); - }); - if (orderedText != null) { - float t = (float) (-textRenderer.width(orderedText) / 2); - textRenderer.drawInBatch(orderedText, t, (float) (s * 10 - 20), q, false, matrixStack.last().pose(), provider, false, 0, light); + FormattedCharSequence formattedCharSequence = formattedCharSequences[s]; + float t = (float) (-this.font.width(formattedCharSequence) / 2); + if (drawOutlined) { + this.font.drawInBatch8xOutline(formattedCharSequence, t, (float) (s * 10 - 20), drawColor, m, + matrixStack.last().pose(), provider, drawLight); + } else { + this.font.drawInBatch((FormattedCharSequence) formattedCharSequence, t, (float) (s * 10 - 20), drawColor, false, + matrixStack.last().pose(), provider, false, 0, drawLight); } } + matrixStack.popPose(); } - public static Material getModelTexture(Block block) { + + + private static boolean isOutlineVisible(BaseSignBlockEntity signBlockEntity, int i) { + if (i == DyeColor.BLACK.getTextColor()) { + return true; + } else { + Minecraft minecraft = Minecraft.getInstance(); + LocalPlayer localPlayer = minecraft.player; + if (localPlayer != null && minecraft.options.getCameraType().isFirstPerson() && localPlayer.isScoping()) { + return true; + } else { + Entity entity = minecraft.getCameraEntity(); + return entity != null && entity.distanceToSqr( + Vec3.atCenterOf(signBlockEntity.getBlockPos())) < (double) OUTLINE_RENDER_DISTANCE; + } + } + } + + public static WoodType getSignType(Block block) { WoodType signType2; if (block instanceof SignBlock) { signType2 = ((SignBlock) block).type(); @@ -93,7 +147,11 @@ public class BaseSignBlockEntityRenderer extends BlockEntityRenderer getKey(String name) { + return ResourceKey.create(Registry.BIOME_REGISTRY, getID(name)); + } + + public boolean modIsInstalled() { + return FabricLoader.getInstance().isModLoaded(modID); + } + + public BCLFeature getFeature(String featureID, String configuredFeatureID, GenerationStep.Decoration featureStep) { + Feature feature = Registry.FEATURE.get(getID(featureID)); + ConfiguredFeature featureConfigured = BuiltinRegistries.CONFIGURED_FEATURE.get(getID(configuredFeatureID)); + return new BCLFeature(feature, featureConfigured, featureStep); + } + + public BCLFeature getFeature(String name, GenerationStep.Decoration featureStep) { + return getFeature(name, name, featureStep); + } + + public ConfiguredFeature getConfiguredFeature(String name) { + return BuiltinRegistries.CONFIGURED_FEATURE.get(getID(name)); + } + + public Biome getBiome(String name) { + return BuiltinRegistries.BIOME.get(getID(name)); + } + + public Class getClass(String path) { + Class cl = null; + try { + cl = Class.forName(path); + } + catch (ClassNotFoundException e) { + BCLib.LOGGER.error(e.getMessage()); + if (BCLib.isDevEnvironment()) { + e.printStackTrace(); + } + } + return cl; + } + + @SuppressWarnings("unchecked") + public T getStaticFieldValue(Class cl, String name) { + if (cl != null) { + try { + Field field = cl.getDeclaredField(name); + if (field != null) { + return (T) field.get(null); + } + } + catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { + e.printStackTrace(); + } + } + return null; + } + + public Object getFieldValue(Class cl, String name, Object classInstance) { + if (cl != null) { + try { + Field field = cl.getDeclaredField(name); + if (field != null) { + return field.get(classInstance); + } + } + catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { + e.printStackTrace(); + } + } + return null; + } + + public Method getMethod(Class cl, String functionName, Class... args) { + if (cl != null) { + try { + return cl.getMethod(functionName, args); + } + catch (NoSuchMethodException | SecurityException e) { + BCLib.LOGGER.error(e.getMessage()); + if (BCLib.isDevEnvironment()) { + e.printStackTrace(); + } + } + } + return null; + } + + public Object executeMethod(Object instance, Method method, Object... args) { + if (method != null) { + try { + return method.invoke(instance, args); + } + catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + BCLib.LOGGER.error(e.getMessage()); + if (BCLib.isDevEnvironment()) { + e.printStackTrace(); + } + } + } + return null; + } + + public Object getAndExecuteStatic(Class cl, String functionName, Object... args) { + if (cl != null) { + Class[] classes = new Class[args.length]; + for (int i = 0; i < args.length; i++) { + classes[i] = args[i].getClass(); + } + Method method = getMethod(cl, functionName, classes); + return executeMethod(null, method, args); + } + return null; + } + + @SuppressWarnings("unchecked") + public T getAndExecuteRuntime(Class cl, Object instance, String functionName, Object... args) { + if (instance != null) { + Class[] classes = new Class[args.length]; + for (int i = 0; i < args.length; i++) { + classes[i] = args[i].getClass(); + } + Method method = getMethod(cl, functionName, classes); + return (T) executeMethod(instance, method, args); + } + return null; + } + + public Object newInstance(Class cl, Object... args) { + if (cl != null) { + for (Constructor constructor: cl.getConstructors()) { + if (constructor.getParameterCount() == args.length) { + try { + return constructor.newInstance(args); + } + catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + BCLib.LOGGER.error(e.getMessage()); + if (BCLib.isDevEnvironment()) { + e.printStackTrace(); + } + } + } + } + } + return null; + } + + public Tag.Named getItemTag(String name) { + ResourceLocation id = getID(name); + Tag tag = ItemTags.getAllTags().getTag(id); + return tag == null ? (Named) TagRegistry.item(id) : (Named) tag; + } + + public Tag.Named getBlockTag(String name) { + ResourceLocation id = getID(name); + Tag tag = BlockTags.getAllTags().getTag(id); + return tag == null ? (Named) TagRegistry.block(id) : (Named) tag; + } +} diff --git a/src/main/java/ru/bclib/interfaces/IRenderTyped.java b/src/main/java/ru/bclib/interfaces/IRenderTyped.java index c82a009b..445f9e6b 100644 --- a/src/main/java/ru/bclib/interfaces/IRenderTyped.java +++ b/src/main/java/ru/bclib/interfaces/IRenderTyped.java @@ -1,7 +1,7 @@ package ru.bclib.interfaces; -import ru.bclib.client.render.ERenderLayer; +import ru.bclib.client.render.BCLRenderLayer; public interface IRenderTyped { - ERenderLayer getRenderLayer(); + BCLRenderLayer getRenderLayer(); } diff --git a/src/main/java/ru/bclib/items/BaseAnvilItem.java b/src/main/java/ru/bclib/items/BaseAnvilItem.java index aa9b6fb9..c1b36914 100644 --- a/src/main/java/ru/bclib/items/BaseAnvilItem.java +++ b/src/main/java/ru/bclib/items/BaseAnvilItem.java @@ -1,8 +1,13 @@ package ru.bclib.items; +import java.util.List; + +import org.jetbrains.annotations.Nullable; + import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.renderer.block.model.BlockModel; +import net.minecraft.core.Registry; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.resources.ResourceLocation; @@ -13,12 +18,9 @@ import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; -import org.jetbrains.annotations.Nullable; import ru.bclib.blocks.BaseAnvilBlock; import ru.bclib.client.models.ItemModelProvider; -import java.util.List; - public class BaseAnvilItem extends BlockItem implements ItemModelProvider { public final static String DESTRUCTION = "destruction"; @@ -28,12 +30,13 @@ public class BaseAnvilItem extends BlockItem implements ItemModelProvider { } @Override - @SuppressWarnings("ConstantConditions") protected BlockState getPlacementState(BlockPlaceContext blockPlaceContext) { BlockState blockState = super.getPlacementState(blockPlaceContext); ItemStack stack = blockPlaceContext.getItemInHand(); int destruction = stack.getOrCreateTag().getInt(DESTRUCTION); - blockState = blockState.setValue(BaseAnvilBlock.DESTRUCTION, destruction); + if (blockState != null) { + blockState = blockState.setValue(BaseAnvilBlock.DESTRUCTION, destruction); + } return blockState; } @@ -48,7 +51,10 @@ public class BaseAnvilItem extends BlockItem implements ItemModelProvider { } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation resourceLocation) { - return ((ItemModelProvider) getBlock()).getItemModel(resourceLocation); + Block anvilBlock = getBlock(); + ResourceLocation blockId = Registry.BLOCK.getKey(anvilBlock); + return ((ItemModelProvider) anvilBlock).getItemModel(blockId); } } diff --git a/src/main/java/ru/bclib/items/BaseBucketItem.java b/src/main/java/ru/bclib/items/BaseBucketItem.java index e33ac83a..fae47053 100644 --- a/src/main/java/ru/bclib/items/BaseBucketItem.java +++ b/src/main/java/ru/bclib/items/BaseBucketItem.java @@ -1,13 +1,14 @@ package ru.bclib.items; import net.fabricmc.fabric.api.item.v1.FabricItemSettings; +import net.minecraft.sounds.SoundEvents; import net.minecraft.world.entity.EntityType; -import net.minecraft.world.item.FishBucketItem; +import net.minecraft.world.item.MobBucketItem; import net.minecraft.world.level.material.Fluids; import ru.bclib.client.models.ItemModelProvider; -public class BaseBucketItem extends FishBucketItem implements ItemModelProvider { +public class BaseBucketItem extends MobBucketItem implements ItemModelProvider { public BaseBucketItem(EntityType type, FabricItemSettings settings) { - super(type, Fluids.WATER, settings.stacksTo(1)); + super(type, Fluids.WATER, SoundEvents.BUCKET_EMPTY_FISH, settings.stacksTo(1)); } } diff --git a/src/main/java/ru/bclib/items/EndDiscItem.java b/src/main/java/ru/bclib/items/BaseDiscItem.java similarity index 56% rename from src/main/java/ru/bclib/items/EndDiscItem.java rename to src/main/java/ru/bclib/items/BaseDiscItem.java index dcae4586..3b6a8e46 100644 --- a/src/main/java/ru/bclib/items/EndDiscItem.java +++ b/src/main/java/ru/bclib/items/BaseDiscItem.java @@ -4,8 +4,8 @@ import net.minecraft.sounds.SoundEvent; import net.minecraft.world.item.RecordItem; import ru.bclib.client.models.ItemModelProvider; -public class EndDiscItem extends RecordItem implements ItemModelProvider { - public EndDiscItem(int comparatorOutput, SoundEvent sound, Properties settings) { +public class BaseDiscItem extends RecordItem implements ItemModelProvider { + public BaseDiscItem(int comparatorOutput, SoundEvent sound, Properties settings) { super(comparatorOutput, sound, settings); } } diff --git a/src/main/java/ru/bclib/items/BaseDrinkItem.java b/src/main/java/ru/bclib/items/BaseDrinkItem.java index 66122ec0..bb2216f2 100644 --- a/src/main/java/ru/bclib/items/BaseDrinkItem.java +++ b/src/main/java/ru/bclib/items/BaseDrinkItem.java @@ -30,22 +30,27 @@ public class BaseDrinkItem extends ModelProviderItem { @Override public InteractionResultHolder use(Level world, Player user, InteractionHand hand) { - return ItemUtils.useDrink(world, user, hand); + return ItemUtils.startUsingInstantly(world, user, hand); } @Override - public ItemStack finishUsingItem(ItemStack stack, Level world, LivingEntity user) { - if (user instanceof ServerPlayer) { - ServerPlayer serverPlayerEntity = (ServerPlayer) user; + public ItemStack finishUsingItem(ItemStack stack, Level level, LivingEntity user) { + if (this.isEdible()) { + int count = stack.getCount(); + user.eat(level, stack); + stack.setCount(count); + } + + if (user instanceof ServerPlayer serverPlayerEntity) { CriteriaTriggers.CONSUME_ITEM.trigger(serverPlayerEntity, stack); serverPlayerEntity.awardStat(Stats.ITEM_USED.get(this)); } - if (user instanceof Player && !((Player) user).abilities.instabuild) { + if (user instanceof Player && !((Player) user).getAbilities().instabuild) { stack.shrink(1); } - if (!world.isClientSide) { + if (!level.isClientSide) { user.removeAllEffects(); } diff --git a/src/main/java/ru/bclib/items/BaseSpawnEggItem.java b/src/main/java/ru/bclib/items/BaseSpawnEggItem.java index fb519f7e..7badc6f9 100644 --- a/src/main/java/ru/bclib/items/BaseSpawnEggItem.java +++ b/src/main/java/ru/bclib/items/BaseSpawnEggItem.java @@ -2,9 +2,12 @@ package ru.bclib.items; import java.util.Optional; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.Mob; import net.minecraft.world.item.SpawnEggItem; import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.ItemModelProvider; @@ -12,11 +15,12 @@ import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.PatternsHelper; public class BaseSpawnEggItem extends SpawnEggItem implements ItemModelProvider { - public BaseSpawnEggItem(EntityType type, int primaryColor, int secondaryColor, Properties settings) { + public BaseSpawnEggItem(EntityType type, int primaryColor, int secondaryColor, Properties settings) { super(type, primaryColor, secondaryColor, settings); } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation resourceLocation) { Optional pattern = PatternsHelper.createJson(BasePatterns.ITEM_SPAWN_EGG, resourceLocation); return ModelsHelper.fromPattern(pattern); diff --git a/src/main/java/ru/bclib/items/ModelProviderItem.java b/src/main/java/ru/bclib/items/ModelProviderItem.java index 208b8eb7..4fbd6a00 100644 --- a/src/main/java/ru/bclib/items/ModelProviderItem.java +++ b/src/main/java/ru/bclib/items/ModelProviderItem.java @@ -1,5 +1,7 @@ package ru.bclib.items; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; @@ -12,6 +14,7 @@ public class ModelProviderItem extends Item implements ItemModelProvider { } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation resourceLocation) { return ModelsHelper.createItemModel(resourceLocation); } diff --git a/src/main/java/ru/bclib/items/tool/BaseAxeItem.java b/src/main/java/ru/bclib/items/tool/BaseAxeItem.java index e3f5cf55..3836f161 100644 --- a/src/main/java/ru/bclib/items/tool/BaseAxeItem.java +++ b/src/main/java/ru/bclib/items/tool/BaseAxeItem.java @@ -1,5 +1,7 @@ package ru.bclib.items.tool; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.minecraft.client.renderer.block.model.BlockModel; @@ -28,6 +30,7 @@ public class BaseAxeItem extends AxeItem implements DynamicAttributeTool, ItemMo } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation resourceLocation) { return ModelsHelper.createHandheldItem(resourceLocation); } diff --git a/src/main/java/ru/bclib/items/tool/BaseHoeItem.java b/src/main/java/ru/bclib/items/tool/BaseHoeItem.java index f44a1af8..6e1aeab4 100644 --- a/src/main/java/ru/bclib/items/tool/BaseHoeItem.java +++ b/src/main/java/ru/bclib/items/tool/BaseHoeItem.java @@ -1,5 +1,7 @@ package ru.bclib.items.tool; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.HoeItem; @@ -13,6 +15,7 @@ public class BaseHoeItem extends HoeItem implements ItemModelProvider { } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation resourceLocation) { return ModelsHelper.createHandheldItem(resourceLocation); } diff --git a/src/main/java/ru/bclib/items/tool/BasePickaxeItem.java b/src/main/java/ru/bclib/items/tool/BasePickaxeItem.java index 858bb692..213c530b 100644 --- a/src/main/java/ru/bclib/items/tool/BasePickaxeItem.java +++ b/src/main/java/ru/bclib/items/tool/BasePickaxeItem.java @@ -1,5 +1,7 @@ package ru.bclib.items.tool; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl; @@ -36,6 +38,7 @@ public class BasePickaxeItem extends PickaxeItem implements DynamicAttributeTool } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation resourceLocation) { return ModelsHelper.createHandheldItem(resourceLocation); } diff --git a/src/main/java/ru/bclib/items/tool/BaseShovelItem.java b/src/main/java/ru/bclib/items/tool/BaseShovelItem.java index 49ffeff8..1a84ee98 100644 --- a/src/main/java/ru/bclib/items/tool/BaseShovelItem.java +++ b/src/main/java/ru/bclib/items/tool/BaseShovelItem.java @@ -1,5 +1,7 @@ package ru.bclib.items.tool; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl; @@ -36,6 +38,7 @@ public class BaseShovelItem extends ShovelItem implements DynamicAttributeTool, } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation resourceLocation) { return ModelsHelper.createHandheldItem(resourceLocation); } diff --git a/src/main/java/ru/bclib/items/tool/BaseSwordItem.java b/src/main/java/ru/bclib/items/tool/BaseSwordItem.java index c5807c12..f78098a3 100644 --- a/src/main/java/ru/bclib/items/tool/BaseSwordItem.java +++ b/src/main/java/ru/bclib/items/tool/BaseSwordItem.java @@ -1,5 +1,7 @@ package ru.bclib.items.tool; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.resources.ResourceLocation; @@ -14,6 +16,7 @@ public class BaseSwordItem extends SwordItem implements DynamicAttributeTool, It } @Override + @Environment(EnvType.CLIENT) public BlockModel getItemModel(ResourceLocation resourceLocation) { return ModelsHelper.createHandheldItem(resourceLocation); } diff --git a/src/main/java/ru/bclib/mixin/client/BackgroundRendererMixin.java b/src/main/java/ru/bclib/mixin/client/BackgroundRendererMixin.java index ca1076be..10495c5a 100644 --- a/src/main/java/ru/bclib/mixin/client/BackgroundRendererMixin.java +++ b/src/main/java/ru/bclib/mixin/client/BackgroundRendererMixin.java @@ -1,5 +1,6 @@ package ru.bclib.mixin.client; +import net.minecraft.world.level.material.FogType; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -41,8 +42,8 @@ public class BackgroundRendererMixin { @Inject(method = "setupColor", at = @At("RETURN")) private static void bcl_onRender(Camera camera, float tickDelta, ClientLevel world, int i, float f, CallbackInfo info) { - FluidState fluidState = camera.getFluidInCamera(); - if (fluidState.isEmpty() && world.dimension().equals(Level.END)) { + FogType fogType = camera.getFluidInCamera(); + if (fogType != FogType.WATER && world.dimension().equals(Level.END)) { Entity entity = camera.getEntity(); boolean skip = false; if (entity instanceof LivingEntity) { @@ -62,10 +63,10 @@ public class BackgroundRendererMixin { } @Inject(method = "setupFog", at = @At("HEAD"), cancellable = true) - private static void bcl_fogDensity(Camera camera, FogRenderer.FogMode fogType, float viewDistance, boolean thickFog, CallbackInfo info) { + private static void bcl_fogDensity(Camera camera, FogRenderer.FogMode fogMode, float viewDistance, boolean thickFog, CallbackInfo info) { Entity entity = camera.getEntity(); - FluidState fluidState = camera.getFluidInCamera(); - if (fluidState.isEmpty()) { + FogType fogType = camera.getFluidInCamera(); + if (fogType != FogType.WATER) { float fog = bcl_getFogDensity(entity.level, entity.getX(), entity.getEyeY(), entity.getZ()); BackgroundInfo.fogDensity = fog; float start = viewDistance * 0.75F / fog; @@ -93,10 +94,8 @@ public class BackgroundRendererMixin { } } - RenderSystem.fogStart(start); - RenderSystem.fogEnd(end); - RenderSystem.fogMode(GlStateManager.FogMode.LINEAR); - RenderSystem.setupNvFogDistance(); + RenderSystem.setShaderFogStart(start); + RenderSystem.setShaderFogEnd(end); info.cancel(); } } diff --git a/src/main/java/ru/bclib/mixin/common/FeatureDecoratorsAccessor.java b/src/main/java/ru/bclib/mixin/common/FeatureDecoratorsAccessor.java new file mode 100644 index 00000000..d54b39cc --- /dev/null +++ b/src/main/java/ru/bclib/mixin/common/FeatureDecoratorsAccessor.java @@ -0,0 +1,18 @@ +package ru.bclib.mixin.common; + +import net.minecraft.data.worldgen.Features; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.level.block.ComposterBlock; +import net.minecraft.world.level.levelgen.placement.ConfiguredDecorator; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import java.util.Map; + +@Mixin(targets = "net.minecraft.data.worldgen.Features$Decorators") +public interface FeatureDecoratorsAccessor { + @Accessor("HEIGHTMAP_SQUARE") + ConfiguredDecorator bcl_getHeightmapSquare(); +} diff --git a/src/main/java/ru/bclib/mixin/common/ServerLevelMixin.java b/src/main/java/ru/bclib/mixin/common/ServerLevelMixin.java index 9211ed91..ef881e4d 100644 --- a/src/main/java/ru/bclib/mixin/common/ServerLevelMixin.java +++ b/src/main/java/ru/bclib/mixin/common/ServerLevelMixin.java @@ -22,6 +22,7 @@ import net.minecraft.world.level.dimension.DimensionType; import net.minecraft.world.level.storage.LevelStorageSource; import net.minecraft.world.level.storage.ServerLevelData; import net.minecraft.world.level.storage.WritableLevelData; +import ru.bclib.api.BiomeAPI; import ru.bclib.api.DataFixerAPI; import ru.bclib.api.WorldDataAPI; @@ -35,6 +36,8 @@ public abstract class ServerLevelMixin extends Level { @Inject(method = "*", at = @At("TAIL")) private void bcl_onServerWorldInit(MinecraftServer server, Executor workerExecutor, LevelStorageSource.LevelStorageAccess session, ServerLevelData properties, ResourceKey registryKey, DimensionType dimensionType, ChunkProgressListener worldGenerationProgressListener, ChunkGenerator chunkGenerator, boolean debugWorld, long l, List list, boolean bl, CallbackInfo info) { + BiomeAPI.initRegistry(server); + if (bcl_lastWorld != null && bcl_lastWorld.equals(session.getLevelId())) { return; } @@ -48,6 +51,6 @@ public abstract class ServerLevelMixin extends Level { } DataFixerAPI.fixData(dir); - WorldDataAPI.load(dir); + WorldDataAPI.load(new File(dir, "data")); } } diff --git a/src/main/java/ru/bclib/mixin/common/TagLoaderMixin.java b/src/main/java/ru/bclib/mixin/common/TagLoaderMixin.java index 743a59f5..e01df428 100644 --- a/src/main/java/ru/bclib/mixin/common/TagLoaderMixin.java +++ b/src/main/java/ru/bclib/mixin/common/TagLoaderMixin.java @@ -1,26 +1,23 @@ -package ru.bclib.mixin.common; - -import java.util.Map; -import java.util.concurrent.Executor; -import java.util.function.Supplier; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyArg; - -import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.Tag; -import net.minecraft.tags.TagLoader; -import ru.bclib.util.TagHelper; - -@Mixin(TagLoader.class) -public class TagLoaderMixin { - @Shadow - private String name; - - @ModifyArg(method = "prepare", at = @At(value = "INVOKE", target = "Ljava/util/concurrent/CompletableFuture;supplyAsync(Ljava/util/function/Supplier;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;")) - public Supplier> be_modifyTags(Supplier> supplier, Executor executor) { - return () -> TagHelper.apply(name, supplier.get()); - } -} +package ru.bclib.mixin.common; + +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.Tag; +import net.minecraft.tags.TagLoader; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyArg; +import ru.bclib.util.TagHelper; + +import java.util.Map; + +@Mixin(TagLoader.class) +public class TagLoaderMixin { + @Shadow + private String directory; + + @ModifyArg(method = "loadAndBuild", at = @At(value = "INVOKE", target = "Lnet/minecraft/tags/TagLoader;build(Ljava/util/Map;)Lnet/minecraft/tags/TagCollection;")) + public Map be_modifyTags(Map tagsMap) { + return TagHelper.apply(directory, tagsMap); + } +} diff --git a/src/main/java/ru/bclib/recipes/CraftingRecipes.java b/src/main/java/ru/bclib/recipes/CraftingRecipes.java new file mode 100644 index 00000000..d28b5b97 --- /dev/null +++ b/src/main/java/ru/bclib/recipes/CraftingRecipes.java @@ -0,0 +1,37 @@ +package ru.bclib.recipes; + +import net.minecraft.tags.ItemTags; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.block.Blocks; +import ru.bclib.BCLib; +import ru.bclib.api.TagAPI; +import ru.bclib.config.Configs; + +public class CraftingRecipes { + public static void init() { + GridRecipe.make(BCLib.MOD_ID, "tag_smith_table", Blocks.SMITHING_TABLE).setShape("II", "##", "##").addMaterial('#', ItemTags.PLANKS).addMaterial('I', TagAPI.IRON_INGOTS).checkConfig(Configs.RECIPE_CONFIG).build(); + GridRecipe.make(BCLib.MOD_ID, "tag_cauldron", Blocks.CAULDRON).setShape("I I", "I I", "III").addMaterial('I', TagAPI.IRON_INGOTS).checkConfig(Configs.RECIPE_CONFIG).build(); + GridRecipe.make(BCLib.MOD_ID, "tag_hopper", Blocks.HOPPER).setShape("I I", "ICI", " I ").addMaterial('I', TagAPI.IRON_INGOTS).addMaterial('C', TagAPI.ITEM_CHEST).checkConfig(Configs.RECIPE_CONFIG).build(); + GridRecipe.make(BCLib.MOD_ID, "tag_piston", Blocks.PISTON).setShape("WWW", "CIC", "CDC").addMaterial('I', TagAPI.IRON_INGOTS).addMaterial('D', Items.REDSTONE).addMaterial('C', Items.COBBLESTONE).addMaterial('W', ItemTags.PLANKS).checkConfig(Configs.RECIPE_CONFIG).build(); + GridRecipe.make(BCLib.MOD_ID, "tag_rail", Blocks.RAIL).setOutputCount(16).setShape("I I", "ISI", "I I").addMaterial('I', TagAPI.IRON_INGOTS).addMaterial('S', Items.STICK).checkConfig(Configs.RECIPE_CONFIG).build(); + GridRecipe.make(BCLib.MOD_ID, "tag_stonecutter", Blocks.STONECUTTER).setShape(" I ", "SSS").addMaterial('I', TagAPI.IRON_INGOTS).addMaterial('S', Items.STONE).checkConfig(Configs.RECIPE_CONFIG).build(); + GridRecipe.make(BCLib.MOD_ID, "tag_bucket", Items.BUCKET).setShape("I I", " I ").addMaterial('I', TagAPI.IRON_INGOTS).checkConfig(Configs.RECIPE_CONFIG).build(); + GridRecipe.make(BCLib.MOD_ID, "tag_compass", Items.COMPASS).setShape(" I ", "IDI", " I ").addMaterial('I', TagAPI.IRON_INGOTS).addMaterial('D', Items.REDSTONE).checkConfig(Configs.RECIPE_CONFIG).build(); + GridRecipe.make(BCLib.MOD_ID, "tag_minecart", Items.MINECART).setShape("I I", "III").addMaterial('I', TagAPI.IRON_INGOTS).checkConfig(Configs.RECIPE_CONFIG).build(); + GridRecipe.make(BCLib.MOD_ID, "tag_shield", Items.SHIELD).setShape("WIW", "WWW", " W ").addMaterial('I', TagAPI.IRON_INGOTS).addMaterial('W', ItemTags.PLANKS).checkConfig(Configs.RECIPE_CONFIG).build(); + + GridRecipe.make(BCLib.MOD_ID, "tag_hopper", Blocks.HOPPER) + .setShape("I I", "ICI", " I ") + .addMaterial('I', TagAPI.IRON_INGOTS) + .addMaterial('C', TagAPI.ITEM_CHEST) + .checkConfig(Configs.RECIPE_CONFIG) + .build(); + + GridRecipe.make(BCLib.MOD_ID, "tag_shulker_box", Blocks.SHULKER_BOX) + .setShape("S", "C", "S") + .addMaterial('S', Items.SHULKER_SHELL) + .addMaterial('C', TagAPI.ITEM_CHEST) + .checkConfig(Configs.RECIPE_CONFIG) + .build(); + } +} diff --git a/src/main/java/ru/bclib/recipes/FurnaceRecipe.java b/src/main/java/ru/bclib/recipes/FurnaceRecipe.java index 66c4ae28..38d20a4b 100644 --- a/src/main/java/ru/bclib/recipes/FurnaceRecipe.java +++ b/src/main/java/ru/bclib/recipes/FurnaceRecipe.java @@ -39,7 +39,7 @@ public class FurnaceRecipe { } public FurnaceRecipe checkConfig(PathConfig config) { - exist = config.getBoolean("furnace", id.getPath(), true); + exist |= config.getBoolean("furnace", id.getPath(), true); return this; } diff --git a/src/main/java/ru/bclib/recipes/GridRecipe.java b/src/main/java/ru/bclib/recipes/GridRecipe.java index 06a15b2b..bfb9abe7 100644 --- a/src/main/java/ru/bclib/recipes/GridRecipe.java +++ b/src/main/java/ru/bclib/recipes/GridRecipe.java @@ -52,7 +52,7 @@ public class GridRecipe { } public GridRecipe checkConfig(PathConfig config) { - exist = config.getBoolean("grid", id.getPath(), true); + exist |= config.getBoolean("grid", id.getPath(), true); return this; } diff --git a/src/main/java/ru/bclib/recipes/SmithingTableRecipe.java b/src/main/java/ru/bclib/recipes/SmithingTableRecipe.java index 45947b4c..bc6aa702 100644 --- a/src/main/java/ru/bclib/recipes/SmithingTableRecipe.java +++ b/src/main/java/ru/bclib/recipes/SmithingTableRecipe.java @@ -40,7 +40,7 @@ public class SmithingTableRecipe { private SmithingTableRecipe() {} public SmithingTableRecipe checkConfig(PathConfig config) { - exist = config.getBoolean("smithing", id.getPath(), true); + exist |= config.getBoolean("smithing", id.getPath(), true); return this; } diff --git a/src/main/java/ru/bclib/registry/BaseBlockEntities.java b/src/main/java/ru/bclib/registry/BaseBlockEntities.java index 989e318a..7da1352b 100644 --- a/src/main/java/ru/bclib/registry/BaseBlockEntities.java +++ b/src/main/java/ru/bclib/registry/BaseBlockEntities.java @@ -13,6 +13,7 @@ import ru.bclib.blockentities.BaseChestBlockEntity; import ru.bclib.blockentities.BaseFurnaceBlockEntity; import ru.bclib.blockentities.BaseSignBlockEntity; import ru.bclib.blockentities.DynamicBlockEntityType; +import ru.bclib.blockentities.DynamicBlockEntityType.BlockEntitySupplier; import ru.bclib.blocks.BaseBarrelBlock; import ru.bclib.blocks.BaseChestBlock; import ru.bclib.blocks.BaseFurnaceBlock; @@ -24,7 +25,7 @@ public class BaseBlockEntities { public static final DynamicBlockEntityType SIGN = registerBlockEntityType(BCLib.makeID("sign"), BaseSignBlockEntity::new); public static final DynamicBlockEntityType FURNACE = registerBlockEntityType(BCLib.makeID("furnace"), BaseFurnaceBlockEntity::new); - public static DynamicBlockEntityType registerBlockEntityType(ResourceLocation typeId, Supplier supplier) { + public static DynamicBlockEntityType registerBlockEntityType(ResourceLocation typeId, BlockEntitySupplier supplier) { return Registry.register(Registry.BLOCK_ENTITY_TYPE, typeId, new DynamicBlockEntityType<>(supplier)); } diff --git a/src/main/java/ru/bclib/registry/ItemsRegistry.java b/src/main/java/ru/bclib/registry/ItemsRegistry.java index 9ca28e68..7dcc9744 100644 --- a/src/main/java/ru/bclib/registry/ItemsRegistry.java +++ b/src/main/java/ru/bclib/registry/ItemsRegistry.java @@ -9,6 +9,7 @@ import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.Tag; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.MobSpawnType; import net.minecraft.world.food.FoodProperties; import net.minecraft.world.item.CreativeModeTab; @@ -19,9 +20,9 @@ import net.minecraft.world.item.SpawnEggItem; import net.minecraft.world.item.SwordItem; import net.minecraft.world.item.TieredItem; import net.minecraft.world.level.block.DispenserBlock; +import ru.bclib.items.BaseDiscItem; import ru.bclib.items.BaseDrinkItem; import ru.bclib.items.BaseSpawnEggItem; -import ru.bclib.items.EndDiscItem; import ru.bclib.items.ModelProviderItem; import ru.bclib.items.tool.BaseAxeItem; import ru.bclib.items.tool.BaseHoeItem; @@ -35,7 +36,7 @@ public abstract class ItemsRegistry extends BaseRegistry { } public Item registerDisc(String name, int power, SoundEvent sound) { - return register(name, new EndDiscItem(power, sound, makeItemSettings())); + return register(name, new BaseDiscItem(power, sound, makeItemSettings().stacksTo(1))); } public Item registerItem(String name) { @@ -67,7 +68,7 @@ public abstract class ItemsRegistry extends BaseRegistry { return item; } - public Item registerEgg(String name, EntityType type, int background, int dots) { + public Item registerEgg(String name, EntityType type, int background, int dots) { SpawnEggItem item = new BaseSpawnEggItem(type, background, dots, makeItemSettings()); DefaultDispenseItemBehavior behavior = new DefaultDispenseItemBehavior() { public ItemStack execute(BlockSource pointer, ItemStack stack) { diff --git a/src/main/java/ru/bclib/server/BCLibServer.java b/src/main/java/ru/bclib/server/BCLibServer.java new file mode 100644 index 00000000..2fbc8c0b --- /dev/null +++ b/src/main/java/ru/bclib/server/BCLibServer.java @@ -0,0 +1,11 @@ +package ru.bclib.server; + +import net.fabricmc.api.DedicatedServerModInitializer; +import ru.bclib.api.ModIntegrationAPI; + +public class BCLibServer implements DedicatedServerModInitializer { + @Override + public void onInitializeServer() { + ModIntegrationAPI.registerAll(); + } +} diff --git a/src/main/java/ru/bclib/util/BlocksHelper.java b/src/main/java/ru/bclib/util/BlocksHelper.java index 78d79a12..21b974f9 100644 --- a/src/main/java/ru/bclib/util/BlocksHelper.java +++ b/src/main/java/ru/bclib/util/BlocksHelper.java @@ -182,6 +182,11 @@ public class BlocksHelper { * @return {@code true} if block is "invulnerable" and {@code false} if not. */ public static boolean isInvulnerableUnsafe(BlockState state) { - return isInvulnerable(state, null, null); + try { + return isInvulnerable(state, null, null); + } + catch (Exception e) { + return false; + } } } diff --git a/src/main/java/ru/bclib/util/StructureHelper.java b/src/main/java/ru/bclib/util/StructureHelper.java index cf68aab5..9d724ac8 100644 --- a/src/main/java/ru/bclib/util/StructureHelper.java +++ b/src/main/java/ru/bclib/util/StructureHelper.java @@ -14,6 +14,7 @@ import com.google.common.collect.Sets; import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.Vec3i; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtIo; import net.minecraft.resources.ResourceLocation; @@ -27,6 +28,7 @@ import net.minecraft.world.level.levelgen.structure.BoundingBox; import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings; import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; import net.minecraft.world.level.material.Material; +import net.minecraft.world.phys.Vec3; import ru.bclib.api.TagAPI; public class StructureHelper { @@ -86,8 +88,8 @@ public class StructureHelper { } public static BlockPos offsetPos(BlockPos pos, StructureTemplate structure, Rotation rotation, Mirror mirror) { - BlockPos offset = StructureTemplate.transform(structure.getSize(), mirror, rotation, BlockPos.ZERO); - return pos.offset(-offset.getX() * 0.5, 0, -offset.getZ() * 0.5); + Vec3 offset = StructureTemplate.transform(Vec3.atCenterOf(structure.getSize()), mirror, rotation, BlockPos.ZERO); + return pos.offset(-offset.x * 0.5, 0, -offset.z * 0.5); } public static void placeCenteredBottom(WorldGenLevel world, BlockPos pos, StructureTemplate structure, Rotation rotation, Mirror mirror, Random random) { @@ -97,7 +99,7 @@ public class StructureHelper { public static void placeCenteredBottom(WorldGenLevel world, BlockPos pos, StructureTemplate structure, Rotation rotation, Mirror mirror, BoundingBox bounds, Random random) { BlockPos offset = offsetPos(pos, structure, rotation, mirror); StructurePlaceSettings placementData = new StructurePlaceSettings().setRotation(rotation).setMirror(mirror).setBoundingBox(bounds); - structure.placeInWorldChunk(world, offset, placementData, random); + structure.placeInWorld(world, offset, offset, placementData, random, 4); } private static BoundingBox makeBox(BlockPos pos) { @@ -105,40 +107,41 @@ public class StructureHelper { int sz = ((pos.getZ() >> 4) << 4) - 16; int ex = sx + 47; int ez = sz + 47; - return BoundingBox.createProper(sx, 0, sz, ex, 255, ez); + return BoundingBox.fromCorners(new Vec3i(sx, 0, sz), new Vec3i(ex, 255, ez)); } public static BoundingBox getStructureBounds(BlockPos pos, StructureTemplate structure, Rotation rotation, Mirror mirror) { - BlockPos max = structure.getSize(); - BlockPos min = StructureTemplate.transform(structure.getSize(), mirror, rotation, BlockPos.ZERO); - max = max.subtract(min); - return new BoundingBox(min.offset(pos), max.offset(pos)); + Vec3i max = structure.getSize(); + Vec3 min = StructureTemplate.transform(Vec3.atCenterOf(structure.getSize()), mirror, rotation, BlockPos.ZERO); + max = max.offset(-min.x, -min.y, -min.z); + return BoundingBox.fromCorners(pos.offset(min.x, min.y, min.z), max.offset(pos)); } public static BoundingBox intersectBoxes(BoundingBox box1, BoundingBox box2) { - int x1 = MHelper.max(box1.x0, box2.x0); - int y1 = MHelper.max(box1.y0, box2.y0); - int z1 = MHelper.max(box1.z0, box2.z0); + int x1 = MHelper.max(box1.minX(), box2.minX()); + int y1 = MHelper.max(box1.minY(), box2.minY()); + int z1 = MHelper.max(box1.minZ(), box2.minZ()); - int x2 = MHelper.min(box1.x1, box2.x1); - int y2 = MHelper.min(box1.y1, box2.y1); - int z2 = MHelper.min(box1.z1, box2.z1); + int x2 = MHelper.min(box1.maxX(), box2.maxX()); + int y2 = MHelper.min(box1.maxY(), box2.maxY()); + int z2 = MHelper.min(box1.maxZ(), box2.maxZ()); - return BoundingBox.createProper(x1, y1, z1, x2, y2, z2); + return BoundingBox.fromCorners(new Vec3i(x1, y1, z1), new Vec3i(x2, y2, z2)); } public static void erode(WorldGenLevel world, BoundingBox bounds, int iterations, Random random) { MutableBlockPos mut = new MutableBlockPos(); boolean canDestruct = true; for (int i = 0; i < iterations; i++) { - for (int x = bounds.x0; x <= bounds.x1; x++) { + for (int x = bounds.minX(); x <= bounds.maxX(); x++) { mut.setX(x); - for (int z = bounds.z0; z <= bounds.z1; z++) { + for (int z = bounds.minZ(); z <= bounds.maxZ(); z++) { mut.setZ(z); - for (int y = bounds.y1; y >= bounds.y0; y--) { + for (int y = bounds.maxY(); y >= bounds.minY(); y--) { mut.setY(y); BlockState state = world.getBlockState(mut); - if (canDestruct && BlocksHelper.isInvulnerableUnsafe(state) && random.nextInt(8) == 0 && world.isEmptyBlock(mut.below(2))) { + boolean ignore = ignore(state, world, mut); + if (canDestruct && BlocksHelper.isInvulnerable(state, world, mut) && random.nextInt(8) == 0 && world.isEmptyBlock(mut.below(2))) { int r = MHelper.randRange(1, 4, random); int cx = mut.getX(); int cy = mut.getY(); @@ -161,7 +164,7 @@ public class StructureHelper { int dz = pz - cz; dz *= dz; mut.setZ(pz); - if (dx + dy + dz <= r && BlocksHelper.isInvulnerableUnsafe(world.getBlockState(mut))) { + if (dx + dy + dz <= r && BlocksHelper.isInvulnerable(world.getBlockState(mut), world, mut)) { BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR); } } @@ -173,7 +176,7 @@ public class StructureHelper { canDestruct = false; continue; } - else if (ignore(state)) { + else if (ignore) { continue; } if (!state.isAir() && random.nextBoolean()) { @@ -182,7 +185,7 @@ public class StructureHelper { if (world.isEmptyBlock(mut.relative(dir)) && world.isEmptyBlock(mut.below().relative(dir))) { BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR); mut.move(dir).move(Direction.DOWN); - for (int py = mut.getY(); y >= bounds.y0 - 10; y--) { + for (int py = mut.getY(); y >= bounds.minY() - 10; y--) { mut.setY(py - 1); if (!world.isEmptyBlock(mut)) { mut.setY(py); @@ -194,23 +197,23 @@ public class StructureHelper { } break; } - else if (random.nextInt(8) == 0 && !BlocksHelper.isInvulnerableUnsafe(world.getBlockState(mut.above()))) { + else if (random.nextInt(8) == 0 && !BlocksHelper.isInvulnerable(world.getBlockState(mut.above()), world, mut)) { BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR); } } } } } - for (int x = bounds.x0; x <= bounds.x1; x++) { + for (int x = bounds.minX(); x <= bounds.maxX(); x++) { mut.setX(x); - for (int z = bounds.z0; z <= bounds.z1; z++) { + for (int z = bounds.minZ(); z <= bounds.maxZ(); z++) { mut.setZ(z); - for (int y = bounds.y1; y >= bounds.y0; y--) { + for (int y = bounds.maxY(); y >= bounds.minY(); y--) { mut.setY(y); BlockState state = world.getBlockState(mut); - if (!ignore(state) && world.isEmptyBlock(mut.below())) { + if (!ignore(state, world, mut) && world.isEmptyBlock(mut.below())) { BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR); - for (int py = mut.getY(); py >= bounds.y0 - 10; py--) { + for (int py = mut.getY(); py >= bounds.minY() - 10; py--) { mut.setY(py - 1); if (!world.isEmptyBlock(mut)) { mut.setY(py); @@ -227,15 +230,15 @@ public class StructureHelper { public static void erodeIntense(WorldGenLevel world, BoundingBox bounds, Random random) { MutableBlockPos mut = new MutableBlockPos(); MutableBlockPos mut2 = new MutableBlockPos(); - int minY = bounds.y0 - 10; - for (int x = bounds.x0; x <= bounds.x1; x++) { + int minY = bounds.minY() - 10; + for (int x = bounds.minX(); x <= bounds.maxX(); x++) { mut.setX(x); - for (int z = bounds.z0; z <= bounds.z1; z++) { + for (int z = bounds.minZ(); z <= bounds.maxZ(); z++) { mut.setZ(z); - for (int y = bounds.y1; y >= bounds.y0; y--) { + for (int y = bounds.maxY(); y >= bounds.minY(); y--) { mut.setY(y); BlockState state = world.getBlockState(mut); - if (!ignore(state)) { + if (!ignore(state, world, mut)) { if (random.nextInt(6) == 0) { BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR); if (random.nextBoolean()) { @@ -278,14 +281,14 @@ public class StructureHelper { Set edge = Sets.newHashSet(); Set add = Sets.newHashSet(); - for (int x = bounds.x0; x <= bounds.x1; x++) { + for (int x = bounds.minX(); x <= bounds.maxX(); x++) { mut.setX(x); - for (int z = bounds.z0; z <= bounds.z1; z++) { + for (int z = bounds.minZ(); z <= bounds.maxZ(); z++) { mut.setZ(z); - for (int y = bounds.y0; y <= bounds.y1; y++) { + for (int y = bounds.minY(); y <= bounds.maxY(); y++) { mut.setY(y); BlockState state = world.getBlockState(mut); - if (!ignore(state) && isTerrainNear(world, mut)) { + if (!ignore(state, world, mut) && isTerrainNear(world, mut)) { edge.add(mut.immutable()); } } @@ -304,7 +307,7 @@ public class StructureHelper { mut.set(center).move(dir); if (bounds.isInside(mut)) { state = world.getBlockState(mut); - if (!ignore(state) && !blocks.contains(mut)) { + if (!ignore(state, world, mut) && !blocks.contains(mut)) { add.add(mut.immutable()); } } @@ -318,15 +321,15 @@ public class StructureHelper { add.clear(); } - int minY = bounds.y0 - 10; - for (int x = bounds.x0; x <= bounds.x1; x++) { + int minY = bounds.minY() - 10; + for (int x = bounds.minX(); x <= bounds.maxX(); x++) { mut.setX(x); - for (int z = bounds.z0; z <= bounds.z1; z++) { + for (int z = bounds.minZ(); z <= bounds.maxZ(); z++) { mut.setZ(z); - for (int y = bounds.y0; y <= bounds.y1; y++) { + for (int y = bounds.minY(); y <= bounds.maxY(); y++) { mut.setY(y); BlockState state = world.getBlockState(mut); - if (!ignore(state) && !blocks.contains(mut)) { + if (!ignore(state, world, mut) && !blocks.contains(mut)) { BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR); while (world.getBlockState(mut).getMaterial().isReplaceable() && mut.getY() > minY) { mut.setY(mut.getY() - 1); @@ -341,7 +344,7 @@ public class StructureHelper { } } - private static boolean ignore(BlockState state) { + private static boolean ignore(BlockState state, WorldGenLevel world, BlockPos pos) { return state.getMaterial().isReplaceable() || !state.getFluidState().isEmpty() || state.is(TagAPI.END_GROUND) || @@ -349,17 +352,17 @@ public class StructureHelper { state.is(BlockTags.LEAVES) || state.getMaterial().equals(Material.PLANT) || state.getMaterial().equals(Material.LEAVES) || - BlocksHelper.isInvulnerableUnsafe(state); + BlocksHelper.isInvulnerable(state, world, pos); } public static void cover(WorldGenLevel world, BoundingBox bounds, Random random) { MutableBlockPos mut = new MutableBlockPos(); - for (int x = bounds.x0; x <= bounds.x1; x++) { + for (int x = bounds.minX(); x <= bounds.maxX(); x++) { mut.setX(x); - for (int z = bounds.z0; z <= bounds.z1; z++) { + for (int z = bounds.minZ(); z <= bounds.maxZ(); z++) { mut.setZ(z); BlockState top = world.getBiome(mut).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial(); - for (int y = bounds.y1; y >= bounds.y0; y--) { + for (int y = bounds.maxY(); y >= bounds.minY(); y--) { mut.setY(y); BlockState state = world.getBlockState(mut); if (state.is(TagAPI.END_GROUND) && !world.getBlockState(mut.above()).getMaterial().isSolidBlocking()) { diff --git a/src/main/java/ru/bclib/util/TagHelper.java b/src/main/java/ru/bclib/util/TagHelper.java index f5dc604d..dae193d0 100644 --- a/src/main/java/ru/bclib/util/TagHelper.java +++ b/src/main/java/ru/bclib/util/TagHelper.java @@ -58,11 +58,11 @@ public class TagHelper { return builder; } - public static Map apply(String entry, Map tagsMap) { + public static Map apply(String directory, Map tagsMap) { Map> endTags = null; - if (entry.equals("block")) { + if ("tags/blocks".equals(directory)) { endTags = TAGS_BLOCK; - } else if (entry.equals("item")) { + } else if ("tags/items".equals(directory)) { endTags = TAGS_ITEM; } if (endTags != null) { diff --git a/src/main/java/ru/bclib/world/biomes/BCLBiomeDef.java b/src/main/java/ru/bclib/world/biomes/BCLBiomeDef.java index 22c75311..1d77c26d 100644 --- a/src/main/java/ru/bclib/world/biomes/BCLBiomeDef.java +++ b/src/main/java/ru/bclib/world/biomes/BCLBiomeDef.java @@ -8,7 +8,6 @@ import com.google.common.collect.Maps; import net.minecraft.core.Registry; import net.minecraft.core.particles.ParticleOptions; -import net.minecraft.data.worldgen.biome.Biomes; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.Music; import net.minecraft.sounds.Musics; @@ -29,6 +28,7 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.levelgen.GenerationStep.Carving; import net.minecraft.world.level.levelgen.GenerationStep.Decoration; +import net.minecraft.world.level.levelgen.carver.CarverConfiguration; import net.minecraft.world.level.levelgen.carver.ConfiguredWorldCarver; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature; @@ -43,8 +43,8 @@ import ru.bclib.world.structures.BCLStructureFeature; import ru.bclib.world.surface.DoubleBlockSurfaceBuilder; public class BCLBiomeDef { - public static final int DEF_FOLIAGE_OVERWORLD = Biomes.PLAINS.getFoliageColor(); - public static final int DEF_FOLIAGE_NETHER =ColorUtil.color(117, 10, 10); + public static final int DEF_FOLIAGE_OVERWORLD = ColorUtil.color(110, 143, 64); + public static final int DEF_FOLIAGE_NETHER = ColorUtil.color(117, 10, 10); public static final int DEF_FOLIAGE_END = ColorUtil.color(197, 210, 112); private final List> structures = Lists.newArrayList(); @@ -346,7 +346,7 @@ public class BCLBiomeDef { private static final class CarverInfo { Carving carverStep; - ConfiguredWorldCarver carver; + ConfiguredWorldCarver carver; } public ResourceLocation getID() { @@ -365,7 +365,7 @@ public class BCLBiomeDef { return edgeSize; } - public BCLBiomeDef addCarver(Carving carverStep, ConfiguredWorldCarver carver) { + public BCLBiomeDef addCarver(Carving carverStep, ConfiguredWorldCarver carver) { CarverInfo info = new CarverInfo(); info.carverStep = carverStep; info.carver = carver; diff --git a/src/main/java/ru/bclib/world/features/BCLDecorators.java b/src/main/java/ru/bclib/world/features/BCLDecorators.java new file mode 100644 index 00000000..d037c5f6 --- /dev/null +++ b/src/main/java/ru/bclib/world/features/BCLDecorators.java @@ -0,0 +1,27 @@ +package ru.bclib.world.features; + +import net.minecraft.data.worldgen.Features; +import net.minecraft.world.level.levelgen.placement.ConfiguredDecorator; +import ru.bclib.BCLib; + +import java.lang.reflect.Field; + +public class BCLDecorators { + public static final ConfiguredDecorator HEIGHTMAP_SQUARE; + + private static final ConfiguredDecorator getDecorator(Field[] fields, int index) { + try { + return (ConfiguredDecorator) fields[index].get(null); + } + catch (IllegalAccessException e) { + BCLib.LOGGER.error(e.getLocalizedMessage()); + return null; + } + } + + static { + Class[] classes = Features.class.getDeclaredClasses(); + Field[] fields = classes[1].getDeclaredFields(); // Decorators class + HEIGHTMAP_SQUARE = getDecorator(fields, 17); + } +} diff --git a/src/main/java/ru/bclib/world/features/BCLFeature.java b/src/main/java/ru/bclib/world/features/BCLFeature.java index d8d3483e..2227cddd 100644 --- a/src/main/java/ru/bclib/world/features/BCLFeature.java +++ b/src/main/java/ru/bclib/world/features/BCLFeature.java @@ -4,9 +4,11 @@ import net.minecraft.core.Registry; import net.minecraft.data.BuiltinRegistries; import net.minecraft.data.worldgen.Features; import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.BlockTags; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.levelgen.GenerationStep; +import net.minecraft.world.level.levelgen.VerticalAnchor; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.configurations.CountConfiguration; @@ -17,12 +19,16 @@ import net.minecraft.world.level.levelgen.feature.configurations.RangeDecoratorC import net.minecraft.world.level.levelgen.placement.ChanceDecoratorConfiguration; import net.minecraft.world.level.levelgen.placement.FeatureDecorator; import net.minecraft.world.level.levelgen.structure.templatesystem.BlockMatchTest; +import net.minecraft.world.level.levelgen.structure.templatesystem.RuleTest; +import net.minecraft.world.level.levelgen.structure.templatesystem.TagMatchTest; +import ru.bclib.api.TagAPI; public class BCLFeature { - private Feature feature; + private static final RuleTest ANY_TERRAIN = new TagMatchTest(TagAPI.GEN_TERRAIN); private ConfiguredFeature featureConfigured; private GenerationStep.Decoration featureStep; - + private Feature feature; + public BCLFeature(Feature feature, ConfiguredFeature configuredFeature, GenerationStep.Decoration featureStep) { this.featureConfigured = configuredFeature; this.featureStep = featureStep; @@ -36,7 +42,7 @@ public class BCLFeature { } public static BCLFeature makeVegetationFeature(ResourceLocation id, Feature feature, int density) { - ConfiguredFeature configured = feature.configured(FeatureConfiguration.NONE).decorated(Features.Decorators.HEIGHTMAP_SQUARE).countRandom(density); + ConfiguredFeature configured = feature.configured(FeatureConfiguration.NONE).decorated(BCLDecorators.HEIGHTMAP_SQUARE).countRandom(density); return new BCLFeature(id, feature, GenerationStep.Decoration.VEGETAL_DECORATION, configured); } @@ -46,17 +52,17 @@ public class BCLFeature { } public static BCLFeature makeLakeFeature(ResourceLocation id, Feature feature, int chance) { - ConfiguredFeature configured = feature.configured(FeatureConfiguration.NONE).decorated(FeatureDecorator.WATER_LAKE.configured(new ChanceDecoratorConfiguration(chance))); + ConfiguredFeature configured = feature.configured(FeatureConfiguration.NONE).decorated(FeatureDecorator.LAVA_LAKE.configured(new ChanceDecoratorConfiguration(chance))); return new BCLFeature(id, feature, GenerationStep.Decoration.LAKES, configured); } public static BCLFeature makeOreFeature(ResourceLocation id, Block blockOre, int veins, int veinSize, int offset, int minY, int maxY) { OreConfiguration featureConfig = new OreConfiguration(new BlockMatchTest(Blocks.END_STONE), blockOre.defaultBlockState(), veinSize); - RangeDecoratorConfiguration rangeDecorator = new RangeDecoratorConfiguration(offset, minY, maxY); + OreConfiguration config = new OreConfiguration(ANY_TERRAIN, blockOre.defaultBlockState(), 33); ConfiguredFeature oreFeature = Feature.ORE.configured(featureConfig) - .decorated(FeatureDecorator.RANGE.configured(rangeDecorator)) - .squared() - .count(veins); + .rangeUniform(VerticalAnchor.absolute(minY), VerticalAnchor.absolute(maxY)) + .squared() + .count(veins); return new BCLFeature(Feature.ORE, Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id, oreFeature), GenerationStep.Decoration.UNDERGROUND_ORES); } diff --git a/src/main/java/ru/bclib/world/features/NBTStructureFeature.java b/src/main/java/ru/bclib/world/features/NBTStructureFeature.java index 80d94729..e48bfb5a 100644 --- a/src/main/java/ru/bclib/world/features/NBTStructureFeature.java +++ b/src/main/java/ru/bclib/world/features/NBTStructureFeature.java @@ -7,6 +7,7 @@ import java.util.Random; import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.Vec3i; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtIo; import net.minecraft.resources.ResourceLocation; @@ -17,11 +18,13 @@ import net.minecraft.world.level.block.Mirror; import net.minecraft.world.level.block.Rotation; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.chunk.ChunkGenerator; +import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; import net.minecraft.world.level.levelgen.structure.BoundingBox; import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings; import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilderConfiguration; +import net.minecraft.world.phys.Vec3; import ru.bclib.api.BiomeAPI; import ru.bclib.api.TagAPI; import ru.bclib.util.BlocksHelper; @@ -76,7 +79,11 @@ public abstract class NBTStructureFeature extends DefaultFeature { } @Override - public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos center, NoneFeatureConfiguration featureConfig) { + public boolean place(FeaturePlaceContext context) { + WorldGenLevel world = context.level(); + Random random = context.random(); + BlockPos center = context.origin(); + center = new BlockPos(((center.getX() >> 4) << 4) | 8, 128, ((center.getZ() >> 4) << 4) | 8); center = getGround(world, center); @@ -88,14 +95,14 @@ public abstract class NBTStructureFeature extends DefaultFeature { StructureTemplate structure = getStructure(world, center, random); Rotation rotation = getRotation(world, center, random); Mirror mirror = getMirror(world, center, random); - BlockPos offset = StructureTemplate.transform(structure.getSize(), mirror, rotation, BlockPos.ZERO); + BlockPos offset = StructureTemplate.transform(new BlockPos(structure.getSize()), mirror, rotation, BlockPos.ZERO); center = center.offset(0, getYOffset(structure, world, center, random) + 0.5, 0); BoundingBox bounds = makeBox(center); StructurePlaceSettings placementData = new StructurePlaceSettings().setRotation(rotation).setMirror(mirror).setBoundingBox(bounds); addStructureData(placementData); center = center.offset(-offset.getX() * 0.5, 0, -offset.getZ() * 0.5); - structure.placeInWorldChunk(world, center, placementData, random); + structure.placeInWorld(world, center, center, placementData, random, 4); TerrainMerge merge = getTerrainMerge(world, center, random); int x1 = center.getX(); @@ -167,7 +174,7 @@ public abstract class NBTStructureFeature extends DefaultFeature { int sz = ((pos.getZ() >> 4) << 4) - 16; int ex = sx + 47; int ez = sz + 47; - return BoundingBox.createProper(sx, 0, sz, ex, 255, ez); + return BoundingBox.fromCorners(new Vec3i(sx, 0, sz), new Vec3i(ex, 255, ez)); } protected static StructureTemplate readStructure(ResourceLocation resource) { diff --git a/src/main/java/ru/bclib/world/structures/StructureWorld.java b/src/main/java/ru/bclib/world/structures/StructureWorld.java index af49651b..8f3c80d5 100644 --- a/src/main/java/ru/bclib/world/structures/StructureWorld.java +++ b/src/main/java/ru/bclib/world/structures/StructureWorld.java @@ -100,7 +100,7 @@ public class StructureWorld { public BoundingBox getBounds() { if (minX == Integer.MAX_VALUE || maxX == Integer.MIN_VALUE || minZ == Integer.MAX_VALUE || maxZ == Integer.MIN_VALUE) { - return BoundingBox.getUnknownBox(); + return BoundingBox.infinite(); } return new BoundingBox(minX << 4, minY, minZ << 4, (maxX << 4) | 15, maxY, (maxZ << 4) | 15); } diff --git a/src/main/java/ru/bclib/world/surface/DoubleBlockSurfaceBuilder.java b/src/main/java/ru/bclib/world/surface/DoubleBlockSurfaceBuilder.java index 1e19d33e..14e6bba4 100644 --- a/src/main/java/ru/bclib/world/surface/DoubleBlockSurfaceBuilder.java +++ b/src/main/java/ru/bclib/world/surface/DoubleBlockSurfaceBuilder.java @@ -34,12 +34,6 @@ public class DoubleBlockSurfaceBuilder extends SurfaceBuilder 0 ? config1 : config2); - } public static DoubleBlockSurfaceBuilder register(String name) { return Registry.register(Registry.SURFACE_BUILDER, name, new DoubleBlockSurfaceBuilder()); @@ -49,4 +43,10 @@ public class DoubleBlockSurfaceBuilder extends SurfaceBuilder 0 ? config1 : config2); + } } \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 0cf6dd3d..d4c9f8f1 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -25,6 +25,9 @@ ], "client": [ "ru.bclib.client.BCLibClient" + ], + "server": [ + "ru.bclib.server.BCLibServer" ] }, "mixins": [