Compare commits

..

No commits in common. "1.17" and "0.1.37" have entirely different histories.
1.17 ... 0.1.37

91 changed files with 356 additions and 753 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

View file

@ -7,12 +7,12 @@ buildscript {
plugins { plugins {
id 'idea' id 'idea'
id 'eclipse' id 'eclipse'
id 'fabric-loom' version '0.8-SNAPSHOT' id 'fabric-loom' version '0.7-SNAPSHOT'
id 'maven-publish' id 'maven-publish'
} }
sourceCompatibility = JavaVersion.VERSION_16 sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_16 targetCompatibility = JavaVersion.VERSION_1_8
archivesBaseName = project.archives_base_name archivesBaseName = project.archives_base_name
version = project.mod_version version = project.mod_version
@ -20,7 +20,7 @@ group = project.maven_group
repositories { repositories {
maven { url "https://maven.dblsaiko.net/" } maven { url "https://maven.dblsaiko.net/" }
maven { url "https://server.bbkr.space:8081/artifactory/libs-release/" } maven { url "http://server.bbkr.space:8081/artifactory/libs-release/" }
maven { url "https://maven.fabricmc.net/" } maven { url "https://maven.fabricmc.net/" }
maven { url 'https://maven.blamejared.com' } maven { url 'https://maven.blamejared.com' }
maven { url "https://maven.shedaniel.me/" } maven { url "https://maven.shedaniel.me/" }
@ -33,7 +33,7 @@ dependencies {
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_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) { def useOptional(String dep) {
@ -65,7 +65,6 @@ def useApi(String dep) {
processResources { processResources {
inputs.property "version", project.version inputs.property "version", project.version
duplicatesStrategy = 'EXCLUDE'
from(sourceSets.main.resources.srcDirs) { from(sourceSets.main.resources.srcDirs) {
include "fabric.mod.json" include "fabric.mod.json"

View file

@ -3,16 +3,16 @@ org.gradle.jvmargs=-Xmx2G
# Fabric Properties # Fabric Properties
# check these on https://fabricmc.net/use # check these on https://fabricmc.net/use
minecraft_version= 1.17 minecraft_version=1.16.5
yarn_mappings=6 yarn_mappings=6
loader_version= 0.11.6 loader_version=0.11.3
# Mod Properties # Mod Properties
mod_version = 0.2.0 mod_version = 0.1.37
maven_group = ru.bclib maven_group = ru.bclib
archives_base_name = bclib archives_base_name = bclib
# Dependencies # Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api # 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 patchouli_version = 50-FABRIC
fabric_version = 0.36.0+1.17 fabric_version = 0.32.9+1.16

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View file

@ -41,7 +41,7 @@ public class BiomeAPI {
} }
public static void registerBiome(BCLBiome biome) { public static void registerBiome(BCLBiome biome) {
if (BuiltinRegistries.BIOME.get(biome.getID()) == null) { if (!BuiltinRegistries.BIOME.containsKey(biome.getID())) {
Registry.register(BuiltinRegistries.BIOME, biome.getID(), biome.getBiome()); Registry.register(BuiltinRegistries.BIOME, biome.getID(), biome.getBiome());
} }
ID_MAP.put(biome.getID(), biome); ID_MAP.put(biome.getID(), biome);
@ -91,9 +91,6 @@ public class BiomeAPI {
* @return {@link BCLBiome} or {@code BiomeAPI.EMPTY_BIOME}. * @return {@link BCLBiome} or {@code BiomeAPI.EMPTY_BIOME}.
*/ */
public static BCLBiome getFromBiome(Biome biome) { public static BCLBiome getFromBiome(Biome biome) {
if (biomeRegistry == null) {
return EMPTY_BIOME;
}
return ID_MAP.getOrDefault(biomeRegistry.getKey(biome), EMPTY_BIOME); return ID_MAP.getOrDefault(biomeRegistry.getKey(biome), EMPTY_BIOME);
} }

View file

@ -1,6 +1,5 @@
package ru.bclib.blockentities; package ru.bclib.blockentities;
import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
import net.minecraft.core.Vec3i; import net.minecraft.core.Vec3i;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
@ -27,13 +26,13 @@ public class BaseBarrelBlockEntity extends RandomizableContainerBlockEntity {
private NonNullList<ItemStack> inventory; private NonNullList<ItemStack> inventory;
private int viewerCount; private int viewerCount;
private BaseBarrelBlockEntity(BlockEntityType<?> type, BlockPos blockPos, BlockState blockState) { private BaseBarrelBlockEntity(BlockEntityType<?> type) {
super(type, blockPos, blockState); super(type);
this.inventory = NonNullList.withSize(27, ItemStack.EMPTY); this.inventory = NonNullList.withSize(27, ItemStack.EMPTY);
} }
public BaseBarrelBlockEntity(BlockPos blockPos, BlockState blockState) { public BaseBarrelBlockEntity() {
this(BaseBlockEntities.BARREL, blockPos, blockState); this(BaseBlockEntities.BARREL);
} }
public CompoundTag save(CompoundTag tag) { public CompoundTag save(CompoundTag tag) {
@ -45,8 +44,8 @@ public class BaseBarrelBlockEntity extends RandomizableContainerBlockEntity {
return tag; return tag;
} }
public void load(CompoundTag tag) { public void load(BlockState state, CompoundTag tag) {
super.load(tag); super.load(state, tag);
this.inventory = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); this.inventory = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY);
if (!this.tryLoadLootTable(tag)) { if (!this.tryLoadLootTable(tag)) {
ContainerHelper.loadAllItems(tag, this.inventory); ContainerHelper.loadAllItems(tag, this.inventory);
@ -98,7 +97,10 @@ public class BaseBarrelBlockEntity extends RandomizableContainerBlockEntity {
public void tick() { public void tick() {
if (level != null) { if (level != null) {
viewerCount = ChestBlockEntity.getOpenCount(level, worldPosition); int x = worldPosition.getX();
int y = worldPosition.getY();
int z = worldPosition.getZ();
viewerCount = ChestBlockEntity.getOpenCount(level, this, x, y, z);
if (viewerCount > 0) { if (viewerCount > 0) {
scheduleUpdate(); scheduleUpdate();
} else { } else {

View file

@ -1,12 +1,10 @@
package ru.bclib.blockentities; package ru.bclib.blockentities;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.entity.ChestBlockEntity; import net.minecraft.world.level.block.entity.ChestBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import ru.bclib.registry.BaseBlockEntities; import ru.bclib.registry.BaseBlockEntities;
public class BaseChestBlockEntity extends ChestBlockEntity { public class BaseChestBlockEntity extends ChestBlockEntity {
public BaseChestBlockEntity(BlockPos blockPos, BlockState blockState) { public BaseChestBlockEntity() {
super(BaseBlockEntities.CHEST, blockPos, blockState); super(BaseBlockEntities.CHEST);
} }
} }

View file

@ -1,6 +1,5 @@
package ru.bclib.blockentities; package ru.bclib.blockentities;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
@ -8,12 +7,11 @@ import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.FurnaceMenu; import net.minecraft.world.inventory.FurnaceMenu;
import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity; import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import ru.bclib.registry.BaseBlockEntities; import ru.bclib.registry.BaseBlockEntities;
public class BaseFurnaceBlockEntity extends AbstractFurnaceBlockEntity { public class BaseFurnaceBlockEntity extends AbstractFurnaceBlockEntity {
public BaseFurnaceBlockEntity(BlockPos blockPos, BlockState blockState) { public BaseFurnaceBlockEntity() {
super(BaseBlockEntities.FURNACE, blockPos, blockState, RecipeType.SMELTING); super(BaseBlockEntities.FURNACE, RecipeType.SMELTING);
} }
protected Component getDefaultName() { protected Component getDefaultName() {

View file

@ -1,14 +1,12 @@
package ru.bclib.blockentities; package ru.bclib.blockentities;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.entity.SignBlockEntity; import net.minecraft.world.level.block.entity.SignBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import ru.bclib.registry.BaseBlockEntities; import ru.bclib.registry.BaseBlockEntities;
public class BaseSignBlockEntity extends SignBlockEntity { public class BaseSignBlockEntity extends SignBlockEntity {
public BaseSignBlockEntity(BlockPos blockPos, BlockState blockState) { public BaseSignBlockEntity() {
super(blockPos, blockState); super();
} }
@Override @Override

View file

@ -6,40 +6,24 @@ import java.util.function.Supplier;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;
public class DynamicBlockEntityType<T extends BlockEntity> extends BlockEntityType<T> { public class DynamicBlockEntityType<T extends BlockEntity> extends BlockEntityType<T> {
private final Set<Block> validBlocks = Sets.newHashSet(); private final Set<Block> validBlocks = Sets.newHashSet();
private final BlockEntitySupplier<? extends T> factory;
public DynamicBlockEntityType(BlockEntitySupplier<? extends T> supplier) { public DynamicBlockEntityType(Supplier<? extends T> supplier) {
super(null, Collections.emptySet(), null); super(supplier, Collections.emptySet(), null);
this.factory = supplier;
} }
@Override @Override
@Nullable public T create(BlockPos blockPos, BlockState blockState) { public boolean isValid(Block block) {
return factory.create(blockPos, blockState); return validBlocks.contains(block);
}
@Override
public boolean isValid(BlockState blockState) {
return validBlocks.contains(blockState.getBlock());
} }
public void registerBlock(Block block) { public void registerBlock(Block block) {
validBlocks.add(block); validBlocks.add(block);
} }
@FunctionalInterface
public
interface BlockEntitySupplier<T extends BlockEntity> {
T create(BlockPos blockPos, BlockState blockState);
}
} }

View file

@ -9,8 +9,6 @@ import org.jetbrains.annotations.Nullable;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; 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.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.client.resources.model.UnbakedModel;
@ -35,7 +33,7 @@ public abstract class BaseAnvilBlock extends AnvilBlock implements BlockModelPro
public static final IntegerProperty DESTRUCTION = BlockProperties.DESTRUCTION; public static final IntegerProperty DESTRUCTION = BlockProperties.DESTRUCTION;
public BaseAnvilBlock(MaterialColor color) { public BaseAnvilBlock(MaterialColor color) {
super(FabricBlockSettings.copyOf(Blocks.ANVIL).mapColor(color)); super(FabricBlockSettings.copyOf(Blocks.ANVIL).materialColor(color));
} }
@Override @Override
@ -45,7 +43,6 @@ public abstract class BaseAnvilBlock extends AnvilBlock implements BlockModelPro
} }
@Override @Override
@SuppressWarnings("deprecation")
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack dropStack = new ItemStack(this); ItemStack dropStack = new ItemStack(this);
int destruction = state.getValue(DESTRUCTION); int destruction = state.getValue(DESTRUCTION);
@ -65,13 +62,11 @@ public abstract class BaseAnvilBlock extends AnvilBlock implements BlockModelPro
public abstract Item asItem(); public abstract Item asItem();
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation blockId) { public BlockModel getItemModel(ResourceLocation blockId) {
return getBlockModel(blockId, defaultBlockState()); return getBlockModel(blockId, defaultBlockState());
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
int destruction = blockState.getValue(DESTRUCTION); int destruction = blockState.getValue(DESTRUCTION);
String name = blockId.getPath(); String name = blockId.getPath();
@ -84,7 +79,6 @@ public abstract class BaseAnvilBlock extends AnvilBlock implements BlockModelPro
} }
@Override @Override
@Environment(EnvType.CLIENT)
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) { public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
int destruction = blockState.getValue(DESTRUCTION); int destruction = blockState.getValue(DESTRUCTION);
String modId = stateId.getNamespace(); String modId = stateId.getNamespace();

View file

@ -16,13 +16,12 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.DirectionProperty; import net.minecraft.world.level.block.state.properties.DirectionProperty;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
@SuppressWarnings("deprecation")
public abstract class BaseAttachedBlock extends BaseBlockNotFull { public abstract class BaseAttachedBlock extends BaseBlockNotFull {
public static final DirectionProperty FACING = BlockStateProperties.FACING; public static final DirectionProperty FACING = BlockStateProperties.FACING;
public BaseAttachedBlock(Properties settings) { public BaseAttachedBlock(Properties settings) {
super(settings); super(settings);
registerDefaultState(defaultBlockState().setValue(FACING, Direction.UP)); this.registerDefaultState(this.defaultBlockState().setValue(FACING, Direction.UP));
} }
@Override @Override
@ -32,7 +31,7 @@ public abstract class BaseAttachedBlock extends BaseBlockNotFull {
@Override @Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) { public BlockState getStateForPlacement(BlockPlaceContext ctx) {
BlockState blockState = defaultBlockState(); BlockState blockState = this.defaultBlockState();
LevelReader worldView = ctx.getLevel(); LevelReader worldView = ctx.getLevel();
BlockPos blockPos = ctx.getClickedPos(); BlockPos blockPos = ctx.getClickedPos();
Direction[] directions = ctx.getNearestLookingDirections(); Direction[] directions = ctx.getNearestLookingDirections();
@ -48,7 +47,7 @@ public abstract class BaseAttachedBlock extends BaseBlockNotFull {
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
Direction direction = state.getValue(FACING); Direction direction = (Direction) state.getValue(FACING);
BlockPos blockPos = pos.relative(direction.getOpposite()); BlockPos blockPos = pos.relative(direction.getOpposite());
return canSupportCenter(world, blockPos, direction) || world.getBlockState(blockPos).is(BlockTags.LEAVES); return canSupportCenter(world, blockPos, direction) || world.getBlockState(blockPos).is(BlockTags.LEAVES);
} }

View file

@ -7,8 +7,6 @@ import java.util.Random;
import org.jetbrains.annotations.Nullable; 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.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.BlockModelRotation; import net.minecraft.client.resources.model.BlockModelRotation;
@ -46,12 +44,11 @@ public class BaseBarrelBlock extends BarrelBlock implements BlockModelProvider {
} }
@Override @Override
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) { public BlockEntity newBlockEntity(BlockGetter world) {
return BaseBlockEntities.BARREL.create(blockPos, blockState); return BaseBlockEntities.BARREL.create();
} }
@Override @Override
@SuppressWarnings("deprecation")
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
List<ItemStack> drop = super.getDrops(state, builder); List<ItemStack> drop = super.getDrops(state, builder);
drop.add(new ItemStack(this.asItem())); drop.add(new ItemStack(this.asItem()));
@ -100,13 +97,11 @@ public class BaseBarrelBlock extends BarrelBlock implements BlockModelProvider {
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation blockId) { public BlockModel getItemModel(ResourceLocation blockId) {
return getBlockModel(blockId, defaultBlockState()); return getBlockModel(blockId, defaultBlockState());
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
Optional<String> pattern; Optional<String> pattern;
if (blockState.getValue(OPEN)) { if (blockState.getValue(OPEN)) {
@ -118,7 +113,6 @@ public class BaseBarrelBlock extends BarrelBlock implements BlockModelProvider {
} }
@Override @Override
@Environment(EnvType.CLIENT)
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) { public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
String open = blockState.getValue(OPEN) ? "_open" : ""; String open = blockState.getValue(OPEN) ? "_open" : "";
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
@ -131,8 +125,8 @@ public class BaseBarrelBlock extends BarrelBlock implements BlockModelProvider {
case EAST: rotation = BlockModelRotation.X90_Y90; break; case EAST: rotation = BlockModelRotation.X90_Y90; break;
case SOUTH: rotation = BlockModelRotation.X90_Y180; break; case SOUTH: rotation = BlockModelRotation.X90_Y180; break;
case WEST: rotation = BlockModelRotation.X90_Y270; break; case WEST: rotation = BlockModelRotation.X90_Y270; break;
case DOWN: rotation = BlockModelRotation.X180_Y0; break; case DOWN:
default: break; default: rotation = BlockModelRotation.X180_Y0; break;
} }
return ModelsHelper.createMultiVariant(modelId, rotation.getRotation(), false); return ModelsHelper.createMultiVariant(modelId, rotation.getRotation(), false);
} }

View file

@ -17,7 +17,6 @@ public class BaseBlock extends Block implements BlockModelProvider {
} }
@Override @Override
@SuppressWarnings("deprecation")
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this)); return Collections.singletonList(new ItemStack(this));
} }

View file

@ -3,7 +3,6 @@ package ru.bclib.blocks;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import net.minecraft.core.BlockPos;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.BaseEntityBlock; import net.minecraft.world.level.block.BaseEntityBlock;
@ -17,12 +16,11 @@ public class BaseBlockWithEntity extends BaseEntityBlock {
} }
@Override @Override
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) { public BlockEntity newBlockEntity(BlockGetter world) {
return null; return null;
} }
@Override @Override
@SuppressWarnings("deprecation")
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this)); return Collections.singletonList(new ItemStack(this));
} }

View file

@ -6,8 +6,6 @@ import java.util.Optional;
import org.jetbrains.annotations.Nullable; 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.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
@ -41,7 +39,6 @@ public class BaseBookshelfBlock extends BaseBlock {
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
Optional<String> pattern = PatternsHelper.createJson(BasePatterns.BLOCK_BOOKSHELF, replacePath(blockId)); Optional<String> pattern = PatternsHelper.createJson(BasePatterns.BLOCK_BOOKSHELF, replacePath(blockId));
return ModelsHelper.fromPattern(pattern); return ModelsHelper.fromPattern(pattern);

View file

@ -7,8 +7,6 @@ import java.util.Optional;
import org.jetbrains.annotations.Nullable; 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.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.BlockModelRotation; import net.minecraft.client.resources.model.BlockModelRotation;
import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.client.resources.model.UnbakedModel;
@ -35,13 +33,11 @@ public abstract class BaseButtonBlock extends ButtonBlock implements BlockModelP
} }
@Override @Override
@SuppressWarnings("deprecation")
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this)); return Collections.singletonList(new ItemStack(this));
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation blockId) { public BlockModel getItemModel(ResourceLocation blockId) {
ResourceLocation parentId = Registry.BLOCK.getKey(parent); ResourceLocation parentId = Registry.BLOCK.getKey(parent);
Optional<String> pattern = PatternsHelper.createJson(BasePatterns.ITEM_BUTTON, parentId); Optional<String> pattern = PatternsHelper.createJson(BasePatterns.ITEM_BUTTON, parentId);
@ -49,7 +45,6 @@ public abstract class BaseButtonBlock extends ButtonBlock implements BlockModelP
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
ResourceLocation parentId = Registry.BLOCK.getKey(parent); ResourceLocation parentId = Registry.BLOCK.getKey(parent);
Optional<String> pattern = blockState.getValue(POWERED) ? Optional<String> pattern = blockState.getValue(POWERED) ?
@ -59,7 +54,6 @@ public abstract class BaseButtonBlock extends ButtonBlock implements BlockModelP
} }
@Override @Override
@Environment(EnvType.CLIENT)
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) { public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
String powered = blockState.getValue(POWERED) ? "_powered" : ""; String powered = blockState.getValue(POWERED) ? "_powered" : "";
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),

View file

@ -7,8 +7,6 @@ import java.util.Optional;
import org.jetbrains.annotations.Nullable; 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.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.client.resources.model.UnbakedModel;
@ -29,30 +27,26 @@ import ru.bclib.interfaces.IRenderTyped;
public class BaseChainBlock extends ChainBlock implements BlockModelProvider, IRenderTyped { public class BaseChainBlock extends ChainBlock implements BlockModelProvider, IRenderTyped {
public BaseChainBlock(MaterialColor color) { public BaseChainBlock(MaterialColor color) {
super(FabricBlockSettings.copyOf(Blocks.CHAIN).mapColor(color)); super(FabricBlockSettings.copyOf(Blocks.CHAIN).materialColor(color));
} }
@Override @Override
@SuppressWarnings("deprecation")
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this)); return Collections.singletonList(new ItemStack(this));
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation blockId) { public BlockModel getItemModel(ResourceLocation blockId) {
return ModelsHelper.createItemModel(blockId); return ModelsHelper.createItemModel(blockId);
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
Optional<String> pattern = PatternsHelper.createJson(BasePatterns.BLOCK_CHAIN, blockId); Optional<String> pattern = PatternsHelper.createJson(BasePatterns.BLOCK_CHAIN, blockId);
return ModelsHelper.fromPattern(pattern); return ModelsHelper.fromPattern(pattern);
} }
@Override @Override
@Environment(EnvType.CLIENT)
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) { public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
Direction.Axis axis = blockState.getValue(AXIS); Direction.Axis axis = blockState.getValue(AXIS);
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),

View file

@ -3,11 +3,8 @@ package ru.bclib.blocks;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import net.minecraft.core.BlockPos;
import org.jetbrains.annotations.Nullable; 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.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
@ -34,12 +31,12 @@ public class BaseChestBlock extends ChestBlock implements BlockModelProvider {
} }
@Override @Override
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) { public BlockEntity newBlockEntity(BlockGetter world)
return BaseBlockEntities.CHEST.create(blockPos, blockState); {
return BaseBlockEntities.CHEST.create();
} }
@Override @Override
@SuppressWarnings("deprecation")
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder)
{ {
List<ItemStack> drop = super.getDrops(state, builder); List<ItemStack> drop = super.getDrops(state, builder);
@ -48,14 +45,12 @@ public class BaseChestBlock extends ChestBlock implements BlockModelProvider {
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation blockId) { public BlockModel getItemModel(ResourceLocation blockId) {
Optional<String> pattern = PatternsHelper.createJson(BasePatterns.ITEM_CHEST, blockId); Optional<String> pattern = PatternsHelper.createJson(BasePatterns.ITEM_CHEST, blockId);
return ModelsHelper.fromPattern(pattern); return ModelsHelper.fromPattern(pattern);
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
ResourceLocation parentId = Registry.BLOCK.getKey(parent); ResourceLocation parentId = Registry.BLOCK.getKey(parent);
return ModelsHelper.createBlockEmpty(parentId); return ModelsHelper.createBlockEmpty(parentId);

View file

@ -7,8 +7,6 @@ import java.util.Optional;
import org.jetbrains.annotations.Nullable; 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.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.client.resources.model.UnbakedModel;
@ -30,26 +28,22 @@ public class BaseComposterBlock extends ComposterBlock implements BlockModelProv
} }
@Override @Override
@SuppressWarnings("deprecation")
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this.asItem())); return Collections.singletonList(new ItemStack(this.asItem()));
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation resourceLocation) { public BlockModel getItemModel(ResourceLocation resourceLocation) {
return getBlockModel(resourceLocation, defaultBlockState()); return getBlockModel(resourceLocation, defaultBlockState());
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
Optional<String> pattern = PatternsHelper.createJson(BasePatterns.BLOCK_COMPOSTER, blockId); Optional<String> pattern = PatternsHelper.createJson(BasePatterns.BLOCK_COMPOSTER, blockId);
return ModelsHelper.fromPattern(pattern); return ModelsHelper.fromPattern(pattern);
} }
@Override @Override
@Environment(EnvType.CLIENT)
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) { public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath()); ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath());
registerBlockModel(stateId, modelId, blockState, modelCache); registerBlockModel(stateId, modelId, blockState, modelCache);

View file

@ -7,8 +7,6 @@ import java.util.Optional;
import org.jetbrains.annotations.Nullable; 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.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
@ -28,19 +26,16 @@ public class BaseCraftingTableBlock extends CraftingTableBlock implements BlockM
} }
@Override @Override
@SuppressWarnings("deprecation")
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this.asItem())); return Collections.singletonList(new ItemStack(this.asItem()));
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation resourceLocation) { public BlockModel getItemModel(ResourceLocation resourceLocation) {
return getBlockModel(resourceLocation, defaultBlockState()); return getBlockModel(resourceLocation, defaultBlockState());
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
String blockName = blockId.getPath(); String blockName = blockId.getPath();
Optional<String> pattern = PatternsHelper.createJson(BasePatterns.BLOCK_SIDED, new HashMap<String, String>() { Optional<String> pattern = PatternsHelper.createJson(BasePatterns.BLOCK_SIDED, new HashMap<String, String>() {

View file

@ -108,7 +108,6 @@ public class BaseCropBlock extends BasePlantBlock {
} }
@Override @Override
@SuppressWarnings("deprecation")
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) { public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
super.tick(state, world, pos, random); super.tick(state, world, pos, random);
if (isBonemealSuccess(world, random, pos, state) && random.nextInt(8) == 0) { if (isBonemealSuccess(world, random, pos, state) && random.nextInt(8) == 0) {

View file

@ -7,8 +7,6 @@ import java.util.Optional;
import org.jetbrains.annotations.Nullable; 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.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.BlockModelRotation; import net.minecraft.client.resources.model.BlockModelRotation;
@ -36,7 +34,6 @@ public class BaseDoorBlock extends DoorBlock implements IRenderTyped, BlockModel
} }
@Override @Override
@SuppressWarnings("deprecation")
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
if (state.getValue(HALF) == DoubleBlockHalf.LOWER) if (state.getValue(HALF) == DoubleBlockHalf.LOWER)
return Collections.singletonList(new ItemStack(this.asItem())); return Collections.singletonList(new ItemStack(this.asItem()));
@ -50,7 +47,6 @@ public class BaseDoorBlock extends DoorBlock implements IRenderTyped, BlockModel
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
DoorType doorType = getDoorType(blockState); DoorType doorType = getDoorType(blockState);
Optional<String> pattern = PatternsHelper.createJson(BasePatterns.BLOCK_DOOR_BOTTOM, resourceLocation); Optional<String> pattern = PatternsHelper.createJson(BasePatterns.BLOCK_DOOR_BOTTOM, resourceLocation);
@ -70,7 +66,6 @@ public class BaseDoorBlock extends DoorBlock implements IRenderTyped, BlockModel
} }
@Override @Override
@Environment(EnvType.CLIENT)
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) { public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
Direction facing = blockState.getValue(FACING); Direction facing = blockState.getValue(FACING);
DoorType doorType = getDoorType(blockState); DoorType doorType = getDoorType(blockState);

View file

@ -38,7 +38,6 @@ import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped; import ru.bclib.interfaces.IRenderTyped;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
@SuppressWarnings("deprecation")
public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements IRenderTyped, BonemealableBlock { public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements IRenderTyped, BonemealableBlock {
private static final VoxelShape SHAPE = Block.box(4, 2, 4, 12, 16, 12); private static final VoxelShape SHAPE = Block.box(4, 2, 4, 12, 16, 12);
public static final IntegerProperty ROTATION = BlockProperties.ROTATION; public static final IntegerProperty ROTATION = BlockProperties.ROTATION;
@ -111,7 +110,7 @@ public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements I
} }
ItemStack tool = builder.getParameter(LootContextParams.TOOL); ItemStack tool = builder.getParameter(LootContextParams.TOOL);
if (tool != null && FabricToolTags.SHEARS.contains(tool.getItem()) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { if (tool != null && tool.getItem().is(FabricToolTags.SHEARS) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
return Lists.newArrayList(new ItemStack(this)); return Lists.newArrayList(new ItemStack(this));
} }
else { else {

View file

@ -7,8 +7,6 @@ import java.util.Optional;
import org.jetbrains.annotations.Nullable; 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.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.BlockModelRotation; import net.minecraft.client.resources.model.BlockModelRotation;
@ -35,13 +33,11 @@ public class BaseFenceBlock extends FenceBlock implements BlockModelProvider {
} }
@Override @Override
@SuppressWarnings("deprecation")
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this)); return Collections.singletonList(new ItemStack(this));
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation blockId) { public BlockModel getItemModel(ResourceLocation blockId) {
ResourceLocation parentId = Registry.BLOCK.getKey(parent); ResourceLocation parentId = Registry.BLOCK.getKey(parent);
Optional<String> pattern = PatternsHelper.createJson(BasePatterns.ITEM_FENCE, parentId); Optional<String> pattern = PatternsHelper.createJson(BasePatterns.ITEM_FENCE, parentId);
@ -49,7 +45,6 @@ public class BaseFenceBlock extends FenceBlock implements BlockModelProvider {
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
ResourceLocation parentId = Registry.BLOCK.getKey(parent); ResourceLocation parentId = Registry.BLOCK.getKey(parent);
String path = blockId.getPath(); String path = blockId.getPath();
@ -64,7 +59,6 @@ public class BaseFenceBlock extends FenceBlock implements BlockModelProvider {
} }
@Override @Override
@Environment(EnvType.CLIENT)
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) { public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
ResourceLocation postId = new ResourceLocation(stateId.getNamespace(), ResourceLocation postId = new ResourceLocation(stateId.getNamespace(),
"block/" + stateId.getPath() + "_post"); "block/" + stateId.getPath() + "_post");

View file

@ -1,9 +1,14 @@
package ru.bclib.blocks; 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.Lists;
import com.google.common.collect.Maps; 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.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.client.resources.model.UnbakedModel;
@ -13,17 +18,14 @@ import net.minecraft.stats.Stats;
import net.minecraft.world.MenuProvider; import net.minecraft.world.MenuProvider;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.FurnaceBlock; 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.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.block.state.BlockState;
import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import org.jetbrains.annotations.Nullable;
import ru.bclib.blockentities.BaseFurnaceBlockEntity; import ru.bclib.blockentities.BaseFurnaceBlockEntity;
import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.BasePatterns;
import ru.bclib.client.models.BlockModelProvider; import ru.bclib.client.models.BlockModelProvider;
@ -31,11 +33,6 @@ import ru.bclib.client.models.ModelsHelper;
import ru.bclib.client.models.PatternsHelper; import ru.bclib.client.models.PatternsHelper;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped; 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 class BaseFurnaceBlock extends FurnaceBlock implements BlockModelProvider, IRenderTyped {
public BaseFurnaceBlock(Block source) { public BaseFurnaceBlock(Block source) {
@ -43,8 +40,8 @@ public class BaseFurnaceBlock extends FurnaceBlock implements BlockModelProvider
} }
@Override @Override
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) { public BlockEntity newBlockEntity(BlockGetter world) {
return new BaseFurnaceBlockEntity(blockPos, blockState); return new BaseFurnaceBlockEntity();
} }
@Override @Override
@ -57,7 +54,6 @@ public class BaseFurnaceBlock extends FurnaceBlock implements BlockModelProvider
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
String blockName = blockId.getPath(); String blockName = blockId.getPath();
Map<String, String> textures = Maps.newHashMap(); Map<String, String> textures = Maps.newHashMap();
@ -77,13 +73,11 @@ public class BaseFurnaceBlock extends FurnaceBlock implements BlockModelProvider
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation resourceLocation) { public BlockModel getItemModel(ResourceLocation resourceLocation) {
return getBlockModel(resourceLocation, defaultBlockState()); return getBlockModel(resourceLocation, defaultBlockState());
} }
@Override @Override
@Environment(EnvType.CLIENT)
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) { public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
String lit = blockState.getValue(LIT) ? "_lit" : ""; String lit = blockState.getValue(LIT) ? "_lit" : "";
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
@ -98,7 +92,6 @@ public class BaseFurnaceBlock extends FurnaceBlock implements BlockModelProvider
} }
@Override @Override
@SuppressWarnings("deprecation")
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
List<ItemStack> drop = Lists.newArrayList(new ItemStack(this)); List<ItemStack> drop = Lists.newArrayList(new ItemStack(this));
BlockEntity blockEntity = builder.getOptionalParameter(LootContextParams.BLOCK_ENTITY); BlockEntity blockEntity = builder.getOptionalParameter(LootContextParams.BLOCK_ENTITY);
@ -110,15 +103,4 @@ public class BaseFurnaceBlock extends FurnaceBlock implements BlockModelProvider
} }
return drop; return drop;
} }
@Override
@Nullable
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState blockState, BlockEntityType<T> blockEntityType) {
return createFurnaceTicker(level, blockEntityType, BaseBlockEntities.FURNACE);
}
@Nullable
protected static <T extends BlockEntity> BlockEntityTicker<T> createFurnaceTicker(Level level, BlockEntityType<T> blockEntityType, BlockEntityType<? extends AbstractFurnaceBlockEntity> blockEntityType2) {
return level.isClientSide ? null : createTickerHelper(blockEntityType, blockEntityType2, AbstractFurnaceBlockEntity::serverTick);
}
} }

View file

@ -7,8 +7,6 @@ import java.util.Optional;
import org.jetbrains.annotations.Nullable; 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.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.client.resources.model.UnbakedModel;
@ -33,19 +31,16 @@ public class BaseGateBlock extends FenceGateBlock implements BlockModelProvider
} }
@Override @Override
@SuppressWarnings("deprecation")
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this)); return Collections.singletonList(new ItemStack(this));
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation resourceLocation) { public BlockModel getItemModel(ResourceLocation resourceLocation) {
return getBlockModel(resourceLocation, defaultBlockState()); return getBlockModel(resourceLocation, defaultBlockState());
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
boolean inWall = blockState.getValue(IN_WALL); boolean inWall = blockState.getValue(IN_WALL);
boolean isOpen = blockState.getValue(OPEN); boolean isOpen = blockState.getValue(OPEN);
@ -62,7 +57,6 @@ public class BaseGateBlock extends FenceGateBlock implements BlockModelProvider
} }
@Override @Override
@Environment(EnvType.CLIENT)
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) { public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
boolean inWall = blockState.getValue(IN_WALL); boolean inWall = blockState.getValue(IN_WALL);
boolean isOpen = blockState.getValue(OPEN); boolean isOpen = blockState.getValue(OPEN);

View file

@ -5,8 +5,6 @@ import java.util.Optional;
import org.jetbrains.annotations.Nullable; 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.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.client.resources.model.UnbakedModel;
@ -39,7 +37,6 @@ import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped; import ru.bclib.interfaces.IRenderTyped;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
@SuppressWarnings("deprecation")
public class BaseLadderBlock extends BaseBlockNotFull implements IRenderTyped, BlockModelProvider { public class BaseLadderBlock extends BaseBlockNotFull implements IRenderTyped, BlockModelProvider {
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING; public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
@ -58,14 +55,17 @@ public class BaseLadderBlock extends BaseBlockNotFull implements IRenderTyped, B
stateManager.add(WATERLOGGED); stateManager.add(WATERLOGGED);
} }
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return switch (state.getValue(FACING)) { switch (state.getValue(FACING)) {
case SOUTH -> SOUTH_SHAPE; case SOUTH:
case WEST -> WEST_SHAPE; return SOUTH_SHAPE;
case EAST -> EAST_SHAPE; case WEST:
default -> NORTH_SHAPE; return WEST_SHAPE;
}; case EAST:
return EAST_SHAPE;
default:
return NORTH_SHAPE;
}
} }
private boolean canPlaceOn(BlockGetter world, BlockPos pos, Direction side) { private boolean canPlaceOn(BlockGetter world, BlockPos pos, Direction side) {
@ -76,7 +76,7 @@ public class BaseLadderBlock extends BaseBlockNotFull implements IRenderTyped, B
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
Direction direction = state.getValue(FACING); Direction direction = state.getValue(FACING);
return canPlaceOn(world, pos.relative(direction.getOpposite()), direction); return this.canPlaceOn(world, pos.relative(direction.getOpposite()), direction);
} }
@Override @Override
@ -142,20 +142,17 @@ public class BaseLadderBlock extends BaseBlockNotFull implements IRenderTyped, B
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation blockId) { public BlockModel getItemModel(ResourceLocation blockId) {
return ModelsHelper.createBlockItem(blockId); return ModelsHelper.createBlockItem(blockId);
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
Optional<String> pattern = PatternsHelper.createJson(BasePatterns.BLOCK_LADDER, blockId); Optional<String> pattern = PatternsHelper.createJson(BasePatterns.BLOCK_LADDER, blockId);
return ModelsHelper.fromPattern(pattern); return ModelsHelper.fromPattern(pattern);
} }
@Override @Override
@Environment(EnvType.CLIENT)
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) { public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath()); ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath());
registerBlockModel(stateId, modelId, blockState, modelCache); registerBlockModel(stateId, modelId, blockState, modelCache);

View file

@ -29,7 +29,7 @@ public class BaseLeavesBlock extends LeavesBlock implements BlockModelProvider,
public BaseLeavesBlock(Block sapling, MaterialColor color) { public BaseLeavesBlock(Block sapling, MaterialColor color) {
super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES) super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES)
.mapColor(color) .materialColor(color)
.breakByTool(FabricToolTags.HOES) .breakByTool(FabricToolTags.HOES)
.breakByTool(FabricToolTags.SHEARS) .breakByTool(FabricToolTags.SHEARS)
.breakByHand(true) .breakByHand(true)
@ -41,7 +41,7 @@ public class BaseLeavesBlock extends LeavesBlock implements BlockModelProvider,
public BaseLeavesBlock(Block sapling, MaterialColor color, int light) { public BaseLeavesBlock(Block sapling, MaterialColor color, int light) {
super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES) super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES)
.mapColor(color) .materialColor(color)
.luminance(light) .luminance(light)
.breakByTool(FabricToolTags.HOES) .breakByTool(FabricToolTags.HOES)
.breakByTool(FabricToolTags.SHEARS) .breakByTool(FabricToolTags.SHEARS)
@ -57,11 +57,10 @@ public class BaseLeavesBlock extends LeavesBlock implements BlockModelProvider,
} }
@Override @Override
@SuppressWarnings("deprecation")
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getParameter(LootContextParams.TOOL); ItemStack tool = builder.getParameter(LootContextParams.TOOL);
if (tool != null) { if (tool != null) {
if (FabricToolTags.SHEARS.contains(tool.getItem()) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { if (tool.getItem().is(FabricToolTags.SHEARS) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
return Collections.singletonList(new ItemStack(this)); return Collections.singletonList(new ItemStack(this));
} }
int fortune = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.BLOCK_FORTUNE, tool); int fortune = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.BLOCK_FORTUNE, tool);

View file

@ -34,7 +34,6 @@ public class BaseMetalBarsBlock extends IronBarsBlock implements BlockModelProvi
} }
@Override @Override
@SuppressWarnings("deprecation")
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this)); return Collections.singletonList(new ItemStack(this));
} }
@ -53,13 +52,11 @@ public class BaseMetalBarsBlock extends IronBarsBlock implements BlockModelProvi
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation resourceLocation) { public BlockModel getItemModel(ResourceLocation resourceLocation) {
return ModelsHelper.createBlockItem(resourceLocation); return ModelsHelper.createBlockItem(resourceLocation);
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
ResourceLocation thisId = Registry.BLOCK.getKey(this); ResourceLocation thisId = Registry.BLOCK.getKey(this);
String path = blockId.getPath(); String path = blockId.getPath();
@ -74,7 +71,6 @@ public class BaseMetalBarsBlock extends IronBarsBlock implements BlockModelProvi
} }
@Override @Override
@Environment(EnvType.CLIENT)
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) { public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
ResourceLocation postId = new ResourceLocation(stateId.getNamespace(), ResourceLocation postId = new ResourceLocation(stateId.getNamespace(),
"block/" + stateId.getPath() + "_post"); "block/" + stateId.getPath() + "_post");
@ -100,7 +96,7 @@ public class BaseMetalBarsBlock extends IronBarsBlock implements BlockModelProvi
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public boolean skipRendering(BlockState state, BlockState stateFrom, Direction direction) { public boolean skipRendering(BlockState state, BlockState stateFrom, Direction direction) {
if (direction.getAxis().isVertical() && stateFrom.getBlock() == this && !stateFrom.equals(state)) { if (direction.getAxis().isVertical() && stateFrom.getBlock().is(this) && !stateFrom.equals(state)) {
return false; return false;
} }
return super.skipRendering(state, stateFrom, direction); return super.skipRendering(state, stateFrom, direction);

View file

@ -8,7 +8,6 @@ import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.util.valueproviders.UniformInt;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.item.enchantment.EnchantmentHelper;
@ -27,20 +26,26 @@ public class BaseOreBlock extends OreBlock implements BlockModelProvider {
private final Item dropItem; private final Item dropItem;
private final int minCount; private final int minCount;
private final int maxCount; private final int maxCount;
private final int experience;
public BaseOreBlock(Item drop, int minCount, int maxCount, int experience) { public BaseOreBlock(Item drop, int minCount, int maxCount, int experience) {
super(FabricBlockSettings.of(Material.STONE, MaterialColor.SAND) super(FabricBlockSettings.of(Material.STONE, MaterialColor.SAND)
.hardness(3F) .hardness(3F)
.resistance(9F) .resistance(9F)
.requiresCorrectToolForDrops() .requiresCorrectToolForDrops()
.sound(SoundType.STONE), UniformInt.of(1, experience)); .sound(SoundType.STONE));
this.dropItem = drop; this.dropItem = drop;
this.minCount = minCount; this.minCount = minCount;
this.maxCount = maxCount; this.maxCount = maxCount;
this.experience = experience;
}
@Override
protected int xpOnDrop(Random random) {
return this.experience > 0 ? random.nextInt(experience) + 1 : 0;
} }
@Override @Override
@SuppressWarnings("deprecation")
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getParameter(LootContextParams.TOOL); ItemStack tool = builder.getParameter(LootContextParams.TOOL);
if (tool != null && tool.isCorrectToolForDrops(state)) { if (tool != null && tool.isCorrectToolForDrops(state)) {

View file

@ -9,8 +9,6 @@ import org.jetbrains.annotations.Nullable;
import com.google.common.collect.Maps; 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.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.client.resources.model.UnbakedModel;
@ -68,13 +66,11 @@ public class BasePathBlock extends BaseBlockNotFull {
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation blockId) { public BlockModel getItemModel(ResourceLocation blockId) {
return getBlockModel(blockId, defaultBlockState()); return getBlockModel(blockId, defaultBlockState());
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
String name = blockId.getPath(); String name = blockId.getPath();
ResourceLocation bottomId = Registry.BLOCK.getKey(baseBlock); ResourceLocation bottomId = Registry.BLOCK.getKey(baseBlock);
@ -89,7 +85,6 @@ public class BasePathBlock extends BaseBlockNotFull {
} }
@Override @Override
@Environment(EnvType.CLIENT)
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) { public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath()); ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath());
registerBlockModel(stateId, modelId, blockState, modelCache); registerBlockModel(stateId, modelId, blockState, modelCache);

View file

@ -33,7 +33,6 @@ import net.minecraft.world.phys.shapes.VoxelShape;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped; import ru.bclib.interfaces.IRenderTyped;
@SuppressWarnings("deprecation")
public abstract class BasePlantBlock extends BaseBlockNotFull implements IRenderTyped, BonemealableBlock { public abstract class BasePlantBlock extends BaseBlockNotFull implements IRenderTyped, BonemealableBlock {
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 14, 12); private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 14, 12);
@ -98,7 +97,7 @@ public abstract class BasePlantBlock extends BaseBlockNotFull implements IRender
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getParameter(LootContextParams.TOOL); ItemStack tool = builder.getParameter(LootContextParams.TOOL);
if (tool != null && FabricToolTags.SHEARS.contains(tool.getItem()) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { if (tool != null && tool.getItem().is(FabricToolTags.SHEARS) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
return Lists.newArrayList(new ItemStack(this)); return Lists.newArrayList(new ItemStack(this));
} }
else { else {

View file

@ -55,7 +55,6 @@ public abstract class BasePlantWithAgeBlock extends BasePlantBlock {
} }
@Override @Override
@SuppressWarnings("deprecation")
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) { public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
super.tick(state, world, pos, random); super.tick(state, world, pos, random);
if (random.nextInt(8) == 0) { if (random.nextInt(8) == 0) {

View file

@ -7,8 +7,6 @@ import java.util.Optional;
import org.jetbrains.annotations.Nullable; 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.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.client.resources.model.UnbakedModel;
@ -33,19 +31,16 @@ public class BasePressurePlateBlock extends PressurePlateBlock implements BlockM
} }
@Override @Override
@SuppressWarnings("deprecation")
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this)); return Collections.singletonList(new ItemStack(this));
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation resourceLocation) { public BlockModel getItemModel(ResourceLocation resourceLocation) {
return getBlockModel(resourceLocation, defaultBlockState()); return getBlockModel(resourceLocation, defaultBlockState());
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
ResourceLocation parentId = Registry.BLOCK.getKey(parent); ResourceLocation parentId = Registry.BLOCK.getKey(parent);
Optional<String> pattern; Optional<String> pattern;
@ -58,7 +53,6 @@ public class BasePressurePlateBlock extends PressurePlateBlock implements BlockM
} }
@Override @Override
@Environment(EnvType.CLIENT)
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) { public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
String state = blockState.getValue(POWERED) ? "_down" : "_up"; String state = blockState.getValue(POWERED) ? "_down" : "_up";
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),

View file

@ -7,8 +7,6 @@ import java.util.Optional;
import org.jetbrains.annotations.Nullable; 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.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.client.resources.model.UnbakedModel;
@ -32,28 +30,25 @@ public class BaseRotatedPillarBlock extends RotatedPillarBlock implements BlockM
} }
@Override @Override
@SuppressWarnings("deprecation")
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this)); return Collections.singletonList(new ItemStack(this));
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation blockId) { public BlockModel getItemModel(ResourceLocation blockId) {
return getBlockModel(blockId, defaultBlockState()); return getBlockModel(blockId, defaultBlockState());
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
Optional<String> pattern = createBlockPattern(blockId); Optional<String> pattern = createBlockPattern(blockId);
return ModelsHelper.fromPattern(pattern); return ModelsHelper.fromPattern(pattern);
} }
@Override @Override
@Environment(EnvType.CLIENT)
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) { public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath()); ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
"block/" + stateId.getPath());
registerBlockModel(stateId, modelId, blockState, modelCache); registerBlockModel(stateId, modelId, blockState, modelCache);
return ModelsHelper.createRotatedModel(modelId, blockState.getValue(AXIS)); return ModelsHelper.createRotatedModel(modelId, blockState.getValue(AXIS));
} }

View file

@ -5,8 +5,6 @@ import java.util.List;
import org.jetbrains.annotations.Nullable; 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.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -48,7 +46,6 @@ import ru.bclib.client.models.ModelsHelper;
import ru.bclib.interfaces.ISpetialItem; import ru.bclib.interfaces.ISpetialItem;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
@SuppressWarnings("deprecation")
public class BaseSignBlock extends SignBlock implements BlockModelProvider, ISpetialItem { public class BaseSignBlock extends SignBlock implements BlockModelProvider, ISpetialItem {
public static final IntegerProperty ROTATION = BlockStateProperties.ROTATION_16; public static final IntegerProperty ROTATION = BlockStateProperties.ROTATION_16;
public static final BooleanProperty FLOOR = BooleanProperty.create("floor"); public static final BooleanProperty FLOOR = BooleanProperty.create("floor");
@ -78,8 +75,8 @@ public class BaseSignBlock extends SignBlock implements BlockModelProvider, ISpe
} }
@Override @Override
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) { public BlockEntity newBlockEntity(BlockGetter world) {
return new BaseSignBlockEntity(blockPos, blockState); return new BaseSignBlockEntity();
} }
@Override @Override
@ -88,7 +85,7 @@ public class BaseSignBlock extends SignBlock implements BlockModelProvider, ISpe
BaseSignBlockEntity sign = (BaseSignBlockEntity) world.getBlockEntity(pos); BaseSignBlockEntity sign = (BaseSignBlockEntity) world.getBlockEntity(pos);
if (sign != null) { if (sign != null) {
if (!world.isClientSide) { if (!world.isClientSide) {
sign.setAllowedPlayerEditor(placer.getUUID()); sign.setAllowedPlayerEditor((Player) placer);
((ServerPlayer) placer).connection.send(new ClientboundOpenSignEditorPacket(pos)); ((ServerPlayer) placer).connection.send(new ClientboundOpenSignEditorPacket(pos));
} else { } else {
sign.setEditable(true); sign.setEditable(true);
@ -149,7 +146,6 @@ public class BaseSignBlock extends SignBlock implements BlockModelProvider, ISpe
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
ResourceLocation parentId = Registry.BLOCK.getKey(parent); ResourceLocation parentId = Registry.BLOCK.getKey(parent);
return ModelsHelper.createBlockEmpty(parentId); return ModelsHelper.createBlockEmpty(parentId);
@ -170,6 +166,12 @@ public class BaseSignBlock extends SignBlock implements BlockModelProvider, ISpe
return Collections.singletonList(new ItemStack(this)); 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 @Override
public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) { public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) {
// TODO Auto-generated method stub // TODO Auto-generated method stub

View file

@ -7,8 +7,6 @@ import java.util.Optional;
import org.jetbrains.annotations.Nullable; 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.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.BlockModelRotation; import net.minecraft.client.resources.model.BlockModelRotation;
@ -35,32 +33,23 @@ public class BaseSlabBlock extends SlabBlock implements BlockModelProvider {
} }
@Override @Override
@SuppressWarnings("deprecation")
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this)); return Collections.singletonList(new ItemStack(this));
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation resourceLocation) { public BlockModel getItemModel(ResourceLocation resourceLocation) {
return getBlockModel(resourceLocation, defaultBlockState()); return getBlockModel(resourceLocation, defaultBlockState());
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
ResourceLocation parentId = Registry.BLOCK.getKey(parent); ResourceLocation parentId = Registry.BLOCK.getKey(parent);
Optional<String> pattern; Optional<String> pattern = PatternsHelper.createJson(BasePatterns.BLOCK_SLAB, parentId);
if (blockState.getValue(TYPE) == SlabType.DOUBLE) {
pattern = PatternsHelper.createBlockSimple(parentId);
} else {
pattern = PatternsHelper.createJson(BasePatterns.BLOCK_SLAB, parentId);
}
return ModelsHelper.fromPattern(pattern); return ModelsHelper.fromPattern(pattern);
} }
@Override @Override
@Environment(EnvType.CLIENT)
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) { public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
SlabType type = blockState.getValue(TYPE); SlabType type = blockState.getValue(TYPE);
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),

View file

@ -7,8 +7,6 @@ import java.util.Optional;
import org.jetbrains.annotations.Nullable; 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.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.BlockModelRotation; import net.minecraft.client.resources.model.BlockModelRotation;
@ -37,19 +35,16 @@ public class BaseStairsBlock extends StairBlock implements BlockModelProvider {
} }
@Override @Override
@SuppressWarnings("deprecation")
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this)); return Collections.singletonList(new ItemStack(this));
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation resourceLocation) { public BlockModel getItemModel(ResourceLocation resourceLocation) {
return getBlockModel(resourceLocation, defaultBlockState()); return getBlockModel(resourceLocation, defaultBlockState());
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
ResourceLocation parentId = Registry.BLOCK.getKey(parent); ResourceLocation parentId = Registry.BLOCK.getKey(parent);
Optional<String> pattern = Optional.empty(); Optional<String> pattern = Optional.empty();
@ -70,7 +65,6 @@ public class BaseStairsBlock extends StairBlock implements BlockModelProvider {
} }
@Override @Override
@Environment(EnvType.CLIENT)
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) { public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
String state; String state;
StairsShape shape = blockState.getValue(SHAPE); StairsShape shape = blockState.getValue(SHAPE);

View file

@ -20,14 +20,13 @@ public class BaseStripableLogBlock extends BaseRotatedPillarBlock {
private final Block striped; private final Block striped;
public BaseStripableLogBlock(MaterialColor color, Block striped) { public BaseStripableLogBlock(MaterialColor color, Block striped) {
super(FabricBlockSettings.copyOf(striped).mapColor(color)); super(FabricBlockSettings.copyOf(striped).materialColor(color));
this.striped = striped; this.striped = striped;
} }
@Override @Override
@SuppressWarnings("deprecation")
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if (FabricToolTags.AXES.contains(player.getMainHandItem().getItem())) { if (player.getMainHandItem().getItem().is(FabricToolTags.AXES)) {
world.playSound(player, pos, SoundEvents.AXE_STRIP, SoundSource.BLOCKS, 1.0F, 1.0F); world.playSound(player, pos, SoundEvents.AXE_STRIP, SoundSource.BLOCKS, 1.0F, 1.0F);
if (!world.isClientSide) { if (!world.isClientSide) {
world.setBlock(pos, striped.defaultBlockState().setValue(RotatedPillarBlock.AXIS, state.getValue(RotatedPillarBlock.AXIS)), 11); world.setBlock(pos, striped.defaultBlockState().setValue(RotatedPillarBlock.AXIS, state.getValue(RotatedPillarBlock.AXIS)), 11);

View file

@ -10,8 +10,6 @@ import org.jetbrains.annotations.Nullable;
import com.google.common.collect.Maps; 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.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
@ -67,7 +65,7 @@ public class BaseTerrainBlock extends BaseBlock {
@Override @Override
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if (pathBlock != null && FabricToolTags.SHOVELS.contains(player.getMainHandItem().getItem())) { if (pathBlock != null && player.getMainHandItem().getItem().is(FabricToolTags.SHOVELS)) {
world.playSound(player, pos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F); world.playSound(player, pos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F);
if (!world.isClientSide) { if (!world.isClientSide) {
world.setBlockAndUpdate(pos, pathBlock.defaultBlockState()); world.setBlockAndUpdate(pos, pathBlock.defaultBlockState());
@ -112,13 +110,11 @@ public class BaseTerrainBlock extends BaseBlock {
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation blockId) { public BlockModel getItemModel(ResourceLocation blockId) {
return getBlockModel(blockId, defaultBlockState()); return getBlockModel(blockId, defaultBlockState());
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
ResourceLocation baseId = Registry.BLOCK.getKey(baseBlock); ResourceLocation baseId = Registry.BLOCK.getKey(baseBlock);
String modId = blockId.getNamespace(); String modId = blockId.getNamespace();
@ -133,7 +129,6 @@ public class BaseTerrainBlock extends BaseBlock {
} }
@Override @Override
@Environment(EnvType.CLIENT)
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) { public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath()); ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath());
registerBlockModel(stateId, modelId, blockState, modelCache); registerBlockModel(stateId, modelId, blockState, modelCache);

View file

@ -8,8 +8,6 @@ import java.util.Optional;
import org.jetbrains.annotations.Nullable; 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.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.BlockModelRotation; import net.minecraft.client.resources.model.BlockModelRotation;
@ -34,7 +32,6 @@ public class BaseTrapdoorBlock extends TrapDoorBlock implements IRenderTyped, Bl
} }
@Override @Override
@SuppressWarnings("deprecation")
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this)); return Collections.singletonList(new ItemStack(this));
} }
@ -45,13 +42,11 @@ public class BaseTrapdoorBlock extends TrapDoorBlock implements IRenderTyped, Bl
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation resourceLocation) { public BlockModel getItemModel(ResourceLocation resourceLocation) {
return getBlockModel(resourceLocation, defaultBlockState()); return getBlockModel(resourceLocation, defaultBlockState());
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
String name = resourceLocation.getPath(); String name = resourceLocation.getPath();
Optional<String> pattern = PatternsHelper.createJson(BasePatterns.BLOCK_TRAPDOOR, new HashMap<String, String>() { Optional<String> pattern = PatternsHelper.createJson(BasePatterns.BLOCK_TRAPDOOR, new HashMap<String, String>() {
@ -66,7 +61,6 @@ public class BaseTrapdoorBlock extends TrapDoorBlock implements IRenderTyped, Bl
} }
@Override @Override
@Environment(EnvType.CLIENT)
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) { public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath()); ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath());
registerBlockModel(stateId, modelId, blockState, modelCache); registerBlockModel(stateId, modelId, blockState, modelCache);

View file

@ -48,7 +48,6 @@ public abstract class BaseUnderwaterWallPlantBlock extends BaseWallPlantBlock im
} }
@Override @Override
@SuppressWarnings("deprecation")
public FluidState getFluidState(BlockState state) { public FluidState getFluidState(BlockState state) {
return Fluids.WATER.getSource(false); return Fluids.WATER.getSource(false);
} }

View file

@ -37,7 +37,6 @@ import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped; import ru.bclib.interfaces.IRenderTyped;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
@SuppressWarnings("deprecation")
public class BaseVineBlock extends BaseBlockNotFull implements IRenderTyped, BonemealableBlock { public class BaseVineBlock extends BaseBlockNotFull implements IRenderTyped, BonemealableBlock {
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE; public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
private static final VoxelShape VOXEL_SHAPE = Block.box(2, 0, 2, 14, 16, 14); private static final VoxelShape VOXEL_SHAPE = Block.box(2, 0, 2, 14, 16, 14);
@ -107,7 +106,7 @@ public class BaseVineBlock extends BaseBlockNotFull implements IRenderTyped, Bon
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getParameter(LootContextParams.TOOL); ItemStack tool = builder.getParameter(LootContextParams.TOOL);
if (tool != null && FabricToolTags.SHEARS.contains(tool.getItem()) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { if (tool != null && tool.getItem().is(FabricToolTags.SHEARS) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
return Lists.newArrayList(new ItemStack(this)); return Lists.newArrayList(new ItemStack(this));
} }
else { else {

View file

@ -7,8 +7,6 @@ import java.util.Optional;
import org.jetbrains.annotations.Nullable; 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.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.BlockModelRotation; import net.minecraft.client.resources.model.BlockModelRotation;
@ -36,13 +34,11 @@ public class BaseWallBlock extends WallBlock implements BlockModelProvider {
} }
@Override @Override
@SuppressWarnings("deprecation")
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this)); return Collections.singletonList(new ItemStack(this));
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation blockId) { public BlockModel getItemModel(ResourceLocation blockId) {
ResourceLocation parentId = Registry.BLOCK.getKey(parent); ResourceLocation parentId = Registry.BLOCK.getKey(parent);
Optional<String> pattern = PatternsHelper.createJson(BasePatterns.ITEM_WALL, parentId); Optional<String> pattern = PatternsHelper.createJson(BasePatterns.ITEM_WALL, parentId);
@ -50,7 +46,6 @@ public class BaseWallBlock extends WallBlock implements BlockModelProvider {
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
ResourceLocation parentId = Registry.BLOCK.getKey(parent); ResourceLocation parentId = Registry.BLOCK.getKey(parent);
String path = blockId.getPath(); String path = blockId.getPath();
@ -68,7 +63,6 @@ public class BaseWallBlock extends WallBlock implements BlockModelProvider {
} }
@Override @Override
@Environment(EnvType.CLIENT)
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) { public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
ResourceLocation postId = new ResourceLocation(stateId.getNamespace(), ResourceLocation postId = new ResourceLocation(stateId.getNamespace(),
"block/" + stateId.getPath() + "_post"); "block/" + stateId.getPath() + "_post");

View file

@ -113,13 +113,11 @@ public abstract class BaseWallPlantBlock extends BasePlantBlock {
} }
@Override @Override
@SuppressWarnings("deprecation")
public BlockState rotate(BlockState state, Rotation rotation) { public BlockState rotate(BlockState state, Rotation rotation) {
return BlocksHelper.rotateHorizontal(state, rotation, FACING); return BlocksHelper.rotateHorizontal(state, rotation, FACING);
} }
@Override @Override
@SuppressWarnings("deprecation")
public BlockState mirror(BlockState state, Mirror mirror) { public BlockState mirror(BlockState state, Mirror mirror) {
return BlocksHelper.mirrorHorizontal(state, mirror, FACING); return BlocksHelper.mirrorHorizontal(state, mirror, FACING);
} }

View file

@ -7,8 +7,6 @@ import java.util.Optional;
import org.jetbrains.annotations.Nullable; 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.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.client.resources.model.UnbakedModel;
@ -33,19 +31,16 @@ public class BaseWeightedPlateBlock extends WeightedPressurePlateBlock implement
} }
@Override @Override
@SuppressWarnings("deprecation")
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this)); return Collections.singletonList(new ItemStack(this));
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation resourceLocation) { public BlockModel getItemModel(ResourceLocation resourceLocation) {
return getBlockModel(resourceLocation, defaultBlockState()); return getBlockModel(resourceLocation, defaultBlockState());
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
ResourceLocation parentId = Registry.BLOCK.getKey(parent); ResourceLocation parentId = Registry.BLOCK.getKey(parent);
Optional<String> pattern; Optional<String> pattern;
@ -58,7 +53,6 @@ public class BaseWeightedPlateBlock extends WeightedPressurePlateBlock implement
} }
@Override @Override
@Environment(EnvType.CLIENT)
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) { public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
String state = blockState.getValue(POWER) > 0 ? "_down" : "_up"; String state = blockState.getValue(POWER) > 0 ? "_down" : "_up";
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),

View file

@ -5,11 +5,8 @@ import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.Random; import java.util.Random;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import org.jetbrains.annotations.Nullable; 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.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -37,7 +34,6 @@ import ru.bclib.client.models.PatternsHelper;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped; import ru.bclib.interfaces.IRenderTyped;
@SuppressWarnings("deprecation")
public abstract class FeatureSaplingBlock extends SaplingBlock implements IRenderTyped, BlockModelProvider { public abstract class FeatureSaplingBlock extends SaplingBlock implements IRenderTyped, BlockModelProvider {
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 14, 12); private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 14, 12);
@ -87,8 +83,7 @@ public abstract class FeatureSaplingBlock extends SaplingBlock implements IRende
@Override @Override
public void advanceTree(ServerLevel world, BlockPos pos, BlockState blockState, Random random) { public void advanceTree(ServerLevel world, BlockPos pos, BlockState blockState, Random random) {
FeaturePlaceContext context = new FeaturePlaceContext(world, world.getChunkSource().getGenerator(), random, pos, null); getFeature().place(world, world.getChunkSource().getGenerator(), random, pos, null);
getFeature().place(context);
} }
@Override @Override
@ -110,13 +105,11 @@ public abstract class FeatureSaplingBlock extends SaplingBlock implements IRende
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation resourceLocation) { public BlockModel getItemModel(ResourceLocation resourceLocation) {
return ModelsHelper.createBlockItem(resourceLocation); return ModelsHelper.createBlockItem(resourceLocation);
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
Optional<String> pattern = PatternsHelper.createJson(BasePatterns.BLOCK_CROSS, resourceLocation); Optional<String> pattern = PatternsHelper.createJson(BasePatterns.BLOCK_CROSS, resourceLocation);
return ModelsHelper.fromPattern(pattern); return ModelsHelper.fromPattern(pattern);

View file

@ -11,7 +11,7 @@ public class SimpleLeavesBlock extends BaseBlockNotFull implements IRenderTyped
public SimpleLeavesBlock(MaterialColor color) { public SimpleLeavesBlock(MaterialColor color) {
super(FabricBlockSettings.of(Material.LEAVES) super(FabricBlockSettings.of(Material.LEAVES)
.strength(0.2F) .strength(0.2F)
.mapColor(color) .materialColor(color)
.sound(SoundType.GRASS) .sound(SoundType.GRASS)
.noOcclusion() .noOcclusion()
.isValidSpawn((state, world, pos, type) -> false) .isValidSpawn((state, world, pos, type) -> false)
@ -22,7 +22,7 @@ public class SimpleLeavesBlock extends BaseBlockNotFull implements IRenderTyped
public SimpleLeavesBlock(MaterialColor color, int light) { public SimpleLeavesBlock(MaterialColor color, int light) {
super(FabricBlockSettings.of(Material.LEAVES) super(FabricBlockSettings.of(Material.LEAVES)
.luminance(light) .luminance(light)
.mapColor(color) .materialColor(color)
.strength(0.2F) .strength(0.2F)
.sound(SoundType.GRASS) .sound(SoundType.GRASS)
.noOcclusion() .noOcclusion()

View file

@ -5,8 +5,6 @@ import java.util.Optional;
import org.jetbrains.annotations.Nullable; 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.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.BlockModelRotation; import net.minecraft.client.resources.model.BlockModelRotation;
@ -43,7 +41,6 @@ import ru.bclib.client.models.PatternsHelper;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped; import ru.bclib.interfaces.IRenderTyped;
@SuppressWarnings("deprecation")
public class StalactiteBlock extends BaseBlockNotFull implements SimpleWaterloggedBlock, LiquidBlockContainer, IRenderTyped { public class StalactiteBlock extends BaseBlockNotFull implements SimpleWaterloggedBlock, LiquidBlockContainer, IRenderTyped {
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public static final BooleanProperty IS_FLOOR = BlockProperties.IS_FLOOR; public static final BooleanProperty IS_FLOOR = BlockProperties.IS_FLOOR;
@ -203,14 +200,12 @@ public class StalactiteBlock extends BaseBlockNotFull implements SimpleWaterlogg
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
Optional<String> pattern = PatternsHelper.createJson(BasePatterns.BLOCK_CROSS_SHADED, resourceLocation); Optional<String> pattern = PatternsHelper.createJson(BasePatterns.BLOCK_CROSS_SHADED, resourceLocation);
return ModelsHelper.fromPattern(pattern); return ModelsHelper.fromPattern(pattern);
} }
@Override @Override
@Environment(EnvType.CLIENT)
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) { public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
BlockModelRotation rotation = blockState.getValue(IS_FLOOR) ? BlockModelRotation.X0_Y0 : BlockModelRotation.X180_Y0; BlockModelRotation rotation = blockState.getValue(IS_FLOOR) ? BlockModelRotation.X0_Y0 : BlockModelRotation.X180_Y0;
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),

View file

@ -20,14 +20,13 @@ public class StripableBarkBlock extends BaseBarkBlock {
private final Block striped; private final Block striped;
public StripableBarkBlock(MaterialColor color, Block striped) { public StripableBarkBlock(MaterialColor color, Block striped) {
super(FabricBlockSettings.copyOf(striped).mapColor(color)); super(FabricBlockSettings.copyOf(striped).materialColor(color));
this.striped = striped; this.striped = striped;
} }
@Override @Override
@SuppressWarnings("deprecation")
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if (FabricToolTags.AXES.contains(player.getMainHandItem().getItem())) { if (player.getMainHandItem().getItem().is(FabricToolTags.AXES)) {
world.playSound(player, pos, SoundEvents.AXE_STRIP, SoundSource.BLOCKS, 1.0F, 1.0F); world.playSound(player, pos, SoundEvents.AXE_STRIP, SoundSource.BLOCKS, 1.0F, 1.0F);
if (!world.isClientSide) { if (!world.isClientSide) {
world.setBlock(pos, striped.defaultBlockState().setValue(RotatedPillarBlock.AXIS, state.getValue(RotatedPillarBlock.AXIS)), 11); world.setBlock(pos, striped.defaultBlockState().setValue(RotatedPillarBlock.AXIS, state.getValue(RotatedPillarBlock.AXIS)), 11);

View file

@ -10,8 +10,6 @@ import org.jetbrains.annotations.Nullable;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; 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.BlockModel;
import net.minecraft.client.renderer.block.model.MultiVariant; import net.minecraft.client.renderer.block.model.MultiVariant;
import net.minecraft.client.renderer.block.model.Variant; import net.minecraft.client.renderer.block.model.Variant;
@ -111,13 +109,11 @@ public class TripleTerrainBlock extends BaseTerrainBlock {
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation blockId) { public BlockModel getItemModel(ResourceLocation blockId) {
return getBlockModel(blockId, defaultBlockState()); return getBlockModel(blockId, defaultBlockState());
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
String path = blockId.getPath(); String path = blockId.getPath();
Optional<String> pattern; Optional<String> pattern;
@ -135,7 +131,6 @@ public class TripleTerrainBlock extends BaseTerrainBlock {
} }
@Override @Override
@Environment(EnvType.CLIENT)
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) { public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
boolean isMiddle = isMiddle(blockState); boolean isMiddle = isMiddle(blockState);
String middle = isMiddle ? "_middle" : ""; String middle = isMiddle ? "_middle" : "";

View file

@ -37,7 +37,6 @@ import net.minecraft.world.phys.shapes.VoxelShape;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped; import ru.bclib.interfaces.IRenderTyped;
@SuppressWarnings("deprecation")
public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements IRenderTyped, BonemealableBlock, LiquidBlockContainer { public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements IRenderTyped, BonemealableBlock, LiquidBlockContainer {
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 14, 12); private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 14, 12);
@ -96,7 +95,7 @@ public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements I
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getParameter(LootContextParams.TOOL); ItemStack tool = builder.getParameter(LootContextParams.TOOL);
if (tool != null && FabricToolTags.SHEARS.contains(tool.getItem()) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { if (tool != null && tool.getItem().is(FabricToolTags.SHEARS) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
return Lists.newArrayList(new ItemStack(this)); return Lists.newArrayList(new ItemStack(this));
} }
else { else {

View file

@ -47,7 +47,6 @@ public abstract class UnderwaterPlantWithAgeBlock extends UnderwaterPlantBlock {
} }
@Override @Override
@SuppressWarnings("deprecation")
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) { public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
super.tick(state, world, pos, random); super.tick(state, world, pos, random);
if (isBonemealSuccess(world, random, pos, state)) { if (isBonemealSuccess(world, random, pos, state)) {

View file

@ -29,7 +29,6 @@ import net.minecraft.world.phys.shapes.VoxelShape;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped; import ru.bclib.interfaces.IRenderTyped;
@SuppressWarnings("deprecation")
public abstract class UpDownPlantBlock extends BaseBlockNotFull implements IRenderTyped { public abstract class UpDownPlantBlock extends BaseBlockNotFull implements IRenderTyped {
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 16, 12); private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 16, 12);
@ -72,7 +71,7 @@ public abstract class UpDownPlantBlock extends BaseBlockNotFull implements IRend
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getParameter(LootContextParams.TOOL); ItemStack tool = builder.getParameter(LootContextParams.TOOL);
if (tool != null && FabricToolTags.SHEARS.contains(tool.getItem()) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) { if (tool != null && tool.getItem().is(FabricToolTags.SHEARS) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
return Lists.newArrayList(new ItemStack(this)); return Lists.newArrayList(new ItemStack(this));
} }
else { else {

View file

@ -4,7 +4,6 @@ import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import ru.bclib.api.ModIntegrationAPI;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped; import ru.bclib.interfaces.IRenderTyped;
import ru.bclib.registry.BaseBlockEntityRenders; import ru.bclib.registry.BaseBlockEntityRenders;
@ -12,7 +11,6 @@ import ru.bclib.registry.BaseBlockEntityRenders;
public class BCLibClient implements ClientModInitializer { public class BCLibClient implements ClientModInitializer {
@Override @Override
public void onInitializeClient() { public void onInitializeClient() {
ModIntegrationAPI.registerAll();
BaseBlockEntityRenders.register(); BaseBlockEntityRenders.register();
registerRenderLayers(); registerRenderLayers();
} }

View file

@ -1,5 +1,7 @@
package ru.bclib.client.gui; package ru.bclib.client.gui;
import java.util.Arrays;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.platform.Lighting; import com.mojang.blaze3d.platform.Lighting;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
@ -9,8 +11,8 @@ import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.Tesselator; import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.blaze3d.vertex.VertexFormat;
import com.mojang.math.Matrix4f; import com.mojang.math.Matrix4f;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.Util; import net.minecraft.Util;
@ -18,25 +20,22 @@ import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.font.TextFieldHelper; import net.minecraft.client.gui.font.TextFieldHelper;
import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.model.geom.ModelLayers;
import net.minecraft.client.multiplayer.ClientPacketListener; import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.blockentity.SignRenderer; import net.minecraft.client.renderer.blockentity.SignRenderer.SignModel;
import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.network.protocol.game.ServerboundSignUpdatePacket; import net.minecraft.network.protocol.game.ServerboundSignUpdatePacket;
import net.minecraft.world.level.block.state.BlockState; 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.blockentities.BaseSignBlockEntity;
import ru.bclib.blocks.BaseSignBlock; import ru.bclib.blocks.BaseSignBlock;
import ru.bclib.client.render.BaseSignBlockEntityRenderer; import ru.bclib.client.render.BaseSignBlockEntityRenderer;
import java.util.Arrays;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public class BlockSignEditScreen extends Screen { public class BlockSignEditScreen extends Screen {
private final SignModel model = new SignModel();
private final BaseSignBlockEntity sign; private final BaseSignBlockEntity sign;
private int ticksSinceOpened; private int ticksSinceOpened;
private int currentRow; private int currentRow;
@ -44,7 +43,6 @@ public class BlockSignEditScreen extends Screen {
private final String[] text = (String[]) Util.make(new String[4], (strings) -> { private final String[] text = (String[]) Util.make(new String[4], (strings) -> {
Arrays.fill(strings, ""); Arrays.fill(strings, "");
}); });
private SignRenderer.SignModel model;
public BlockSignEditScreen(BaseSignBlockEntity sign) { public BlockSignEditScreen(BaseSignBlockEntity sign) {
super(new TranslatableComponent("sign.edit")); super(new TranslatableComponent("sign.edit"));
@ -52,11 +50,8 @@ public class BlockSignEditScreen extends Screen {
} }
protected void init() { protected void init() {
//set up a default model
model = new SignRenderer.SignModel(this.minecraft.getEntityModels().bakeLayer(ModelLayers.createSignModelName(WoodType.OAK)));
minecraft.keyboardHandler.setSendRepeatsToGui(true); minecraft.keyboardHandler.setSendRepeatsToGui(true);
this.addRenderableWidget(new Button(this.width / 2 - 100, this.height / 4 + 120, 200, 20, CommonComponents.GUI_DONE, this.addButton(new Button(this.width / 2 - 100, this.height / 4 + 120, 200, 20, CommonComponents.GUI_DONE,
(buttonWidget) -> { (buttonWidget) -> {
this.finishEditing(); this.finishEditing();
})); }));
@ -85,7 +80,7 @@ public class BlockSignEditScreen extends Screen {
public void tick() { public void tick() {
++this.ticksSinceOpened; ++this.ticksSinceOpened;
if (!this.sign.getType().isValid(this.sign.getBlockState())) { if (!this.sign.getType().isValid(this.sign.getBlockState().getBlock())) {
this.finishEditing(); this.finishEditing();
} }
} }
@ -140,7 +135,7 @@ public class BlockSignEditScreen extends Screen {
matrices.scale(0.6666667F, -0.6666667F, -0.6666667F); matrices.scale(0.6666667F, -0.6666667F, -0.6666667F);
MultiBufferSource.BufferSource immediate = minecraft.renderBuffers().bufferSource(); MultiBufferSource.BufferSource immediate = minecraft.renderBuffers().bufferSource();
VertexConsumer vertexConsumer = BaseSignBlockEntityRenderer.getConsumer(immediate, blockState.getBlock()); VertexConsumer vertexConsumer = BaseSignBlockEntityRenderer.getConsumer(immediate, blockState.getBlock());
model.root.getChild("sign").render(matrices, vertexConsumer, 15728880, OverlayTexture.NO_OVERLAY); model.sign.render(matrices, vertexConsumer, 15728880, OverlayTexture.NO_OVERLAY);
if (bl) { if (bl) {
model.stick.render(matrices, vertexConsumer, 15728880, OverlayTexture.NO_OVERLAY); model.stick.render(matrices, vertexConsumer, 15728880, OverlayTexture.NO_OVERLAY);
@ -211,7 +206,7 @@ public class BlockSignEditScreen extends Screen {
RenderSystem.disableTexture(); RenderSystem.disableTexture();
RenderSystem.enableColorLogicOp(); RenderSystem.enableColorLogicOp();
RenderSystem.logicOp(GlStateManager.LogicOp.OR_REVERSE); RenderSystem.logicOp(GlStateManager.LogicOp.OR_REVERSE);
bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); bufferBuilder.begin(7, DefaultVertexFormat.POSITION_COLOR);
float var32 = (float) x; float var32 = (float) x;
bufferBuilder.vertex(matrix4f, var32, (float) (l + 9), 0.0F).color(0, 0, 255, 255).endVertex(); bufferBuilder.vertex(matrix4f, var32, (float) (l + 9), 0.0F).color(0, 0, 255, 255).endVertex();
var32 = (float) y; var32 = (float) y;

View file

@ -1,91 +0,0 @@
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");
}
}

View file

@ -7,8 +7,6 @@ import java.util.Optional;
import org.jetbrains.annotations.Nullable; 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.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
@ -16,20 +14,17 @@ import net.minecraft.world.level.block.state.BlockState;
import ru.bclib.BCLib; import ru.bclib.BCLib;
public interface BlockModelProvider extends ItemModelProvider { public interface BlockModelProvider extends ItemModelProvider {
@Environment(EnvType.CLIENT)
default @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) { default @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
Optional<String> pattern = PatternsHelper.createBlockSimple(resourceLocation); Optional<String> pattern = PatternsHelper.createBlockSimple(resourceLocation);
return ModelsHelper.fromPattern(pattern); return ModelsHelper.fromPattern(pattern);
} }
@Environment(EnvType.CLIENT)
default UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) { default UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath()); ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath());
registerBlockModel(stateId, modelId, blockState, modelCache); registerBlockModel(stateId, modelId, blockState, modelCache);
return ModelsHelper.createBlockSimple(modelId); return ModelsHelper.createBlockSimple(modelId);
} }
@Environment(EnvType.CLIENT)
default void registerBlockModel(ResourceLocation stateId, ResourceLocation modelId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) { default void registerBlockModel(ResourceLocation stateId, ResourceLocation modelId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
if (!modelCache.containsKey(modelId)) { if (!modelCache.containsKey(modelId)) {
BlockModel model = getBlockModel(stateId, blockState); BlockModel model = getBlockModel(stateId, blockState);

View file

@ -1,12 +1,9 @@
package ru.bclib.client.models; 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.client.renderer.block.model.BlockModel;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
public interface ItemModelProvider { public interface ItemModelProvider {
@Environment(EnvType.CLIENT)
default BlockModel getItemModel(ResourceLocation resourceLocation) { default BlockModel getItemModel(ResourceLocation resourceLocation) {
return ModelsHelper.createItemModel(resourceLocation); return ModelsHelper.createItemModel(resourceLocation);
} }

View file

@ -1,9 +1,12 @@
package ru.bclib.client.render; package ru.bclib.client.render;
import java.util.HashMap;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Vector3f; import com.mojang.math.Vector3f;
import it.unimi.dsi.fastutil.floats.Float2FloatFunction; import it.unimi.dsi.fastutil.floats.Float2FloatFunction;
import it.unimi.dsi.fastutil.ints.Int2IntFunction; import it.unimi.dsi.fastutil.ints.Int2IntFunction;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
@ -11,25 +14,27 @@ import net.fabricmc.api.Environment;
import net.minecraft.client.model.geom.ModelPart; import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType; 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.BlockEntityRenderer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.client.renderer.blockentity.BrightnessCombiner; import net.minecraft.client.renderer.blockentity.BrightnessCombiner;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.*; 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.DoubleBlockCombiner.NeighborCombineResult; import net.minecraft.world.level.block.DoubleBlockCombiner.NeighborCombineResult;
import net.minecraft.world.level.block.entity.ChestBlockEntity; 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.BlockState;
import net.minecraft.world.level.block.state.properties.ChestType; import net.minecraft.world.level.block.state.properties.ChestType;
import ru.bclib.blockentities.BaseChestBlockEntity; import ru.bclib.blockentities.BaseChestBlockEntity;
import ru.bclib.client.models.BaseChestBlockModel;
import java.util.HashMap;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public class BaseChestBlockEntityRenderer implements BlockEntityRenderer<BaseChestBlockEntity> { public class BaseChestBlockEntityRenderer extends BlockEntityRenderer<BaseChestBlockEntity> {
private static final HashMap<Block, RenderType[]> LAYERS = Maps.newHashMap(); private static final HashMap<Block, RenderType[]> LAYERS = Maps.newHashMap();
private static final RenderType[] defaultLayer; private static final RenderType[] defaultLayer;
@ -37,17 +42,53 @@ public class BaseChestBlockEntityRenderer implements BlockEntityRenderer<BaseChe
private static final int ID_LEFT = 1; private static final int ID_LEFT = 1;
private static final int ID_RIGHT = 2; private static final int ID_RIGHT = 2;
private final BaseChestBlockModel chestModel; private final ModelPart partA;
public BaseChestBlockEntityRenderer(BlockEntityRendererProvider.Context ctx) { private final ModelPart partC;
super(); private final ModelPart partB;
chestModel = new BaseChestBlockModel(BaseChestBlockModel.getTexturedModelData().bakeRoot()); private final ModelPart partRightA;
private final ModelPart partRightC;
private final ModelPart partRightB;
private final ModelPart partLeftA;
private final ModelPart partLeftC;
private final ModelPart partLeftB;
public BaseChestBlockEntityRenderer(BlockEntityRenderDispatcher blockEntityRenderDispatcher) {
super(blockEntityRenderDispatcher);
this.partC = new ModelPart(64, 64, 0, 19);
this.partC.addBox(1.0F, 0.0F, 1.0F, 14.0F, 9.0F, 14.0F, 0.0F);
this.partA = new ModelPart(64, 64, 0, 0);
this.partA.addBox(1.0F, 0.0F, 0.0F, 14.0F, 5.0F, 14.0F, 0.0F);
this.partA.y = 9.0F;
this.partA.z = 1.0F;
this.partB = new ModelPart(64, 64, 0, 0);
this.partB.addBox(7.0F, -1.0F, 15.0F, 2.0F, 4.0F, 1.0F, 0.0F);
this.partB.y = 8.0F;
this.partRightC = new ModelPart(64, 64, 0, 19);
this.partRightC.addBox(1.0F, 0.0F, 1.0F, 15.0F, 9.0F, 14.0F, 0.0F);
this.partRightA = new ModelPart(64, 64, 0, 0);
this.partRightA.addBox(1.0F, 0.0F, 0.0F, 15.0F, 5.0F, 14.0F, 0.0F);
this.partRightA.y = 9.0F;
this.partRightA.z = 1.0F;
this.partRightB = new ModelPart(64, 64, 0, 0);
this.partRightB.addBox(15.0F, -1.0F, 15.0F, 1.0F, 4.0F, 1.0F, 0.0F);
this.partRightB.y = 8.0F;
this.partLeftC = new ModelPart(64, 64, 0, 19);
this.partLeftC.addBox(0.0F, 0.0F, 1.0F, 15.0F, 9.0F, 14.0F, 0.0F);
this.partLeftA = new ModelPart(64, 64, 0, 0);
this.partLeftA.addBox(0.0F, 0.0F, 0.0F, 15.0F, 5.0F, 14.0F, 0.0F);
this.partLeftA.y = 9.0F;
this.partLeftA.z = 1.0F;
this.partLeftB = new ModelPart(64, 64, 0, 0);
this.partLeftB.addBox(0.0F, -1.0F, 15.0F, 1.0F, 4.0F, 1.0F, 0.0F);
this.partLeftB.y = 8.0F;
} }
public void render(BaseChestBlockEntity entity, float tickDelta, PoseStack matrices, MultiBufferSource vertexConsumers, int light, int overlay) { public void render(BaseChestBlockEntity entity, float tickDelta, PoseStack matrices, MultiBufferSource vertexConsumers, int light, int overlay) {
Level world = entity.getLevel(); Level world = entity.getLevel();
boolean worldExists = world != null; boolean worldExists = world != null;
BlockState blockState = worldExists ? entity.getBlockState() : Blocks.CHEST.defaultBlockState().setValue(ChestBlock.FACING, Direction.SOUTH); BlockState blockState = worldExists ? entity.getBlockState() : (BlockState) Blocks.CHEST.defaultBlockState().setValue(ChestBlock.FACING, Direction.SOUTH);
ChestType chestType = blockState.hasProperty(ChestBlock.TYPE) ? blockState.getValue(ChestBlock.TYPE) : ChestType.SINGLE; ChestType chestType = blockState.hasProperty(ChestBlock.TYPE) ? (ChestType) blockState.getValue(ChestBlock.TYPE) : ChestType.SINGLE;
Block block = blockState.getBlock(); Block block = blockState.getBlock();
if (block instanceof AbstractChestBlock) { if (block instanceof AbstractChestBlock) {
AbstractChestBlock<?> abstractChestBlock = (AbstractChestBlock<?>) block; AbstractChestBlock<?> abstractChestBlock = (AbstractChestBlock<?>) block;
@ -66,7 +107,7 @@ public class BaseChestBlockEntityRenderer implements BlockEntityRenderer<BaseChe
propertySource = DoubleBlockCombiner.Combiner::acceptNone; propertySource = DoubleBlockCombiner.Combiner::acceptNone;
} }
float pitch = ((Float2FloatFunction) propertySource.apply(ChestBlock.opennessCombiner(entity))).get(tickDelta); float pitch = ((Float2FloatFunction) propertySource.apply(ChestBlock.opennessCombiner((LidBlockEntity) entity))).get(tickDelta);
pitch = 1.0F - pitch; pitch = 1.0F - pitch;
pitch = 1.0F - pitch * pitch * pitch; pitch = 1.0F - pitch * pitch * pitch;
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked", "rawtypes" })
@ -76,12 +117,12 @@ public class BaseChestBlockEntityRenderer implements BlockEntityRenderer<BaseChe
if (isDouble) { if (isDouble) {
if (chestType == ChestType.LEFT) { if (chestType == ChestType.LEFT) {
renderParts(matrices, vertexConsumer, chestModel.partLeftA, chestModel.partLeftB, chestModel.partLeftC, pitch, blockLight, overlay); renderParts(matrices, vertexConsumer, this.partLeftA, this.partLeftB, this.partLeftC, pitch, blockLight, overlay);
} else { } else {
renderParts(matrices, vertexConsumer, chestModel.partRightA, chestModel.partRightB, chestModel.partRightC, pitch, blockLight, overlay); renderParts(matrices, vertexConsumer, this.partRightA, this.partRightB, this.partRightC, pitch, blockLight, overlay);
} }
} else { } else {
renderParts(matrices, vertexConsumer, chestModel.partA, chestModel.partB, chestModel.partC, pitch, blockLight, overlay); renderParts(matrices, vertexConsumer, this.partA, this.partB, this.partC, pitch, blockLight, overlay);
} }
matrices.popPose(); matrices.popPose();
@ -97,11 +138,15 @@ public class BaseChestBlockEntityRenderer implements BlockEntityRenderer<BaseChe
} }
private static RenderType getChestTexture(ChestType type, RenderType[] layers) { private static RenderType getChestTexture(ChestType type, RenderType[] layers) {
return switch (type) { switch (type) {
case LEFT -> layers[ID_LEFT]; case LEFT:
case RIGHT -> layers[ID_RIGHT]; return layers[ID_LEFT];
default -> layers[ID_NORMAL]; case RIGHT:
}; return layers[ID_RIGHT];
case SINGLE:
default:
return layers[ID_NORMAL];
}
} }
public static VertexConsumer getConsumer(MultiBufferSource provider, Block block, ChestType chestType) { public static VertexConsumer getConsumer(MultiBufferSource provider, Block block, ChestType chestType) {

View file

@ -1,84 +1,68 @@
package ru.bclib.client.render; package ru.bclib.client.render;
import java.util.HashMap;
import java.util.List;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.platform.NativeImage;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Vector3f; import com.mojang.math.Vector3f;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font; 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.MultiBufferSource;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.Sheets; 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.BlockEntityRenderer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.client.renderer.blockentity.SignRenderer; 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.client.resources.model.Material;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.FormattedCharSequence; 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.Block;
import net.minecraft.world.level.block.SignBlock; import net.minecraft.world.level.block.SignBlock;
import net.minecraft.world.level.block.StandingSignBlock; import net.minecraft.world.level.block.StandingSignBlock;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.WoodType; import net.minecraft.world.level.block.state.properties.WoodType;
import net.minecraft.world.phys.Vec3;
import ru.bclib.blockentities.BaseSignBlockEntity; import ru.bclib.blockentities.BaseSignBlockEntity;
import ru.bclib.blocks.BaseSignBlock; import ru.bclib.blocks.BaseSignBlock;
import java.util.HashMap; public class BaseSignBlockEntityRenderer extends BlockEntityRenderer<BaseSignBlockEntity> {
import java.util.List;
public class BaseSignBlockEntityRenderer implements BlockEntityRenderer<BaseSignBlockEntity> {
private static final HashMap<Block, RenderType> LAYERS = Maps.newHashMap(); private static final HashMap<Block, RenderType> LAYERS = Maps.newHashMap();
private static final RenderType defaultLayer; private static final RenderType defaultLayer;
private final Font font; private final SignModel model = new SignRenderer.SignModel();
private final SignRenderer.SignModel model;
public BaseSignBlockEntityRenderer(BlockEntityRenderDispatcher dispatcher) {
private static final int OUTLINE_RENDER_DISTANCE = Mth.square(16); super(dispatcher);
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, public void render(BaseSignBlockEntity signBlockEntity, float tickDelta, PoseStack matrixStack,
MultiBufferSource provider, int light, int overlay) { MultiBufferSource provider, int light, int overlay) {
BlockState state = signBlockEntity.getBlockState(); BlockState state = signBlockEntity.getBlockState();
matrixStack.pushPose(); matrixStack.pushPose();
matrixStack.translate(0.5D, 0.5D, 0.5D); matrixStack.translate(0.5D, 0.5D, 0.5D);
float angle = -((float) (state.getValue(StandingSignBlock.ROTATION) * 360) / 16.0F); float angle = -((float) (state.getValue(StandingSignBlock.ROTATION) * 360) / 16.0F);
BlockState blockState = signBlockEntity.getBlockState(); BlockState blockState = signBlockEntity.getBlockState();
if (blockState.getValue(BaseSignBlock.FLOOR)) { if (blockState.getValue(BaseSignBlock.FLOOR)) {
matrixStack.mulPose(Vector3f.YP.rotationDegrees(angle)); matrixStack.mulPose(Vector3f.YP.rotationDegrees(angle));
model.stick.visible = true; this.model.stick.visible = true;
} else { } else {
matrixStack.mulPose(Vector3f.YP.rotationDegrees(angle + 180)); matrixStack.mulPose(Vector3f.YP.rotationDegrees(angle + 180));
matrixStack.translate(0.0D, -0.3125D, -0.4375D); matrixStack.translate(0.0D, -0.3125D, -0.4375D);
model.stick.visible = false; this.model.stick.visible = false;
} }
matrixStack.pushPose(); matrixStack.pushPose();
matrixStack.scale(0.6666667F, -0.6666667F, -0.6666667F); matrixStack.scale(0.6666667F, -0.6666667F, -0.6666667F);
VertexConsumer vertexConsumer = getConsumer(provider, state.getBlock()); VertexConsumer vertexConsumer = getConsumer(provider, state.getBlock());
model.sign.render(matrixStack, vertexConsumer, light, overlay);
model.root.render(matrixStack, vertexConsumer, light, overlay); model.stick.render(matrixStack, vertexConsumer, light, overlay);
//model.stick.render(matrixStack, vertexConsumer, light, overlay);
matrixStack.popPose(); matrixStack.popPose();
//Font textRenderer = renderer.getFont(); Font textRenderer = renderer.getFont();
matrixStack.translate(0.0D, 0.3333333432674408D, 0.046666666865348816D); matrixStack.translate(0.0D, 0.3333333432674408D, 0.046666666865348816D);
matrixStack.scale(0.010416667F, -0.010416667F, 0.010416667F); matrixStack.scale(0.010416667F, -0.010416667F, 0.010416667F);
int m = signBlockEntity.getColor().getTextColor(); int m = signBlockEntity.getColor().getTextColor();
@ -87,59 +71,21 @@ public class BaseSignBlockEntityRenderer implements BlockEntityRenderer<BaseSign
int p = (int) (NativeImage.getB(m) * 0.4D); int p = (int) (NativeImage.getB(m) * 0.4D);
int q = NativeImage.combine(0, p, o, n); int q = NativeImage.combine(0, p, o, n);
FormattedCharSequence[] formattedCharSequences = signBlockEntity
.getRenderMessages(Minecraft.getInstance().isTextFilteringEnabled(), (component) -> {
List<FormattedCharSequence> 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) { for (int s = 0; s < 4; ++s) {
FormattedCharSequence formattedCharSequence = formattedCharSequences[s]; FormattedCharSequence orderedText = signBlockEntity.getRenderMessage(s, (text) -> {
float t = (float) (-this.font.width(formattedCharSequence) / 2); List<FormattedCharSequence> list = textRenderer.split(text, 90);
if (drawOutlined) { return list.isEmpty() ? FormattedCharSequence.EMPTY : list.get(0);
this.font.drawInBatch8xOutline(formattedCharSequence, t, (float) (s * 10 - 20), drawColor, m, });
matrixStack.last().pose(), provider, drawLight); if (orderedText != null) {
} else { float t = (float) (-textRenderer.width(orderedText) / 2);
this.font.drawInBatch((FormattedCharSequence) formattedCharSequence, t, (float) (s * 10 - 20), drawColor, false, textRenderer.drawInBatch(orderedText, t, (float) (s * 10 - 20), q, false, matrixStack.last().pose(), provider, false, 0, light);
matrixStack.last().pose(), provider, false, 0, drawLight);
} }
} }
matrixStack.popPose(); 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; WoodType signType2;
if (block instanceof SignBlock) { if (block instanceof SignBlock) {
signType2 = ((SignBlock) block).type(); signType2 = ((SignBlock) block).type();
@ -147,11 +93,7 @@ public class BaseSignBlockEntityRenderer implements BlockEntityRenderer<BaseSign
signType2 = WoodType.OAK; signType2 = WoodType.OAK;
} }
return signType2; return Sheets.signTexture(signType2);
}
public static Material getModelTexture(Block block) {
return Sheets.getSignMaterial(getSignType(block));
} }
public static VertexConsumer getConsumer(MultiBufferSource provider, Block block) { public static VertexConsumer getConsumer(MultiBufferSource provider, Block block) {

View file

@ -30,13 +30,12 @@ public class BaseAnvilItem extends BlockItem implements ItemModelProvider {
} }
@Override @Override
@SuppressWarnings("ConstantConditions")
protected BlockState getPlacementState(BlockPlaceContext blockPlaceContext) { protected BlockState getPlacementState(BlockPlaceContext blockPlaceContext) {
BlockState blockState = super.getPlacementState(blockPlaceContext); BlockState blockState = super.getPlacementState(blockPlaceContext);
ItemStack stack = blockPlaceContext.getItemInHand(); ItemStack stack = blockPlaceContext.getItemInHand();
int destruction = stack.getOrCreateTag().getInt(DESTRUCTION); int destruction = stack.getOrCreateTag().getInt(DESTRUCTION);
if (blockState != null) {
blockState = blockState.setValue(BaseAnvilBlock.DESTRUCTION, destruction); blockState = blockState.setValue(BaseAnvilBlock.DESTRUCTION, destruction);
}
return blockState; return blockState;
} }
@ -51,7 +50,6 @@ public class BaseAnvilItem extends BlockItem implements ItemModelProvider {
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation resourceLocation) { public BlockModel getItemModel(ResourceLocation resourceLocation) {
Block anvilBlock = getBlock(); Block anvilBlock = getBlock();
ResourceLocation blockId = Registry.BLOCK.getKey(anvilBlock); ResourceLocation blockId = Registry.BLOCK.getKey(anvilBlock);

View file

@ -1,14 +1,13 @@
package ru.bclib.items; package ru.bclib.items;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings; import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.MobBucketItem; import net.minecraft.world.item.FishBucketItem;
import net.minecraft.world.level.material.Fluids; import net.minecraft.world.level.material.Fluids;
import ru.bclib.client.models.ItemModelProvider; import ru.bclib.client.models.ItemModelProvider;
public class BaseBucketItem extends MobBucketItem implements ItemModelProvider { public class BaseBucketItem extends FishBucketItem implements ItemModelProvider {
public BaseBucketItem(EntityType<?> type, FabricItemSettings settings) { public BaseBucketItem(EntityType<?> type, FabricItemSettings settings) {
super(type, Fluids.WATER, SoundEvents.BUCKET_EMPTY_FISH, settings.stacksTo(1)); super(type, Fluids.WATER, settings.stacksTo(1));
} }
} }

View file

@ -30,7 +30,7 @@ public class BaseDrinkItem extends ModelProviderItem {
@Override @Override
public InteractionResultHolder<ItemStack> use(Level world, Player user, InteractionHand hand) { public InteractionResultHolder<ItemStack> use(Level world, Player user, InteractionHand hand) {
return ItemUtils.startUsingInstantly(world, user, hand); return ItemUtils.useDrink(world, user, hand);
} }
@Override @Override
@ -41,12 +41,13 @@ public class BaseDrinkItem extends ModelProviderItem {
stack.setCount(count); stack.setCount(count);
} }
if (user instanceof ServerPlayer serverPlayerEntity) { if (user instanceof ServerPlayer) {
ServerPlayer serverPlayerEntity = (ServerPlayer) user;
CriteriaTriggers.CONSUME_ITEM.trigger(serverPlayerEntity, stack); CriteriaTriggers.CONSUME_ITEM.trigger(serverPlayerEntity, stack);
serverPlayerEntity.awardStat(Stats.ITEM_USED.get(this)); serverPlayerEntity.awardStat(Stats.ITEM_USED.get(this));
} }
if (user instanceof Player && !((Player) user).getAbilities().instabuild) { if (user instanceof Player && !((Player) user).abilities.instabuild) {
stack.shrink(1); stack.shrink(1);
} }

View file

@ -2,12 +2,9 @@ package ru.bclib.items;
import java.util.Optional; 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.client.renderer.block.model.BlockModel;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.item.SpawnEggItem; import net.minecraft.world.item.SpawnEggItem;
import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.BasePatterns;
import ru.bclib.client.models.ItemModelProvider; import ru.bclib.client.models.ItemModelProvider;
@ -15,12 +12,11 @@ import ru.bclib.client.models.ModelsHelper;
import ru.bclib.client.models.PatternsHelper; import ru.bclib.client.models.PatternsHelper;
public class BaseSpawnEggItem extends SpawnEggItem implements ItemModelProvider { public class BaseSpawnEggItem extends SpawnEggItem implements ItemModelProvider {
public BaseSpawnEggItem(EntityType<? extends Mob> type, int primaryColor, int secondaryColor, Properties settings) { public BaseSpawnEggItem(EntityType<?> type, int primaryColor, int secondaryColor, Properties settings) {
super(type, primaryColor, secondaryColor, settings); super(type, primaryColor, secondaryColor, settings);
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation resourceLocation) { public BlockModel getItemModel(ResourceLocation resourceLocation) {
Optional<String> pattern = PatternsHelper.createJson(BasePatterns.ITEM_SPAWN_EGG, resourceLocation); Optional<String> pattern = PatternsHelper.createJson(BasePatterns.ITEM_SPAWN_EGG, resourceLocation);
return ModelsHelper.fromPattern(pattern); return ModelsHelper.fromPattern(pattern);

View file

@ -1,7 +1,5 @@
package ru.bclib.items; 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.client.renderer.block.model.BlockModel;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
@ -14,7 +12,6 @@ public class ModelProviderItem extends Item implements ItemModelProvider {
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation resourceLocation) { public BlockModel getItemModel(ResourceLocation resourceLocation) {
return ModelsHelper.createItemModel(resourceLocation); return ModelsHelper.createItemModel(resourceLocation);
} }

View file

@ -1,7 +1,5 @@
package ru.bclib.items.tool; 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.DynamicAttributeTool;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
@ -30,7 +28,6 @@ public class BaseAxeItem extends AxeItem implements DynamicAttributeTool, ItemMo
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation resourceLocation) { public BlockModel getItemModel(ResourceLocation resourceLocation) {
return ModelsHelper.createHandheldItem(resourceLocation); return ModelsHelper.createHandheldItem(resourceLocation);
} }

View file

@ -1,7 +1,5 @@
package ru.bclib.items.tool; 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.client.renderer.block.model.BlockModel;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.HoeItem; import net.minecraft.world.item.HoeItem;
@ -15,7 +13,6 @@ public class BaseHoeItem extends HoeItem implements ItemModelProvider {
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation resourceLocation) { public BlockModel getItemModel(ResourceLocation resourceLocation) {
return ModelsHelper.createHandheldItem(resourceLocation); return ModelsHelper.createHandheldItem(resourceLocation);
} }

View file

@ -1,7 +1,5 @@
package ru.bclib.items.tool; 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.DynamicAttributeTool;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl; import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl;
@ -38,7 +36,6 @@ public class BasePickaxeItem extends PickaxeItem implements DynamicAttributeTool
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation resourceLocation) { public BlockModel getItemModel(ResourceLocation resourceLocation) {
return ModelsHelper.createHandheldItem(resourceLocation); return ModelsHelper.createHandheldItem(resourceLocation);
} }

View file

@ -1,7 +1,5 @@
package ru.bclib.items.tool; 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.DynamicAttributeTool;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl; import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl;
@ -38,7 +36,6 @@ public class BaseShovelItem extends ShovelItem implements DynamicAttributeTool,
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation resourceLocation) { public BlockModel getItemModel(ResourceLocation resourceLocation) {
return ModelsHelper.createHandheldItem(resourceLocation); return ModelsHelper.createHandheldItem(resourceLocation);
} }

View file

@ -1,7 +1,5 @@
package ru.bclib.items.tool; 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.DynamicAttributeTool;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
@ -16,7 +14,6 @@ public class BaseSwordItem extends SwordItem implements DynamicAttributeTool, It
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation resourceLocation) { public BlockModel getItemModel(ResourceLocation resourceLocation) {
return ModelsHelper.createHandheldItem(resourceLocation); return ModelsHelper.createHandheldItem(resourceLocation);
} }

View file

@ -1,6 +1,5 @@
package ru.bclib.mixin.client; package ru.bclib.mixin.client;
import net.minecraft.world.level.material.FogType;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
@ -42,8 +41,8 @@ public class BackgroundRendererMixin {
@Inject(method = "setupColor", at = @At("RETURN")) @Inject(method = "setupColor", at = @At("RETURN"))
private static void bcl_onRender(Camera camera, float tickDelta, ClientLevel world, int i, float f, CallbackInfo info) { private static void bcl_onRender(Camera camera, float tickDelta, ClientLevel world, int i, float f, CallbackInfo info) {
FogType fogType = camera.getFluidInCamera(); FluidState fluidState = camera.getFluidInCamera();
if (fogType != FogType.WATER && world.dimension().equals(Level.END)) { if (fluidState.isEmpty() && world.dimension().equals(Level.END)) {
Entity entity = camera.getEntity(); Entity entity = camera.getEntity();
boolean skip = false; boolean skip = false;
if (entity instanceof LivingEntity) { if (entity instanceof LivingEntity) {
@ -63,10 +62,10 @@ public class BackgroundRendererMixin {
} }
@Inject(method = "setupFog", at = @At("HEAD"), cancellable = true) @Inject(method = "setupFog", at = @At("HEAD"), cancellable = true)
private static void bcl_fogDensity(Camera camera, FogRenderer.FogMode fogMode, float viewDistance, boolean thickFog, CallbackInfo info) { private static void bcl_fogDensity(Camera camera, FogRenderer.FogMode fogType, float viewDistance, boolean thickFog, CallbackInfo info) {
Entity entity = camera.getEntity(); Entity entity = camera.getEntity();
FogType fogType = camera.getFluidInCamera(); FluidState fluidState = camera.getFluidInCamera();
if (fogType != FogType.WATER) { if (fluidState.isEmpty()) {
float fog = bcl_getFogDensity(entity.level, entity.getX(), entity.getEyeY(), entity.getZ()); float fog = bcl_getFogDensity(entity.level, entity.getX(), entity.getEyeY(), entity.getZ());
BackgroundInfo.fogDensity = fog; BackgroundInfo.fogDensity = fog;
float start = viewDistance * 0.75F / fog; float start = viewDistance * 0.75F / fog;
@ -94,8 +93,10 @@ public class BackgroundRendererMixin {
} }
} }
RenderSystem.setShaderFogStart(start); RenderSystem.fogStart(start);
RenderSystem.setShaderFogEnd(end); RenderSystem.fogEnd(end);
RenderSystem.fogMode(GlStateManager.FogMode.LINEAR);
RenderSystem.setupNvFogDistance();
info.cancel(); info.cancel();
} }
} }

View file

@ -0,0 +1,19 @@
package ru.bclib.mixin.common;
import java.io.File;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.fabricmc.loader.entrypoint.minecraft.hooks.EntrypointServer;
import ru.bclib.api.ModIntegrationAPI;
@Mixin(value = EntrypointServer.class, remap = false)
public class EntrypointServerMixin {
@Inject(method = "start", at = @At(value = "TAIL"))
private static void start(File runDir, Object gameInstance, CallbackInfo info) {
ModIntegrationAPI.registerAll();
}
}

View file

@ -1,18 +0,0 @@
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();
}

View file

@ -22,7 +22,6 @@ import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.storage.LevelStorageSource; import net.minecraft.world.level.storage.LevelStorageSource;
import net.minecraft.world.level.storage.ServerLevelData; import net.minecraft.world.level.storage.ServerLevelData;
import net.minecraft.world.level.storage.WritableLevelData; import net.minecraft.world.level.storage.WritableLevelData;
import ru.bclib.api.BiomeAPI;
import ru.bclib.api.DataFixerAPI; import ru.bclib.api.DataFixerAPI;
import ru.bclib.api.WorldDataAPI; import ru.bclib.api.WorldDataAPI;
@ -36,8 +35,6 @@ public abstract class ServerLevelMixin extends Level {
@Inject(method = "<init>*", at = @At("TAIL")) @Inject(method = "<init>*", at = @At("TAIL"))
private void bcl_onServerWorldInit(MinecraftServer server, Executor workerExecutor, LevelStorageSource.LevelStorageAccess session, ServerLevelData properties, ResourceKey<Level> registryKey, DimensionType dimensionType, ChunkProgressListener worldGenerationProgressListener, ChunkGenerator chunkGenerator, boolean debugWorld, long l, List<CustomSpawner> list, boolean bl, CallbackInfo info) { private void bcl_onServerWorldInit(MinecraftServer server, Executor workerExecutor, LevelStorageSource.LevelStorageAccess session, ServerLevelData properties, ResourceKey<Level> registryKey, DimensionType dimensionType, ChunkProgressListener worldGenerationProgressListener, ChunkGenerator chunkGenerator, boolean debugWorld, long l, List<CustomSpawner> list, boolean bl, CallbackInfo info) {
BiomeAPI.initRegistry(server);
if (bcl_lastWorld != null && bcl_lastWorld.equals(session.getLevelId())) { if (bcl_lastWorld != null && bcl_lastWorld.equals(session.getLevelId())) {
return; return;
} }

View file

@ -1,23 +1,26 @@
package ru.bclib.mixin.common; package ru.bclib.mixin.common;
import net.minecraft.resources.ResourceLocation; import java.util.Map;
import net.minecraft.tags.Tag; import java.util.concurrent.Executor;
import net.minecraft.tags.TagLoader; import java.util.function.Supplier;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.ModifyArg;
import ru.bclib.util.TagHelper;
import java.util.Map; import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.Tag;
import net.minecraft.tags.TagLoader;
import ru.bclib.util.TagHelper;
@Mixin(TagLoader.class) @Mixin(TagLoader.class)
public class TagLoaderMixin { public class TagLoaderMixin {
@Shadow @Shadow
private String directory; private String name;
@ModifyArg(method = "loadAndBuild", at = @At(value = "INVOKE", target = "Lnet/minecraft/tags/TagLoader;build(Ljava/util/Map;)Lnet/minecraft/tags/TagCollection;")) @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 Map<ResourceLocation, Tag.Builder> be_modifyTags(Map<ResourceLocation, Tag.Builder> tagsMap) { public Supplier<Map<ResourceLocation, Tag.Builder>> be_modifyTags(Supplier<Map<ResourceLocation, Tag.Builder>> supplier, Executor executor) {
return TagHelper.apply(directory, tagsMap); return () -> TagHelper.apply(name, supplier.get());
} }
} }

View file

@ -13,7 +13,6 @@ import ru.bclib.blockentities.BaseChestBlockEntity;
import ru.bclib.blockentities.BaseFurnaceBlockEntity; import ru.bclib.blockentities.BaseFurnaceBlockEntity;
import ru.bclib.blockentities.BaseSignBlockEntity; import ru.bclib.blockentities.BaseSignBlockEntity;
import ru.bclib.blockentities.DynamicBlockEntityType; import ru.bclib.blockentities.DynamicBlockEntityType;
import ru.bclib.blockentities.DynamicBlockEntityType.BlockEntitySupplier;
import ru.bclib.blocks.BaseBarrelBlock; import ru.bclib.blocks.BaseBarrelBlock;
import ru.bclib.blocks.BaseChestBlock; import ru.bclib.blocks.BaseChestBlock;
import ru.bclib.blocks.BaseFurnaceBlock; import ru.bclib.blocks.BaseFurnaceBlock;
@ -25,7 +24,7 @@ public class BaseBlockEntities {
public static final DynamicBlockEntityType<BaseSignBlockEntity> SIGN = registerBlockEntityType(BCLib.makeID("sign"), BaseSignBlockEntity::new); public static final DynamicBlockEntityType<BaseSignBlockEntity> SIGN = registerBlockEntityType(BCLib.makeID("sign"), BaseSignBlockEntity::new);
public static final DynamicBlockEntityType<BaseFurnaceBlockEntity> FURNACE = registerBlockEntityType(BCLib.makeID("furnace"), BaseFurnaceBlockEntity::new); public static final DynamicBlockEntityType<BaseFurnaceBlockEntity> FURNACE = registerBlockEntityType(BCLib.makeID("furnace"), BaseFurnaceBlockEntity::new);
public static <T extends BlockEntity> DynamicBlockEntityType<T> registerBlockEntityType(ResourceLocation typeId, BlockEntitySupplier<? extends T> supplier) { public static <T extends BlockEntity> DynamicBlockEntityType<T> registerBlockEntityType(ResourceLocation typeId, Supplier<? extends T> supplier) {
return Registry.register(Registry.BLOCK_ENTITY_TYPE, typeId, new DynamicBlockEntityType<>(supplier)); return Registry.register(Registry.BLOCK_ENTITY_TYPE, typeId, new DynamicBlockEntityType<>(supplier));
} }

View file

@ -9,7 +9,6 @@ import net.minecraft.sounds.SoundEvent;
import net.minecraft.tags.Tag; import net.minecraft.tags.Tag;
import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.MobSpawnType; import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.food.FoodProperties; import net.minecraft.world.food.FoodProperties;
import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.CreativeModeTab;
@ -20,9 +19,9 @@ import net.minecraft.world.item.SpawnEggItem;
import net.minecraft.world.item.SwordItem; import net.minecraft.world.item.SwordItem;
import net.minecraft.world.item.TieredItem; import net.minecraft.world.item.TieredItem;
import net.minecraft.world.level.block.DispenserBlock; import net.minecraft.world.level.block.DispenserBlock;
import ru.bclib.items.BaseDiscItem;
import ru.bclib.items.BaseDrinkItem; import ru.bclib.items.BaseDrinkItem;
import ru.bclib.items.BaseSpawnEggItem; import ru.bclib.items.BaseSpawnEggItem;
import ru.bclib.items.BaseDiscItem;
import ru.bclib.items.ModelProviderItem; import ru.bclib.items.ModelProviderItem;
import ru.bclib.items.tool.BaseAxeItem; import ru.bclib.items.tool.BaseAxeItem;
import ru.bclib.items.tool.BaseHoeItem; import ru.bclib.items.tool.BaseHoeItem;
@ -68,7 +67,7 @@ public abstract class ItemsRegistry extends BaseRegistry<Item> {
return item; return item;
} }
public Item registerEgg(String name, EntityType<? extends Mob> type, int background, int dots) { public Item registerEgg(String name, EntityType<?> type, int background, int dots) {
SpawnEggItem item = new BaseSpawnEggItem(type, background, dots, makeItemSettings()); SpawnEggItem item = new BaseSpawnEggItem(type, background, dots, makeItemSettings());
DefaultDispenseItemBehavior behavior = new DefaultDispenseItemBehavior() { DefaultDispenseItemBehavior behavior = new DefaultDispenseItemBehavior() {
public ItemStack execute(BlockSource pointer, ItemStack stack) { public ItemStack execute(BlockSource pointer, ItemStack stack) {

View file

@ -1,11 +0,0 @@
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();
}
}

View file

@ -182,11 +182,6 @@ public class BlocksHelper {
* @return {@code true} if block is "invulnerable" and {@code false} if not. * @return {@code true} if block is "invulnerable" and {@code false} if not.
*/ */
public static boolean isInvulnerableUnsafe(BlockState state) { public static boolean isInvulnerableUnsafe(BlockState state) {
try {
return isInvulnerable(state, null, null); return isInvulnerable(state, null, null);
} }
catch (Exception e) {
return false;
}
}
} }

View file

@ -14,7 +14,6 @@ import com.google.common.collect.Sets;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.Vec3i;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtIo; import net.minecraft.nbt.NbtIo;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
@ -28,7 +27,6 @@ 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.StructurePlaceSettings;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.Vec3;
import ru.bclib.api.TagAPI; import ru.bclib.api.TagAPI;
public class StructureHelper { public class StructureHelper {
@ -88,8 +86,8 @@ public class StructureHelper {
} }
public static BlockPos offsetPos(BlockPos pos, StructureTemplate structure, Rotation rotation, Mirror mirror) { public static BlockPos offsetPos(BlockPos pos, StructureTemplate structure, Rotation rotation, Mirror mirror) {
Vec3 offset = StructureTemplate.transform(Vec3.atCenterOf(structure.getSize()), mirror, rotation, BlockPos.ZERO); BlockPos offset = StructureTemplate.transform(structure.getSize(), mirror, rotation, BlockPos.ZERO);
return pos.offset(-offset.x * 0.5, 0, -offset.z * 0.5); return pos.offset(-offset.getX() * 0.5, 0, -offset.getZ() * 0.5);
} }
public static void placeCenteredBottom(WorldGenLevel world, BlockPos pos, StructureTemplate structure, Rotation rotation, Mirror mirror, Random random) { public static void placeCenteredBottom(WorldGenLevel world, BlockPos pos, StructureTemplate structure, Rotation rotation, Mirror mirror, Random random) {
@ -99,7 +97,7 @@ public class StructureHelper {
public static void placeCenteredBottom(WorldGenLevel world, BlockPos pos, StructureTemplate structure, Rotation rotation, Mirror mirror, BoundingBox bounds, Random random) { 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); BlockPos offset = offsetPos(pos, structure, rotation, mirror);
StructurePlaceSettings placementData = new StructurePlaceSettings().setRotation(rotation).setMirror(mirror).setBoundingBox(bounds); StructurePlaceSettings placementData = new StructurePlaceSettings().setRotation(rotation).setMirror(mirror).setBoundingBox(bounds);
structure.placeInWorld(world, offset, offset, placementData, random, 4); structure.placeInWorldChunk(world, offset, placementData, random);
} }
private static BoundingBox makeBox(BlockPos pos) { private static BoundingBox makeBox(BlockPos pos) {
@ -107,41 +105,40 @@ public class StructureHelper {
int sz = ((pos.getZ() >> 4) << 4) - 16; int sz = ((pos.getZ() >> 4) << 4) - 16;
int ex = sx + 47; int ex = sx + 47;
int ez = sz + 47; int ez = sz + 47;
return BoundingBox.fromCorners(new Vec3i(sx, 0, sz), new Vec3i(ex, 255, ez)); return BoundingBox.createProper(sx, 0, sz, ex, 255, ez);
} }
public static BoundingBox getStructureBounds(BlockPos pos, StructureTemplate structure, Rotation rotation, Mirror mirror) { public static BoundingBox getStructureBounds(BlockPos pos, StructureTemplate structure, Rotation rotation, Mirror mirror) {
Vec3i max = structure.getSize(); BlockPos max = structure.getSize();
Vec3 min = StructureTemplate.transform(Vec3.atCenterOf(structure.getSize()), mirror, rotation, BlockPos.ZERO); BlockPos min = StructureTemplate.transform(structure.getSize(), mirror, rotation, BlockPos.ZERO);
max = max.offset(-min.x, -min.y, -min.z); max = max.subtract(min);
return BoundingBox.fromCorners(pos.offset(min.x, min.y, min.z), max.offset(pos)); return new BoundingBox(min.offset(pos), max.offset(pos));
} }
public static BoundingBox intersectBoxes(BoundingBox box1, BoundingBox box2) { public static BoundingBox intersectBoxes(BoundingBox box1, BoundingBox box2) {
int x1 = MHelper.max(box1.minX(), box2.minX()); int x1 = MHelper.max(box1.x0, box2.x0);
int y1 = MHelper.max(box1.minY(), box2.minY()); int y1 = MHelper.max(box1.y0, box2.y0);
int z1 = MHelper.max(box1.minZ(), box2.minZ()); int z1 = MHelper.max(box1.z0, box2.z0);
int x2 = MHelper.min(box1.maxX(), box2.maxX()); int x2 = MHelper.min(box1.x1, box2.x1);
int y2 = MHelper.min(box1.maxY(), box2.maxY()); int y2 = MHelper.min(box1.y1, box2.y1);
int z2 = MHelper.min(box1.maxZ(), box2.maxZ()); int z2 = MHelper.min(box1.z1, box2.z1);
return BoundingBox.fromCorners(new Vec3i(x1, y1, z1), new Vec3i(x2, y2, z2)); return BoundingBox.createProper(x1, y1, z1, x2, y2, z2);
} }
public static void erode(WorldGenLevel world, BoundingBox bounds, int iterations, Random random) { public static void erode(WorldGenLevel world, BoundingBox bounds, int iterations, Random random) {
MutableBlockPos mut = new MutableBlockPos(); MutableBlockPos mut = new MutableBlockPos();
boolean canDestruct = true; boolean canDestruct = true;
for (int i = 0; i < iterations; i++) { for (int i = 0; i < iterations; i++) {
for (int x = bounds.minX(); x <= bounds.maxX(); x++) { for (int x = bounds.x0; x <= bounds.x1; x++) {
mut.setX(x); mut.setX(x);
for (int z = bounds.minZ(); z <= bounds.maxZ(); z++) { for (int z = bounds.z0; z <= bounds.z1; z++) {
mut.setZ(z); mut.setZ(z);
for (int y = bounds.maxY(); y >= bounds.minY(); y--) { for (int y = bounds.y1; y >= bounds.y0; y--) {
mut.setY(y); mut.setY(y);
BlockState state = world.getBlockState(mut); BlockState state = world.getBlockState(mut);
boolean ignore = ignore(state, world, mut); if (canDestruct && BlocksHelper.isInvulnerableUnsafe(state) && random.nextInt(8) == 0 && world.isEmptyBlock(mut.below(2))) {
if (canDestruct && BlocksHelper.isInvulnerable(state, world, mut) && random.nextInt(8) == 0 && world.isEmptyBlock(mut.below(2))) {
int r = MHelper.randRange(1, 4, random); int r = MHelper.randRange(1, 4, random);
int cx = mut.getX(); int cx = mut.getX();
int cy = mut.getY(); int cy = mut.getY();
@ -164,7 +161,7 @@ public class StructureHelper {
int dz = pz - cz; int dz = pz - cz;
dz *= dz; dz *= dz;
mut.setZ(pz); mut.setZ(pz);
if (dx + dy + dz <= r && BlocksHelper.isInvulnerable(world.getBlockState(mut), world, mut)) { if (dx + dy + dz <= r && BlocksHelper.isInvulnerableUnsafe(world.getBlockState(mut))) {
BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR); BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR);
} }
} }
@ -176,7 +173,7 @@ public class StructureHelper {
canDestruct = false; canDestruct = false;
continue; continue;
} }
else if (ignore) { else if (ignore(state)) {
continue; continue;
} }
if (!state.isAir() && random.nextBoolean()) { if (!state.isAir() && random.nextBoolean()) {
@ -185,7 +182,7 @@ public class StructureHelper {
if (world.isEmptyBlock(mut.relative(dir)) && world.isEmptyBlock(mut.below().relative(dir))) { if (world.isEmptyBlock(mut.relative(dir)) && world.isEmptyBlock(mut.below().relative(dir))) {
BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR); BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR);
mut.move(dir).move(Direction.DOWN); mut.move(dir).move(Direction.DOWN);
for (int py = mut.getY(); y >= bounds.minY() - 10; y--) { for (int py = mut.getY(); y >= bounds.y0 - 10; y--) {
mut.setY(py - 1); mut.setY(py - 1);
if (!world.isEmptyBlock(mut)) { if (!world.isEmptyBlock(mut)) {
mut.setY(py); mut.setY(py);
@ -197,23 +194,23 @@ public class StructureHelper {
} }
break; break;
} }
else if (random.nextInt(8) == 0 && !BlocksHelper.isInvulnerable(world.getBlockState(mut.above()), world, mut)) { else if (random.nextInt(8) == 0 && !BlocksHelper.isInvulnerableUnsafe(world.getBlockState(mut.above()))) {
BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR); BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR);
} }
} }
} }
} }
} }
for (int x = bounds.minX(); x <= bounds.maxX(); x++) { for (int x = bounds.x0; x <= bounds.x1; x++) {
mut.setX(x); mut.setX(x);
for (int z = bounds.minZ(); z <= bounds.maxZ(); z++) { for (int z = bounds.z0; z <= bounds.z1; z++) {
mut.setZ(z); mut.setZ(z);
for (int y = bounds.maxY(); y >= bounds.minY(); y--) { for (int y = bounds.y1; y >= bounds.y0; y--) {
mut.setY(y); mut.setY(y);
BlockState state = world.getBlockState(mut); BlockState state = world.getBlockState(mut);
if (!ignore(state, world, mut) && world.isEmptyBlock(mut.below())) { if (!ignore(state) && world.isEmptyBlock(mut.below())) {
BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR); BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR);
for (int py = mut.getY(); py >= bounds.minY() - 10; py--) { for (int py = mut.getY(); py >= bounds.y0 - 10; py--) {
mut.setY(py - 1); mut.setY(py - 1);
if (!world.isEmptyBlock(mut)) { if (!world.isEmptyBlock(mut)) {
mut.setY(py); mut.setY(py);
@ -230,15 +227,15 @@ public class StructureHelper {
public static void erodeIntense(WorldGenLevel world, BoundingBox bounds, Random random) { public static void erodeIntense(WorldGenLevel world, BoundingBox bounds, Random random) {
MutableBlockPos mut = new MutableBlockPos(); MutableBlockPos mut = new MutableBlockPos();
MutableBlockPos mut2 = new MutableBlockPos(); MutableBlockPos mut2 = new MutableBlockPos();
int minY = bounds.minY() - 10; int minY = bounds.y0 - 10;
for (int x = bounds.minX(); x <= bounds.maxX(); x++) { for (int x = bounds.x0; x <= bounds.x1; x++) {
mut.setX(x); mut.setX(x);
for (int z = bounds.minZ(); z <= bounds.maxZ(); z++) { for (int z = bounds.z0; z <= bounds.z1; z++) {
mut.setZ(z); mut.setZ(z);
for (int y = bounds.maxY(); y >= bounds.minY(); y--) { for (int y = bounds.y1; y >= bounds.y0; y--) {
mut.setY(y); mut.setY(y);
BlockState state = world.getBlockState(mut); BlockState state = world.getBlockState(mut);
if (!ignore(state, world, mut)) { if (!ignore(state)) {
if (random.nextInt(6) == 0) { if (random.nextInt(6) == 0) {
BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR); BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR);
if (random.nextBoolean()) { if (random.nextBoolean()) {
@ -281,14 +278,14 @@ public class StructureHelper {
Set<BlockPos> edge = Sets.newHashSet(); Set<BlockPos> edge = Sets.newHashSet();
Set<BlockPos> add = Sets.newHashSet(); Set<BlockPos> add = Sets.newHashSet();
for (int x = bounds.minX(); x <= bounds.maxX(); x++) { for (int x = bounds.x0; x <= bounds.x1; x++) {
mut.setX(x); mut.setX(x);
for (int z = bounds.minZ(); z <= bounds.maxZ(); z++) { for (int z = bounds.z0; z <= bounds.z1; z++) {
mut.setZ(z); mut.setZ(z);
for (int y = bounds.minY(); y <= bounds.maxY(); y++) { for (int y = bounds.y0; y <= bounds.y1; y++) {
mut.setY(y); mut.setY(y);
BlockState state = world.getBlockState(mut); BlockState state = world.getBlockState(mut);
if (!ignore(state, world, mut) && isTerrainNear(world, mut)) { if (!ignore(state) && isTerrainNear(world, mut)) {
edge.add(mut.immutable()); edge.add(mut.immutable());
} }
} }
@ -307,7 +304,7 @@ public class StructureHelper {
mut.set(center).move(dir); mut.set(center).move(dir);
if (bounds.isInside(mut)) { if (bounds.isInside(mut)) {
state = world.getBlockState(mut); state = world.getBlockState(mut);
if (!ignore(state, world, mut) && !blocks.contains(mut)) { if (!ignore(state) && !blocks.contains(mut)) {
add.add(mut.immutable()); add.add(mut.immutable());
} }
} }
@ -321,15 +318,15 @@ public class StructureHelper {
add.clear(); add.clear();
} }
int minY = bounds.minY() - 10; int minY = bounds.y0 - 10;
for (int x = bounds.minX(); x <= bounds.maxX(); x++) { for (int x = bounds.x0; x <= bounds.x1; x++) {
mut.setX(x); mut.setX(x);
for (int z = bounds.minZ(); z <= bounds.maxZ(); z++) { for (int z = bounds.z0; z <= bounds.z1; z++) {
mut.setZ(z); mut.setZ(z);
for (int y = bounds.minY(); y <= bounds.maxY(); y++) { for (int y = bounds.y0; y <= bounds.y1; y++) {
mut.setY(y); mut.setY(y);
BlockState state = world.getBlockState(mut); BlockState state = world.getBlockState(mut);
if (!ignore(state, world, mut) && !blocks.contains(mut)) { if (!ignore(state) && !blocks.contains(mut)) {
BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR); BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR);
while (world.getBlockState(mut).getMaterial().isReplaceable() && mut.getY() > minY) { while (world.getBlockState(mut).getMaterial().isReplaceable() && mut.getY() > minY) {
mut.setY(mut.getY() - 1); mut.setY(mut.getY() - 1);
@ -344,7 +341,7 @@ public class StructureHelper {
} }
} }
private static boolean ignore(BlockState state, WorldGenLevel world, BlockPos pos) { private static boolean ignore(BlockState state) {
return state.getMaterial().isReplaceable() || return state.getMaterial().isReplaceable() ||
!state.getFluidState().isEmpty() || !state.getFluidState().isEmpty() ||
state.is(TagAPI.END_GROUND) || state.is(TagAPI.END_GROUND) ||
@ -352,17 +349,17 @@ public class StructureHelper {
state.is(BlockTags.LEAVES) || state.is(BlockTags.LEAVES) ||
state.getMaterial().equals(Material.PLANT) || state.getMaterial().equals(Material.PLANT) ||
state.getMaterial().equals(Material.LEAVES) || state.getMaterial().equals(Material.LEAVES) ||
BlocksHelper.isInvulnerable(state, world, pos); BlocksHelper.isInvulnerableUnsafe(state);
} }
public static void cover(WorldGenLevel world, BoundingBox bounds, Random random) { public static void cover(WorldGenLevel world, BoundingBox bounds, Random random) {
MutableBlockPos mut = new MutableBlockPos(); MutableBlockPos mut = new MutableBlockPos();
for (int x = bounds.minX(); x <= bounds.maxX(); x++) { for (int x = bounds.x0; x <= bounds.x1; x++) {
mut.setX(x); mut.setX(x);
for (int z = bounds.minZ(); z <= bounds.maxZ(); z++) { for (int z = bounds.z0; z <= bounds.z1; z++) {
mut.setZ(z); mut.setZ(z);
BlockState top = world.getBiome(mut).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial(); BlockState top = world.getBiome(mut).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
for (int y = bounds.maxY(); y >= bounds.minY(); y--) { for (int y = bounds.y1; y >= bounds.y0; y--) {
mut.setY(y); mut.setY(y);
BlockState state = world.getBlockState(mut); BlockState state = world.getBlockState(mut);
if (state.is(TagAPI.END_GROUND) && !world.getBlockState(mut.above()).getMaterial().isSolidBlocking()) { if (state.is(TagAPI.END_GROUND) && !world.getBlockState(mut.above()).getMaterial().isSolidBlocking()) {

View file

@ -58,11 +58,11 @@ public class TagHelper {
return builder; return builder;
} }
public static Map<ResourceLocation, Tag.Builder> apply(String directory, Map<ResourceLocation, Tag.Builder> tagsMap) { public static Map<ResourceLocation, Tag.Builder> apply(String entry, Map<ResourceLocation, Tag.Builder> tagsMap) {
Map<ResourceLocation, Set<ResourceLocation>> endTags = null; Map<ResourceLocation, Set<ResourceLocation>> endTags = null;
if ("tags/blocks".equals(directory)) { if (entry.equals("block")) {
endTags = TAGS_BLOCK; endTags = TAGS_BLOCK;
} else if ("tags/items".equals(directory)) { } else if (entry.equals("item")) {
endTags = TAGS_ITEM; endTags = TAGS_ITEM;
} }
if (endTags != null) { if (endTags != null) {

View file

@ -8,6 +8,7 @@ import com.google.common.collect.Maps;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.data.worldgen.biome.Biomes;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.Music; import net.minecraft.sounds.Music;
import net.minecraft.sounds.Musics; import net.minecraft.sounds.Musics;
@ -28,7 +29,6 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.levelgen.GenerationStep.Carving; import net.minecraft.world.level.levelgen.GenerationStep.Carving;
import net.minecraft.world.level.levelgen.GenerationStep.Decoration; 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.carver.ConfiguredWorldCarver;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature; import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
@ -43,7 +43,7 @@ import ru.bclib.world.structures.BCLStructureFeature;
import ru.bclib.world.surface.DoubleBlockSurfaceBuilder; import ru.bclib.world.surface.DoubleBlockSurfaceBuilder;
public class BCLBiomeDef { public class BCLBiomeDef {
public static final int DEF_FOLIAGE_OVERWORLD = ColorUtil.color(110, 143, 64); 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_NETHER =ColorUtil.color(117, 10, 10);
public static final int DEF_FOLIAGE_END = ColorUtil.color(197, 210, 112); public static final int DEF_FOLIAGE_END = ColorUtil.color(197, 210, 112);
@ -346,7 +346,7 @@ public class BCLBiomeDef {
private static final class CarverInfo { private static final class CarverInfo {
Carving carverStep; Carving carverStep;
ConfiguredWorldCarver<CarverConfiguration> carver; ConfiguredWorldCarver<ProbabilityFeatureConfiguration> carver;
} }
public ResourceLocation getID() { public ResourceLocation getID() {
@ -365,7 +365,7 @@ public class BCLBiomeDef {
return edgeSize; return edgeSize;
} }
public BCLBiomeDef addCarver(Carving carverStep, ConfiguredWorldCarver<CarverConfiguration> carver) { public BCLBiomeDef addCarver(Carving carverStep, ConfiguredWorldCarver<ProbabilityFeatureConfiguration> carver) {
CarverInfo info = new CarverInfo(); CarverInfo info = new CarverInfo();
info.carverStep = carverStep; info.carverStep = carverStep;
info.carver = carver; info.carver = carver;

View file

@ -1,27 +0,0 @@
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);
}
}

View file

@ -4,11 +4,9 @@ import net.minecraft.core.Registry;
import net.minecraft.data.BuiltinRegistries; import net.minecraft.data.BuiltinRegistries;
import net.minecraft.data.worldgen.Features; import net.minecraft.data.worldgen.Features;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.levelgen.GenerationStep; 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.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.configurations.CountConfiguration; import net.minecraft.world.level.levelgen.feature.configurations.CountConfiguration;
@ -19,15 +17,11 @@ import net.minecraft.world.level.levelgen.feature.configurations.RangeDecoratorC
import net.minecraft.world.level.levelgen.placement.ChanceDecoratorConfiguration; import net.minecraft.world.level.levelgen.placement.ChanceDecoratorConfiguration;
import net.minecraft.world.level.levelgen.placement.FeatureDecorator; 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.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 { public class BCLFeature {
private static final RuleTest ANY_TERRAIN = new TagMatchTest(TagAPI.GEN_TERRAIN); private Feature<?> feature;
private ConfiguredFeature<?, ?> featureConfigured; private ConfiguredFeature<?, ?> featureConfigured;
private GenerationStep.Decoration featureStep; private GenerationStep.Decoration featureStep;
private Feature<?> feature;
public BCLFeature(Feature<?> feature, ConfiguredFeature<?, ?> configuredFeature, GenerationStep.Decoration featureStep) { public BCLFeature(Feature<?> feature, ConfiguredFeature<?, ?> configuredFeature, GenerationStep.Decoration featureStep) {
this.featureConfigured = configuredFeature; this.featureConfigured = configuredFeature;
@ -42,7 +36,7 @@ public class BCLFeature {
} }
public static BCLFeature makeVegetationFeature(ResourceLocation id, Feature<NoneFeatureConfiguration> feature, int density) { public static BCLFeature makeVegetationFeature(ResourceLocation id, Feature<NoneFeatureConfiguration> feature, int density) {
ConfiguredFeature<?, ?> configured = feature.configured(FeatureConfiguration.NONE).decorated(BCLDecorators.HEIGHTMAP_SQUARE).countRandom(density); ConfiguredFeature<?, ?> configured = feature.configured(FeatureConfiguration.NONE).decorated(Features.Decorators.HEIGHTMAP_SQUARE).countRandom(density);
return new BCLFeature(id, feature, GenerationStep.Decoration.VEGETAL_DECORATION, configured); return new BCLFeature(id, feature, GenerationStep.Decoration.VEGETAL_DECORATION, configured);
} }
@ -52,15 +46,15 @@ public class BCLFeature {
} }
public static BCLFeature makeLakeFeature(ResourceLocation id, Feature<NoneFeatureConfiguration> feature, int chance) { public static BCLFeature makeLakeFeature(ResourceLocation id, Feature<NoneFeatureConfiguration> feature, int chance) {
ConfiguredFeature<?, ?> configured = feature.configured(FeatureConfiguration.NONE).decorated(FeatureDecorator.LAVA_LAKE.configured(new ChanceDecoratorConfiguration(chance))); ConfiguredFeature<?, ?> configured = feature.configured(FeatureConfiguration.NONE).decorated(FeatureDecorator.WATER_LAKE.configured(new ChanceDecoratorConfiguration(chance)));
return new BCLFeature(id, feature, GenerationStep.Decoration.LAKES, configured); 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) { 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); OreConfiguration featureConfig = new OreConfiguration(new BlockMatchTest(Blocks.END_STONE), blockOre.defaultBlockState(), veinSize);
OreConfiguration config = new OreConfiguration(ANY_TERRAIN, blockOre.defaultBlockState(), 33); RangeDecoratorConfiguration rangeDecorator = new RangeDecoratorConfiguration(offset, minY, maxY);
ConfiguredFeature<?, ?> oreFeature = Feature.ORE.configured(featureConfig) ConfiguredFeature<?, ?> oreFeature = Feature.ORE.configured(featureConfig)
.rangeUniform(VerticalAnchor.absolute(minY), VerticalAnchor.absolute(maxY)) .decorated(FeatureDecorator.RANGE.configured(rangeDecorator))
.squared() .squared()
.count(veins); .count(veins);
return new BCLFeature(Feature.ORE, Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id, oreFeature), GenerationStep.Decoration.UNDERGROUND_ORES); return new BCLFeature(Feature.ORE, Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id, oreFeature), GenerationStep.Decoration.UNDERGROUND_ORES);

View file

@ -7,7 +7,6 @@ import java.util.Random;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.Vec3i;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtIo; import net.minecraft.nbt.NbtIo;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
@ -18,13 +17,11 @@ import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation; import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator; 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.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.structure.BoundingBox; 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.StructurePlaceSettings;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilderConfiguration; import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilderConfiguration;
import net.minecraft.world.phys.Vec3;
import ru.bclib.api.BiomeAPI; import ru.bclib.api.BiomeAPI;
import ru.bclib.api.TagAPI; import ru.bclib.api.TagAPI;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
@ -79,11 +76,7 @@ public abstract class NBTStructureFeature extends DefaultFeature {
} }
@Override @Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> context) { public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos center, NoneFeatureConfiguration featureConfig) {
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 = new BlockPos(((center.getX() >> 4) << 4) | 8, 128, ((center.getZ() >> 4) << 4) | 8);
center = getGround(world, center); center = getGround(world, center);
@ -95,14 +88,14 @@ public abstract class NBTStructureFeature extends DefaultFeature {
StructureTemplate structure = getStructure(world, center, random); StructureTemplate structure = getStructure(world, center, random);
Rotation rotation = getRotation(world, center, random); Rotation rotation = getRotation(world, center, random);
Mirror mirror = getMirror(world, center, random); Mirror mirror = getMirror(world, center, random);
BlockPos offset = StructureTemplate.transform(new BlockPos(structure.getSize()), mirror, rotation, BlockPos.ZERO); BlockPos offset = StructureTemplate.transform(structure.getSize(), mirror, rotation, BlockPos.ZERO);
center = center.offset(0, getYOffset(structure, world, center, random) + 0.5, 0); center = center.offset(0, getYOffset(structure, world, center, random) + 0.5, 0);
BoundingBox bounds = makeBox(center); BoundingBox bounds = makeBox(center);
StructurePlaceSettings placementData = new StructurePlaceSettings().setRotation(rotation).setMirror(mirror).setBoundingBox(bounds); StructurePlaceSettings placementData = new StructurePlaceSettings().setRotation(rotation).setMirror(mirror).setBoundingBox(bounds);
addStructureData(placementData); addStructureData(placementData);
center = center.offset(-offset.getX() * 0.5, 0, -offset.getZ() * 0.5); center = center.offset(-offset.getX() * 0.5, 0, -offset.getZ() * 0.5);
structure.placeInWorld(world, center, center, placementData, random, 4); structure.placeInWorldChunk(world, center, placementData, random);
TerrainMerge merge = getTerrainMerge(world, center, random); TerrainMerge merge = getTerrainMerge(world, center, random);
int x1 = center.getX(); int x1 = center.getX();
@ -174,7 +167,7 @@ public abstract class NBTStructureFeature extends DefaultFeature {
int sz = ((pos.getZ() >> 4) << 4) - 16; int sz = ((pos.getZ() >> 4) << 4) - 16;
int ex = sx + 47; int ex = sx + 47;
int ez = sz + 47; int ez = sz + 47;
return BoundingBox.fromCorners(new Vec3i(sx, 0, sz), new Vec3i(ex, 255, ez)); return BoundingBox.createProper(sx, 0, sz, ex, 255, ez);
} }
protected static StructureTemplate readStructure(ResourceLocation resource) { protected static StructureTemplate readStructure(ResourceLocation resource) {

View file

@ -100,7 +100,7 @@ public class StructureWorld {
public BoundingBox getBounds() { public BoundingBox getBounds() {
if (minX == Integer.MAX_VALUE || maxX == Integer.MIN_VALUE || minZ == Integer.MAX_VALUE || maxZ == Integer.MIN_VALUE) { if (minX == Integer.MAX_VALUE || maxX == Integer.MIN_VALUE || minZ == Integer.MAX_VALUE || maxZ == Integer.MIN_VALUE) {
return BoundingBox.infinite(); return BoundingBox.getUnknownBox();
} }
return new BoundingBox(minX << 4, minY, minZ << 4, (maxX << 4) | 15, maxY, (maxZ << 4) | 15); return new BoundingBox(minX << 4, minY, minZ << 4, (maxX << 4) | 15, maxY, (maxZ << 4) | 15);
} }

View file

@ -35,6 +35,12 @@ public class DoubleBlockSurfaceBuilder extends SurfaceBuilder<SurfaceBuilderBase
return this; return this;
} }
@Override
public void apply(Random random, ChunkAccess chunk, Biome biome, int x, int z, int height, double noise, BlockState defaultBlock, BlockState defaultFluid, int seaLevel, long seed, SurfaceBuilderBaseConfiguration surfaceBlocks) {
noise = NOISE.eval(x * 0.1, z * 0.1) + MHelper.randRange(-0.4, 0.4, random);
SurfaceBuilder.DEFAULT.apply(random, chunk, biome, x, z, height, noise, defaultBlock, defaultFluid, seaLevel, seed, noise > 0 ? config1 : config2);
}
public static DoubleBlockSurfaceBuilder register(String name) { public static DoubleBlockSurfaceBuilder register(String name) {
return Registry.register(Registry.SURFACE_BUILDER, name, new DoubleBlockSurfaceBuilder()); return Registry.register(Registry.SURFACE_BUILDER, name, new DoubleBlockSurfaceBuilder());
} }
@ -43,10 +49,4 @@ public class DoubleBlockSurfaceBuilder extends SurfaceBuilder<SurfaceBuilderBase
BlockState stone = Blocks.END_STONE.defaultBlockState(); BlockState stone = Blocks.END_STONE.defaultBlockState();
return this.configured(new SurfaceBuilderBaseConfiguration(config1.getTopMaterial(), stone, stone)); return this.configured(new SurfaceBuilderBaseConfiguration(config1.getTopMaterial(), stone, stone));
} }
@Override
public void apply(Random random, ChunkAccess chunkAccess, Biome biome, int x, int z, int height, double noise, BlockState defaultBlock, BlockState defaultFluid, int l, int m, long seed, SurfaceBuilderBaseConfiguration surfaceBuilderConfiguration) {
noise = NOISE.eval(x * 0.1, z * 0.1) + MHelper.randRange(-0.4, 0.4, random);
SurfaceBuilder.DEFAULT.apply(random, chunkAccess, biome, x, z, height, noise, defaultBlock, defaultFluid, l, m, seed, noise > 0 ? config1 : config2);
}
} }

View file

@ -5,6 +5,7 @@
"compatibilityLevel": "JAVA_8", "compatibilityLevel": "JAVA_8",
"mixins": [ "mixins": [
"ComposterBlockAccessor", "ComposterBlockAccessor",
"EntrypointServerMixin",
"PotionBrewingAccessor", "PotionBrewingAccessor",
"RecipeManagerAccessor", "RecipeManagerAccessor",
"EnchantmentMenuMixin", "EnchantmentMenuMixin",

View file

@ -25,9 +25,6 @@
], ],
"client": [ "client": [
"ru.bclib.client.BCLibClient" "ru.bclib.client.BCLibClient"
],
"server": [
"ru.bclib.server.BCLibServer"
] ]
}, },
"mixins": [ "mixins": [