Code style fix, interface rename, custom item getter

This commit is contained in:
paulevsGitch 2021-07-20 00:10:00 +03:00
parent 179ada3296
commit c6afa74529
134 changed files with 3404 additions and 1244 deletions

View file

@ -24,7 +24,12 @@ public class BiomeAPI {
* Empty biome used as default value if requested biome doesn't exist or linked. Shouldn't be registered anywhere to prevent bugs. * Empty biome used as default value if requested biome doesn't exist or linked. Shouldn't be registered anywhere to prevent bugs.
* Have {@code Biomes.THE_VOID} as the reference biome. * Have {@code Biomes.THE_VOID} as the reference biome.
*/ */
public static final BCLBiome EMPTY_BIOME = new BCLBiome(Biomes.THE_VOID.location(), BuiltinRegistries.BIOME.get(Biomes.THE_VOID), 1, 0); public static final BCLBiome EMPTY_BIOME = new BCLBiome(
Biomes.THE_VOID.location(),
BuiltinRegistries.BIOME.get(Biomes.THE_VOID),
1,
0
);
private static final HashMap<ResourceLocation, BCLBiome> ID_MAP = Maps.newHashMap(); private static final HashMap<ResourceLocation, BCLBiome> ID_MAP = Maps.newHashMap();
private static final HashMap<Biome, BCLBiome> CLIENT = Maps.newHashMap(); private static final HashMap<Biome, BCLBiome> CLIENT = Maps.newHashMap();
@ -55,7 +60,13 @@ public class BiomeAPI {
public static void addNetherBiomeToFabricApi(BCLBiome biome) { public static void addNetherBiomeToFabricApi(BCLBiome biome) {
ResourceKey<Biome> key = BuiltinRegistries.BIOME.getResourceKey(biome.getBiome()).get(); ResourceKey<Biome> key = BuiltinRegistries.BIOME.getResourceKey(biome.getBiome()).get();
Random random = new Random(biome.getID().toString().hashCode()); Random random = new Random(biome.getID().toString().hashCode());
ClimateParameters parameters = new ClimateParameters(MHelper.randRange(-2F, 2F, random), MHelper.randRange(-2F, 2F, random), MHelper.randRange(-2F, 2F, random), MHelper.randRange(-2F, 2F, random), MHelper.randRange(-2F, 2F, random)); ClimateParameters parameters = new ClimateParameters(
MHelper.randRange(-2F, 2F, random),
MHelper.randRange(-2F, 2F, random),
MHelper.randRange(-2F, 2F, random),
MHelper.randRange(-2F, 2F, random),
MHelper.randRange(-2F, 2F, random)
);
InternalBiomeData.addNetherBiome(key, parameters); InternalBiomeData.addNetherBiome(key, parameters);
} }
@ -106,7 +117,9 @@ public class BiomeAPI {
BCLBiome endBiome = CLIENT.get(biome); BCLBiome endBiome = CLIENT.get(biome);
if (endBiome == null) { if (endBiome == null) {
Minecraft minecraft = Minecraft.getInstance(); Minecraft minecraft = Minecraft.getInstance();
ResourceLocation id = minecraft.level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getKey(biome); ResourceLocation id = minecraft.level.registryAccess()
.registryOrThrow(Registry.BIOME_REGISTRY)
.getKey(biome);
endBiome = id == null ? EMPTY_BIOME : ID_MAP.getOrDefault(id, EMPTY_BIOME); endBiome = id == null ? EMPTY_BIOME : ID_MAP.getOrDefault(id, EMPTY_BIOME);
CLIENT.put(biome, endBiome); CLIENT.put(biome, endBiome);
} }

View file

@ -166,12 +166,20 @@ public class DataFixerAPI2 {
if (modID == null || "".equals(modID)) { if (modID == null || "".equals(modID)) {
throw new RuntimeException("[INTERNAL ERROR] Patches need a valid modID!"); throw new RuntimeException("[INTERNAL ERROR] Patches need a valid modID!");
} }
if (!ALL.stream().filter(p -> p.getModID().equals(modID)).noneMatch(p -> p.getLevel() >= level) || level <= 0) { if (!ALL.stream()
throw new RuntimeException("[INTERNAL ERROR] Patch-levels need to be created in ascending order beginning with 1."); .filter(p -> p.getModID().equals(modID))
.noneMatch(p -> p.getLevel() >= level) || level <= 0) {
throw new RuntimeException(
"[INTERNAL ERROR] Patch-levels need to be created in ascending order beginning with 1.");
} }
BCLib.LOGGER.info("Creating Patchlevel {} ({}, {})", level, ALL, ALL.stream().noneMatch(p -> p.getLevel() >= level)); BCLib.LOGGER.info(
"Creating Patchlevel {} ({}, {})",
level,
ALL,
ALL.stream().noneMatch(p -> p.getLevel() >= level)
);
this.level = level; this.level = level;
this.modID = modID; this.modID = modID;
} }
@ -229,7 +237,10 @@ public class DataFixerAPI2 {
private MigrationData(PathConfig config) { private MigrationData(PathConfig config) {
this.config = config; this.config = config;
this.mods = Collections.unmodifiableSet(Patch.getALL().stream().map(p -> p.modID).collect(Collectors.toSet())); this.mods = Collections.unmodifiableSet(Patch.getALL()
.stream()
.map(p -> p.modID)
.collect(Collectors.toSet()));
HashMap<String, String> replacements = new HashMap<String, String>(); HashMap<String, String> replacements = new HashMap<String, String>();
for (String modID : mods) { for (String modID : mods) {
@ -249,7 +260,13 @@ public class DataFixerAPI2 {
final public void markApplied() { final public void markApplied() {
for (String modID : mods) { for (String modID : mods) {
LOGGER.info("Updating Patch-Level for '{}' from {} to {} -> {}", modID, currentPatchLevel(modID), Patch.maxPatchLevel(modID), config.setInt(Configs.MAIN_PATCH_CATEGORY, modID, Patch.maxPatchLevel(modID))); LOGGER.info(
"Updating Patch-Level for '{}' from {} to {} -> {}",
modID,
currentPatchLevel(modID),
Patch.maxPatchLevel(modID),
config.setInt(Configs.MAIN_PATCH_CATEGORY, modID, Patch.maxPatchLevel(modID))
);
} }
config.saveChanges(); config.saveChanges();

View file

@ -134,7 +134,16 @@ public class BaseBarrelBlockEntity extends RandomizableContainerBlockEntity {
double d = (double) this.worldPosition.getX() + 0.5D + (double) vec3i.getX() / 2.0D; double d = (double) this.worldPosition.getX() + 0.5D + (double) vec3i.getX() / 2.0D;
double e = (double) this.worldPosition.getY() + 0.5D + (double) vec3i.getY() / 2.0D; double e = (double) this.worldPosition.getY() + 0.5D + (double) vec3i.getY() / 2.0D;
double f = (double) this.worldPosition.getZ() + 0.5D + (double) vec3i.getZ() / 2.0D; double f = (double) this.worldPosition.getZ() + 0.5D + (double) vec3i.getZ() / 2.0D;
level.playSound(null, d, e, f, soundEvent, SoundSource.BLOCKS, 0.5F, this.level.random.nextFloat() * 0.1F + 0.9F); level.playSound(
null,
d,
e,
f,
soundEvent,
SoundSource.BLOCKS,
0.5F,
this.level.random.nextFloat() * 0.1F + 0.9F
);
} }
} }
} }

View file

@ -4,10 +4,12 @@ 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.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
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;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.BlockItem;
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.level.block.AnvilBlock; import net.minecraft.world.level.block.AnvilBlock;
@ -20,16 +22,18 @@ import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootContext;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.BasePatterns;
import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.client.models.PatternsHelper; import ru.bclib.client.models.PatternsHelper;
import ru.bclib.interfaces.BlockModelGetter;
import ru.bclib.interfaces.CustomItemGetter;
import ru.bclib.items.BaseAnvilItem; import ru.bclib.items.BaseAnvilItem;
import ru.bclib.registry.BlocksRegistry;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
public abstract class BaseAnvilBlock extends AnvilBlock implements BlockModelProvider { public abstract class BaseAnvilBlock extends AnvilBlock implements BlockModelGetter, CustomItemGetter {
public static final IntegerProperty DESTRUCTION = BlockProperties.DESTRUCTION; public static final IntegerProperty DESTRUCTION = BlockProperties.DESTRUCTION;
public BaseAnvilBlock(MaterialColor color) { public BaseAnvilBlock(MaterialColor color) {
@ -91,4 +95,9 @@ public abstract class BaseAnvilBlock extends AnvilBlock implements BlockModelPro
registerBlockModel(stateId, modelLocation, blockState, modelCache); registerBlockModel(stateId, modelLocation, blockState, modelCache);
return ModelsHelper.createFacingModel(modelLocation, blockState.getValue(FACING), false, false); return ModelsHelper.createFacingModel(modelLocation, blockState.getValue(FACING), false, false);
} }
@Override
public BlockItem getCustomItem(ResourceLocation blockID, FabricItemSettings settings) {
return new BaseAnvilItem(this, settings);
}
} }

View file

@ -28,9 +28,9 @@ import net.minecraft.world.phys.BlockHitResult;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import ru.bclib.blockentities.BaseBarrelBlockEntity; import ru.bclib.blockentities.BaseBarrelBlockEntity;
import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.BasePatterns;
import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.client.models.PatternsHelper; import ru.bclib.client.models.PatternsHelper;
import ru.bclib.interfaces.BlockModelGetter;
import ru.bclib.registry.BaseBlockEntities; import ru.bclib.registry.BaseBlockEntities;
import java.util.List; import java.util.List;
@ -38,7 +38,7 @@ import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.Random; import java.util.Random;
public class BaseBarrelBlock extends BarrelBlock implements BlockModelProvider { public class BaseBarrelBlock extends BarrelBlock implements BlockModelGetter {
public BaseBarrelBlock(Block source) { public BaseBarrelBlock(Block source) {
super(FabricBlockSettings.copyOf(source).noOcclusion()); super(FabricBlockSettings.copyOf(source).noOcclusion());
} }

View file

@ -8,7 +8,7 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.MaterialColor; import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootContext;
import ru.bclib.client.models.BlockModelProvider; import ru.bclib.interfaces.BlockModelGetter;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -23,7 +23,7 @@ import java.util.function.Consumer;
* <li>Automatically create an Item-Model from the Block-Model</li> * <li>Automatically create an Item-Model from the Block-Model</li>
* </ul> * </ul>
*/ */
public class BaseBlock extends Block implements BlockModelProvider { public class BaseBlock extends Block implements BlockModelGetter {
/** /**
* Creates a new Block with the passed properties * Creates a new Block with the passed properties
* *

View file

@ -15,16 +15,16 @@ import net.minecraft.world.level.block.state.properties.AttachFace;
import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootContext;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.BasePatterns;
import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.client.models.PatternsHelper; import ru.bclib.client.models.PatternsHelper;
import ru.bclib.interfaces.BlockModelGetter;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
public abstract class BaseButtonBlock extends ButtonBlock implements BlockModelProvider { public abstract class BaseButtonBlock extends ButtonBlock implements BlockModelGetter {
private final Block parent; private final Block parent;
@ -51,7 +51,10 @@ public abstract class BaseButtonBlock extends ButtonBlock implements BlockModelP
@Environment(EnvType.CLIENT) @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) ? PatternsHelper.createJson(BasePatterns.BLOCK_BUTTON_PRESSED, parentId) : PatternsHelper.createJson(BasePatterns.BLOCK_BUTTON, parentId); Optional<String> pattern = blockState.getValue(POWERED) ? PatternsHelper.createJson(
BasePatterns.BLOCK_BUTTON_PRESSED,
parentId
) : PatternsHelper.createJson(BasePatterns.BLOCK_BUTTON, parentId);
return ModelsHelper.fromPattern(pattern); return ModelsHelper.fromPattern(pattern);
} }

View file

@ -15,18 +15,18 @@ import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootContext;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.BasePatterns;
import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.models.ModelsHelper; 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.BlockModelGetter;
import ru.bclib.interfaces.RenderLayerGetter;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
public class BaseChainBlock extends ChainBlock implements BlockModelProvider, IRenderTyped { public class BaseChainBlock extends ChainBlock implements BlockModelGetter, RenderLayerGetter {
public BaseChainBlock(MaterialColor color) { public BaseChainBlock(MaterialColor color) {
super(FabricBlockSettings.copyOf(Blocks.CHAIN).mapColor(color)); super(FabricBlockSettings.copyOf(Blocks.CHAIN).mapColor(color));
} }

View file

@ -15,15 +15,15 @@ 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 org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.BasePatterns;
import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.client.models.PatternsHelper; import ru.bclib.client.models.PatternsHelper;
import ru.bclib.interfaces.BlockModelGetter;
import ru.bclib.registry.BaseBlockEntities; import ru.bclib.registry.BaseBlockEntities;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
public class BaseChestBlock extends ChestBlock implements BlockModelProvider { public class BaseChestBlock extends ChestBlock implements BlockModelGetter {
private final Block parent; private final Block parent;
public BaseChestBlock(Block source) { public BaseChestBlock(Block source) {

View file

@ -13,17 +13,17 @@ 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 org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.BasePatterns;
import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.client.models.ModelsHelper.MultiPartBuilder; import ru.bclib.client.models.ModelsHelper.MultiPartBuilder;
import ru.bclib.client.models.PatternsHelper; import ru.bclib.client.models.PatternsHelper;
import ru.bclib.interfaces.BlockModelGetter;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
public class BaseComposterBlock extends ComposterBlock implements BlockModelProvider { public class BaseComposterBlock extends ComposterBlock implements BlockModelGetter {
public BaseComposterBlock(Block source) { public BaseComposterBlock(Block source) {
super(FabricBlockSettings.copyOf(source)); super(FabricBlockSettings.copyOf(source));
} }

View file

@ -12,16 +12,16 @@ 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 org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.BasePatterns;
import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.client.models.PatternsHelper; import ru.bclib.client.models.PatternsHelper;
import ru.bclib.interfaces.BlockModelGetter;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
public class BaseCraftingTableBlock extends CraftingTableBlock implements BlockModelProvider { public class BaseCraftingTableBlock extends CraftingTableBlock implements BlockModelGetter {
public BaseCraftingTableBlock(Block source) { public BaseCraftingTableBlock(Block source) {
super(FabricBlockSettings.copyOf(source)); super(FabricBlockSettings.copyOf(source));
} }

View file

@ -38,7 +38,12 @@ public class BaseCropBlock extends BasePlantBlock {
private final Item drop; private final Item drop;
public BaseCropBlock(Item drop, Block... terrain) { public BaseCropBlock(Item drop, Block... terrain) {
super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.HOES).breakByHand(true).sound(SoundType.GRASS).randomTicks().noCollission()); super(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.HOES)
.breakByHand(true)
.sound(SoundType.GRASS)
.randomTicks()
.noCollission());
this.drop = drop; this.drop = drop;
this.terrain = terrain; this.terrain = terrain;
this.registerDefaultState(defaultBlockState().setValue(AGE, 0)); this.registerDefaultState(defaultBlockState().setValue(AGE, 0));

View file

@ -18,18 +18,18 @@ import net.minecraft.world.level.block.state.properties.DoubleBlockHalf;
import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootContext;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.BasePatterns;
import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.models.ModelsHelper; 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.BlockModelGetter;
import ru.bclib.interfaces.RenderLayerGetter;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
public class BaseDoorBlock extends DoorBlock implements IRenderTyped, BlockModelProvider { public class BaseDoorBlock extends DoorBlock implements RenderLayerGetter, BlockModelGetter {
public BaseDoorBlock(Block source) { public BaseDoorBlock(Block source) {
super(FabricBlockSettings.copyOf(source).strength(3F, 3F).noOcclusion()); super(FabricBlockSettings.copyOf(source).strength(3F, 3F).noOcclusion());
} }
@ -114,7 +114,10 @@ public class BaseDoorBlock extends DoorBlock implements IRenderTyped, BlockModel
} }
break; break;
} }
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath() + "_" + doorType); ResourceLocation modelId = new ResourceLocation(
stateId.getNamespace(),
"block/" + stateId.getPath() + "_" + doorType
);
registerBlockModel(stateId, modelId, blockState, modelCache); registerBlockModel(stateId, modelId, blockState, modelCache);
return ModelsHelper.createMultiVariant(modelId, rotation.getRotation(), false); return ModelsHelper.createMultiVariant(modelId, rotation.getRotation(), false);
} }

View file

@ -31,25 +31,34 @@ import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape; 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.RenderLayerGetter;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements IRenderTyped, BonemealableBlock { public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements RenderLayerGetter, 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;
public static final BooleanProperty TOP = BooleanProperty.create("top"); public static final BooleanProperty TOP = BooleanProperty.create("top");
public BaseDoublePlantBlock() { public BaseDoublePlantBlock() {
super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).breakByHand(true).sound(SoundType.WET_GRASS).noCollission()); super(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.breakByHand(true)
.sound(SoundType.WET_GRASS)
.noCollission());
this.registerDefaultState(this.stateDefinition.any().setValue(TOP, false)); this.registerDefaultState(this.stateDefinition.any().setValue(TOP, false));
} }
public BaseDoublePlantBlock(int light) { public BaseDoublePlantBlock(int light) {
super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).breakByHand(true).sound(SoundType.WET_GRASS).lightLevel((state) -> state.getValue(TOP) ? light : 0).noCollission()); super(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.breakByHand(true)
.sound(SoundType.WET_GRASS)
.lightLevel((state) -> state.getValue(TOP) ? light : 0)
.noCollission());
this.registerDefaultState(this.stateDefinition.any().setValue(TOP, false)); this.registerDefaultState(this.stateDefinition.any().setValue(TOP, false));
} }
@ -101,7 +110,10 @@ 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 && FabricToolTags.SHEARS.contains(tool.getItem()) || EnchantmentHelper.getItemEnchantmentLevel(
Enchantments.SILK_TOUCH,
tool
) > 0) {
return Lists.newArrayList(new ItemStack(this)); return Lists.newArrayList(new ItemStack(this));
} }
else { else {
@ -126,7 +138,13 @@ public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements I
@Override @Override
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) { public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) {
ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, new ItemStack(this)); ItemEntity item = new ItemEntity(
world,
pos.getX() + 0.5,
pos.getY() + 0.5,
pos.getZ() + 0.5,
new ItemStack(this)
);
world.addFreshEntity(item); world.addFreshEntity(item);
} }

View file

@ -15,17 +15,17 @@ 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 org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.BasePatterns;
import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.client.models.ModelsHelper.MultiPartBuilder; import ru.bclib.client.models.ModelsHelper.MultiPartBuilder;
import ru.bclib.client.models.PatternsHelper; import ru.bclib.client.models.PatternsHelper;
import ru.bclib.interfaces.BlockModelGetter;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
public class BaseFenceBlock extends FenceBlock implements BlockModelProvider { public class BaseFenceBlock extends FenceBlock implements BlockModelGetter {
private final Block parent; private final Block parent;
public BaseFenceBlock(Block source) { public BaseFenceBlock(Block source) {
@ -72,9 +72,21 @@ public class BaseFenceBlock extends FenceBlock implements BlockModelProvider {
MultiPartBuilder builder = MultiPartBuilder.create(stateDefinition); MultiPartBuilder builder = MultiPartBuilder.create(stateDefinition);
builder.part(sideId).setCondition(state -> state.getValue(NORTH)).setUVLock(true).add(); builder.part(sideId).setCondition(state -> state.getValue(NORTH)).setUVLock(true).add();
builder.part(sideId).setCondition(state -> state.getValue(EAST)).setTransformation(BlockModelRotation.X0_Y90.getRotation()).setUVLock(true).add(); builder.part(sideId)
builder.part(sideId).setCondition(state -> state.getValue(SOUTH)).setTransformation(BlockModelRotation.X0_Y180.getRotation()).setUVLock(true).add(); .setCondition(state -> state.getValue(EAST))
builder.part(sideId).setCondition(state -> state.getValue(WEST)).setTransformation(BlockModelRotation.X0_Y270.getRotation()).setUVLock(true).add(); .setTransformation(BlockModelRotation.X0_Y90.getRotation())
.setUVLock(true)
.add();
builder.part(sideId)
.setCondition(state -> state.getValue(SOUTH))
.setTransformation(BlockModelRotation.X0_Y180.getRotation())
.setUVLock(true)
.add();
builder.part(sideId)
.setCondition(state -> state.getValue(WEST))
.setTransformation(BlockModelRotation.X0_Y270.getRotation())
.setUVLock(true)
.add();
builder.part(postId).add(); builder.part(postId).add();
return builder.build(); return builder.build();

View file

@ -26,18 +26,18 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import org.jetbrains.annotations.Nullable; 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.ModelsHelper; 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.BlockModelGetter;
import ru.bclib.interfaces.RenderLayerGetter;
import ru.bclib.registry.BaseBlockEntities; import ru.bclib.registry.BaseBlockEntities;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
public class BaseFurnaceBlock extends FurnaceBlock implements BlockModelProvider, IRenderTyped { public class BaseFurnaceBlock extends FurnaceBlock implements BlockModelGetter, RenderLayerGetter {
public BaseFurnaceBlock(Block source) { public BaseFurnaceBlock(Block source) {
super(FabricBlockSettings.copyOf(source).luminance(state -> state.getValue(LIT) ? 13 : 0)); super(FabricBlockSettings.copyOf(source).luminance(state -> state.getValue(LIT) ? 13 : 0));
} }
@ -119,6 +119,10 @@ public class BaseFurnaceBlock extends FurnaceBlock implements BlockModelProvider
@Nullable @Nullable
protected static <T extends BlockEntity> BlockEntityTicker<T> createFurnaceTicker(Level level, BlockEntityType<T> blockEntityType, BlockEntityType<? extends AbstractFurnaceBlockEntity> blockEntityType2) { 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); return level.isClientSide ? null : createTickerHelper(
blockEntityType,
blockEntityType2,
AbstractFurnaceBlockEntity::serverTick
);
} }
} }

View file

@ -14,16 +14,16 @@ 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 org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.BasePatterns;
import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.client.models.PatternsHelper; import ru.bclib.client.models.PatternsHelper;
import ru.bclib.interfaces.BlockModelGetter;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
public class BaseGateBlock extends FenceGateBlock implements BlockModelProvider { public class BaseGateBlock extends FenceGateBlock implements BlockModelGetter {
private final Block parent; private final Block parent;
public BaseGateBlock(Block source) { public BaseGateBlock(Block source) {
@ -51,10 +51,16 @@ public class BaseGateBlock extends FenceGateBlock implements BlockModelProvider
ResourceLocation parentId = Registry.BLOCK.getKey(parent); ResourceLocation parentId = Registry.BLOCK.getKey(parent);
Optional<String> pattern; Optional<String> pattern;
if (inWall) { if (inWall) {
pattern = isOpen ? PatternsHelper.createJson(BasePatterns.BLOCK_GATE_OPEN_WALL, parentId) : PatternsHelper.createJson(BasePatterns.BLOCK_GATE_CLOSED_WALL, parentId); pattern = isOpen ? PatternsHelper.createJson(
BasePatterns.BLOCK_GATE_OPEN_WALL,
parentId
) : PatternsHelper.createJson(BasePatterns.BLOCK_GATE_CLOSED_WALL, parentId);
} }
else { else {
pattern = isOpen ? PatternsHelper.createJson(BasePatterns.BLOCK_GATE_OPEN, parentId) : PatternsHelper.createJson(BasePatterns.BLOCK_GATE_CLOSED, parentId); pattern = isOpen ? PatternsHelper.createJson(
BasePatterns.BLOCK_GATE_OPEN,
parentId
) : PatternsHelper.createJson(BasePatterns.BLOCK_GATE_CLOSED, parentId);
} }
return ModelsHelper.fromPattern(pattern); return ModelsHelper.fromPattern(pattern);
} }

View file

@ -28,18 +28,18 @@ import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.BasePatterns;
import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.models.ModelsHelper; 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.BlockModelGetter;
import ru.bclib.interfaces.RenderLayerGetter;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class BaseLadderBlock extends BaseBlockNotFull implements IRenderTyped, BlockModelProvider { public class BaseLadderBlock extends BaseBlockNotFull implements RenderLayerGetter, BlockModelGetter {
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;
protected static final VoxelShape EAST_SHAPE = Block.box(0.0D, 0.0D, 0.0D, 3.0D, 16.0D, 16.0D); protected static final VoxelShape EAST_SHAPE = Block.box(0.0D, 0.0D, 0.0D, 3.0D, 16.0D, 16.0D);

View file

@ -15,20 +15,27 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.MaterialColor; import net.minecraft.world.level.material.MaterialColor;
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 ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped; import ru.bclib.interfaces.BlockModelGetter;
import ru.bclib.interfaces.RenderLayerGetter;
import ru.bclib.util.MHelper; import ru.bclib.util.MHelper;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.function.Consumer; import java.util.function.Consumer;
public class BaseLeavesBlock extends LeavesBlock implements BlockModelProvider, IRenderTyped { public class BaseLeavesBlock extends LeavesBlock implements BlockModelGetter, RenderLayerGetter {
private final Block sapling; private final Block sapling;
private static FabricBlockSettings makeLeaves(MaterialColor color) { private static FabricBlockSettings makeLeaves(MaterialColor color) {
return FabricBlockSettings.copyOf(Blocks.OAK_LEAVES).mapColor(color).breakByTool(FabricToolTags.HOES).breakByTool(FabricToolTags.SHEARS).breakByHand(true).allowsSpawning((state, world, pos, type) -> false).suffocates((state, world, pos) -> false).blockVision((state, world, pos) -> false); return FabricBlockSettings.copyOf(Blocks.OAK_LEAVES)
.mapColor(color)
.breakByTool(FabricToolTags.HOES)
.breakByTool(FabricToolTags.SHEARS)
.breakByHand(true)
.allowsSpawning((state, world, pos, type) -> false)
.suffocates((state, world, pos) -> false)
.blockVision((state, world, pos) -> false);
} }
public BaseLeavesBlock(Block sapling, MaterialColor color, Consumer<FabricBlockSettings> customizeProperties) { public BaseLeavesBlock(Block sapling, MaterialColor color, Consumer<FabricBlockSettings> customizeProperties) {
@ -61,7 +68,10 @@ public class BaseLeavesBlock extends LeavesBlock implements BlockModelProvider,
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 (FabricToolTags.SHEARS.contains(tool.getItem()) || 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

@ -16,18 +16,18 @@ 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 org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.BasePatterns;
import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.models.ModelsHelper; 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.BlockModelGetter;
import ru.bclib.interfaces.RenderLayerGetter;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
public class BaseMetalBarsBlock extends IronBarsBlock implements BlockModelProvider, IRenderTyped { public class BaseMetalBarsBlock extends IronBarsBlock implements BlockModelGetter, RenderLayerGetter {
public BaseMetalBarsBlock(Block source) { public BaseMetalBarsBlock(Block source) {
super(FabricBlockSettings.copyOf(source).strength(5.0F, 6.0F).noOcclusion()); super(FabricBlockSettings.copyOf(source).strength(5.0F, 6.0F).noOcclusion());
} }
@ -81,11 +81,26 @@ public class BaseMetalBarsBlock extends IronBarsBlock implements BlockModelProvi
registerBlockModel(sideId, sideId, blockState, modelCache); registerBlockModel(sideId, sideId, blockState, modelCache);
ModelsHelper.MultiPartBuilder builder = ModelsHelper.MultiPartBuilder.create(stateDefinition); ModelsHelper.MultiPartBuilder builder = ModelsHelper.MultiPartBuilder.create(stateDefinition);
builder.part(postId).setCondition(state -> !state.getValue(NORTH) && !state.getValue(EAST) && !state.getValue(SOUTH) && !state.getValue(WEST)).add(); builder.part(postId)
.setCondition(state -> !state.getValue(NORTH) && !state.getValue(EAST) && !state.getValue(SOUTH) && !state
.getValue(WEST))
.add();
builder.part(sideId).setCondition(state -> state.getValue(NORTH)).setUVLock(true).add(); builder.part(sideId).setCondition(state -> state.getValue(NORTH)).setUVLock(true).add();
builder.part(sideId).setCondition(state -> state.getValue(EAST)).setTransformation(BlockModelRotation.X0_Y90.getRotation()).setUVLock(true).add(); builder.part(sideId)
builder.part(sideId).setCondition(state -> state.getValue(SOUTH)).setTransformation(BlockModelRotation.X0_Y180.getRotation()).setUVLock(true).add(); .setCondition(state -> state.getValue(EAST))
builder.part(sideId).setCondition(state -> state.getValue(WEST)).setTransformation(BlockModelRotation.X0_Y270.getRotation()).setUVLock(true).add(); .setTransformation(BlockModelRotation.X0_Y90.getRotation())
.setUVLock(true)
.add();
builder.part(sideId)
.setCondition(state -> state.getValue(SOUTH))
.setTransformation(BlockModelRotation.X0_Y180.getRotation())
.setUVLock(true)
.add();
builder.part(sideId)
.setCondition(state -> state.getValue(WEST))
.setTransformation(BlockModelRotation.X0_Y270.getRotation())
.setUVLock(true)
.add();
return builder.build(); return builder.build();
} }

View file

@ -16,19 +16,23 @@ import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor; import net.minecraft.world.level.material.MaterialColor;
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 ru.bclib.client.models.BlockModelProvider; import ru.bclib.interfaces.BlockModelGetter;
import ru.bclib.util.MHelper; import ru.bclib.util.MHelper;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
public class BaseOreBlock extends OreBlock implements BlockModelProvider { public class BaseOreBlock extends OreBlock implements BlockModelGetter {
private final Item dropItem; private final Item dropItem;
private final int minCount; private final int minCount;
private final int maxCount; private final int maxCount;
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).hardness(3F).resistance(9F).requiresCorrectToolForDrops().sound(SoundType.STONE), UniformInt.of(1, experience)); super(FabricBlockSettings.of(Material.STONE, MaterialColor.SAND)
.hardness(3F)
.resistance(9F)
.requiresCorrectToolForDrops()
.sound(SoundType.STONE), UniformInt.of(1, experience));
this.dropItem = drop; this.dropItem = drop;
this.minCount = minCount; this.minCount = minCount;
this.maxCount = maxCount; this.maxCount = maxCount;

View file

@ -27,13 +27,13 @@ import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape; 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.RenderLayerGetter;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public abstract class BasePlantBlock extends BaseBlockNotFull implements IRenderTyped, BonemealableBlock { public abstract class BasePlantBlock extends BaseBlockNotFull implements RenderLayerGetter, 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);
public BasePlantBlock() { public BasePlantBlock() {
@ -45,11 +45,20 @@ public abstract class BasePlantBlock extends BaseBlockNotFull implements IRender
} }
public BasePlantBlock(boolean replaceable) { public BasePlantBlock(boolean replaceable) {
super(FabricBlockSettings.of(replaceable ? Material.REPLACEABLE_PLANT : Material.PLANT).breakByTool(FabricToolTags.SHEARS).breakByHand(true).sound(SoundType.GRASS).noCollission()); super(FabricBlockSettings.of(replaceable ? Material.REPLACEABLE_PLANT : Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.breakByHand(true)
.sound(SoundType.GRASS)
.noCollission());
} }
public BasePlantBlock(boolean replaceable, int light) { public BasePlantBlock(boolean replaceable, int light) {
super(FabricBlockSettings.of(replaceable ? Material.REPLACEABLE_PLANT : Material.PLANT).breakByTool(FabricToolTags.SHEARS).breakByHand(true).luminance(light).sound(SoundType.GRASS).noCollission()); super(FabricBlockSettings.of(replaceable ? Material.REPLACEABLE_PLANT : Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.breakByHand(true)
.luminance(light)
.sound(SoundType.GRASS)
.noCollission());
} }
public BasePlantBlock(Properties settings) { public BasePlantBlock(Properties settings) {
@ -88,7 +97,10 @@ 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 && FabricToolTags.SHEARS.contains(tool.getItem()) || EnchantmentHelper.getItemEnchantmentLevel(
Enchantments.SILK_TOUCH,
tool
) > 0) {
return Lists.newArrayList(new ItemStack(this)); return Lists.newArrayList(new ItemStack(this));
} }
else { else {
@ -113,7 +125,13 @@ public abstract class BasePlantBlock extends BaseBlockNotFull implements IRender
@Override @Override
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) { public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) {
ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, new ItemStack(this)); ItemEntity item = new ItemEntity(
world,
pos.getX() + 0.5,
pos.getY() + 0.5,
pos.getZ() + 0.5,
new ItemStack(this)
);
world.addFreshEntity(item); world.addFreshEntity(item);
} }
} }

View file

@ -19,7 +19,12 @@ public abstract class BasePlantWithAgeBlock extends BasePlantBlock {
public static final IntegerProperty AGE = BlockProperties.AGE; public static final IntegerProperty AGE = BlockProperties.AGE;
public BasePlantWithAgeBlock() { public BasePlantWithAgeBlock() {
this(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).breakByHand(true).sound(SoundType.GRASS).randomTicks().noCollission()); this(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.breakByHand(true)
.sound(SoundType.GRASS)
.randomTicks()
.noCollission());
} }
public BasePlantWithAgeBlock(Properties settings) { public BasePlantWithAgeBlock(Properties settings) {

View file

@ -14,16 +14,16 @@ 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 org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.BasePatterns;
import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.client.models.PatternsHelper; import ru.bclib.client.models.PatternsHelper;
import ru.bclib.interfaces.BlockModelGetter;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
public class BasePressurePlateBlock extends PressurePlateBlock implements BlockModelProvider { public class BasePressurePlateBlock extends PressurePlateBlock implements BlockModelGetter {
private final Block parent; private final Block parent;
public BasePressurePlateBlock(Sensitivity rule, Block source) { public BasePressurePlateBlock(Sensitivity rule, Block source) {

View file

@ -12,16 +12,16 @@ import net.minecraft.world.level.block.RotatedPillarBlock;
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 org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.client.models.PatternsHelper; import ru.bclib.client.models.PatternsHelper;
import ru.bclib.interfaces.BlockModelGetter;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
public class BaseRotatedPillarBlock extends RotatedPillarBlock implements BlockModelProvider { public class BaseRotatedPillarBlock extends RotatedPillarBlock implements BlockModelGetter {
public BaseRotatedPillarBlock(Properties settings) { public BaseRotatedPillarBlock(Properties settings) {
super(settings); super(settings);
} }

View file

@ -2,6 +2,7 @@ package ru.bclib.blocks;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
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;
@ -13,6 +14,7 @@ import net.minecraft.server.level.ServerPlayer;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.BlockGetter;
@ -39,25 +41,34 @@ import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import ru.bclib.blockentities.BaseSignBlockEntity; import ru.bclib.blockentities.BaseSignBlockEntity;
import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.interfaces.ISpetialItem; import ru.bclib.interfaces.BlockModelGetter;
import ru.bclib.interfaces.CustomItemGetter;
import ru.bclib.registry.BlocksRegistry;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class BaseSignBlock extends SignBlock implements BlockModelProvider, ISpetialItem { public class BaseSignBlock extends SignBlock implements BlockModelGetter, CustomItemGetter {
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");
private static final VoxelShape[] WALL_SHAPES = new VoxelShape[] {Block.box(0.0D, 4.5D, 14.0D, 16.0D, 12.5D, 16.0D), Block.box(0.0D, 4.5D, 0.0D, 2.0D, 12.5D, 16.0D), Block.box(0.0D, 4.5D, 0.0D, 16.0D, 12.5D, 2.0D), Block.box(14.0D, 4.5D, 0.0D, 16.0D, 12.5D, 16.0D)}; private static final VoxelShape[] WALL_SHAPES = new VoxelShape[] {
Block.box(0.0D, 4.5D, 14.0D, 16.0D, 12.5D, 16.0D),
Block.box(0.0D, 4.5D, 0.0D, 2.0D, 12.5D, 16.0D),
Block.box(0.0D, 4.5D, 0.0D, 16.0D, 12.5D, 2.0D),
Block.box(14.0D, 4.5D, 0.0D, 16.0D, 12.5D, 16.0D)
};
private final Block parent; private final Block parent;
public BaseSignBlock(Block source) { public BaseSignBlock(Block source) {
super(FabricBlockSettings.copyOf(source).strength(1.0F, 1.0F).noCollission().noOcclusion(), WoodType.OAK); super(FabricBlockSettings.copyOf(source).strength(1.0F, 1.0F).noCollission().noOcclusion(), WoodType.OAK);
this.registerDefaultState(this.stateDefinition.any().setValue(ROTATION, 0).setValue(FLOOR, false).setValue(WATERLOGGED, false)); this.registerDefaultState(this.stateDefinition.any()
.setValue(ROTATION, 0)
.setValue(FLOOR, false)
.setValue(WATERLOGGED, false));
this.parent = source; this.parent = source;
} }
@ -98,7 +109,8 @@ public class BaseSignBlock extends SignBlock implements BlockModelProvider, ISpe
world.getLiquidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); world.getLiquidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
} }
if (!canSurvive(state, world, pos)) { if (!canSurvive(state, world, pos)) {
return state.getValue(WATERLOGGED) ? state.getFluidState().createLegacyBlock() : Blocks.AIR.defaultBlockState(); return state.getValue(WATERLOGGED) ? state.getFluidState()
.createLegacyBlock() : Blocks.AIR.defaultBlockState();
} }
return super.updateShape(state, facing, neighborState, world, pos, neighborPos); return super.updateShape(state, facing, neighborState, world, pos, neighborPos);
} }
@ -118,7 +130,10 @@ public class BaseSignBlock extends SignBlock implements BlockModelProvider, ISpe
public BlockState getStateForPlacement(BlockPlaceContext ctx) { public BlockState getStateForPlacement(BlockPlaceContext ctx) {
if (ctx.getClickedFace() == Direction.UP) { if (ctx.getClickedFace() == Direction.UP) {
FluidState fluidState = ctx.getLevel().getFluidState(ctx.getClickedPos()); FluidState fluidState = ctx.getLevel().getFluidState(ctx.getClickedPos());
return this.defaultBlockState().setValue(FLOOR, true).setValue(ROTATION, Mth.floor((180.0 + ctx.getRotation() * 16.0 / 360.0) + 0.5 - 12) & 15).setValue(WATERLOGGED, fluidState.getType() == Fluids.WATER); return this.defaultBlockState()
.setValue(FLOOR, true)
.setValue(ROTATION, Mth.floor((180.0 + ctx.getRotation() * 16.0 / 360.0) + 0.5 - 12) & 15)
.setValue(WATERLOGGED, fluidState.getType() == Fluids.WATER);
} }
else if (ctx.getClickedFace() != Direction.DOWN) { else if (ctx.getClickedFace() != Direction.DOWN) {
BlockState blockState = this.defaultBlockState(); BlockState blockState = this.defaultBlockState();
@ -133,7 +148,8 @@ public class BaseSignBlock extends SignBlock implements BlockModelProvider, ISpe
int rot = Mth.floor((180.0 + dir.toYRot() * 16.0 / 360.0) + 0.5 + 4) & 15; int rot = Mth.floor((180.0 + dir.toYRot() * 16.0 / 360.0) + 0.5 + 4) & 15;
blockState = blockState.setValue(ROTATION, rot); blockState = blockState.setValue(ROTATION, rot);
if (blockState.canSurvive(worldView, blockPos)) { if (blockState.canSurvive(worldView, blockPos)) {
return blockState.setValue(FLOOR, false).setValue(WATERLOGGED, fluidState.getType() == Fluids.WATER); return blockState.setValue(FLOOR, false)
.setValue(WATERLOGGED, fluidState.getType() == Fluids.WATER);
} }
} }
} }
@ -177,12 +193,7 @@ public class BaseSignBlock extends SignBlock implements BlockModelProvider, ISpe
} }
@Override @Override
public int getStackSize() { public BlockItem getCustomItem(ResourceLocation blockID, FabricItemSettings settings) {
return 16; return new BlockItem(this, settings.maxCount(16));
}
@Override
public boolean canPlaceOnWater() {
return false;
} }
} }

View file

@ -16,16 +16,16 @@ import net.minecraft.world.level.block.state.properties.SlabType;
import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootContext;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.BasePatterns;
import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.client.models.PatternsHelper; import ru.bclib.client.models.PatternsHelper;
import ru.bclib.interfaces.BlockModelGetter;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
public class BaseSlabBlock extends SlabBlock implements BlockModelProvider { public class BaseSlabBlock extends SlabBlock implements BlockModelGetter {
private final Block parent; private final Block parent;
public BaseSlabBlock(Block source) { public BaseSlabBlock(Block source) {
@ -63,7 +63,10 @@ public class BaseSlabBlock extends SlabBlock implements BlockModelProvider {
@Environment(EnvType.CLIENT) @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(), "block/" + stateId.getPath() + "_" + type); ResourceLocation modelId = new ResourceLocation(
stateId.getNamespace(),
"block/" + stateId.getPath() + "_" + type
);
registerBlockModel(stateId, modelId, blockState, modelCache); registerBlockModel(stateId, modelId, blockState, modelCache);
if (type == SlabType.TOP) { if (type == SlabType.TOP) {
return ModelsHelper.createMultiVariant(modelId, BlockModelRotation.X180_Y0.getRotation(), true); return ModelsHelper.createMultiVariant(modelId, BlockModelRotation.X180_Y0.getRotation(), true);

View file

@ -17,16 +17,16 @@ import net.minecraft.world.level.block.state.properties.StairsShape;
import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootContext;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.BasePatterns;
import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.client.models.PatternsHelper; import ru.bclib.client.models.PatternsHelper;
import ru.bclib.interfaces.BlockModelGetter;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
public class BaseStairsBlock extends StairBlock implements BlockModelProvider { public class BaseStairsBlock extends StairBlock implements BlockModelGetter {
private final Block parent; private final Block parent;

View file

@ -30,7 +30,11 @@ public class BaseStripableLogBlock extends BaseRotatedPillarBlock {
if (FabricToolTags.AXES.contains(player.getMainHandItem().getItem())) { if (FabricToolTags.AXES.contains(player.getMainHandItem().getItem())) {
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
);
if (!player.isCreative()) { if (!player.isCreative()) {
player.getMainHandItem().hurt(1, world.random, (ServerPlayer) player); player.getMainHandItem().hurt(1, world.random, (ServerPlayer) player);
} }

View file

@ -51,7 +51,10 @@ public class BaseTerrainBlock extends BaseBlock {
private Block pathBlock; private Block pathBlock;
public BaseTerrainBlock(Block baseBlock, MaterialColor color) { public BaseTerrainBlock(Block baseBlock, MaterialColor color) {
super(FabricBlockSettings.copyOf(baseBlock).materialColor(color).sound(BlockSounds.TERRAIN_SOUND).randomTicks()); super(FabricBlockSettings.copyOf(baseBlock)
.materialColor(color)
.sound(BlockSounds.TERRAIN_SOUND)
.randomTicks());
this.baseBlock = baseBlock; this.baseBlock = baseBlock;
} }
@ -104,7 +107,15 @@ public class BaseTerrainBlock extends BaseBlock {
return false; return false;
} }
else { else {
int i = LayerLightEngine.getLightBlockInto(worldView, state, pos, blockState, blockPos, Direction.UP, blockState.getLightBlock(worldView, blockPos)); int i = LayerLightEngine.getLightBlockInto(
worldView,
state,
pos,
blockState,
blockPos,
Direction.UP,
blockState.getLightBlock(worldView, blockPos)
);
return i < 5; return i < 5;
} }
} }

View file

@ -15,11 +15,11 @@ import net.minecraft.world.level.block.state.properties.Half;
import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootContext;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.BasePatterns;
import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.models.ModelsHelper; 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.BlockModelGetter;
import ru.bclib.interfaces.RenderLayerGetter;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
@ -27,7 +27,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
public class BaseTrapdoorBlock extends TrapDoorBlock implements IRenderTyped, BlockModelProvider { public class BaseTrapdoorBlock extends TrapDoorBlock implements RenderLayerGetter, BlockModelGetter {
public BaseTrapdoorBlock(Block source) { public BaseTrapdoorBlock(Block source) {
super(FabricBlockSettings.copyOf(source).strength(3.0F, 3.0F).noOcclusion()); super(FabricBlockSettings.copyOf(source).strength(3.0F, 3.0F).noOcclusion());
} }
@ -53,15 +53,18 @@ public class BaseTrapdoorBlock extends TrapDoorBlock implements IRenderTyped, Bl
@Environment(EnvType.CLIENT) @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(
private static final long serialVersionUID = 1L; BasePatterns.BLOCK_TRAPDOOR,
new HashMap<String, String>() {
{ private static final long serialVersionUID = 1L;
put("%modid%", resourceLocation.getNamespace());
put("%texture%", name); {
put("%side%", name.replace("trapdoor", "door_side")); put("%modid%", resourceLocation.getNamespace());
put("%texture%", name);
put("%side%", name.replace("trapdoor", "door_side"));
}
} }
}); );
return ModelsHelper.fromPattern(pattern); return ModelsHelper.fromPattern(pattern);
} }

View file

@ -17,11 +17,20 @@ import net.minecraft.world.level.material.Material;
public abstract class BaseUnderwaterWallPlantBlock extends BaseWallPlantBlock implements LiquidBlockContainer { public abstract class BaseUnderwaterWallPlantBlock extends BaseWallPlantBlock implements LiquidBlockContainer {
public BaseUnderwaterWallPlantBlock() { public BaseUnderwaterWallPlantBlock() {
super(FabricBlockSettings.of(Material.WATER_PLANT).breakByTool(FabricToolTags.SHEARS).breakByHand(true).sound(SoundType.WET_GRASS).noCollission()); super(FabricBlockSettings.of(Material.WATER_PLANT)
.breakByTool(FabricToolTags.SHEARS)
.breakByHand(true)
.sound(SoundType.WET_GRASS)
.noCollission());
} }
public BaseUnderwaterWallPlantBlock(int light) { public BaseUnderwaterWallPlantBlock(int light) {
super(FabricBlockSettings.of(Material.WATER_PLANT).breakByTool(FabricToolTags.SHEARS).breakByHand(true).luminance(light).sound(SoundType.WET_GRASS).noCollission()); super(FabricBlockSettings.of(Material.WATER_PLANT)
.breakByTool(FabricToolTags.SHEARS)
.breakByHand(true)
.luminance(light)
.sound(SoundType.WET_GRASS)
.noCollission());
} }
public BaseUnderwaterWallPlantBlock(Properties settings) { public BaseUnderwaterWallPlantBlock(Properties settings) {

View file

@ -30,14 +30,14 @@ import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
import ru.bclib.blocks.BlockProperties.TripleShape; import ru.bclib.blocks.BlockProperties.TripleShape;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped; import ru.bclib.interfaces.RenderLayerGetter;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class BaseVineBlock extends BaseBlockNotFull implements IRenderTyped, BonemealableBlock { public class BaseVineBlock extends BaseBlockNotFull implements RenderLayerGetter, 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);
@ -50,7 +50,12 @@ public class BaseVineBlock extends BaseBlockNotFull implements IRenderTyped, Bon
} }
public BaseVineBlock(int light, boolean bottomOnly) { public BaseVineBlock(int light, boolean bottomOnly) {
super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).breakByHand(true).sound(SoundType.GRASS).lightLevel((state) -> bottomOnly ? state.getValue(SHAPE) == TripleShape.BOTTOM ? light : 0 : light).noCollission()); super(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.breakByHand(true)
.sound(SoundType.GRASS)
.lightLevel((state) -> bottomOnly ? state.getValue(SHAPE) == TripleShape.BOTTOM ? light : 0 : light)
.noCollission());
this.registerDefaultState(this.stateDefinition.any().setValue(SHAPE, TripleShape.BOTTOM)); this.registerDefaultState(this.stateDefinition.any().setValue(SHAPE, TripleShape.BOTTOM));
} }
@ -99,7 +104,10 @@ 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 && FabricToolTags.SHEARS.contains(tool.getItem()) || EnchantmentHelper.getItemEnchantmentLevel(
Enchantments.SILK_TOUCH,
tool
) > 0) {
return Lists.newArrayList(new ItemStack(this)); return Lists.newArrayList(new ItemStack(this));
} }
else { else {

View file

@ -16,16 +16,16 @@ import net.minecraft.world.level.block.state.properties.WallSide;
import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootContext;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.BasePatterns;
import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.client.models.PatternsHelper; import ru.bclib.client.models.PatternsHelper;
import ru.bclib.interfaces.BlockModelGetter;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
public class BaseWallBlock extends WallBlock implements BlockModelProvider { public class BaseWallBlock extends WallBlock implements BlockModelGetter {
private final Block parent; private final Block parent;
@ -71,20 +71,50 @@ public class BaseWallBlock extends WallBlock implements BlockModelProvider {
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(), "block/" + stateId.getPath() + "_post"); ResourceLocation postId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath() + "_post");
ResourceLocation sideId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath() + "_side"); ResourceLocation sideId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath() + "_side");
ResourceLocation sideTallId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath() + "_side_tall"); ResourceLocation sideTallId = new ResourceLocation(
stateId.getNamespace(),
"block/" + stateId.getPath() + "_side_tall"
);
registerBlockModel(postId, postId, blockState, modelCache); registerBlockModel(postId, postId, blockState, modelCache);
registerBlockModel(sideId, sideId, blockState, modelCache); registerBlockModel(sideId, sideId, blockState, modelCache);
registerBlockModel(sideTallId, sideTallId, blockState, modelCache); registerBlockModel(sideTallId, sideTallId, blockState, modelCache);
ModelsHelper.MultiPartBuilder builder = ModelsHelper.MultiPartBuilder.create(stateDefinition); ModelsHelper.MultiPartBuilder builder = ModelsHelper.MultiPartBuilder.create(stateDefinition);
builder.part(sideId).setCondition(state -> state.getValue(NORTH_WALL) == WallSide.LOW).setUVLock(true).add(); builder.part(sideId).setCondition(state -> state.getValue(NORTH_WALL) == WallSide.LOW).setUVLock(true).add();
builder.part(sideId).setCondition(state -> state.getValue(EAST_WALL) == WallSide.LOW).setTransformation(BlockModelRotation.X0_Y90.getRotation()).setUVLock(true).add(); builder.part(sideId)
builder.part(sideId).setCondition(state -> state.getValue(SOUTH_WALL) == WallSide.LOW).setTransformation(BlockModelRotation.X0_Y180.getRotation()).setUVLock(true).add(); .setCondition(state -> state.getValue(EAST_WALL) == WallSide.LOW)
builder.part(sideId).setCondition(state -> state.getValue(WEST_WALL) == WallSide.LOW).setTransformation(BlockModelRotation.X0_Y270.getRotation()).setUVLock(true).add(); .setTransformation(BlockModelRotation.X0_Y90.getRotation())
builder.part(sideTallId).setCondition(state -> state.getValue(NORTH_WALL) == WallSide.TALL).setUVLock(true).add(); .setUVLock(true)
builder.part(sideTallId).setCondition(state -> state.getValue(EAST_WALL) == WallSide.TALL).setTransformation(BlockModelRotation.X0_Y90.getRotation()).setUVLock(true).add(); .add();
builder.part(sideTallId).setCondition(state -> state.getValue(SOUTH_WALL) == WallSide.TALL).setTransformation(BlockModelRotation.X0_Y180.getRotation()).setUVLock(true).add(); builder.part(sideId)
builder.part(sideTallId).setCondition(state -> state.getValue(WEST_WALL) == WallSide.TALL).setTransformation(BlockModelRotation.X0_Y270.getRotation()).setUVLock(true).add(); .setCondition(state -> state.getValue(SOUTH_WALL) == WallSide.LOW)
.setTransformation(BlockModelRotation.X0_Y180.getRotation())
.setUVLock(true)
.add();
builder.part(sideId)
.setCondition(state -> state.getValue(WEST_WALL) == WallSide.LOW)
.setTransformation(BlockModelRotation.X0_Y270.getRotation())
.setUVLock(true)
.add();
builder.part(sideTallId)
.setCondition(state -> state.getValue(NORTH_WALL) == WallSide.TALL)
.setUVLock(true)
.add();
builder.part(sideTallId)
.setCondition(state -> state.getValue(EAST_WALL) == WallSide.TALL)
.setTransformation(BlockModelRotation.X0_Y90.getRotation())
.setUVLock(true)
.add();
builder.part(sideTallId)
.setCondition(state -> state.getValue(SOUTH_WALL) == WallSide.TALL)
.setTransformation(BlockModelRotation.X0_Y180.getRotation())
.setUVLock(true)
.add();
builder.part(sideTallId)
.setCondition(state -> state.getValue(WEST_WALL) == WallSide.TALL)
.setTransformation(BlockModelRotation.X0_Y270.getRotation())
.setUVLock(true)
.add();
builder.part(postId).setCondition(state -> state.getValue(UP)).add(); builder.part(postId).setCondition(state -> state.getValue(UP)).add();
return builder.build(); return builder.build();

View file

@ -28,15 +28,33 @@ import ru.bclib.util.BlocksHelper;
import java.util.EnumMap; import java.util.EnumMap;
public abstract class BaseWallPlantBlock extends BasePlantBlock { public abstract class BaseWallPlantBlock extends BasePlantBlock {
private static final EnumMap<Direction, VoxelShape> SHAPES = Maps.newEnumMap(ImmutableMap.of(Direction.NORTH, Block.box(1, 1, 8, 15, 15, 16), Direction.SOUTH, Block.box(1, 1, 0, 15, 15, 8), Direction.WEST, Block.box(8, 1, 1, 16, 15, 15), Direction.EAST, Block.box(0, 1, 1, 8, 15, 15))); private static final EnumMap<Direction, VoxelShape> SHAPES = Maps.newEnumMap(ImmutableMap.of(
Direction.NORTH,
Block.box(1, 1, 8, 15, 15, 16),
Direction.SOUTH,
Block.box(1, 1, 0, 15, 15, 8),
Direction.WEST,
Block.box(8, 1, 1, 16, 15, 15),
Direction.EAST,
Block.box(0, 1, 1, 8, 15, 15)
));
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING; public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
public BaseWallPlantBlock() { public BaseWallPlantBlock() {
this(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).breakByHand(true).sound(SoundType.GRASS).noCollission()); this(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.breakByHand(true)
.sound(SoundType.GRASS)
.noCollission());
} }
public BaseWallPlantBlock(int light) { public BaseWallPlantBlock(int light) {
this(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).breakByHand(true).luminance(light).sound(SoundType.GRASS).noCollission()); this(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.breakByHand(true)
.luminance(light)
.sound(SoundType.GRASS)
.noCollission());
} }
public BaseWallPlantBlock(Properties settings) { public BaseWallPlantBlock(Properties settings) {

View file

@ -14,20 +14,23 @@ 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 org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.BasePatterns;
import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.client.models.PatternsHelper; import ru.bclib.client.models.PatternsHelper;
import ru.bclib.interfaces.BlockModelGetter;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
public class BaseWeightedPlateBlock extends WeightedPressurePlateBlock implements BlockModelProvider { public class BaseWeightedPlateBlock extends WeightedPressurePlateBlock implements BlockModelGetter {
private final Block parent; private final Block parent;
public BaseWeightedPlateBlock(Block source) { public BaseWeightedPlateBlock(Block source) {
super(15, FabricBlockSettings.copyOf(source).noCollission().noOcclusion().requiresCorrectToolForDrops().strength(0.5F)); super(
15,
FabricBlockSettings.copyOf(source).noCollission().noOcclusion().requiresCorrectToolForDrops().strength(0.5F)
);
this.parent = source; this.parent = source;
} }

View file

@ -25,11 +25,11 @@ import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.BasePatterns; import ru.bclib.client.models.BasePatterns;
import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.models.ModelsHelper; 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.BlockModelGetter;
import ru.bclib.interfaces.RenderLayerGetter;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -37,15 +37,32 @@ import java.util.Optional;
import java.util.Random; import java.util.Random;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public abstract class FeatureSaplingBlock extends SaplingBlock implements IRenderTyped, BlockModelProvider { public abstract class FeatureSaplingBlock extends SaplingBlock implements RenderLayerGetter, BlockModelGetter {
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);
public FeatureSaplingBlock() { public FeatureSaplingBlock() {
super(null, FabricBlockSettings.of(Material.PLANT).breakByHand(true).collidable(false).instabreak().sound(SoundType.GRASS).randomTicks()); super(
null,
FabricBlockSettings.of(Material.PLANT)
.breakByHand(true)
.collidable(false)
.instabreak()
.sound(SoundType.GRASS)
.randomTicks()
);
} }
public FeatureSaplingBlock(int light) { public FeatureSaplingBlock(int light) {
super(null, FabricBlockSettings.of(Material.PLANT).breakByHand(true).collidable(false).luminance(light).instabreak().sound(SoundType.GRASS).randomTicks()); super(
null,
FabricBlockSettings.of(Material.PLANT)
.breakByHand(true)
.collidable(false)
.luminance(light)
.instabreak()
.sound(SoundType.GRASS)
.randomTicks()
);
} }
protected abstract Feature<?> getFeature(); protected abstract Feature<?> getFeature();
@ -73,7 +90,13 @@ 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); FeaturePlaceContext context = new FeaturePlaceContext(
world,
world.getChunkSource().getGenerator(),
random,
pos,
null
);
getFeature().place(context); getFeature().place(context);
} }

View file

@ -5,15 +5,30 @@ import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor; import net.minecraft.world.level.material.MaterialColor;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped; import ru.bclib.interfaces.RenderLayerGetter;
public class SimpleLeavesBlock extends BaseBlockNotFull implements IRenderTyped { public class SimpleLeavesBlock extends BaseBlockNotFull implements RenderLayerGetter {
public SimpleLeavesBlock(MaterialColor color) { public SimpleLeavesBlock(MaterialColor color) {
super(FabricBlockSettings.of(Material.LEAVES).strength(0.2F).mapColor(color).sound(SoundType.GRASS).noOcclusion().isValidSpawn((state, world, pos, type) -> false).isSuffocating((state, world, pos) -> false).isViewBlocking((state, world, pos) -> false)); super(FabricBlockSettings.of(Material.LEAVES)
.strength(0.2F)
.mapColor(color)
.sound(SoundType.GRASS)
.noOcclusion()
.isValidSpawn((state, world, pos, type) -> false)
.isSuffocating((state, world, pos) -> false)
.isViewBlocking((state, world, pos) -> false));
} }
public SimpleLeavesBlock(MaterialColor color, int light) { public SimpleLeavesBlock(MaterialColor color, int light) {
super(FabricBlockSettings.of(Material.LEAVES).luminance(light).mapColor(color).strength(0.2F).sound(SoundType.GRASS).noOcclusion().isValidSpawn((state, world, pos, type) -> false).isSuffocating((state, world, pos) -> false).isViewBlocking((state, world, pos) -> false)); super(FabricBlockSettings.of(Material.LEAVES)
.luminance(light)
.mapColor(color)
.strength(0.2F)
.sound(SoundType.GRASS)
.noOcclusion()
.isValidSpawn((state, world, pos, type) -> false)
.isSuffocating((state, world, pos) -> false)
.isViewBlocking((state, world, pos) -> false));
} }
@Override @Override

View file

@ -37,13 +37,13 @@ import ru.bclib.client.models.BasePatterns;
import ru.bclib.client.models.ModelsHelper; 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.RenderLayerGetter;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class StalactiteBlock extends BaseBlockNotFull implements SimpleWaterloggedBlock, LiquidBlockContainer, IRenderTyped { public class StalactiteBlock extends BaseBlockNotFull implements SimpleWaterloggedBlock, LiquidBlockContainer, RenderLayerGetter {
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;
public static final IntegerProperty SIZE = BlockProperties.SIZE; public static final IntegerProperty SIZE = BlockProperties.SIZE;
@ -51,7 +51,10 @@ public class StalactiteBlock extends BaseBlockNotFull implements SimpleWaterlogg
public StalactiteBlock(Block source) { public StalactiteBlock(Block source) {
super(FabricBlockSettings.copy(source).noOcclusion()); super(FabricBlockSettings.copy(source).noOcclusion());
this.registerDefaultState(getStateDefinition().any().setValue(SIZE, 0).setValue(IS_FLOOR, true).setValue(WATERLOGGED, false)); this.registerDefaultState(getStateDefinition().any()
.setValue(SIZE, 0)
.setValue(IS_FLOOR, true)
.setValue(WATERLOGGED, false));
} }
@Override @Override
@ -212,7 +215,10 @@ public class StalactiteBlock extends BaseBlockNotFull implements SimpleWaterlogg
@Environment(EnvType.CLIENT) @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(), stateId.getPath() + "_" + blockState.getValue(SIZE)); ResourceLocation modelId = new ResourceLocation(
stateId.getNamespace(),
stateId.getPath() + "_" + blockState.getValue(SIZE)
);
registerBlockModel(modelId, modelId, blockState, modelCache); registerBlockModel(modelId, modelId, blockState, modelCache);
return ModelsHelper.createMultiVariant(modelId, rotation.getRotation(), false); return ModelsHelper.createMultiVariant(modelId, rotation.getRotation(), false);
} }

View file

@ -30,7 +30,11 @@ public class StripableBarkBlock extends BaseBarkBlock {
if (FabricToolTags.AXES.contains(player.getMainHandItem().getItem())) { if (FabricToolTags.AXES.contains(player.getMainHandItem().getItem())) {
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
);
if (!player.isCreative()) { if (!player.isCreative()) {
player.getMainHandItem().hurt(1, world.random, (ServerPlayer) player); player.getMainHandItem().hurt(1, world.random, (ServerPlayer) player);
} }

View file

@ -153,7 +153,17 @@ public class TripleTerrainBlock extends BaseTerrainBlock {
return new MultiVariant(variants); return new MultiVariant(variants);
} }
else if (blockState.getValue(SHAPE) == TripleShape.TOP) { else if (blockState.getValue(SHAPE) == TripleShape.TOP) {
return new MultiVariant(Lists.newArrayList(new Variant(modelId, BlockModelRotation.X180_Y0.getRotation(), false, 1), new Variant(modelId, BlockModelRotation.X180_Y90.getRotation(), false, 1), new Variant(modelId, BlockModelRotation.X180_Y180.getRotation(), false, 1), new Variant(modelId, BlockModelRotation.X180_Y270.getRotation(), false, 1))); return new MultiVariant(Lists.newArrayList(
new Variant(
modelId,
BlockModelRotation.X180_Y0.getRotation(),
false,
1
),
new Variant(modelId, BlockModelRotation.X180_Y90.getRotation(), false, 1),
new Variant(modelId, BlockModelRotation.X180_Y180.getRotation(), false, 1),
new Variant(modelId, BlockModelRotation.X180_Y270.getRotation(), false, 1)
));
} }
return ModelsHelper.createRandomTopModel(modelId); return ModelsHelper.createRandomTopModel(modelId);
} }

View file

@ -31,21 +31,30 @@ import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape; 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.RenderLayerGetter;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements IRenderTyped, BonemealableBlock, LiquidBlockContainer { public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements RenderLayerGetter, 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);
public UnderwaterPlantBlock() { public UnderwaterPlantBlock() {
super(FabricBlockSettings.of(Material.WATER_PLANT).breakByTool(FabricToolTags.SHEARS).breakByHand(true).sound(SoundType.WET_GRASS).noCollission()); super(FabricBlockSettings.of(Material.WATER_PLANT)
.breakByTool(FabricToolTags.SHEARS)
.breakByHand(true)
.sound(SoundType.WET_GRASS)
.noCollission());
} }
public UnderwaterPlantBlock(int light) { public UnderwaterPlantBlock(int light) {
super(FabricBlockSettings.of(Material.WATER_PLANT).breakByTool(FabricToolTags.SHEARS).breakByHand(true).luminance(light).sound(SoundType.WET_GRASS).noCollission()); super(FabricBlockSettings.of(Material.WATER_PLANT)
.breakByTool(FabricToolTags.SHEARS)
.breakByHand(true)
.luminance(light)
.sound(SoundType.WET_GRASS)
.noCollission());
} }
public UnderwaterPlantBlock(Properties settings) { public UnderwaterPlantBlock(Properties settings) {
@ -86,7 +95,10 @@ 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 && FabricToolTags.SHEARS.contains(tool.getItem()) || EnchantmentHelper.getItemEnchantmentLevel(
Enchantments.SILK_TOUCH,
tool
) > 0) {
return Lists.newArrayList(new ItemStack(this)); return Lists.newArrayList(new ItemStack(this));
} }
else { else {
@ -111,7 +123,13 @@ public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements I
@Override @Override
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) { public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) {
ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, new ItemStack(this)); ItemEntity item = new ItemEntity(
world,
pos.getX() + 0.5,
pos.getY() + 0.5,
pos.getZ() + 0.5,
new ItemStack(this)
);
world.addFreshEntity(item); world.addFreshEntity(item);
} }

View file

@ -18,7 +18,12 @@ public abstract class UnderwaterPlantWithAgeBlock extends UnderwaterPlantBlock {
public static final IntegerProperty AGE = BlockProperties.AGE; public static final IntegerProperty AGE = BlockProperties.AGE;
public UnderwaterPlantWithAgeBlock() { public UnderwaterPlantWithAgeBlock() {
super(FabricBlockSettings.of(Material.WATER_PLANT).breakByTool(FabricToolTags.SHEARS).breakByHand(true).sound(SoundType.WET_GRASS).randomTicks().noCollission()); super(FabricBlockSettings.of(Material.WATER_PLANT)
.breakByTool(FabricToolTags.SHEARS)
.breakByHand(true)
.sound(SoundType.WET_GRASS)
.randomTicks()
.noCollission());
} }
@Override @Override

View file

@ -24,16 +24,20 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape; 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.RenderLayerGetter;
import java.util.List; import java.util.List;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public abstract class UpDownPlantBlock extends BaseBlockNotFull implements IRenderTyped { public abstract class UpDownPlantBlock extends BaseBlockNotFull implements RenderLayerGetter {
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);
public UpDownPlantBlock() { public UpDownPlantBlock() {
super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).breakByHand(true).sound(SoundType.GRASS).noCollission()); super(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.breakByHand(true)
.sound(SoundType.GRASS)
.noCollission());
} }
protected abstract boolean isTerrain(BlockState state); protected abstract boolean isTerrain(BlockState state);
@ -67,7 +71,10 @@ 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 && FabricToolTags.SHEARS.contains(tool.getItem()) || EnchantmentHelper.getItemEnchantmentLevel(
Enchantments.SILK_TOUCH,
tool
) > 0) {
return Lists.newArrayList(new ItemStack(this)); return Lists.newArrayList(new ItemStack(this));
} }
else { else {

View file

@ -16,7 +16,14 @@ import java.util.List;
public abstract class WallMushroomBlock extends BaseWallPlantBlock { public abstract class WallMushroomBlock extends BaseWallPlantBlock {
public WallMushroomBlock(int light) { public WallMushroomBlock(int light) {
super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.AXES).breakByHand(true).luminance(light).hardness(0.2F).sound(SoundType.GRASS).sound(SoundType.WOOD).noCollission()); super(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.AXES)
.breakByHand(true)
.luminance(light)
.hardness(0.2F)
.sound(SoundType.GRASS)
.sound(SoundType.WOOD)
.noCollission());
} }
@Override @Override

View file

@ -6,8 +6,8 @@ import net.minecraft.client.renderer.RenderType;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import ru.bclib.api.ModIntegrationAPI; import ru.bclib.api.ModIntegrationAPI;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IPostInit; import ru.bclib.interfaces.PostInitable;
import ru.bclib.interfaces.IRenderTyped; import ru.bclib.interfaces.RenderLayerGetter;
import ru.bclib.registry.BaseBlockEntityRenders; import ru.bclib.registry.BaseBlockEntityRenders;
public class BCLibClient implements ClientModInitializer { public class BCLibClient implements ClientModInitializer {
@ -17,8 +17,8 @@ public class BCLibClient implements ClientModInitializer {
BaseBlockEntityRenders.register(); BaseBlockEntityRenders.register();
registerRenderLayers(); registerRenderLayers();
Registry.BLOCK.forEach(block -> { Registry.BLOCK.forEach(block -> {
if (block instanceof IPostInit) { if (block instanceof PostInitable) {
((IPostInit) block).postInit(); ((PostInitable) block).postInit();
} }
}); });
} }
@ -27,8 +27,8 @@ public class BCLibClient implements ClientModInitializer {
RenderType cutout = RenderType.cutout(); RenderType cutout = RenderType.cutout();
RenderType translucent = RenderType.translucent(); RenderType translucent = RenderType.translucent();
Registry.BLOCK.forEach(block -> { Registry.BLOCK.forEach(block -> {
if (block instanceof IRenderTyped) { if (block instanceof RenderLayerGetter) {
BCLRenderLayer layer = ((IRenderTyped) block).getRenderLayer(); BCLRenderLayer layer = ((RenderLayerGetter) block).getRenderLayer();
if (layer == BCLRenderLayer.CUTOUT) BlockRenderLayerMap.INSTANCE.putBlock(block, cutout); if (layer == BCLRenderLayer.CUTOUT) BlockRenderLayerMap.INSTANCE.putBlock(block, cutout);
else if (layer == BCLRenderLayer.TRANSLUCENT) BlockRenderLayerMap.INSTANCE.putBlock(block, translucent); else if (layer == BCLRenderLayer.TRANSLUCENT) BlockRenderLayerMap.INSTANCE.putBlock(block, translucent);
} }

View file

@ -53,28 +53,48 @@ public class BlockSignEditScreen extends Screen {
protected void init() { protected void init() {
//set up a default model //set up a default model
model = new SignRenderer.SignModel(this.minecraft.getEntityModels().bakeLayer(ModelLayers.createSignModelName(WoodType.OAK))); 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, (buttonWidget) -> { this.addRenderableWidget(new Button(
this.finishEditing(); this.width / 2 - 100,
})); this.height / 4 + 120,
200,
20,
CommonComponents.GUI_DONE,
(buttonWidget) -> {
this.finishEditing();
}
));
this.sign.setEditable(false); this.sign.setEditable(false);
this.selectionManager = new TextFieldHelper(() -> { this.selectionManager = new TextFieldHelper(
return this.text[this.currentRow]; () -> {
}, (string) -> { return this.text[this.currentRow];
this.text[this.currentRow] = string; },
this.sign.setMessage(this.currentRow, new TextComponent(string)); (string) -> {
}, TextFieldHelper.createClipboardGetter(this.minecraft), TextFieldHelper.createClipboardSetter(this.minecraft), (string) -> { this.text[this.currentRow] = string;
return this.minecraft.font.width(string) <= 90; this.sign.setMessage(this.currentRow, new TextComponent(string));
}); },
TextFieldHelper.createClipboardGetter(this.minecraft),
TextFieldHelper.createClipboardSetter(this.minecraft),
(string) -> {
return this.minecraft.font.width(string) <= 90;
}
);
} }
public void removed() { public void removed() {
minecraft.keyboardHandler.setSendRepeatsToGui(false); minecraft.keyboardHandler.setSendRepeatsToGui(false);
ClientPacketListener clientPlayNetworkHandler = this.minecraft.getConnection(); ClientPacketListener clientPlayNetworkHandler = this.minecraft.getConnection();
if (clientPlayNetworkHandler != null) { if (clientPlayNetworkHandler != null) {
clientPlayNetworkHandler.send(new ServerboundSignUpdatePacket(this.sign.getBlockPos(), this.text[0], this.text[1], this.text[2], this.text[3])); clientPlayNetworkHandler.send(new ServerboundSignUpdatePacket(
this.sign.getBlockPos(),
this.text[0],
this.text[1],
this.text[2],
this.text[3]
));
} }
this.sign.setEditable(true); this.sign.setEditable(true);
@ -167,12 +187,36 @@ public class BlockSignEditScreen extends Screen {
} }
float n = (float) (-this.minecraft.font.width(string2) / 2); float n = (float) (-this.minecraft.font.width(string2) / 2);
this.minecraft.font.drawInBatch(string2, n, (float) (m * 10 - this.text.length * 5), i, false, matrix4f, immediate, false, 0, 15728880, false); this.minecraft.font.drawInBatch(
string2,
n,
(float) (m * 10 - this.text.length * 5),
i,
false,
matrix4f,
immediate,
false,
0,
15728880,
false
);
if (m == this.currentRow && j >= 0 && bl2) { if (m == this.currentRow && j >= 0 && bl2) {
s = this.minecraft.font.width(string2.substring(0, Math.max(Math.min(j, string2.length()), 0))); s = this.minecraft.font.width(string2.substring(0, Math.max(Math.min(j, string2.length()), 0)));
t = s - this.minecraft.font.width(string2) / 2; t = s - this.minecraft.font.width(string2) / 2;
if (j >= string2.length()) { if (j >= string2.length()) {
this.minecraft.font.drawInBatch("_", (float) t, (float) l, i, false, matrix4f, immediate, false, 0, 15728880, false); this.minecraft.font.drawInBatch(
"_",
(float) t,
(float) l,
i,
false,
matrix4f,
immediate,
false,
0,
15728880,
false
);
} }
} }
} }

View file

@ -23,31 +23,71 @@ public class BaseChestBlockModel {
MeshDefinition modelData = new MeshDefinition(); MeshDefinition modelData = new MeshDefinition();
PartDefinition modelPartData = modelData.getRoot(); PartDefinition modelPartData = modelData.getRoot();
CubeDeformation deformation_partC = new CubeDeformation(0.0f); 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); 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); 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)); 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); 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)); 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); 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); 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); 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)); 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); 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)); 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); 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); 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); 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)); 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); 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)); 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); return LayerDefinition.create(modelData, 64, 64);
} }

View file

@ -78,7 +78,12 @@ public class ModelsHelper {
} }
public static MultiVariant createRandomTopModel(ResourceLocation resourceLocation) { public static MultiVariant createRandomTopModel(ResourceLocation resourceLocation) {
return new MultiVariant(Lists.newArrayList(new Variant(resourceLocation, Transformation.identity(), false, 1), new Variant(resourceLocation, BlockModelRotation.X0_Y90.getRotation(), false, 1), new Variant(resourceLocation, BlockModelRotation.X0_Y180.getRotation(), false, 1), new Variant(resourceLocation, BlockModelRotation.X0_Y270.getRotation(), false, 1))); return new MultiVariant(Lists.newArrayList(
new Variant(resourceLocation, Transformation.identity(), false, 1),
new Variant(resourceLocation, BlockModelRotation.X0_Y90.getRotation(), false, 1),
new Variant(resourceLocation, BlockModelRotation.X0_Y180.getRotation(), false, 1),
new Variant(resourceLocation, BlockModelRotation.X0_Y270.getRotation(), false, 1)
));
} }
public static class MultiPartBuilder { public static class MultiPartBuilder {

View file

@ -52,7 +52,8 @@ public class PatternsHelper {
public static Optional<String> createJson(ResourceLocation patternId, Map<String, String> textures) { public static Optional<String> createJson(ResourceLocation patternId, Map<String, String> textures) {
ResourceManager resourceManager = Minecraft.getInstance().getResourceManager(); ResourceManager resourceManager = Minecraft.getInstance().getResourceManager();
try (InputStream input = resourceManager.getResource(patternId).getInputStream()) { try (InputStream input = resourceManager.getResource(patternId).getInputStream()) {
String json = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8)).lines().collect(Collectors.joining()); String json = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8)).lines()
.collect(Collectors.joining());
for (Map.Entry<String, String> texture : textures.entrySet()) { for (Map.Entry<String, String> texture : textures.entrySet()) {
json = json.replace(texture.getKey(), texture.getValue()); json = json.replace(texture.getKey(), texture.getValue());
} }

View file

@ -51,7 +51,11 @@ public class BaseChestBlockEntityRenderer implements BlockEntityRenderer<BaseChe
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() : 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) ? blockState.getValue(ChestBlock.TYPE) : ChestType.SINGLE;
Block block = blockState.getBlock(); Block block = blockState.getBlock();
if (block instanceof AbstractChestBlock) { if (block instanceof AbstractChestBlock) {
@ -72,23 +76,54 @@ 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(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"}) int blockLight = ((Int2IntFunction) propertySource.apply(new BrightnessCombiner())).applyAsInt(light); @SuppressWarnings({
"unchecked",
"rawtypes"
}) int blockLight = ((Int2IntFunction) propertySource.apply(new BrightnessCombiner())).applyAsInt(light);
VertexConsumer vertexConsumer = getConsumer(vertexConsumers, block, chestType); VertexConsumer vertexConsumer = getConsumer(vertexConsumers, block, chestType);
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,
chestModel.partLeftA,
chestModel.partLeftB,
chestModel.partLeftC,
pitch,
blockLight,
overlay
);
} }
else { else {
renderParts(matrices, vertexConsumer, chestModel.partRightA, chestModel.partRightB, chestModel.partRightC, pitch, blockLight, overlay); renderParts(
matrices,
vertexConsumer,
chestModel.partRightA,
chestModel.partRightB,
chestModel.partRightC,
pitch,
blockLight,
overlay
);
} }
} }
else { else {
renderParts(matrices, vertexConsumer, chestModel.partA, chestModel.partB, chestModel.partC, pitch, blockLight, overlay); renderParts(
matrices,
vertexConsumer,
chestModel.partA,
chestModel.partB,
chestModel.partC,
pitch,
blockLight,
overlay
);
} }
matrices.popPose(); matrices.popPose();
@ -120,10 +155,24 @@ public class BaseChestBlockEntityRenderer implements BlockEntityRenderer<BaseChe
ResourceLocation blockId = Registry.BLOCK.getKey(block); ResourceLocation blockId = Registry.BLOCK.getKey(block);
String modId = blockId.getNamespace(); String modId = blockId.getNamespace();
String path = blockId.getPath(); String path = blockId.getPath();
LAYERS.put(block, new RenderType[] {RenderType.entityCutout(new ResourceLocation(modId, "textures/entity/chest/" + path + ".png")), RenderType.entityCutout(new ResourceLocation(modId, "textures/entity/chest/" + path + "_left.png")), RenderType.entityCutout(new ResourceLocation(modId, "textures/entity/chest/" + path + "_right.png"))}); LAYERS.put(
block,
new RenderType[] {
RenderType.entityCutout(new ResourceLocation(
modId,
"textures/entity/chest/" + path + ".png"
)),
RenderType.entityCutout(new ResourceLocation(modId, "textures/entity/chest/" + path + "_left.png")),
RenderType.entityCutout(new ResourceLocation(modId, "textures/entity/chest/" + path + "_right.png"))
}
);
} }
static { static {
defaultLayer = new RenderType[] {RenderType.entityCutout(new ResourceLocation("textures/entity/chest/normal.png")), RenderType.entityCutout(new ResourceLocation("textures/entity/chest/normal_left.png")), RenderType.entityCutout(new ResourceLocation("textures/entity/chest/normal_right.png"))}; defaultLayer = new RenderType[] {
RenderType.entityCutout(new ResourceLocation("textures/entity/chest/normal.png")),
RenderType.entityCutout(new ResourceLocation("textures/entity/chest/normal_left.png")),
RenderType.entityCutout(new ResourceLocation("textures/entity/chest/normal_right.png"))
};
} }
} }

View file

@ -87,10 +87,14 @@ 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) -> { FormattedCharSequence[] formattedCharSequences = signBlockEntity.getRenderMessages(
List<FormattedCharSequence> list = this.font.split(component, 90); Minecraft.getInstance()
return list.isEmpty() ? FormattedCharSequence.EMPTY : (FormattedCharSequence) list.get(0); .isTextFilteringEnabled(),
}); (component) -> {
List<FormattedCharSequence> list = this.font.split(component, 90);
return list.isEmpty() ? FormattedCharSequence.EMPTY : (FormattedCharSequence) list.get(0);
}
);
int drawColor; int drawColor;
boolean drawOutlined; boolean drawOutlined;
int drawLight; int drawLight;
@ -109,10 +113,30 @@ public class BaseSignBlockEntityRenderer implements BlockEntityRenderer<BaseSign
FormattedCharSequence formattedCharSequence = formattedCharSequences[s]; FormattedCharSequence formattedCharSequence = formattedCharSequences[s];
float t = (float) (-this.font.width(formattedCharSequence) / 2); float t = (float) (-this.font.width(formattedCharSequence) / 2);
if (drawOutlined) { if (drawOutlined) {
this.font.drawInBatch8xOutline(formattedCharSequence, t, (float) (s * 10 - 20), drawColor, m, matrixStack.last().pose(), provider, drawLight); this.font.drawInBatch8xOutline(
formattedCharSequence,
t,
(float) (s * 10 - 20),
drawColor,
m,
matrixStack.last().pose(),
provider,
drawLight
);
} }
else { else {
this.font.drawInBatch((FormattedCharSequence) formattedCharSequence, t, (float) (s * 10 - 20), drawColor, false, matrixStack.last().pose(), provider, false, 0, drawLight); this.font.drawInBatch(
(FormattedCharSequence) formattedCharSequence,
t,
(float) (s * 10 - 20),
drawColor,
false,
matrixStack.last().pose(),
provider,
false,
0,
drawLight
);
} }
} }
@ -160,7 +184,10 @@ public class BaseSignBlockEntityRenderer implements BlockEntityRenderer<BaseSign
public static void registerRenderLayer(Block block) { public static void registerRenderLayer(Block block) {
ResourceLocation blockId = Registry.BLOCK.getKey(block); ResourceLocation blockId = Registry.BLOCK.getKey(block);
RenderType layer = RenderType.entitySolid(new ResourceLocation(blockId.getNamespace(), "textures/entity/sign/" + blockId.getPath() + ".png")); RenderType layer = RenderType.entitySolid(new ResourceLocation(
blockId.getNamespace(),
"textures/entity/sign/" + blockId.getPath() + ".png"
));
LAYERS.put(block, layer); LAYERS.put(block, layer);
} }

View file

@ -4,5 +4,13 @@ import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.SoundType;
public class BlockSounds { public class BlockSounds {
public static final SoundType TERRAIN_SOUND = new SoundType(1.0F, 1.0F, SoundEvents.STONE_BREAK, SoundEvents.WART_BLOCK_STEP, SoundEvents.STONE_PLACE, SoundEvents.STONE_HIT, SoundEvents.STONE_FALL); public static final SoundType TERRAIN_SOUND = new SoundType(
1.0F,
1.0F,
SoundEvents.STONE_BREAK,
SoundEvents.WART_BLOCK_STEP,
SoundEvents.STONE_PLACE,
SoundEvents.STONE_HIT,
SoundEvents.STONE_FALL
);
} }

View file

@ -19,7 +19,10 @@ public class ConfigWriter {
} }
public ConfigWriter(String modID, String configFile, File configFolder) { public ConfigWriter(String modID, String configFile, File configFolder) {
this.configFile = new File((configFolder == null ? GAME_CONFIG_DIR.resolve(modID).toFile() : new File(configFolder, modID)), configFile + ".json"); this.configFile = new File((configFolder == null ? GAME_CONFIG_DIR.resolve(modID).toFile() : new File(
configFolder,
modID
)), configFile + ".json");
File parent = this.configFile.getParentFile(); File parent = this.configFile.getParentFile();
if (!parent.exists()) { if (!parent.exists()) {
parent.mkdirs(); parent.mkdirs();

View file

@ -1,4 +1,4 @@
package ru.bclib.client.models; package ru.bclib.interfaces;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
@ -8,13 +8,15 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import ru.bclib.BCLib; import ru.bclib.BCLib;
import ru.bclib.client.models.ModelsHelper;
import ru.bclib.client.models.PatternsHelper;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import static net.minecraft.client.resources.model.ModelBakery.MISSING_MODEL_LOCATION; import static net.minecraft.client.resources.model.ModelBakery.MISSING_MODEL_LOCATION;
public interface BlockModelProvider extends ItemModelProvider { public interface BlockModelGetter extends ItemModelGetter {
@Environment(EnvType.CLIENT) @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);

View file

@ -3,7 +3,7 @@ package ru.bclib.interfaces;
import net.minecraft.client.color.block.BlockColor; import net.minecraft.client.color.block.BlockColor;
import net.minecraft.client.color.item.ItemColor; import net.minecraft.client.color.item.ItemColor;
public interface IColorProvider { public interface ColorProviderGetter {
BlockColor getProvider(); BlockColor getProvider();
ItemColor getItemProvider(); ItemColor getItemProvider();

View file

@ -0,0 +1,15 @@
package ru.bclib.interfaces;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.BlockItem;
import ru.bclib.registry.BlocksRegistry;
public interface CustomItemGetter {
/**
* Used to replace default Block Item when block is registered.
*
* @return {@link BlockItem}
*/
BlockItem getCustomItem(ResourceLocation blockID, FabricItemSettings settings);
}

View file

@ -1,7 +0,0 @@
package ru.bclib.interfaces;
public interface ISpetialItem {
boolean canPlaceOnWater();
int getStackSize();
}

View file

@ -1,11 +1,12 @@
package ru.bclib.client.models; package ru.bclib.interfaces;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; 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 ru.bclib.client.models.ModelsHelper;
public interface ItemModelProvider { public interface ItemModelGetter {
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
default BlockModel getItemModel(ResourceLocation resourceLocation) { default BlockModel getItemModel(ResourceLocation resourceLocation) {
return ModelsHelper.createItemModel(resourceLocation); return ModelsHelper.createItemModel(resourceLocation);

View file

@ -1,5 +1,5 @@
package ru.bclib.interfaces; package ru.bclib.interfaces;
public interface IPostInit { public interface PostInitable {
void postInit(); void postInit();
} }

View file

@ -2,6 +2,6 @@ package ru.bclib.interfaces;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
public interface IRenderTyped { public interface RenderLayerGetter {
BCLRenderLayer getRenderLayer(); BCLRenderLayer getRenderLayer();
} }

View file

@ -16,11 +16,11 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import ru.bclib.blocks.BaseAnvilBlock; import ru.bclib.blocks.BaseAnvilBlock;
import ru.bclib.client.models.ItemModelProvider; import ru.bclib.interfaces.ItemModelGetter;
import java.util.List; import java.util.List;
public class BaseAnvilItem extends BlockItem implements ItemModelProvider { public class BaseAnvilItem extends BlockItem implements ItemModelGetter {
public final static String DESTRUCTION = "destruction"; public final static String DESTRUCTION = "destruction";
@ -54,6 +54,6 @@ public class BaseAnvilItem extends BlockItem implements ItemModelProvider {
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);
return ((ItemModelProvider) anvilBlock).getItemModel(blockId); return ((ItemModelGetter) anvilBlock).getItemModel(blockId);
} }
} }

View file

@ -8,13 +8,18 @@ import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.item.ArmorItem; import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.ArmorMaterial; import net.minecraft.world.item.ArmorMaterial;
import ru.bclib.client.models.ItemModelProvider; import ru.bclib.interfaces.ItemModelGetter;
import java.util.UUID; import java.util.UUID;
public class BaseArmorItem extends ArmorItem implements ItemModelProvider { public class BaseArmorItem extends ArmorItem implements ItemModelGetter {
protected static final UUID[] ARMOR_MODIFIER_UUID_PER_SLOT = new UUID[] {UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"), UUID.fromString("D8499B04-0E66-4726-AB29-64469D734E0D"), UUID.fromString("9F3D476D-C118-4544-8365-64846904B48E"), UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150")}; protected static final UUID[] ARMOR_MODIFIER_UUID_PER_SLOT = new UUID[] {
UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"),
UUID.fromString("D8499B04-0E66-4726-AB29-64469D734E0D"),
UUID.fromString("9F3D476D-C118-4544-8365-64846904B48E"),
UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150")
};
protected final Multimap<Attribute, AttributeModifier> defaultModifiers; protected final Multimap<Attribute, AttributeModifier> defaultModifiers;
@ -22,10 +27,23 @@ public class BaseArmorItem extends ArmorItem implements ItemModelProvider {
super(material, equipmentSlot, settings); super(material, equipmentSlot, settings);
this.defaultModifiers = HashMultimap.create(); this.defaultModifiers = HashMultimap.create();
UUID uuid = ARMOR_MODIFIER_UUID_PER_SLOT[equipmentSlot.getIndex()]; UUID uuid = ARMOR_MODIFIER_UUID_PER_SLOT[equipmentSlot.getIndex()];
addAttributeModifier(Attributes.ARMOR, new AttributeModifier(uuid, "Armor modifier", getDefense(), AttributeModifier.Operation.ADDITION)); addAttributeModifier(
addAttributeModifier(Attributes.ARMOR_TOUGHNESS, new AttributeModifier(uuid, "Armor toughness", getToughness(), AttributeModifier.Operation.ADDITION)); Attributes.ARMOR,
new AttributeModifier(uuid, "Armor modifier", getDefense(), AttributeModifier.Operation.ADDITION)
);
addAttributeModifier(
Attributes.ARMOR_TOUGHNESS,
new AttributeModifier(uuid, "Armor toughness", getToughness(), AttributeModifier.Operation.ADDITION)
);
if (knockbackResistance > 0.0F) { if (knockbackResistance > 0.0F) {
addAttributeModifier(Attributes.KNOCKBACK_RESISTANCE, new AttributeModifier(uuid, "Armor knockback resistance", knockbackResistance, AttributeModifier.Operation.ADDITION)); addAttributeModifier(
Attributes.KNOCKBACK_RESISTANCE,
new AttributeModifier(uuid,
"Armor knockback resistance",
knockbackResistance,
AttributeModifier.Operation.ADDITION
)
);
} }
} }

View file

@ -5,9 +5,9 @@ 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.MobBucketItem;
import net.minecraft.world.level.material.Fluids; import net.minecraft.world.level.material.Fluids;
import ru.bclib.client.models.ItemModelProvider; import ru.bclib.interfaces.ItemModelGetter;
public class BaseBucketItem extends MobBucketItem implements ItemModelProvider { public class BaseBucketItem extends MobBucketItem implements ItemModelGetter {
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, SoundEvents.BUCKET_EMPTY_FISH, settings.stacksTo(1));
} }

View file

@ -2,9 +2,9 @@ package ru.bclib.items;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.item.RecordItem; import net.minecraft.world.item.RecordItem;
import ru.bclib.client.models.ItemModelProvider; import ru.bclib.interfaces.ItemModelGetter;
public class BaseDiscItem extends RecordItem implements ItemModelProvider { public class BaseDiscItem extends RecordItem implements ItemModelGetter {
public BaseDiscItem(int comparatorOutput, SoundEvent sound, Properties settings) { public BaseDiscItem(int comparatorOutput, SoundEvent sound, Properties settings) {
super(comparatorOutput, sound, settings); super(comparatorOutput, sound, settings);
} }

View file

@ -8,13 +8,13 @@ import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Mob; 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.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.client.models.PatternsHelper; import ru.bclib.client.models.PatternsHelper;
import ru.bclib.interfaces.ItemModelGetter;
import java.util.Optional; import java.util.Optional;
public class BaseSpawnEggItem extends SpawnEggItem implements ItemModelProvider { public class BaseSpawnEggItem extends SpawnEggItem implements ItemModelGetter {
public BaseSpawnEggItem(EntityType<? extends Mob> type, int primaryColor, int secondaryColor, Properties settings) { public BaseSpawnEggItem(EntityType<? extends Mob> type, int primaryColor, int secondaryColor, Properties settings) {
super(type, primaryColor, secondaryColor, settings); super(type, primaryColor, secondaryColor, settings);
} }

View file

@ -5,10 +5,10 @@ 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;
import ru.bclib.client.models.ItemModelProvider;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.interfaces.ItemModelGetter;
public class ModelProviderItem extends Item implements ItemModelProvider { public class ModelProviderItem extends Item implements ItemModelGetter {
public ModelProviderItem(Properties settings) { public ModelProviderItem(Properties settings) {
super(settings); super(settings);
} }

View file

@ -13,10 +13,10 @@ import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Tier; import net.minecraft.world.item.Tier;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import ru.bclib.client.models.ItemModelProvider;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.interfaces.ItemModelGetter;
public class BaseAxeItem extends AxeItem implements DynamicAttributeTool, ItemModelProvider { public class BaseAxeItem extends AxeItem implements DynamicAttributeTool, ItemModelGetter {
public BaseAxeItem(Tier material, float attackDamage, float attackSpeed, Properties settings) { public BaseAxeItem(Tier material, float attackDamage, float attackSpeed, Properties settings) {
super(material, attackDamage, attackSpeed, settings); super(material, attackDamage, attackSpeed, settings);
} }

View file

@ -6,10 +6,10 @@ 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;
import net.minecraft.world.item.Tier; import net.minecraft.world.item.Tier;
import ru.bclib.client.models.ItemModelProvider;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.interfaces.ItemModelGetter;
public class BaseHoeItem extends HoeItem implements ItemModelProvider { public class BaseHoeItem extends HoeItem implements ItemModelGetter {
public BaseHoeItem(Tier material, int attackDamage, float attackSpeed, Properties settings) { public BaseHoeItem(Tier material, int attackDamage, float attackSpeed, Properties settings) {
super(material, attackDamage, attackSpeed, settings); super(material, attackDamage, attackSpeed, settings);
} }

View file

@ -15,10 +15,10 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.PickaxeItem; import net.minecraft.world.item.PickaxeItem;
import net.minecraft.world.item.Tier; import net.minecraft.world.item.Tier;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import ru.bclib.client.models.ItemModelProvider;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.interfaces.ItemModelGetter;
public class BasePickaxeItem extends PickaxeItem implements DynamicAttributeTool, ItemModelProvider { public class BasePickaxeItem extends PickaxeItem implements DynamicAttributeTool, ItemModelGetter {
public BasePickaxeItem(Tier material, int attackDamage, float attackSpeed, Properties settings) { public BasePickaxeItem(Tier material, int attackDamage, float attackSpeed, Properties settings) {
super(material, attackDamage, attackSpeed, settings); super(material, attackDamage, attackSpeed, settings);
} }
@ -34,7 +34,10 @@ public class BasePickaxeItem extends PickaxeItem implements DynamicAttributeTool
@Override @Override
public float getDestroySpeed(ItemStack stack, BlockState state) { public float getDestroySpeed(ItemStack stack, BlockState state) {
Entry entry = ToolManagerImpl.entryNullable(state.getBlock()); Entry entry = ToolManagerImpl.entryNullable(state.getBlock());
return (entry != null && entry.getMiningLevel(FabricToolTags.PICKAXES) >= 0) ? speed : super.getDestroySpeed(stack, state); return (entry != null && entry.getMiningLevel(FabricToolTags.PICKAXES) >= 0) ? speed : super.getDestroySpeed(
stack,
state
);
} }
@Override @Override

View file

@ -15,10 +15,10 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.ShovelItem; import net.minecraft.world.item.ShovelItem;
import net.minecraft.world.item.Tier; import net.minecraft.world.item.Tier;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import ru.bclib.client.models.ItemModelProvider;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.interfaces.ItemModelGetter;
public class BaseShovelItem extends ShovelItem implements DynamicAttributeTool, ItemModelProvider { public class BaseShovelItem extends ShovelItem implements DynamicAttributeTool, ItemModelGetter {
public BaseShovelItem(Tier material, float attackDamage, float attackSpeed, Properties settings) { public BaseShovelItem(Tier material, float attackDamage, float attackSpeed, Properties settings) {
super(material, attackDamage, attackSpeed, settings); super(material, attackDamage, attackSpeed, settings);
} }
@ -34,7 +34,10 @@ public class BaseShovelItem extends ShovelItem implements DynamicAttributeTool,
@Override @Override
public float getDestroySpeed(ItemStack stack, BlockState state) { public float getDestroySpeed(ItemStack stack, BlockState state) {
Entry entry = ToolManagerImpl.entryNullable(state.getBlock()); Entry entry = ToolManagerImpl.entryNullable(state.getBlock());
return (entry != null && entry.getMiningLevel(FabricToolTags.SHOVELS) >= 0) ? speed : super.getDestroySpeed(stack, state); return (entry != null && entry.getMiningLevel(FabricToolTags.SHOVELS) >= 0) ? speed : super.getDestroySpeed(
stack,
state
);
} }
@Override @Override

View file

@ -7,10 +7,10 @@ import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.SwordItem; import net.minecraft.world.item.SwordItem;
import net.minecraft.world.item.Tier; import net.minecraft.world.item.Tier;
import ru.bclib.client.models.ItemModelProvider;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.interfaces.ItemModelGetter;
public class BaseSwordItem extends SwordItem implements DynamicAttributeTool, ItemModelProvider { public class BaseSwordItem extends SwordItem implements DynamicAttributeTool, ItemModelGetter {
public BaseSwordItem(Tier material, int attackDamage, float attackSpeed, Properties settings) { public BaseSwordItem(Tier material, int attackDamage, float attackSpeed, Properties settings) {
super(material, attackDamage, attackSpeed, settings); super(material, attackDamage, attackSpeed, settings);
} }

View file

@ -34,7 +34,15 @@ public abstract class EnchantingTableBlockMixin extends Block {
if (!world.isEmptyBlock(pos.offset(px / 2, 0, pz / 2))) { if (!world.isEmptyBlock(pos.offset(px / 2, 0, pz / 2))) {
break; break;
} }
world.addParticle(ParticleTypes.ENCHANT, pos.getX() + 0.5, pos.getY() + 2.0, pos.getZ() + 0.5, px + random.nextFloat() - 0.5, py - random.nextFloat() - 1.0, pz + random.nextFloat() - 0.5); world.addParticle(
ParticleTypes.ENCHANT,
pos.getX() + 0.5,
pos.getY() + 2.0,
pos.getZ() + 0.5,
px + random.nextFloat() - 0.5,
py - random.nextFloat() - 1.0,
pz + random.nextFloat() - 0.5
);
} }
} }
} }

View file

@ -11,7 +11,7 @@ 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.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import ru.bclib.interfaces.IColorProvider; import ru.bclib.interfaces.ColorProviderGetter;
@Mixin(Minecraft.class) @Mixin(Minecraft.class)
public class MinecraftMixin { public class MinecraftMixin {
@ -26,8 +26,8 @@ public class MinecraftMixin {
@Inject(method = "<init>*", at = @At("TAIL")) @Inject(method = "<init>*", at = @At("TAIL"))
private void bclib_onMCInit(GameConfig args, CallbackInfo info) { private void bclib_onMCInit(GameConfig args, CallbackInfo info) {
Registry.BLOCK.forEach(block -> { Registry.BLOCK.forEach(block -> {
if (block instanceof IColorProvider) { if (block instanceof ColorProviderGetter) {
IColorProvider provider = (IColorProvider) block; ColorProviderGetter provider = (ColorProviderGetter) block;
blockColors.register(provider.getProvider(), block); blockColors.register(provider.getProvider(), block);
itemColors.register(provider.getItemProvider(), block.asItem()); itemColors.register(provider.getItemProvider(), block.asItem());
} }

View file

@ -20,8 +20,8 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import ru.bclib.BCLib; import ru.bclib.BCLib;
import ru.bclib.client.models.BlockModelProvider; import ru.bclib.interfaces.BlockModelGetter;
import ru.bclib.client.models.ItemModelProvider; import ru.bclib.interfaces.ItemModelGetter;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -51,14 +51,14 @@ public abstract class ModelBakeryMixin {
ResourceLocation itemModelLoc = new ResourceLocation(modId, "models/" + itemLoc.getPath() + ".json"); ResourceLocation itemModelLoc = new ResourceLocation(modId, "models/" + itemLoc.getPath() + ".json");
if (!resourceManager.hasResource(itemModelLoc)) { if (!resourceManager.hasResource(itemModelLoc)) {
Item item = Registry.ITEM.get(clearLoc); Item item = Registry.ITEM.get(clearLoc);
ItemModelProvider modelProvider = null; ItemModelGetter modelProvider = null;
if (item instanceof ItemModelProvider) { if (item instanceof ItemModelGetter) {
modelProvider = (ItemModelProvider) item; modelProvider = (ItemModelGetter) item;
} }
else if (item instanceof BlockItem) { else if (item instanceof BlockItem) {
Block block = Registry.BLOCK.get(clearLoc); Block block = Registry.BLOCK.get(clearLoc);
if (block instanceof ItemModelProvider) { if (block instanceof ItemModelGetter) {
modelProvider = (ItemModelProvider) block; modelProvider = (ItemModelGetter) block;
} }
} }
if (modelProvider != null) { if (modelProvider != null) {
@ -79,15 +79,28 @@ public abstract class ModelBakeryMixin {
ResourceLocation stateLoc = new ResourceLocation(modId, "blockstates/" + path + ".json"); ResourceLocation stateLoc = new ResourceLocation(modId, "blockstates/" + path + ".json");
if (!resourceManager.hasResource(stateLoc)) { if (!resourceManager.hasResource(stateLoc)) {
Block block = Registry.BLOCK.get(clearLoc); Block block = Registry.BLOCK.get(clearLoc);
if (block instanceof BlockModelProvider) { if (block instanceof BlockModelGetter) {
List<BlockState> possibleStates = block.getStateDefinition().getPossibleStates(); List<BlockState> possibleStates = block.getStateDefinition().getPossibleStates();
Optional<BlockState> possibleState = possibleStates.stream().filter(state -> modelId.equals(BlockModelShaper.stateToModelLocation(clearLoc, state))).findFirst(); Optional<BlockState> possibleState = possibleStates.stream()
.filter(state -> modelId.equals(
BlockModelShaper.stateToModelLocation(
clearLoc,
state
)))
.findFirst();
if (possibleState.isPresent()) { if (possibleState.isPresent()) {
UnbakedModel modelVariant = ((BlockModelProvider) block).getModelVariant(modelId, possibleState.get(), unbakedCache); UnbakedModel modelVariant = ((BlockModelGetter) block).getModelVariant(
modelId,
possibleState.get(),
unbakedCache
);
if (modelVariant != null) { if (modelVariant != null) {
if (modelVariant instanceof MultiPart) { if (modelVariant instanceof MultiPart) {
possibleStates.forEach(state -> { possibleStates.forEach(state -> {
ResourceLocation stateId = BlockModelShaper.stateToModelLocation(clearLoc, state); ResourceLocation stateId = BlockModelShaper.stateToModelLocation(
clearLoc,
state
);
cacheAndQueueDependencies(stateId, modelVariant); cacheAndQueueDependencies(stateId, modelVariant);
}); });
} }

View file

@ -29,12 +29,18 @@ public class TextureAtlasMixin {
private void bclib_loadSprite(ResourceManager resourceManager, TextureAtlasSprite.Info spriteInfo, int atlasWidth, int atlasHeight, int maxLevel, int posX, int posY, CallbackInfoReturnable<TextureAtlasSprite> info) { private void bclib_loadSprite(ResourceManager resourceManager, TextureAtlasSprite.Info spriteInfo, int atlasWidth, int atlasHeight, int maxLevel, int posX, int posY, CallbackInfoReturnable<TextureAtlasSprite> info) {
ResourceLocation location = spriteInfo.name(); ResourceLocation location = spriteInfo.name();
if (bclib_modifyAtlas && location.getPath().startsWith("block")) { if (bclib_modifyAtlas && location.getPath().startsWith("block")) {
ResourceLocation emissiveLocation = new ResourceLocation(location.getNamespace(), "textures/" + location.getPath() + "_e.png"); ResourceLocation emissiveLocation = new ResourceLocation(
location.getNamespace(),
"textures/" + location.getPath() + "_e.png"
);
if (resourceManager.hasResource(emissiveLocation)) { if (resourceManager.hasResource(emissiveLocation)) {
NativeImage sprite = null; NativeImage sprite = null;
NativeImage emission = null; NativeImage emission = null;
try { try {
ResourceLocation spriteLocation = new ResourceLocation(location.getNamespace(), "textures/" + location.getPath() + ".png"); ResourceLocation spriteLocation = new ResourceLocation(
location.getNamespace(),
"textures/" + location.getPath() + ".png"
);
Resource resource = resourceManager.getResource(spriteLocation); Resource resource = resourceManager.getResource(spriteLocation);
sprite = NativeImage.read(resource.getInputStream()); sprite = NativeImage.read(resource.getInputStream());
resource.close(); resource.close();
@ -65,7 +71,16 @@ public class TextureAtlasMixin {
} }
} }
TextureAtlas self = (TextureAtlas) (Object) this; TextureAtlas self = (TextureAtlas) (Object) this;
FabricSprite result = new FabricSprite(self, spriteInfo, maxLevel, atlasWidth, atlasHeight, posX, posY, sprite); FabricSprite result = new FabricSprite(
self,
spriteInfo,
maxLevel,
atlasWidth,
atlasHeight,
posX,
posY,
sprite
);
info.setReturnValue(result); info.setReturnValue(result);
} }
} }

View file

@ -99,7 +99,8 @@ public class BoneMealItemMixin {
for (int y = y1; y >= y2; y--) { for (int y = y1; y >= y2; y--) {
bclib_BLOCK_POS.setY(y); bclib_BLOCK_POS.setY(y);
BlockPos down = bclib_BLOCK_POS.below(); BlockPos down = bclib_BLOCK_POS.below();
if (BlocksHelper.isFluid(world.getBlockState(bclib_BLOCK_POS)) && !BlocksHelper.isFluid(world.getBlockState(down))) { if (BlocksHelper.isFluid(world.getBlockState(bclib_BLOCK_POS)) && !BlocksHelper.isFluid(world.getBlockState(
down))) {
BlockState grass = bclib_getWaterGrassState(world, down); BlockState grass = bclib_getWaterGrassState(world, down);
if (grass != null) { if (grass != null) {
BlocksHelper.setWithoutUpdate(world, bclib_BLOCK_POS, grass); BlocksHelper.setWithoutUpdate(world, bclib_BLOCK_POS, grass);

View file

@ -66,7 +66,11 @@ public abstract class EnchantmentMenuMixin extends AbstractContainerMenu {
int j; int j;
for (j = -1; j <= 1; ++j) { for (j = -1; j <= 1; ++j) {
for (int k = -1; k <= 1; ++k) { for (int k = -1; k <= 1; ++k) {
if ((j != 0 || k != 0) && world.isEmptyBlock(blockPos.offset(k, 0, j)) && world.isEmptyBlock(blockPos.offset(k, 1, j))) { if ((j != 0 || k != 0) && world.isEmptyBlock(blockPos.offset(
k,
0,
j
)) && world.isEmptyBlock(blockPos.offset(k, 1, j))) {
if (world.getBlockState(blockPos.offset(k * 2, 0, j * 2)).is(TagAPI.BOOKSHELVES)) { if (world.getBlockState(blockPos.offset(k * 2, 0, j * 2)).is(TagAPI.BOOKSHELVES)) {
++i; ++i;
} }
@ -111,7 +115,8 @@ public abstract class EnchantmentMenuMixin extends AbstractContainerMenu {
if (this.costs[j] > 0) { if (this.costs[j] > 0) {
List<EnchantmentInstance> list = this.getEnchantmentList(itemStack, j, this.costs[j]); List<EnchantmentInstance> list = this.getEnchantmentList(itemStack, j, this.costs[j]);
if (list != null && !list.isEmpty()) { if (list != null && !list.isEmpty()) {
EnchantmentInstance enchantmentLevelEntry = (EnchantmentInstance) list.get(this.random.nextInt(list.size())); EnchantmentInstance enchantmentLevelEntry = (EnchantmentInstance) list.get(this.random.nextInt(
list.size()));
enchantClue[j] = Registry.ENCHANTMENT.getId(enchantmentLevelEntry.enchantment); enchantClue[j] = Registry.ENCHANTMENT.getId(enchantmentLevelEntry.enchantment);
levelClue[j] = enchantmentLevelEntry.level; levelClue[j] = enchantmentLevelEntry.level;
} }

View file

@ -2256,21 +2256,48 @@ public class OpenSimplexNoise {
double attn_ext0 = 2 - dx_ext0 * dx_ext0 - dy_ext0 * dy_ext0 - dz_ext0 * dz_ext0 - dw_ext0 * dw_ext0; double attn_ext0 = 2 - dx_ext0 * dx_ext0 - dy_ext0 * dy_ext0 - dz_ext0 * dz_ext0 - dw_ext0 * dw_ext0;
if (attn_ext0 > 0) { if (attn_ext0 > 0) {
attn_ext0 *= attn_ext0; attn_ext0 *= attn_ext0;
value += attn_ext0 * attn_ext0 * extrapolate(xsv_ext0, ysv_ext0, zsv_ext0, wsv_ext0, dx_ext0, dy_ext0, dz_ext0, dw_ext0); value += attn_ext0 * attn_ext0 * extrapolate(
xsv_ext0,
ysv_ext0,
zsv_ext0,
wsv_ext0,
dx_ext0,
dy_ext0,
dz_ext0,
dw_ext0
);
} }
// Second extra vertex // Second extra vertex
double attn_ext1 = 2 - dx_ext1 * dx_ext1 - dy_ext1 * dy_ext1 - dz_ext1 * dz_ext1 - dw_ext1 * dw_ext1; double attn_ext1 = 2 - dx_ext1 * dx_ext1 - dy_ext1 * dy_ext1 - dz_ext1 * dz_ext1 - dw_ext1 * dw_ext1;
if (attn_ext1 > 0) { if (attn_ext1 > 0) {
attn_ext1 *= attn_ext1; attn_ext1 *= attn_ext1;
value += attn_ext1 * attn_ext1 * extrapolate(xsv_ext1, ysv_ext1, zsv_ext1, wsv_ext1, dx_ext1, dy_ext1, dz_ext1, dw_ext1); value += attn_ext1 * attn_ext1 * extrapolate(
xsv_ext1,
ysv_ext1,
zsv_ext1,
wsv_ext1,
dx_ext1,
dy_ext1,
dz_ext1,
dw_ext1
);
} }
// Third extra vertex // Third extra vertex
double attn_ext2 = 2 - dx_ext2 * dx_ext2 - dy_ext2 * dy_ext2 - dz_ext2 * dz_ext2 - dw_ext2 * dw_ext2; double attn_ext2 = 2 - dx_ext2 * dx_ext2 - dy_ext2 * dy_ext2 - dz_ext2 * dz_ext2 - dw_ext2 * dw_ext2;
if (attn_ext2 > 0) { if (attn_ext2 > 0) {
attn_ext2 *= attn_ext2; attn_ext2 *= attn_ext2;
value += attn_ext2 * attn_ext2 * extrapolate(xsv_ext2, ysv_ext2, zsv_ext2, wsv_ext2, dx_ext2, dy_ext2, dz_ext2, dw_ext2); value += attn_ext2 * attn_ext2 * extrapolate(
xsv_ext2,
ysv_ext2,
zsv_ext2,
wsv_ext2,
dx_ext2,
dy_ext2,
dz_ext2,
dw_ext2
);
} }
return value / NORM_CONSTANT_4D; return value / NORM_CONSTANT_4D;
@ -2304,11 +2331,341 @@ public class OpenSimplexNoise {
// vertices of a rhombicuboctahedron from the center, skewed so // vertices of a rhombicuboctahedron from the center, skewed so
// that the triangular and square facets can be inscribed inside // that the triangular and square facets can be inscribed inside
// circles of the same radius. // circles of the same radius.
private static byte[] gradients3D = new byte[] {-11, 4, 4, -4, 11, 4, -4, 4, 11, 11, 4, 4, 4, 11, 4, 4, 4, 11, -11, -4, 4, -4, -11, 4, -4, -4, 11, 11, -4, 4, 4, -11, 4, 4, -4, 11, -11, 4, -4, -4, 11, -4, -4, 4, -11, 11, 4, -4, 4, 11, -4, 4, 4, -11, -11, -4, -4, -4, -11, -4, -4, -4, -11, 11, -4, -4, 4, -11, -4, 4, -4, -11,}; private static byte[] gradients3D = new byte[] {
-11,
4,
4,
-4,
11,
4,
-4,
4,
11,
11,
4,
4,
4,
11,
4,
4,
4,
11,
-11,
-4,
4,
-4,
-11,
4,
-4,
-4,
11,
11,
-4,
4,
4,
-11,
4,
4,
-4,
11,
-11,
4,
-4,
-4,
11,
-4,
-4,
4,
-11,
11,
4,
-4,
4,
11,
-4,
4,
4,
-11,
-11,
-4,
-4,
-4,
-11,
-4,
-4,
-4,
-11,
11,
-4,
-4,
4,
-11,
-4,
4,
-4,
-11,
};
// Gradients for 4D. They approximate the directions to the // Gradients for 4D. They approximate the directions to the
// vertices of a disprismatotesseractihexadecachoron from the center, // vertices of a disprismatotesseractihexadecachoron from the center,
// skewed so that the tetrahedral and cubic facets can be inscribed inside // skewed so that the tetrahedral and cubic facets can be inscribed inside
// spheres of the same radius. // spheres of the same radius.
private static byte[] gradients4D = new byte[] {3, 1, 1, 1, 1, 3, 1, 1, 1, 1, 3, 1, 1, 1, 1, 3, -3, 1, 1, 1, -1, 3, 1, 1, -1, 1, 3, 1, -1, 1, 1, 3, 3, -1, 1, 1, 1, -3, 1, 1, 1, -1, 3, 1, 1, -1, 1, 3, -3, -1, 1, 1, -1, -3, 1, 1, -1, -1, 3, 1, -1, -1, 1, 3, 3, 1, -1, 1, 1, 3, -1, 1, 1, 1, -3, 1, 1, 1, -1, 3, -3, 1, -1, 1, -1, 3, -1, 1, -1, 1, -3, 1, -1, 1, -1, 3, 3, -1, -1, 1, 1, -3, -1, 1, 1, -1, -3, 1, 1, -1, -1, 3, -3, -1, -1, 1, -1, -3, -1, 1, -1, -1, -3, 1, -1, -1, -1, 3, 3, 1, 1, -1, 1, 3, 1, -1, 1, 1, 3, -1, 1, 1, 1, -3, -3, 1, 1, -1, -1, 3, 1, -1, -1, 1, 3, -1, -1, 1, 1, -3, 3, -1, 1, -1, 1, -3, 1, -1, 1, -1, 3, -1, 1, -1, 1, -3, -3, -1, 1, -1, -1, -3, 1, -1, -1, -1, 3, -1, -1, -1, 1, -3, 3, 1, -1, -1, 1, 3, -1, -1, 1, 1, -3, -1, 1, 1, -1, -3, -3, 1, -1, -1, -1, 3, -1, -1, -1, 1, -3, -1, -1, 1, -1, -3, 3, -1, -1, -1, 1, -3, -1, -1, 1, -1, -3, -1, 1, -1, -1, -3, -3, -1, -1, -1, -1, -3, -1, -1, -1, -1, -3, -1, -1, -1, -1, -3,}; private static byte[] gradients4D = new byte[] {
3,
1,
1,
1,
1,
3,
1,
1,
1,
1,
3,
1,
1,
1,
1,
3,
-3,
1,
1,
1,
-1,
3,
1,
1,
-1,
1,
3,
1,
-1,
1,
1,
3,
3,
-1,
1,
1,
1,
-3,
1,
1,
1,
-1,
3,
1,
1,
-1,
1,
3,
-3,
-1,
1,
1,
-1,
-3,
1,
1,
-1,
-1,
3,
1,
-1,
-1,
1,
3,
3,
1,
-1,
1,
1,
3,
-1,
1,
1,
1,
-3,
1,
1,
1,
-1,
3,
-3,
1,
-1,
1,
-1,
3,
-1,
1,
-1,
1,
-3,
1,
-1,
1,
-1,
3,
3,
-1,
-1,
1,
1,
-3,
-1,
1,
1,
-1,
-3,
1,
1,
-1,
-1,
3,
-3,
-1,
-1,
1,
-1,
-3,
-1,
1,
-1,
-1,
-3,
1,
-1,
-1,
-1,
3,
3,
1,
1,
-1,
1,
3,
1,
-1,
1,
1,
3,
-1,
1,
1,
1,
-3,
-3,
1,
1,
-1,
-1,
3,
1,
-1,
-1,
1,
3,
-1,
-1,
1,
1,
-3,
3,
-1,
1,
-1,
1,
-3,
1,
-1,
1,
-1,
3,
-1,
1,
-1,
1,
-3,
-3,
-1,
1,
-1,
-1,
-3,
1,
-1,
-1,
-1,
3,
-1,
-1,
-1,
1,
-3,
3,
1,
-1,
-1,
1,
3,
-1,
-1,
1,
1,
-3,
-1,
1,
1,
-1,
-3,
-3,
1,
-1,
-1,
-1,
3,
-1,
-1,
-1,
1,
-3,
-1,
-1,
1,
-1,
-3,
3,
-1,
-1,
-1,
1,
-3,
-1,
-1,
1,
-1,
-3,
-1,
1,
-1,
-1,
-3,
-3,
-1,
-1,
-1,
-1,
-3,
-1,
-1,
-1,
-1,
-3,
-1,
-1,
-1,
-1,
-3,
};
} }

View file

@ -133,8 +133,16 @@ public class VoronoiNoise {
} }
} }
BlockPos p1 = new BlockPos((ix + (double) selX) * scale, (iy + (double) selY) * scale, (iz + (double) selZ) * scale); BlockPos p1 = new BlockPos(
BlockPos p2 = new BlockPos((ix + (double) selXPre) * scale, (iy + (double) selYPre) * scale, (iz + (double) selZPre) * scale); (ix + (double) selX) * scale,
(iy + (double) selY) * scale,
(iz + (double) selZ) * scale
);
BlockPos p2 = new BlockPos(
(ix + (double) selXPre) * scale,
(iy + (double) selYPre) * scale,
(iz + (double) selZPre) * scale
);
return new BlockPos[] {p1, p2}; return new BlockPos[] {p1, p2};
} }
} }

View file

@ -9,19 +9,79 @@ import ru.bclib.config.Configs;
public class CraftingRecipes { public class CraftingRecipes {
public static void init() { public static void init() {
GridRecipe.make(BCLib.MOD_ID, "tag_smith_table", Blocks.SMITHING_TABLE).setShape("II", "##", "##").addMaterial('#', ItemTags.PLANKS).addMaterial('I', TagAPI.IRON_INGOTS).checkConfig(Configs.RECIPE_CONFIG).build(); GridRecipe.make(BCLib.MOD_ID, "tag_smith_table", Blocks.SMITHING_TABLE)
GridRecipe.make(BCLib.MOD_ID, "tag_cauldron", Blocks.CAULDRON).setShape("I I", "I I", "III").addMaterial('I', TagAPI.IRON_INGOTS).checkConfig(Configs.RECIPE_CONFIG).build(); .setShape("II", "##", "##")
GridRecipe.make(BCLib.MOD_ID, "tag_hopper", Blocks.HOPPER).setShape("I I", "ICI", " I ").addMaterial('I', TagAPI.IRON_INGOTS).addMaterial('C', TagAPI.ITEM_CHEST).checkConfig(Configs.RECIPE_CONFIG).build(); .addMaterial('#', ItemTags.PLANKS)
GridRecipe.make(BCLib.MOD_ID, "tag_piston", Blocks.PISTON).setShape("WWW", "CIC", "CDC").addMaterial('I', TagAPI.IRON_INGOTS).addMaterial('D', Items.REDSTONE).addMaterial('C', Items.COBBLESTONE).addMaterial('W', ItemTags.PLANKS).checkConfig(Configs.RECIPE_CONFIG).build(); .addMaterial('I', TagAPI.IRON_INGOTS)
GridRecipe.make(BCLib.MOD_ID, "tag_rail", Blocks.RAIL).setOutputCount(16).setShape("I I", "ISI", "I I").addMaterial('I', TagAPI.IRON_INGOTS).addMaterial('S', Items.STICK).checkConfig(Configs.RECIPE_CONFIG).build(); .checkConfig(Configs.RECIPE_CONFIG)
GridRecipe.make(BCLib.MOD_ID, "tag_stonecutter", Blocks.STONECUTTER).setShape(" I ", "SSS").addMaterial('I', TagAPI.IRON_INGOTS).addMaterial('S', Items.STONE).checkConfig(Configs.RECIPE_CONFIG).build(); .build();
GridRecipe.make(BCLib.MOD_ID, "tag_bucket", Items.BUCKET).setShape("I I", " I ").addMaterial('I', TagAPI.IRON_INGOTS).checkConfig(Configs.RECIPE_CONFIG).build(); GridRecipe.make(BCLib.MOD_ID, "tag_cauldron", Blocks.CAULDRON)
GridRecipe.make(BCLib.MOD_ID, "tag_compass", Items.COMPASS).setShape(" I ", "IDI", " I ").addMaterial('I', TagAPI.IRON_INGOTS).addMaterial('D', Items.REDSTONE).checkConfig(Configs.RECIPE_CONFIG).build(); .setShape("I I", "I I", "III")
GridRecipe.make(BCLib.MOD_ID, "tag_minecart", Items.MINECART).setShape("I I", "III").addMaterial('I', TagAPI.IRON_INGOTS).checkConfig(Configs.RECIPE_CONFIG).build(); .addMaterial('I', TagAPI.IRON_INGOTS)
GridRecipe.make(BCLib.MOD_ID, "tag_shield", Items.SHIELD).setShape("WIW", "WWW", " W ").addMaterial('I', TagAPI.IRON_INGOTS).addMaterial('W', ItemTags.PLANKS).checkConfig(Configs.RECIPE_CONFIG).build(); .checkConfig(Configs.RECIPE_CONFIG)
.build();
GridRecipe.make(BCLib.MOD_ID, "tag_hopper", Blocks.HOPPER)
.setShape("I I", "ICI", " I ")
.addMaterial('I', TagAPI.IRON_INGOTS)
.addMaterial('C', TagAPI.ITEM_CHEST)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
GridRecipe.make(BCLib.MOD_ID, "tag_piston", Blocks.PISTON)
.setShape("WWW", "CIC", "CDC")
.addMaterial('I', TagAPI.IRON_INGOTS)
.addMaterial('D', Items.REDSTONE)
.addMaterial('C', Items.COBBLESTONE)
.addMaterial('W', ItemTags.PLANKS)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
GridRecipe.make(BCLib.MOD_ID, "tag_rail", Blocks.RAIL)
.setOutputCount(16)
.setShape("I I", "ISI", "I I")
.addMaterial('I', TagAPI.IRON_INGOTS)
.addMaterial('S', Items.STICK)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
GridRecipe.make(BCLib.MOD_ID, "tag_stonecutter", Blocks.STONECUTTER)
.setShape(" I ", "SSS")
.addMaterial('I', TagAPI.IRON_INGOTS)
.addMaterial('S', Items.STONE)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
GridRecipe.make(BCLib.MOD_ID, "tag_bucket", Items.BUCKET)
.setShape("I I", " I ")
.addMaterial('I', TagAPI.IRON_INGOTS)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
GridRecipe.make(BCLib.MOD_ID, "tag_compass", Items.COMPASS)
.setShape(" I ", "IDI", " I ")
.addMaterial('I', TagAPI.IRON_INGOTS)
.addMaterial('D', Items.REDSTONE)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
GridRecipe.make(BCLib.MOD_ID, "tag_minecart", Items.MINECART)
.setShape("I I", "III")
.addMaterial('I', TagAPI.IRON_INGOTS)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
GridRecipe.make(BCLib.MOD_ID, "tag_shield", Items.SHIELD)
.setShape("WIW", "WWW", " W ")
.addMaterial('I', TagAPI.IRON_INGOTS)
.addMaterial('W', ItemTags.PLANKS)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
GridRecipe.make(BCLib.MOD_ID, "tag_hopper", Blocks.HOPPER).setShape("I I", "ICI", " I ").addMaterial('I', TagAPI.IRON_INGOTS).addMaterial('C', TagAPI.ITEM_CHEST).checkConfig(Configs.RECIPE_CONFIG).build(); GridRecipe.make(BCLib.MOD_ID, "tag_hopper", Blocks.HOPPER)
.setShape("I I", "ICI", " I ")
.addMaterial('I', TagAPI.IRON_INGOTS)
.addMaterial('C', TagAPI.ITEM_CHEST)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
GridRecipe.make(BCLib.MOD_ID, "tag_shulker_box", Blocks.SHULKER_BOX).setShape("S", "C", "S").addMaterial('S', Items.SHULKER_SHELL).addMaterial('C', TagAPI.ITEM_CHEST).checkConfig(Configs.RECIPE_CONFIG).build(); GridRecipe.make(BCLib.MOD_ID, "tag_shulker_box", Blocks.SHULKER_BOX)
.setShape("S", "C", "S")
.addMaterial('S', Items.SHULKER_SHELL)
.addMaterial('C', TagAPI.ITEM_CHEST)
.checkConfig(Configs.RECIPE_CONFIG)
.build();
} }
} }

View file

@ -77,21 +77,49 @@ public class FurnaceRecipe {
public void build(boolean blasting, boolean campfire, boolean smoker) { public void build(boolean blasting, boolean campfire, boolean smoker) {
if (exist) { if (exist) {
SmeltingRecipe recipe = new SmeltingRecipe(id, group, Ingredient.of(input), new ItemStack(output, count), xp, time); SmeltingRecipe recipe = new SmeltingRecipe(
id,
group,
Ingredient.of(input),
new ItemStack(output, count),
xp,
time
);
BCLRecipeManager.addRecipe(RecipeType.SMELTING, recipe); BCLRecipeManager.addRecipe(RecipeType.SMELTING, recipe);
if (blasting) { if (blasting) {
BlastingRecipe recipe2 = new BlastingRecipe(id, group, Ingredient.of(input), new ItemStack(output, count), xp, time / 2); BlastingRecipe recipe2 = new BlastingRecipe(
id,
group,
Ingredient.of(input),
new ItemStack(output, count),
xp,
time / 2
);
BCLRecipeManager.addRecipe(RecipeType.BLASTING, recipe2); BCLRecipeManager.addRecipe(RecipeType.BLASTING, recipe2);
} }
if (campfire) { if (campfire) {
CampfireCookingRecipe recipe2 = new CampfireCookingRecipe(id, group, Ingredient.of(input), new ItemStack(output, count), xp, time * 3); CampfireCookingRecipe recipe2 = new CampfireCookingRecipe(
id,
group,
Ingredient.of(input),
new ItemStack(output, count),
xp,
time * 3
);
BCLRecipeManager.addRecipe(RecipeType.CAMPFIRE_COOKING, recipe2); BCLRecipeManager.addRecipe(RecipeType.CAMPFIRE_COOKING, recipe2);
} }
if (smoker) { if (smoker) {
SmokingRecipe recipe2 = new SmokingRecipe(id, group, Ingredient.of(input), new ItemStack(output, count), xp, time / 2); SmokingRecipe recipe2 = new SmokingRecipe(
id,
group,
Ingredient.of(input),
new ItemStack(output, count),
xp,
time / 2
);
BCLRecipeManager.addRecipe(RecipeType.SMOKING, recipe2); BCLRecipeManager.addRecipe(RecipeType.SMOKING, recipe2);
} }
} }

View file

@ -116,7 +116,14 @@ public class GridRecipe {
ItemStack result = new ItemStack(output, count); ItemStack result = new ItemStack(output, count);
NonNullList<Ingredient> materials = this.getMaterials(width, height); NonNullList<Ingredient> materials = this.getMaterials(width, height);
CraftingRecipe recipe = shaped ? new ShapedRecipe(id, group, width, height, materials, result) : new ShapelessRecipe(id, group, result, materials); CraftingRecipe recipe = shaped ? new ShapedRecipe(
id,
group,
width,
height,
materials,
result
) : new ShapelessRecipe(id, group, result, materials);
BCLRecipeManager.addRecipe(type, recipe); BCLRecipeManager.addRecipe(type, recipe);
} }
else { else {

View file

@ -18,10 +18,16 @@ import ru.bclib.blocks.BaseFurnaceBlock;
import ru.bclib.blocks.BaseSignBlock; import ru.bclib.blocks.BaseSignBlock;
public class BaseBlockEntities { public class BaseBlockEntities {
public static final DynamicBlockEntityType<BaseChestBlockEntity> CHEST = registerBlockEntityType(BCLib.makeID("chest"), BaseChestBlockEntity::new); public static final DynamicBlockEntityType<BaseChestBlockEntity> CHEST = registerBlockEntityType(BCLib.makeID(
public static final DynamicBlockEntityType<BaseBarrelBlockEntity> BARREL = registerBlockEntityType(BCLib.makeID("barrel"), BaseBarrelBlockEntity::new); "chest"), BaseChestBlockEntity::new);
public static final DynamicBlockEntityType<BaseSignBlockEntity> SIGN = registerBlockEntityType(BCLib.makeID("sign"), BaseSignBlockEntity::new); public static final DynamicBlockEntityType<BaseBarrelBlockEntity> BARREL = registerBlockEntityType(BCLib.makeID(
public static final DynamicBlockEntityType<BaseFurnaceBlockEntity> FURNACE = registerBlockEntityType(BCLib.makeID("furnace"), BaseFurnaceBlockEntity::new); "barrel"), BaseBarrelBlockEntity::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 <T extends BlockEntity> DynamicBlockEntityType<T> registerBlockEntityType(ResourceLocation typeId, BlockEntitySupplier<? extends T> supplier) { public static <T extends BlockEntity> DynamicBlockEntityType<T> registerBlockEntityType(ResourceLocation typeId, BlockEntitySupplier<? 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));
@ -30,19 +36,39 @@ public class BaseBlockEntities {
public static void register() {} public static void register() {}
public static Block[] getChests() { public static Block[] getChests() {
return BaseRegistry.getRegisteredBlocks().values().stream().filter(item -> item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof BaseChestBlock).map(item -> ((BlockItem) item).getBlock()).toArray(Block[]::new); return BaseRegistry.getRegisteredBlocks()
.values()
.stream()
.filter(item -> item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof BaseChestBlock)
.map(item -> ((BlockItem) item).getBlock())
.toArray(Block[]::new);
} }
public static Block[] getBarrels() { public static Block[] getBarrels() {
return BaseRegistry.getRegisteredBlocks().values().stream().filter(item -> item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof BaseBarrelBlock).map(item -> ((BlockItem) item).getBlock()).toArray(Block[]::new); return BaseRegistry.getRegisteredBlocks()
.values()
.stream()
.filter(item -> item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof BaseBarrelBlock)
.map(item -> ((BlockItem) item).getBlock())
.toArray(Block[]::new);
} }
public static Block[] getSigns() { public static Block[] getSigns() {
return BaseRegistry.getRegisteredBlocks().values().stream().filter(item -> item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof BaseSignBlock).map(item -> ((BlockItem) item).getBlock()).toArray(Block[]::new); return BaseRegistry.getRegisteredBlocks()
.values()
.stream()
.filter(item -> item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof BaseSignBlock)
.map(item -> ((BlockItem) item).getBlock())
.toArray(Block[]::new);
} }
public static Block[] getFurnaces() { public static Block[] getFurnaces() {
return BaseRegistry.getRegisteredBlocks().values().stream().filter(item -> item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof BaseFurnaceBlock).map(item -> ((BlockItem) item).getBlock()).toArray(Block[]::new); return BaseRegistry.getRegisteredBlocks()
.values()
.stream()
.filter(item -> item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof BaseFurnaceBlock)
.map(item -> ((BlockItem) item).getBlock())
.toArray(Block[]::new);
} }
public static boolean registerSpecialBlock(Block block) { public static boolean registerSpecialBlock(Block block) {

View file

@ -14,11 +14,12 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public abstract class BaseRegistry<T> { public abstract class BaseRegistry<T> {
private static final List<BaseRegistry<?>> REGISTRIES = Lists.newArrayList(); private static final List<BaseRegistry<?>> REGISTRIES = Lists.newArrayList();
private static final Map<String, List<Item>> MOD_BLOCKS = Maps.newHashMap(); private static final Map<String, List<Item>> MOD_BLOCKS = Maps.newHashMap();
private static final Map<String, List<Item>> MOD_ITEMS = Maps.newHashMap(); private static final Map<String, List<Item>> MOD_ITEMS = Maps.newHashMap();
protected final CreativeModeTab creativeTab;
public static Map<String, List<Item>> getRegisteredBlocks() { public static Map<String, List<Item>> getRegisteredBlocks() {
return MOD_BLOCKS; return MOD_BLOCKS;
} }
@ -49,8 +50,6 @@ public abstract class BaseRegistry<T> {
REGISTRIES.forEach(BaseRegistry::registerInternal); REGISTRIES.forEach(BaseRegistry::registerInternal);
} }
protected final CreativeModeTab creativeTab;
protected BaseRegistry(CreativeModeTab creativeTab) { protected BaseRegistry(CreativeModeTab creativeTab) {
this.creativeTab = creativeTab; this.creativeTab = creativeTab;
REGISTRIES.add(this); REGISTRIES.add(this);

View file

@ -6,10 +6,8 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.Item.Properties;
import net.minecraft.world.item.WaterLilyBlockItem;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import ru.bclib.interfaces.ISpetialItem; import ru.bclib.interfaces.CustomItemGetter;
public abstract class BlocksRegistry extends BaseRegistry<Block> { public abstract class BlocksRegistry extends BaseRegistry<Block> {
@ -19,21 +17,17 @@ public abstract class BlocksRegistry extends BaseRegistry<Block> {
@Override @Override
public Block register(ResourceLocation id, Block block) { public Block register(ResourceLocation id, Block block) {
int maxCount = 64; BlockItem item = null;
boolean placeOnWater = false; if (block instanceof CustomItemGetter) {
if (block instanceof ISpetialItem) { item = ((CustomItemGetter) block).getCustomItem(id, makeItemSettings());
ISpetialItem item = (ISpetialItem) block;
maxCount = item.getStackSize();
placeOnWater = item.canPlaceOnWater();
}
Properties item = makeItemSettings().stacksTo(maxCount);
if (placeOnWater) {
registerBlockItem(id, new WaterLilyBlockItem(block, item));
} }
else { else {
registerBlockItem(id, new BlockItem(block, item)); item = new BlockItem(block, makeItemSettings());
} }
if (block.defaultBlockState().getMaterial().isFlammable() && FlammableBlockRegistry.getDefaultInstance().get(block).getBurnChance() == 0) { registerBlockItem(id, item);
if (block.defaultBlockState().getMaterial().isFlammable() && FlammableBlockRegistry.getDefaultInstance()
.get(block)
.getBurnChance() == 0) {
FlammableBlockRegistry.getDefaultInstance().add(block, 5, 5); FlammableBlockRegistry.getDefaultInstance().add(block, 5, 5);
} }
return Registry.register(Registry.BLOCK, id, block); return Registry.register(Registry.BLOCK, id, block);

View file

@ -78,7 +78,15 @@ public abstract class ItemsRegistry extends BaseRegistry<Item> {
public ItemStack execute(BlockSource pointer, ItemStack stack) { public ItemStack execute(BlockSource pointer, ItemStack stack) {
Direction direction = pointer.getBlockState().getValue(DispenserBlock.FACING); Direction direction = pointer.getBlockState().getValue(DispenserBlock.FACING);
EntityType<?> entityType = ((SpawnEggItem) stack.getItem()).getType(stack.getTag()); EntityType<?> entityType = ((SpawnEggItem) stack.getItem()).getType(stack.getTag());
entityType.spawn(pointer.getLevel(), stack, null, pointer.getPos().relative(direction), MobSpawnType.DISPENSER, direction != Direction.UP, false); entityType.spawn(
pointer.getLevel(),
stack,
null,
pointer.getPos().relative(direction),
MobSpawnType.DISPENSER,
direction != Direction.UP,
false
);
stack.shrink(1); stack.shrink(1);
return stack; return stack;
} }

View file

@ -34,7 +34,10 @@ public class SDFRadialNoiseMap extends SDFDisplacement {
} }
private float getNoise(double x, double z) { private float getNoise(double x, double z) {
return (float) noise.eval(x, z) + (float) noise.eval(x * 3 + 1000, z * 3) * 0.5F + (float) noise.eval(x * 9 + 1000, z * 9) * 0.2F; return (float) noise.eval(x, z) + (float) noise.eval(
x * 3 + 1000,
z * 3
) * 0.5F + (float) noise.eval(x * 9 + 1000, z * 9) * 0.2F;
} }
public SDFRadialNoiseMap setSeed(long seed) { public SDFRadialNoiseMap setSeed(long seed) {

View file

@ -30,7 +30,11 @@ public class SDFCappedCone extends SDFPrimitive {
float k2y = 2 * height; float k2y = 2 * height;
float cax = qx - MHelper.min(qx, (y < 0F) ? radius1 : radius2); float cax = qx - MHelper.min(qx, (y < 0F) ? radius1 : radius2);
float cay = Math.abs(y) - height; float cay = Math.abs(y) - height;
float mlt = Mth.clamp(MHelper.dot(radius2 - qx, height - y, k2x, k2y) / MHelper.dot(k2x, k2y, k2x, k2y), 0F, 1F); float mlt = Mth.clamp(
MHelper.dot(radius2 - qx, height - y, k2x, k2y) / MHelper.dot(k2x, k2y, k2x, k2y),
0F,
1F
);
float cbx = qx - radius2 + k2x * mlt; float cbx = qx - radius2 + k2x * mlt;
float cby = y - height + k2y * mlt; float cby = y - height + k2y * mlt;
float s = (cbx < 0F && cay < 0F) ? -1F : 1F; float s = (cbx < 0F && cay < 0F) ? -1F : 1F;

View file

@ -3,15 +3,15 @@ package ru.bclib.server;
import net.fabricmc.api.DedicatedServerModInitializer; import net.fabricmc.api.DedicatedServerModInitializer;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import ru.bclib.api.ModIntegrationAPI; import ru.bclib.api.ModIntegrationAPI;
import ru.bclib.interfaces.IPostInit; import ru.bclib.interfaces.PostInitable;
public class BCLibServer implements DedicatedServerModInitializer { public class BCLibServer implements DedicatedServerModInitializer {
@Override @Override
public void onInitializeServer() { public void onInitializeServer() {
ModIntegrationAPI.registerAll(); ModIntegrationAPI.registerAll();
Registry.BLOCK.forEach(block -> { Registry.BLOCK.forEach(block -> {
if (block instanceof IPostInit) { if (block instanceof PostInitable) {
((IPostInit) block).postInit(); ((PostInitable) block).postInit();
} }
}); });
} }

View file

@ -85,7 +85,10 @@ public class SplineHelper {
for (int i = 1; i < count; i++) { for (int i = 1; i < count; i++) {
Vector3f pos = spline.get(i); Vector3f pos = spline.get(i);
float delta = (float) (i - 1) / max; float delta = (float) (i - 1) / max;
SDF line = new SDFLine().setRadius(Mth.lerp(delta, radius1, radius2)).setStart(start.x(), start.y(), start.z()).setEnd(pos.x(), pos.y(), pos.z()).setBlock(placerFunction); SDF line = new SDFLine().setRadius(Mth.lerp(delta, radius1, radius2))
.setStart(start.x(), start.y(), start.z())
.setEnd(pos.x(), pos.y(), pos.z())
.setBlock(placerFunction);
result = result == null ? line : new SDFUnion().setSourceA(result).setSourceB(line); result = result == null ? line : new SDFUnion().setSourceA(result).setSourceB(line);
start = pos; start = pos;
} }
@ -100,7 +103,10 @@ public class SplineHelper {
for (int i = 1; i < count; i++) { for (int i = 1; i < count; i++) {
Vector3f pos = spline.get(i); Vector3f pos = spline.get(i);
float delta = (float) (i - 1) / max; float delta = (float) (i - 1) / max;
SDF line = new SDFLine().setRadius(radiusFunction.apply(delta)).setStart(start.x(), start.y(), start.z()).setEnd(pos.x(), pos.y(), pos.z()).setBlock(placerFunction); SDF line = new SDFLine().setRadius(radiusFunction.apply(delta))
.setStart(start.x(), start.y(), start.z())
.setEnd(pos.x(), pos.y(), pos.z())
.setBlock(placerFunction);
result = result == null ? line : new SDFUnion().setSourceA(result).setSourceB(line); result = result == null ? line : new SDFUnion().setSourceA(result).setSourceB(line);
start = pos; start = pos;
} }

View file

@ -87,7 +87,12 @@ 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); Vec3 offset = StructureTemplate.transform(
Vec3.atCenterOf(structure.getSize()),
mirror,
rotation,
BlockPos.ZERO
);
return pos.offset(-offset.x * 0.5, 0, -offset.z * 0.5); return pos.offset(-offset.x * 0.5, 0, -offset.z * 0.5);
} }
@ -97,7 +102,9 @@ 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.placeInWorld(world, offset, offset, placementData, random, 4);
} }
@ -140,7 +147,11 @@ public class StructureHelper {
mut.setY(y); mut.setY(y);
BlockState state = world.getBlockState(mut); BlockState state = world.getBlockState(mut);
boolean ignore = ignore(state, world, mut); boolean ignore = ignore(state, world, mut);
if (canDestruct && BlocksHelper.isInvulnerable(state, world, mut) && 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();
@ -163,7 +174,11 @@ 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.isInvulnerable(
world.getBlockState(mut),
world,
mut
)) {
BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR); BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR);
} }
} }
@ -181,7 +196,8 @@ public class StructureHelper {
if (!state.isAir() && random.nextBoolean()) { if (!state.isAir() && random.nextBoolean()) {
MHelper.shuffle(DIR, random); MHelper.shuffle(DIR, random);
for (Direction dir : DIR) { for (Direction dir : DIR) {
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.minY() - 10; y--) {
@ -196,7 +212,11 @@ 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.isInvulnerable(
world.getBlockState(mut.above()),
world,
mut
)) {
BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR); BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR);
} }
} }
@ -344,7 +364,12 @@ public class StructureHelper {
} }
private static boolean ignore(BlockState state, WorldGenLevel world, BlockPos pos) { private static boolean ignore(BlockState state, WorldGenLevel world, BlockPos pos) {
return state.getMaterial().isReplaceable() || !state.getFluidState().isEmpty() || state.is(TagAPI.END_GROUND) || state.is(BlockTags.LOGS) || state.is(BlockTags.LEAVES) || state.getMaterial().equals(Material.PLANT) || state.getMaterial().equals(Material.LEAVES) || BlocksHelper.isInvulnerable(state, world, pos); return state.getMaterial().isReplaceable() || !state.getFluidState()
.isEmpty() || state.is(TagAPI.END_GROUND) || state.is(
BlockTags.LOGS) || state.is(BlockTags.LEAVES) || state.getMaterial()
.equals(Material.PLANT) || state.getMaterial()
.equals(Material.LEAVES) || BlocksHelper
.isInvulnerable(state, world, pos);
} }
public static void cover(WorldGenLevel world, BoundingBox bounds, Random random) { public static void cover(WorldGenLevel world, BoundingBox bounds, Random random) {
@ -357,7 +382,9 @@ public class StructureHelper {
for (int y = bounds.maxY(); y >= bounds.minY(); y--) { for (int y = bounds.maxY(); y >= bounds.minY(); 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()) {
BlocksHelper.setWithoutUpdate(world, mut, top); BlocksHelper.setWithoutUpdate(world, mut, top);
} }
} }

View file

@ -142,7 +142,11 @@ public class BCLBiome {
list.add(new StructureInfo(structure, offsetY, terrainMerge)); list.add(new StructureInfo(structure, offsetY, terrainMerge));
}); });
if (!list.isEmpty()) { if (!list.isEmpty()) {
structuresFeature = BCLFeature.makeChansedFeature(new ResourceLocation(ns, nm + "_structures"), new ListFeature(list), 10); structuresFeature = BCLFeature.makeChansedFeature(
new ResourceLocation(ns, nm + "_structures"),
new ListFeature(list),
10
);
} }
} }
} }

View file

@ -140,12 +140,19 @@ public class BCLBiomeDef {
} }
public BCLBiomeDef setSurface(Block block) { public BCLBiomeDef setSurface(Block block) {
setSurface(SurfaceBuilder.DEFAULT.configured(new SurfaceBuilderBaseConfiguration(block.defaultBlockState(), Blocks.END_STONE.defaultBlockState(), Blocks.END_STONE.defaultBlockState()))); setSurface(SurfaceBuilder.DEFAULT.configured(new SurfaceBuilderBaseConfiguration(
block.defaultBlockState(),
Blocks.END_STONE.defaultBlockState(),
Blocks.END_STONE.defaultBlockState()
)));
return this; return this;
} }
public BCLBiomeDef setSurface(Block block1, Block block2) { public BCLBiomeDef setSurface(Block block1, Block block2) {
setSurface(DoubleBlockSurfaceBuilder.register("bclib_" + id.getPath() + "_surface").setBlock1(block1).setBlock2(block2).configured()); setSurface(DoubleBlockSurfaceBuilder.register("bclib_" + id.getPath() + "_surface")
.setBlock1(block1)
.setBlock2(block2)
.configured());
return this; return this;
} }
@ -299,7 +306,10 @@ public class BCLBiomeDef {
Builder effects = new Builder(); Builder effects = new Builder();
mobs.forEach((spawn) -> { mobs.forEach((spawn) -> {
spawnSettings.addSpawn(spawn.type.getCategory(), new MobSpawnSettings.SpawnerData(spawn.type, spawn.weight, spawn.minGroupSize, spawn.maxGroupSize)); spawnSettings.addSpawn(
spawn.type.getCategory(),
new MobSpawnSettings.SpawnerData(spawn.type, spawn.weight, spawn.minGroupSize, spawn.maxGroupSize)
);
}); });
spawns.forEach((entry) -> { spawns.forEach((entry) -> {
@ -311,14 +321,28 @@ public class BCLBiomeDef {
features.forEach((info) -> generationSettings.addFeature(info.featureStep, info.feature)); features.forEach((info) -> generationSettings.addFeature(info.featureStep, info.feature));
carvers.forEach((info) -> generationSettings.addCarver(info.carverStep, info.carver)); carvers.forEach((info) -> generationSettings.addCarver(info.carverStep, info.carver));
effects.skyColor(0).waterColor(waterColor).waterFogColor(waterFogColor).fogColor(fogColor).foliageColorOverride(foliageColor).grassColorOverride(grassColor); effects.skyColor(0)
.waterColor(waterColor)
.waterFogColor(waterFogColor)
.fogColor(fogColor)
.foliageColorOverride(foliageColor)
.grassColorOverride(grassColor);
if (loop != null) effects.ambientLoopSound(loop); if (loop != null) effects.ambientLoopSound(loop);
if (mood != null) effects.ambientMoodSound(mood); if (mood != null) effects.ambientMoodSound(mood);
if (additions != null) effects.ambientAdditionsSound(additions); if (additions != null) effects.ambientAdditionsSound(additions);
if (particleConfig != null) effects.ambientParticle(particleConfig); if (particleConfig != null) effects.ambientParticle(particleConfig);
effects.backgroundMusic(music != null ? new Music(music, 600, 2400, true) : Musics.END); effects.backgroundMusic(music != null ? new Music(music, 600, 2400, true) : Musics.END);
return new Biome.BiomeBuilder().precipitation(precipitation).biomeCategory(category).depth(depth).scale(0.2F).temperature(temperature).downfall(downfall).specialEffects(effects.build()).mobSpawnSettings(spawnSettings.build()).generationSettings(generationSettings.build()).build(); return new Biome.BiomeBuilder().precipitation(precipitation)
.biomeCategory(category)
.depth(depth)
.scale(0.2F)
.temperature(temperature)
.downfall(downfall)
.specialEffects(effects.build())
.mobSpawnSettings(spawnSettings.build())
.generationSettings(generationSettings.build())
.build();
} }
private static final class SpawnInfo { private static final class SpawnInfo {

View file

@ -39,39 +39,65 @@ 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(BCLDecorators.HEIGHTMAP_SQUARE)
.countRandom(density);
return new BCLFeature(id, feature, GenerationStep.Decoration.VEGETAL_DECORATION, configured); return new BCLFeature(id, feature, GenerationStep.Decoration.VEGETAL_DECORATION, configured);
} }
public static BCLFeature makeRawGenFeature(ResourceLocation id, Feature<NoneFeatureConfiguration> feature, int chance) { public static BCLFeature makeRawGenFeature(ResourceLocation id, Feature<NoneFeatureConfiguration> feature, int chance) {
ConfiguredFeature<?, ?> configured = feature.configured(FeatureConfiguration.NONE).decorated(FeatureDecorator.CHANCE.configured(new ChanceDecoratorConfiguration(chance))); ConfiguredFeature<?, ?> configured = feature.configured(FeatureConfiguration.NONE)
.decorated(FeatureDecorator.CHANCE.configured(new ChanceDecoratorConfiguration(
chance)));
return new BCLFeature(id, feature, GenerationStep.Decoration.RAW_GENERATION, configured); return new BCLFeature(id, feature, GenerationStep.Decoration.RAW_GENERATION, configured);
} }
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.LAVA_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); OreConfiguration config = new OreConfiguration(ANY_TERRAIN, blockOre.defaultBlockState(), 33);
ConfiguredFeature<?, ?> oreFeature = Feature.ORE.configured(featureConfig).rangeUniform(VerticalAnchor.absolute(minY), VerticalAnchor.absolute(maxY)).squared().count(veins); ConfiguredFeature<?, ?> oreFeature = Feature.ORE.configured(featureConfig)
return new BCLFeature(Feature.ORE, Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id, oreFeature), GenerationStep.Decoration.UNDERGROUND_ORES); .rangeUniform(
VerticalAnchor.absolute(minY),
VerticalAnchor.absolute(maxY)
)
.squared()
.count(veins);
return new BCLFeature(
Feature.ORE,
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id, oreFeature),
GenerationStep.Decoration.UNDERGROUND_ORES
);
} }
public static BCLFeature makeChunkFeature(ResourceLocation id, Feature<NoneFeatureConfiguration> feature) { public static BCLFeature makeChunkFeature(ResourceLocation id, Feature<NoneFeatureConfiguration> feature) {
ConfiguredFeature<?, ?> configured = feature.configured(FeatureConfiguration.NONE).decorated(FeatureDecorator.COUNT.configured(new CountConfiguration(1))); ConfiguredFeature<?, ?> configured = feature.configured(FeatureConfiguration.NONE)
.decorated(FeatureDecorator.COUNT.configured(new CountConfiguration(
1)));
return new BCLFeature(id, feature, GenerationStep.Decoration.LOCAL_MODIFICATIONS, configured); return new BCLFeature(id, feature, GenerationStep.Decoration.LOCAL_MODIFICATIONS, configured);
} }
public static BCLFeature makeChansedFeature(ResourceLocation id, Feature<NoneFeatureConfiguration> feature, int chance) { public static BCLFeature makeChansedFeature(ResourceLocation id, Feature<NoneFeatureConfiguration> feature, int chance) {
ConfiguredFeature<?, ?> configured = feature.configured(FeatureConfiguration.NONE).decorated(FeatureDecorator.CHANCE.configured(new ChanceDecoratorConfiguration(chance))); ConfiguredFeature<?, ?> configured = feature.configured(FeatureConfiguration.NONE)
.decorated(FeatureDecorator.CHANCE.configured(new ChanceDecoratorConfiguration(
chance)));
return new BCLFeature(id, feature, GenerationStep.Decoration.SURFACE_STRUCTURES, configured); return new BCLFeature(id, feature, GenerationStep.Decoration.SURFACE_STRUCTURES, configured);
} }
public static BCLFeature makeCountRawFeature(ResourceLocation id, Feature<NoneFeatureConfiguration> feature, int chance) { public static BCLFeature makeCountRawFeature(ResourceLocation id, Feature<NoneFeatureConfiguration> feature, int chance) {
ConfiguredFeature<?, ?> configured = feature.configured(FeatureConfiguration.NONE).decorated(FeatureDecorator.COUNT.configured(new CountConfiguration(chance))); ConfiguredFeature<?, ?> configured = feature.configured(FeatureConfiguration.NONE)
.decorated(FeatureDecorator.COUNT.configured(new CountConfiguration(
chance)));
return new BCLFeature(id, feature, GenerationStep.Decoration.RAW_GENERATION, configured); return new BCLFeature(id, feature, GenerationStep.Decoration.RAW_GENERATION, configured);
} }

View file

@ -93,11 +93,18 @@ 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(
new BlockPos(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.placeInWorld(world, center, center, placementData, random, 4);
@ -135,7 +142,9 @@ public abstract class NBTStructureFeature extends DefaultFeature {
BlockState stateSt = world.getBlockState(mut); BlockState stateSt = world.getBlockState(mut);
if (!stateSt.is(TagAPI.GEN_TERRAIN)) { if (!stateSt.is(TagAPI.GEN_TERRAIN)) {
if (merge == TerrainMerge.SURFACE) { if (merge == TerrainMerge.SURFACE) {
SurfaceBuilderConfiguration config = world.getBiome(mut).getGenerationSettings().getSurfaceBuilderConfig(); SurfaceBuilderConfiguration config = world.getBiome(mut)
.getGenerationSettings()
.getSurfaceBuilderConfig();
boolean isTop = mut.getY() == surfMax && state.getMaterial().isSolidBlocking(); boolean isTop = mut.getY() == surfMax && state.getMaterial().isSolidBlocking();
BlockState top = isTop ? config.getTopMaterial() : config.getUnderMaterial(); BlockState top = isTop ? config.getTopMaterial() : config.getUnderMaterial();
BlocksHelper.setWithoutUpdate(world, mut, top); BlocksHelper.setWithoutUpdate(world, mut, top);
@ -147,7 +156,9 @@ public abstract class NBTStructureFeature extends DefaultFeature {
else { else {
if (stateSt.is(TagAPI.END_GROUND) && state.getMaterial().isSolidBlocking()) { if (stateSt.is(TagAPI.END_GROUND) && state.getMaterial().isSolidBlocking()) {
if (merge == TerrainMerge.SURFACE) { if (merge == TerrainMerge.SURFACE) {
SurfaceBuilderConfiguration config = world.getBiome(mut).getGenerationSettings().getSurfaceBuilderConfig(); SurfaceBuilderConfiguration config = world.getBiome(mut)
.getGenerationSettings()
.getSurfaceBuilderConfig();
BlocksHelper.setWithoutUpdate(world, mut, config.getUnderMaterial()); BlocksHelper.setWithoutUpdate(world, mut, config.getUnderMaterial());
} }
else { else {

View file

@ -18,7 +18,11 @@ public class DestructionStructureProcessor extends StructureProcessor {
@Override @Override
public StructureBlockInfo processBlock(LevelReader worldView, BlockPos pos, BlockPos blockPos, StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2, StructurePlaceSettings structurePlacementData) { public StructureBlockInfo processBlock(LevelReader worldView, BlockPos pos, BlockPos blockPos, StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2, StructurePlaceSettings structurePlacementData) {
if (!BlocksHelper.isInvulnerable(structureBlockInfo2.state, worldView, structureBlockInfo2.pos) && MHelper.RANDOM.nextInt(chance) == 0) { if (!BlocksHelper.isInvulnerable(
structureBlockInfo2.state,
worldView,
structureBlockInfo2.pos
) && MHelper.RANDOM.nextInt(chance) == 0) {
return null; return null;
} }
return structureBlockInfo2; return structureBlockInfo2;

View file

@ -14,7 +14,10 @@ public class TerrainStructureProcessor extends StructureProcessor {
public StructureBlockInfo processBlock(LevelReader worldView, BlockPos pos, BlockPos blockPos, StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2, StructurePlaceSettings structurePlacementData) { public StructureBlockInfo processBlock(LevelReader worldView, BlockPos pos, BlockPos blockPos, StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2, StructurePlaceSettings structurePlacementData) {
BlockPos bpos = structureBlockInfo2.pos; BlockPos bpos = structureBlockInfo2.pos;
if (structureBlockInfo2.state.is(Blocks.END_STONE) && worldView.isEmptyBlock(bpos.above())) { if (structureBlockInfo2.state.is(Blocks.END_STONE) && worldView.isEmptyBlock(bpos.above())) {
BlockState top = worldView.getBiome(structureBlockInfo2.pos).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial(); BlockState top = worldView.getBiome(structureBlockInfo2.pos)
.getGenerationSettings()
.getSurfaceBuilderConfig()
.getTopMaterial();
return new StructureBlockInfo(bpos, top, structureBlockInfo2.nbt); return new StructureBlockInfo(bpos, top, structureBlockInfo2.nbt);
} }
return structureBlockInfo2; return structureBlockInfo2;

View file

@ -19,7 +19,10 @@ public class BCLStructureFeature {
public BCLStructureFeature(ResourceLocation id, StructureFeature<NoneFeatureConfiguration> structure, GenerationStep.Decoration step, int spacing, int separation) { public BCLStructureFeature(ResourceLocation id, StructureFeature<NoneFeatureConfiguration> structure, GenerationStep.Decoration step, int spacing, int separation) {
this.featureStep = step; this.featureStep = step;
this.structure = FabricStructureBuilder.create(id, structure).step(step).defaultConfig(spacing, separation, RANDOM.nextInt(8192)).register(); this.structure = FabricStructureBuilder.create(id, structure)
.step(step)
.defaultConfig(spacing, separation, RANDOM.nextInt(8192))
.register();
this.featureConfigured = this.structure.configured(NoneFeatureConfiguration.NONE); this.featureConfigured = this.structure.configured(NoneFeatureConfiguration.NONE);
BuiltinRegistries.register(BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE, id, this.featureConfigured); BuiltinRegistries.register(BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE, id, this.featureConfigured);
FlatChunkGeneratorConfigAccessor.getStructureToFeatures().put(this.structure, this.featureConfigured); FlatChunkGeneratorConfigAccessor.getStructureToFeatures().put(this.structure, this.featureConfigured);

View file

@ -47,6 +47,20 @@ public class DoubleBlockSurfaceBuilder extends SurfaceBuilder<SurfaceBuilderBase
@Override @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) { 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); 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); SurfaceBuilder.DEFAULT.apply(
random,
chunkAccess,
biome,
x,
z,
height,
noise,
defaultBlock,
defaultFluid,
l,
m,
seed,
noise > 0 ? config1 : config2
);
} }
} }

Some files were not shown because too many files have changed in this diff Show more