Merge remote-tracking branch 'upstream/1.17' into 1.17

This commit is contained in:
Frank Bauer 2021-07-09 00:54:46 +02:00
commit 4e1dcac17e
386 changed files with 5651 additions and 5403 deletions

View file

@ -72,7 +72,7 @@ def useApi(String dep) {
processResources { processResources {
inputs.property "version", project.version inputs.property "version", project.version
duplicatesStrategy = 'EXCLUDE' duplicatesStrategy = 'WARN'
from(sourceSets.main.resources.srcDirs) { from(sourceSets.main.resources.srcDirs) {
include "fabric.mod.json" include "fabric.mod.json"

View file

@ -33,7 +33,7 @@ import ru.betterend.world.surface.SurfaceBuilders;
public class BetterEnd implements ModInitializer { public class BetterEnd implements ModInitializer {
public static final String MOD_ID = "betterend"; public static final String MOD_ID = "betterend";
public static final Logger LOGGER = new Logger(MOD_ID); public static final Logger LOGGER = new Logger(MOD_ID);
@Override @Override
public void onInitialize() { public void onInitialize() {
WorldDataAPI.registerModCache(MOD_ID); WorldDataAPI.registerModCache(MOD_ID);
@ -62,11 +62,11 @@ public class BetterEnd implements ModInitializer {
Integrations.init(); Integrations.init();
Configs.saveConfigs(); Configs.saveConfigs();
} }
public static ResourceLocation makeID(String path) { public static ResourceLocation makeID(String path) {
return new ResourceLocation(MOD_ID, path); return new ResourceLocation(MOD_ID, path);
} }
public static String getStringId(String id) { public static String getStringId(String id) {
return String.format("%s:%s", MOD_ID, id); return String.format("%s:%s", MOD_ID, id);
} }

View file

@ -2,29 +2,33 @@ package ru.betterend.api;
public interface BetterEndPlugin { public interface BetterEndPlugin {
/** /**
* Alloying recipes registration. * Alloying recipes registration.
* See AlloyingRecipe.Builder for details. * See AlloyingRecipe.Builder for details.
*/ */
default void registerAlloyingRecipes() {} default void registerAlloyingRecipes() {
}
/** /**
* Smithing recipes registration. * Smithing recipes registration.
* See AnvilSmithingRecipe.Builder for details. * See AnvilSmithingRecipe.Builder for details.
*/ */
default void registerSmithingRecipes() {} default void registerSmithingRecipes() {
}
/** /**
* Additional biomes registration. * Additional biomes registration.
* See BiomeRegistry.registerBiome for details. * See BiomeRegistry.registerBiome for details.
*/ */
default void registerEndBiomes() {} default void registerEndBiomes() {
}
/** /**
* Register other mod stuff, for example, EndHammers. * Register other mod stuff, for example, EndHammers.
*/ */
default void registerOthers() {} default void registerOthers() {
}
public static void register(BetterEndPlugin plugin) { public static void register(BetterEndPlugin plugin) {
plugin.registerAlloyingRecipes(); plugin.registerAlloyingRecipes();
plugin.registerSmithingRecipes(); plugin.registerSmithingRecipes();

View file

@ -1,9 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
@ -21,15 +17,19 @@ import ru.bclib.util.MHelper;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndParticles; import ru.betterend.registry.EndParticles;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public class AncientEmeraldIceBlock extends BaseBlock { public class AncientEmeraldIceBlock extends BaseBlock {
public AncientEmeraldIceBlock() { public AncientEmeraldIceBlock() {
super(FabricBlockSettings.copyOf(Blocks.BLUE_ICE).randomTicks()); super(FabricBlockSettings.copyOf(Blocks.BLUE_ICE).randomTicks());
} }
@Override @Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
Direction dir = BlocksHelper.randomDirection(random); Direction dir = BlocksHelper.randomDirection(random);
if (random.nextBoolean()) { if (random.nextBoolean()) {
int x = MHelper.randRange(-2, 2, random); int x = MHelper.randRange(-2, 2, random);
int y = MHelper.randRange(-2, 2, random); int y = MHelper.randRange(-2, 2, random);
@ -40,7 +40,7 @@ public class AncientEmeraldIceBlock extends BaseBlock {
makeParticles(world, p, random); makeParticles(world, p, random);
} }
} }
pos = pos.relative(dir); pos = pos.relative(dir);
state = world.getBlockState(pos); state = world.getBlockState(pos);
if (state.is(Blocks.WATER)) { if (state.is(Blocks.WATER)) {
@ -52,11 +52,11 @@ public class AncientEmeraldIceBlock extends BaseBlock {
makeParticles(world, pos, random); makeParticles(world, pos, random);
} }
} }
private void makeParticles(ServerLevel world, BlockPos pos, Random random) { private void makeParticles(ServerLevel world, BlockPos pos, Random random) {
world.sendParticles(EndParticles.SNOWFLAKE, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 20, 0.5, 0.5, 0.5, 0); world.sendParticles(EndParticles.SNOWFLAKE, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 20, 0.5, 0.5, 0.5, 0);
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getOptionalParameter(LootContextParams.TOOL); ItemStack tool = builder.getOptionalParameter(LootContextParams.TOOL);

View file

@ -1,9 +1,6 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.List;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.client.color.block.BlockColor; import net.minecraft.client.color.block.BlockColor;
@ -20,23 +17,25 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
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.api.TagAPI;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IColorProvider; import ru.bclib.interfaces.IColorProvider;
import ru.bclib.interfaces.IRenderTyped; import ru.bclib.interfaces.IRenderTyped;
import ru.bclib.util.ColorUtil; import ru.bclib.util.ColorUtil;
import ru.bclib.util.MHelper; import ru.bclib.util.MHelper;
import ru.betterend.registry.EndItems; import ru.betterend.registry.EndItems;
import ru.betterend.registry.EndTags;
import java.util.List;
public class AuroraCrystalBlock extends AbstractGlassBlock implements IRenderTyped, IColorProvider { public class AuroraCrystalBlock extends AbstractGlassBlock implements IRenderTyped, IColorProvider {
public static final Vec3i[] COLORS; public static final Vec3i[] COLORS;
private static final int MIN_DROP = 1; private static final int MIN_DROP = 1;
private static final int MAX_DROP = 4; private static final int MAX_DROP = 4;
public AuroraCrystalBlock() { public AuroraCrystalBlock() {
super(FabricBlockSettings.of(Material.GLASS) super(FabricBlockSettings.of(Material.GLASS)
.breakByTool(FabricToolTags.PICKAXES) .breakByTool(FabricToolTags.PICKAXES)
.breakByTool(EndTags.HAMMERS) .breakByTool(TagAPI.HAMMERS)
.hardness(1F) .hardness(1F)
.resistance(1F) .resistance(1F)
.luminance(15) .luminance(15)
@ -50,22 +49,23 @@ public class AuroraCrystalBlock extends AbstractGlassBlock implements IRenderTyp
return (state, world, pos, tintIndex) -> { return (state, world, pos, tintIndex) -> {
if (pos == null) { if (pos == null) {
pos = BlockPos.ZERO; pos = BlockPos.ZERO;
}; }
;
long i = (long) pos.getX() + (long) pos.getY() + (long) pos.getZ(); long i = (long) pos.getX() + (long) pos.getY() + (long) pos.getZ();
double delta = i * 0.1; double delta = i * 0.1;
int index = MHelper.floor(delta); int index = MHelper.floor(delta);
int index2 = (index + 1) & 3; int index2 = (index + 1) & 3;
delta -= index; delta -= index;
index &= 3; index &= 3;
Vec3i color1 = COLORS[index]; Vec3i color1 = COLORS[index];
Vec3i color2 = COLORS[index2]; Vec3i color2 = COLORS[index2];
int r = MHelper.floor(Mth.lerp(delta, color1.getX(), color2.getX())); int r = MHelper.floor(Mth.lerp(delta, color1.getX(), color2.getX()));
int g = MHelper.floor(Mth.lerp(delta, color1.getY(), color2.getY())); int g = MHelper.floor(Mth.lerp(delta, color1.getY(), color2.getY()));
int b = MHelper.floor(Mth.lerp(delta, color1.getZ(), color2.getZ())); int b = MHelper.floor(Mth.lerp(delta, color1.getZ(), color2.getZ()));
return ColorUtil.color(r, g, b); return ColorUtil.color(r, g, b);
}; };
} }
@ -81,7 +81,7 @@ public class AuroraCrystalBlock extends AbstractGlassBlock implements IRenderTyp
public BCLRenderLayer getRenderLayer() { public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.TRANSLUCENT; return BCLRenderLayer.TRANSLUCENT;
} }
@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);
@ -99,20 +99,21 @@ public class AuroraCrystalBlock extends AbstractGlassBlock implements IRenderTyp
return Lists.newArrayList(new ItemStack(EndItems.CRYSTAL_SHARDS, max)); return Lists.newArrayList(new ItemStack(EndItems.CRYSTAL_SHARDS, max));
} }
count = MHelper.randRange(min, max, MHelper.RANDOM); count = MHelper.randRange(min, max, MHelper.RANDOM);
} else { }
else {
count = MHelper.randRange(MIN_DROP, MAX_DROP, MHelper.RANDOM); count = MHelper.randRange(MIN_DROP, MAX_DROP, MHelper.RANDOM);
} }
return Lists.newArrayList(new ItemStack(EndItems.CRYSTAL_SHARDS, count)); return Lists.newArrayList(new ItemStack(EndItems.CRYSTAL_SHARDS, count));
} }
return Lists.newArrayList(); return Lists.newArrayList();
} }
static { static {
COLORS = new Vec3i[] { COLORS = new Vec3i[]{
new Vec3i(247, 77, 161), new Vec3i(247, 77, 161),
new Vec3i(120, 184, 255), new Vec3i(120, 184, 255),
new Vec3i(120, 255, 168), new Vec3i(120, 255, 168),
new Vec3i(243, 58, 255) new Vec3i(243, 58, 255)
}; };
} }
} }

View file

@ -10,12 +10,12 @@ import ru.betterend.registry.EndBlocks;
public class BlueVineBlock extends UpDownPlantBlock { public class BlueVineBlock extends UpDownPlantBlock {
public static final EnumProperty<BlockProperties.TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE; public static final EnumProperty<BlockProperties.TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(SHAPE); stateManager.add(SHAPE);
} }
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
return state.getBlock() == EndBlocks.END_MOSS || state.getBlock() == EndBlocks.END_MYCELIUM; return state.getBlock() == EndBlocks.END_MOSS || state.getBlock() == EndBlocks.END_MYCELIUM;

View file

@ -19,17 +19,17 @@ import ru.betterend.registry.EndBlocks;
public class BlueVineLanternBlock extends BaseBlock { public class BlueVineLanternBlock extends BaseBlock {
public static final BooleanProperty NATURAL = BlockProperties.NATURAL; public static final BooleanProperty NATURAL = BlockProperties.NATURAL;
public BlueVineLanternBlock() { public BlueVineLanternBlock() {
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).luminance(15).sound(SoundType.WART_BLOCK)); super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).luminance(15).sound(SoundType.WART_BLOCK));
this.registerDefaultState(this.stateDefinition.any().setValue(NATURAL, false)); this.registerDefaultState(this.stateDefinition.any().setValue(NATURAL, false));
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return !state.getValue(NATURAL) || world.getBlockState(pos.below()).getBlock() == EndBlocks.BLUE_VINE; return !state.getValue(NATURAL) || world.getBlockState(pos.below()).getBlock() == EndBlocks.BLUE_VINE;
} }
@Override @Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (!canSurvive(state, world, pos)) { if (!canSurvive(state, world, pos)) {
@ -39,7 +39,7 @@ public class BlueVineLanternBlock extends BaseBlock {
return state; return state;
} }
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(NATURAL); stateManager.add(NATURAL);

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.WorldGenLevel;
@ -14,6 +12,8 @@ import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.blocks.basis.FurBlock; import ru.betterend.blocks.basis.FurBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class BlueVineSeedBlock extends EndPlantWithAgeBlock { public class BlueVineSeedBlock extends EndPlantWithAgeBlock {
@Override @Override
public void growAdult(WorldGenLevel world, Random random, BlockPos pos) { public void growAdult(WorldGenLevel world, Random random, BlockPos pos) {
@ -29,10 +29,10 @@ public class BlueVineSeedBlock extends EndPlantWithAgeBlock {
BlocksHelper.setWithoutUpdate(world, pos.above(height), EndBlocks.BLUE_VINE.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, BlockProperties.TripleShape.TOP)); BlocksHelper.setWithoutUpdate(world, pos.above(height), EndBlocks.BLUE_VINE.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, BlockProperties.TripleShape.TOP));
placeLantern(world, pos.above(height + 1)); placeLantern(world, pos.above(height + 1));
} }
private void placeLantern(WorldGenLevel world, BlockPos pos) { private void placeLantern(WorldGenLevel world, BlockPos pos) {
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.BLUE_VINE_LANTERN.defaultBlockState().setValue(BlueVineLanternBlock.NATURAL, true)); BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.BLUE_VINE_LANTERN.defaultBlockState().setValue(BlueVineLanternBlock.NATURAL, true));
for (Direction dir: BlocksHelper.HORIZONTAL) { for (Direction dir : BlocksHelper.HORIZONTAL) {
BlockPos p = pos.relative(dir); BlockPos p = pos.relative(dir);
if (world.isEmptyBlock(p)) { if (world.isEmptyBlock(p)) {
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.BLUE_VINE_FUR.defaultBlockState().setValue(FurBlock.FACING, dir)); BlocksHelper.setWithoutUpdate(world, p, EndBlocks.BLUE_VINE_FUR.defaultBlockState().setValue(FurBlock.FACING, dir));
@ -42,12 +42,12 @@ public class BlueVineSeedBlock extends EndPlantWithAgeBlock {
BlocksHelper.setWithoutUpdate(world, pos.above(), EndBlocks.BLUE_VINE_FUR.defaultBlockState().setValue(FurBlock.FACING, Direction.UP)); BlocksHelper.setWithoutUpdate(world, pos.above(), EndBlocks.BLUE_VINE_FUR.defaultBlockState().setValue(FurBlock.FACING, Direction.UP));
} }
} }
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.END_MOSS) || state.is(EndBlocks.END_MYCELIUM); return state.is(EndBlocks.END_MOSS) || state.is(EndBlocks.END_MYCELIUM);
} }
@Override @Override
public BlockBehaviour.OffsetType getOffsetType() { public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE; return BlockBehaviour.OffsetType.NONE;

View file

@ -1,10 +1,6 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.List;
import java.util.Random;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.BlockGetter;
@ -18,18 +14,21 @@ import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.blocks.basis.EndPlantBlock; import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.List;
import java.util.Random;
public class BoluxMushroomBlock extends EndPlantBlock { public class BoluxMushroomBlock extends EndPlantBlock {
private static final VoxelShape SHAPE = Block.box(1, 0, 1, 15, 9, 15); private static final VoxelShape SHAPE = Block.box(1, 0, 1, 15, 9, 15);
public BoluxMushroomBlock() { public BoluxMushroomBlock() {
super(10); super(10);
} }
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.RUTISCUS); return state.is(EndBlocks.RUTISCUS);
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE; return SHAPE;
@ -39,7 +38,7 @@ public class BoluxMushroomBlock extends EndPlantBlock {
public BlockBehaviour.OffsetType getOffsetType() { public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE; return BlockBehaviour.OffsetType.NONE;
} }
@Override @Override
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) { public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
return false; return false;
@ -49,7 +48,7 @@ public class BoluxMushroomBlock extends EndPlantBlock {
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) { public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
return false; return false;
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Lists.newArrayList(new ItemStack(this)); return Lists.newArrayList(new ItemStack(this));

View file

@ -1,9 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Random;
import org.jetbrains.annotations.Nullable;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -20,19 +16,22 @@ import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BooleanProperty; import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.material.Fluids; import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.material.MaterialColor; import net.minecraft.world.level.material.MaterialColor;
import org.jetbrains.annotations.Nullable;
import ru.bclib.blocks.BaseBlock; import ru.bclib.blocks.BaseBlock;
import ru.bclib.blocks.BlockProperties; import ru.bclib.blocks.BlockProperties;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class BrimstoneBlock extends BaseBlock { public class BrimstoneBlock extends BaseBlock {
public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVE; public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVE;
public BrimstoneBlock() { public BrimstoneBlock() {
super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(MaterialColor.COLOR_BROWN).randomTicks()); super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(MaterialColor.COLOR_BROWN).randomTicks());
registerDefaultState(stateDefinition.any().setValue(ACTIVATED, false)); registerDefaultState(stateDefinition.any().setValue(ACTIVATED, false));
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(ACTIVATED); stateManager.add(ACTIVATED);
@ -44,13 +43,13 @@ public class BrimstoneBlock extends BaseBlock {
updateChunks((ClientLevel) world, pos); updateChunks((ClientLevel) world, pos);
} }
} }
public void destroy(LevelAccessor world, BlockPos pos, BlockState state) { public void destroy(LevelAccessor world, BlockPos pos, BlockState state) {
if (world.isClientSide()) { if (world.isClientSide()) {
updateChunks((ClientLevel) world, pos); updateChunks((ClientLevel) world, pos);
} }
} }
private void updateChunks(ClientLevel world, BlockPos pos) { private void updateChunks(ClientLevel world, BlockPos pos) {
int y = pos.getY() >> 4; int y = pos.getY() >> 4;
int x1 = (pos.getX() - 2) >> 4; int x1 = (pos.getX() - 2) >> 4;
@ -63,11 +62,11 @@ public class BrimstoneBlock extends BaseBlock {
} }
} }
} }
@Override @Override
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) { public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
boolean deactivate = true; boolean deactivate = true;
for (Direction dir: BlocksHelper.DIRECTIONS) { for (Direction dir : BlocksHelper.DIRECTIONS) {
if (world.getFluidState(pos.relative(dir)).getType().equals(Fluids.WATER)) { if (world.getFluidState(pos.relative(dir)).getType().equals(Fluids.WATER)) {
deactivate = false; deactivate = false;
break; break;

View file

@ -22,7 +22,7 @@ import java.util.Random;
public class BubbleCoralBlock extends EndUnderwaterPlantBlock { public class BubbleCoralBlock extends EndUnderwaterPlantBlock {
private static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 14, 16); private static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 14, 16);
public BubbleCoralBlock() { public BubbleCoralBlock() {
super(FabricBlockSettings.of(Material.WATER_PLANT) super(FabricBlockSettings.of(Material.WATER_PLANT)
.breakByTool(FabricToolTags.SHEARS) .breakByTool(FabricToolTags.SHEARS)
@ -30,7 +30,7 @@ public class BubbleCoralBlock extends EndUnderwaterPlantBlock {
.sound(SoundType.CORAL_BLOCK) .sound(SoundType.CORAL_BLOCK)
.noCollission()); .noCollission());
} }
@Override @Override
public BlockBehaviour.OffsetType getOffsetType() { public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE; return BlockBehaviour.OffsetType.NONE;
@ -43,12 +43,12 @@ public class BubbleCoralBlock extends EndUnderwaterPlantBlock {
double z = pos.getZ() + random.nextDouble(); double z = pos.getZ() + random.nextDouble();
world.addParticle(ParticleTypes.BUBBLE, x, y, z, 0.0D, 0.0D, 0.0D); world.addParticle(ParticleTypes.BUBBLE, x, y, z, 0.0D, 0.0D, 0.0D);
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE; return SHAPE;
} }
@Override @Override
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) { public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
return false; return false;

View file

@ -1,9 +1,6 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.List;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.BlockGetter;
@ -16,11 +13,13 @@ import ru.bclib.util.MHelper;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems; import ru.betterend.registry.EndItems;
import java.util.List;
public class BulbVineBlock extends BaseVineBlock { public class BulbVineBlock extends BaseVineBlock {
public BulbVineBlock() { public BulbVineBlock() {
super(15, true); super(15, true);
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
if (state.getValue(SHAPE) == TripleShape.BOTTOM) { if (state.getValue(SHAPE) == TripleShape.BOTTOM) {
@ -33,12 +32,12 @@ public class BulbVineBlock extends BaseVineBlock {
return Lists.newArrayList(); return Lists.newArrayList();
} }
} }
@Override @Override
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) { public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
return false; return false;
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
boolean canPlace = super.canSurvive(state, world, pos); boolean canPlace = super.canSurvive(state, world, pos);

View file

@ -1,12 +1,6 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Map;
import java.util.Optional;
import org.jetbrains.annotations.Nullable;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -22,6 +16,7 @@ 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.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 org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.BlockModelProvider; import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
@ -29,10 +24,13 @@ import ru.bclib.interfaces.IRenderTyped;
import ru.betterend.blocks.basis.EndLanternBlock; import ru.betterend.blocks.basis.EndLanternBlock;
import ru.betterend.client.models.Patterns; import ru.betterend.client.models.Patterns;
import java.util.Map;
import java.util.Optional;
public class BulbVineLanternBlock extends EndLanternBlock implements IRenderTyped, BlockModelProvider { public class BulbVineLanternBlock extends EndLanternBlock implements IRenderTyped, BlockModelProvider {
private static final VoxelShape SHAPE_CEIL = Block.box(4, 4, 4, 12, 16, 12); private static final VoxelShape SHAPE_CEIL = Block.box(4, 4, 4, 12, 16, 12);
private static final VoxelShape SHAPE_FLOOR = Block.box(4, 0, 4, 12, 12, 12); private static final VoxelShape SHAPE_FLOOR = Block.box(4, 0, 4, 12, 12, 12);
public BulbVineLanternBlock() { public BulbVineLanternBlock() {
this(FabricBlockSettings.of(Material.METAL) this(FabricBlockSettings.of(Material.METAL)
.hardness(1) .hardness(1)
@ -43,11 +41,11 @@ public class BulbVineLanternBlock extends EndLanternBlock implements IRenderType
.requiresCorrectToolForDrops() .requiresCorrectToolForDrops()
.sound(SoundType.LANTERN)); .sound(SoundType.LANTERN));
} }
public BulbVineLanternBlock(Properties settings) { public BulbVineLanternBlock(Properties settings) {
super(settings); super(settings);
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return state.getValue(IS_FLOOR) ? SHAPE_FLOOR : SHAPE_CEIL; return state.getValue(IS_FLOOR) ? SHAPE_FLOOR : SHAPE_CEIL;
@ -69,13 +67,13 @@ public class BulbVineLanternBlock extends EndLanternBlock implements IRenderType
Patterns.createJson(Patterns.BLOCK_BULB_LANTERN_CEIL, textures); Patterns.createJson(Patterns.BLOCK_BULB_LANTERN_CEIL, textures);
return ModelsHelper.fromPattern(pattern); return ModelsHelper.fromPattern(pattern);
} }
protected String getMetalTexture(ResourceLocation blockId) { protected String getMetalTexture(ResourceLocation blockId) {
String name = blockId.getPath(); String name = blockId.getPath();
name = name.substring(0, name.indexOf('_')); name = name.substring(0, name.indexOf('_'));
return name + "_bulb_vine_lantern_metal"; return name + "_bulb_vine_lantern_metal";
} }
protected String getGlowTexture() { protected String getGlowTexture() {
return "bulb_vine_lantern_bulb"; return "bulb_vine_lantern_bulb";
} }

View file

@ -21,7 +21,7 @@ public class BulbVineLanternColoredBlock extends BulbVineLanternBlock implements
public ItemColor getItemProvider() { public ItemColor getItemProvider() {
return (stack, tintIndex) -> getColor(); return (stack, tintIndex) -> getColor();
} }
private int getColor() { private int getColor() {
int color = BlocksHelper.getBlockColor(this); int color = BlocksHelper.getBlockColor(this);
int b = (color & 255); int b = (color & 255);
@ -30,7 +30,7 @@ public class BulbVineLanternColoredBlock extends BulbVineLanternBlock implements
float[] hsv = ColorUtil.RGBtoHSB(r, g, b, new float[3]); float[] hsv = ColorUtil.RGBtoHSB(r, g, b, new float[3]);
return ColorUtil.HSBtoRGB(hsv[0], hsv[1], hsv[1] > 0.2 ? 1 : hsv[2]); return ColorUtil.HSBtoRGB(hsv[0], hsv[1], hsv[1] > 0.2 ? 1 : hsv[2]);
} }
@Override @Override
protected String getGlowTexture() { protected String getGlowTexture() {
return "bulb_vine_lantern_overlay"; return "bulb_vine_lantern_overlay";

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.tags.BlockTags; import net.minecraft.tags.BlockTags;
import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.LevelReader;
@ -14,6 +12,8 @@ import ru.bclib.util.BlocksHelper;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock; import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class BulbVineSeedBlock extends EndPlantWithAgeBlock { public class BulbVineSeedBlock extends EndPlantWithAgeBlock {
@Override @Override

View file

@ -1,8 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
@ -22,21 +19,24 @@ import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped; import ru.bclib.interfaces.IRenderTyped;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Collections;
import java.util.List;
public class CavePumpkinBlock extends BaseBlockNotFull implements IRenderTyped { public class CavePumpkinBlock extends BaseBlockNotFull implements IRenderTyped {
public static final BooleanProperty SMALL = BlockProperties.SMALL; public static final BooleanProperty SMALL = BlockProperties.SMALL;
private static final VoxelShape SHAPE_SMALL; private static final VoxelShape SHAPE_SMALL;
private static final VoxelShape SHAPE_BIG; private static final VoxelShape SHAPE_BIG;
public CavePumpkinBlock() { public CavePumpkinBlock() {
super(FabricBlockSettings.copyOf(Blocks.PUMPKIN).luminance((state) -> state.getValue(SMALL) ? 10 : 15)); super(FabricBlockSettings.copyOf(Blocks.PUMPKIN).luminance((state) -> state.getValue(SMALL) ? 10 : 15));
registerDefaultState(defaultBlockState().setValue(SMALL, false)); registerDefaultState(defaultBlockState().setValue(SMALL, false));
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(SMALL); stateManager.add(SMALL);
} }
@Override @Override
public BCLRenderLayer getRenderLayer() { public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT; return BCLRenderLayer.CUTOUT;
@ -46,18 +46,18 @@ public class CavePumpkinBlock extends BaseBlockNotFull implements IRenderTyped {
public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
return state.getValue(SMALL) ? SHAPE_SMALL : SHAPE_BIG; return state.getValue(SMALL) ? SHAPE_SMALL : SHAPE_BIG;
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return state.getValue(SMALL) ? Collections.singletonList(new ItemStack(EndBlocks.CAVE_PUMPKIN_SEED)) : Collections.singletonList(new ItemStack(this)); return state.getValue(SMALL) ? Collections.singletonList(new ItemStack(EndBlocks.CAVE_PUMPKIN_SEED)) : Collections.singletonList(new ItemStack(this));
} }
static { static {
VoxelShape lantern = Block.box(1, 0, 1, 15, 13, 15); VoxelShape lantern = Block.box(1, 0, 1, 15, 13, 15);
VoxelShape cap = Block.box(0, 12, 0, 16, 15, 16); VoxelShape cap = Block.box(0, 12, 0, 16, 15, 16);
VoxelShape top = Block.box(5, 15, 5, 11, 16, 11); VoxelShape top = Block.box(5, 15, 5, 11, 16, 11);
SHAPE_BIG = Shapes.or(lantern, cap, top); SHAPE_BIG = Shapes.or(lantern, cap, top);
lantern = Block.box(1, 7, 1, 15, 13, 15); lantern = Block.box(1, 7, 1, 15, 13, 15);
cap = Block.box(4, 12, 4, 12, 15, 12); cap = Block.box(4, 12, 4, 12, 15, 12);
top = Block.box(6, 15, 6, 10, 16, 10); top = Block.box(6, 15, 6, 10, 16, 10);

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
@ -18,15 +16,17 @@ import ru.bclib.blocks.BlockProperties;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock; import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class CavePumpkinVineBlock extends EndPlantWithAgeBlock { public class CavePumpkinVineBlock extends EndPlantWithAgeBlock {
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);
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
BlockState down = world.getBlockState(pos.above()); BlockState down = world.getBlockState(pos.above());
return isTerrain(down); return isTerrain(down);
} }
@Override @Override
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) { public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) {
int age = state.getValue(AGE); int age = state.getValue(AGE);
@ -45,8 +45,9 @@ public class CavePumpkinVineBlock extends EndPlantWithAgeBlock {
} }
@Override @Override
public void growAdult(WorldGenLevel world, Random random, BlockPos pos) {} public void growAdult(WorldGenLevel world, Random random, BlockPos pos) {
}
@Override @Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
state = super.updateShape(state, facing, neighborState, world, pos, neighborPos); state = super.updateShape(state, facing, neighborState, world, pos, neighborPos);
@ -63,7 +64,7 @@ public class CavePumpkinVineBlock extends EndPlantWithAgeBlock {
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE; return SHAPE;
} }
@Override @Override
public BlockBehaviour.OffsetType getOffsetType() { public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE; return BlockBehaviour.OffsetType.NONE;

View file

@ -1,13 +1,6 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.EnumMap;
import java.util.Map;
import java.util.Optional;
import org.jetbrains.annotations.Nullable;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -23,6 +16,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.Nullable;
import ru.bclib.blocks.BaseAttachedBlock; import ru.bclib.blocks.BaseAttachedBlock;
import ru.bclib.client.models.BlockModelProvider; import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
@ -30,18 +24,22 @@ import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped; import ru.bclib.interfaces.IRenderTyped;
import ru.betterend.client.models.Patterns; import ru.betterend.client.models.Patterns;
import java.util.EnumMap;
import java.util.Map;
import java.util.Optional;
public class ChandelierBlock extends BaseAttachedBlock implements IRenderTyped, BlockModelProvider { public class ChandelierBlock extends BaseAttachedBlock implements IRenderTyped, BlockModelProvider {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class); private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
public ChandelierBlock(Block source) { public ChandelierBlock(Block source) {
super(FabricBlockSettings.copyOf(source).luminance(15).noCollission().noOcclusion().requiresCorrectToolForDrops()); super(FabricBlockSettings.copyOf(source).luminance(15).noCollission().noOcclusion().requiresCorrectToolForDrops());
} }
@Override @Override
public BCLRenderLayer getRenderLayer() { public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT; return BCLRenderLayer.CUTOUT;
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return BOUNDING_SHAPES.get(state.getValue(FACING)); return BOUNDING_SHAPES.get(state.getValue(FACING));

View file

@ -8,7 +8,7 @@ public class ChorusGrassBlock extends EndPlantBlock {
public ChorusGrassBlock() { public ChorusGrassBlock() {
super(true); super(true);
} }
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
return state.getBlock() == EndBlocks.CHORUS_NYLIUM; return state.getBlock() == EndBlocks.CHORUS_NYLIUM;

View file

@ -1,8 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.item.enchantment.EnchantmentHelper;
@ -15,6 +12,9 @@ import ru.bclib.blocks.BaseBlock;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped; import ru.bclib.interfaces.IRenderTyped;
import java.util.Collections;
import java.util.List;
public class DenseEmeraldIceBlock extends BaseBlock implements IRenderTyped { public class DenseEmeraldIceBlock extends BaseBlock implements IRenderTyped {
public DenseEmeraldIceBlock() { public DenseEmeraldIceBlock() {
super(FabricBlockSettings.copyOf(Blocks.PACKED_ICE)); super(FabricBlockSettings.copyOf(Blocks.PACKED_ICE));
@ -24,7 +24,7 @@ public class DenseEmeraldIceBlock extends BaseBlock implements IRenderTyped {
public BCLRenderLayer getRenderLayer() { public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.TRANSLUCENT; return BCLRenderLayer.TRANSLUCENT;
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getOptionalParameter(LootContextParams.TOOL); ItemStack tool = builder.getOptionalParameter(LootContextParams.TOOL);

View file

@ -17,7 +17,7 @@ public class DragonTreeSaplingBlock extends FeatureSaplingBlock {
protected Feature<?> getFeature() { protected Feature<?> getFeature() {
return EndFeatures.DRAGON_TREE.getFeature(); return EndFeatures.DRAGON_TREE.getFeature();
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return world.getBlockState(pos.below()).is(EndBlocks.SHADOW_GRASS); return world.getBlockState(pos.below()).is(EndBlocks.SHADOW_GRASS);

View file

@ -1,11 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import org.jetbrains.annotations.Nullable;
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.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -26,10 +20,15 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.BlockModelProvider; 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.IRenderTyped;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public class EmeraldIceBlock extends HalfTransparentBlock implements IRenderTyped, BlockModelProvider { public class EmeraldIceBlock extends HalfTransparentBlock implements IRenderTyped, BlockModelProvider {
public EmeraldIceBlock() { public EmeraldIceBlock() {
super(FabricBlockSettings.copyOf(Blocks.ICE)); super(FabricBlockSettings.copyOf(Blocks.ICE));
@ -74,7 +73,7 @@ public class EmeraldIceBlock extends HalfTransparentBlock implements IRenderType
world.neighborChanged(pos, Blocks.WATER, pos); world.neighborChanged(pos, Blocks.WATER, pos);
} }
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getOptionalParameter(LootContextParams.TOOL); ItemStack tool = builder.getOptionalParameter(LootContextParams.TOOL);

View file

@ -11,10 +11,10 @@ public class EndBlockProperties extends BlockProperties {
public static final EnumProperty<HydraluxShape> HYDRALUX_SHAPE = EnumProperty.create("shape", HydraluxShape.class); public static final EnumProperty<HydraluxShape> HYDRALUX_SHAPE = EnumProperty.create("shape", HydraluxShape.class);
public static final EnumProperty<PedestalState> PEDESTAL_STATE = EnumProperty.create("state", PedestalState.class); public static final EnumProperty<PedestalState> PEDESTAL_STATE = EnumProperty.create("state", PedestalState.class);
public static final EnumProperty<CactusBottom> CACTUS_BOTTOM = EnumProperty.create("bottom", CactusBottom.class); public static final EnumProperty<CactusBottom> CACTUS_BOTTOM = EnumProperty.create("bottom", CactusBottom.class);
public static final BooleanProperty HAS_ITEM = BooleanProperty.create("has_item"); public static final BooleanProperty HAS_ITEM = BooleanProperty.create("has_item");
public static final IntegerProperty PORTAL = IntegerProperty.create("portal", 0, EndPortals.getCount()); public static final IntegerProperty PORTAL = IntegerProperty.create("portal", 0, EndPortals.getCount());
public enum PedestalState implements StringRepresentable { public enum PedestalState implements StringRepresentable {
PEDESTAL_TOP("pedestal_top"), PEDESTAL_TOP("pedestal_top"),
COLUMN_TOP("column_top"), COLUMN_TOP("column_top"),
@ -22,24 +22,24 @@ public class EndBlockProperties extends BlockProperties {
PILLAR("pillar"), PILLAR("pillar"),
COLUMN("column"), COLUMN("column"),
DEFAULT("default"); DEFAULT("default");
private final String name; private final String name;
PedestalState(String name) { PedestalState(String name) {
this.name = name; this.name = name;
} }
@Override @Override
public String getSerializedName() { public String getSerializedName() {
return this.name; return this.name;
} }
@Override @Override
public String toString() { public String toString() {
return this.name; return this.name;
} }
} }
public enum HydraluxShape implements StringRepresentable { public enum HydraluxShape implements StringRepresentable {
FLOWER_BIG_BOTTOM("flower_big_bottom", true), FLOWER_BIG_BOTTOM("flower_big_bottom", true),
FLOWER_BIG_TOP("flower_big_top", true), FLOWER_BIG_TOP("flower_big_top", true),
@ -47,10 +47,10 @@ public class EndBlockProperties extends BlockProperties {
FLOWER_SMALL_TOP("flower_small_top", true), FLOWER_SMALL_TOP("flower_small_top", true),
VINE("vine", false), VINE("vine", false),
ROOTS("roots", false); ROOTS("roots", false);
private final String name; private final String name;
private final boolean glow; private final boolean glow;
HydraluxShape(String name, boolean glow) { HydraluxShape(String name, boolean glow) {
this.name = name; this.name = name;
this.glow = glow; this.glow = glow;
@ -60,17 +60,17 @@ public class EndBlockProperties extends BlockProperties {
public String getSerializedName() { public String getSerializedName() {
return name; return name;
} }
@Override @Override
public String toString() { public String toString() {
return name; return name;
} }
public boolean hasGlow() { public boolean hasGlow() {
return glow; return glow;
} }
} }
public enum LumecornShape implements StringRepresentable { public enum LumecornShape implements StringRepresentable {
LIGHT_TOP("light_top", 15), LIGHT_TOP("light_top", 15),
LIGHT_TOP_MIDDLE("light_top_middle", 15), LIGHT_TOP_MIDDLE("light_top_middle", 15),
@ -79,10 +79,10 @@ public class EndBlockProperties extends BlockProperties {
MIDDLE("middle", 0), MIDDLE("middle", 0),
BOTTOM_BIG("bottom_big", 0), BOTTOM_BIG("bottom_big", 0),
BOTTOM_SMALL("bottom_small", 0); BOTTOM_SMALL("bottom_small", 0);
private final String name; private final String name;
private final int light; private final int light;
LumecornShape(String name, int light) { LumecornShape(String name, int light) {
this.name = name; this.name = name;
this.light = light; this.light = light;
@ -92,24 +92,24 @@ public class EndBlockProperties extends BlockProperties {
public String getSerializedName() { public String getSerializedName() {
return name; return name;
} }
@Override @Override
public String toString() { public String toString() {
return name; return name;
} }
public int getLight() { public int getLight() {
return light; return light;
} }
} }
public enum CactusBottom implements StringRepresentable { public enum CactusBottom implements StringRepresentable {
EMPTY("empty"), EMPTY("empty"),
SAND("sand"), SAND("sand"),
MOSS("moss"); MOSS("moss");
private final String name; private final String name;
CactusBottom(String name) { CactusBottom(String name) {
this.name = name; this.name = name;
} }
@ -118,7 +118,7 @@ public class EndBlockProperties extends BlockProperties {
public String getSerializedName() { public String getSerializedName() {
return name; return name;
} }
@Override @Override
public String toString() { public String toString() {
return name; return name;

View file

@ -1,11 +1,6 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
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.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -37,11 +32,15 @@ import ru.betterend.blocks.basis.EndUnderwaterPlantBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems; import ru.betterend.registry.EndItems;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public class EndLilyBlock extends EndUnderwaterPlantBlock { public class EndLilyBlock extends EndUnderwaterPlantBlock {
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE; public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
private static final VoxelShape SHAPE_BOTTOM = Block.box(4, 0, 4, 12, 16, 12); private static final VoxelShape SHAPE_BOTTOM = Block.box(4, 0, 4, 12, 16, 12);
private static final VoxelShape SHAPE_TOP = Block.box(2, 0, 2, 14, 6, 14); private static final VoxelShape SHAPE_TOP = Block.box(2, 0, 2, 14, 6, 14);
public EndLilyBlock() { public EndLilyBlock() {
super(FabricBlockSettings.of(Material.WATER_PLANT) super(FabricBlockSettings.of(Material.WATER_PLANT)
.breakByTool(FabricToolTags.SHEARS) .breakByTool(FabricToolTags.SHEARS)
@ -50,7 +49,7 @@ public class EndLilyBlock extends EndUnderwaterPlantBlock {
.lightLevel((state) -> state.getValue(SHAPE) == TripleShape.TOP ? 13 : 0) .lightLevel((state) -> state.getValue(SHAPE) == TripleShape.TOP ? 13 : 0)
.noCollission()); .noCollission());
} }
@Override @Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (!canSurvive(state, world, pos)) { if (!canSurvive(state, world, pos)) {
@ -60,24 +59,24 @@ public class EndLilyBlock extends EndUnderwaterPlantBlock {
return state; return state;
} }
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
Vec3 vec3d = state.getOffset(view, pos); Vec3 vec3d = state.getOffset(view, pos);
VoxelShape shape = state.getValue(SHAPE) == TripleShape.TOP ? SHAPE_TOP : SHAPE_BOTTOM; VoxelShape shape = state.getValue(SHAPE) == TripleShape.TOP ? SHAPE_TOP : SHAPE_BOTTOM;
return shape.move(vec3d.x, vec3d.y, vec3d.z); return shape.move(vec3d.x, vec3d.y, vec3d.z);
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(SHAPE); stateManager.add(SHAPE);
} }
@Override @Override
public FluidState getFluidState(BlockState state) { public FluidState getFluidState(BlockState state) {
return state.getValue(SHAPE) == TripleShape.TOP ? Fluids.EMPTY.defaultFluidState() : Fluids.WATER.getSource(false); return state.getValue(SHAPE) == TripleShape.TOP ? Fluids.EMPTY.defaultFluidState() : Fluids.WATER.getSource(false);
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
if (state.getValue(SHAPE) == TripleShape.TOP) { if (state.getValue(SHAPE) == TripleShape.TOP) {
@ -92,7 +91,7 @@ public class EndLilyBlock extends EndUnderwaterPlantBlock {
return up.getBlock() == this && down.getBlock() == this; return up.getBlock() == this && down.getBlock() == this;
} }
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
if (state.getValue(SHAPE) == TripleShape.TOP) { if (state.getValue(SHAPE) == TripleShape.TOP) {
@ -100,13 +99,13 @@ public class EndLilyBlock extends EndUnderwaterPlantBlock {
} }
return Collections.emptyList(); return Collections.emptyList();
} }
@Override @Override
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) { public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) {
return new ItemStack(EndBlocks.END_LILY_SEED); return new ItemStack(EndBlocks.END_LILY_SEED);
} }
@Override @Override
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) { public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
return false; return false;

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
@ -12,6 +10,8 @@ import ru.bclib.blocks.UnderwaterPlantWithAgeBlock;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class EndLilySeedBlock extends UnderwaterPlantWithAgeBlock { public class EndLilySeedBlock extends UnderwaterPlantWithAgeBlock {
@Override @Override
public void grow(WorldGenLevel world, Random random, BlockPos pos) { public void grow(WorldGenLevel world, Random random, BlockPos pos) {
@ -25,7 +25,7 @@ public class EndLilySeedBlock extends UnderwaterPlantWithAgeBlock {
BlocksHelper.setWithoutUpdate(world, up, EndBlocks.END_LILY.defaultBlockState().setValue(EndLilyBlock.SHAPE, TripleShape.TOP)); BlocksHelper.setWithoutUpdate(world, up, EndBlocks.END_LILY.defaultBlockState().setValue(EndLilyBlock.SHAPE, TripleShape.TOP));
} }
} }
private boolean canGrow(WorldGenLevel world, BlockPos pos) { private boolean canGrow(WorldGenLevel world, BlockPos pos) {
BlockPos up = pos.above(); BlockPos up = pos.above();
while (world.getBlockState(up).getFluidState().getType().equals(Fluids.WATER.getSource())) { while (world.getBlockState(up).getFluidState().getType().equals(Fluids.WATER.getSource())) {

View file

@ -1,9 +1,6 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.List;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
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.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -21,40 +18,42 @@ import ru.bclib.util.MHelper;
import ru.betterend.blocks.basis.EndPlantBlock; import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.List;
public class EndLotusFlowerBlock extends EndPlantBlock { public class EndLotusFlowerBlock extends EndPlantBlock {
private static final VoxelShape SHAPE_OUTLINE = Block.box(2, 0, 2, 14, 14, 14); private static final VoxelShape SHAPE_OUTLINE = Block.box(2, 0, 2, 14, 14, 14);
private static final VoxelShape SHAPE_COLLISION = Block.box(0, 0, 0, 16, 2, 16); private static final VoxelShape SHAPE_COLLISION = Block.box(0, 0, 0, 16, 2, 16);
public EndLotusFlowerBlock() { public EndLotusFlowerBlock() {
super(FabricBlockSettings.of(Material.PLANT).luminance(15).noOcclusion()); super(FabricBlockSettings.of(Material.PLANT).luminance(15).noOcclusion());
} }
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.END_LOTUS_STEM); return state.is(EndBlocks.END_LOTUS_STEM);
} }
@Override @Override
public BlockBehaviour.OffsetType getOffsetType() { public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE; return BlockBehaviour.OffsetType.NONE;
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE_OUTLINE; return SHAPE_OUTLINE;
} }
@Override @Override
public VoxelShape getCollisionShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getCollisionShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE_COLLISION; return SHAPE_COLLISION;
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
int count = MHelper.randRange(1, 2, MHelper.RANDOM); int count = MHelper.randRange(1, 2, MHelper.RANDOM);
return Lists.newArrayList(new ItemStack(EndBlocks.END_LOTUS_SEED, count)); return Lists.newArrayList(new ItemStack(EndBlocks.END_LOTUS_SEED, count));
} }
@Override @Override
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) { public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) {

View file

@ -32,27 +32,27 @@ public class EndLotusLeafBlock extends BaseBlockNotFull implements IRenderTyped
public static final EnumProperty<Direction> HORIZONTAL_FACING = BlockStateProperties.HORIZONTAL_FACING; public static final EnumProperty<Direction> HORIZONTAL_FACING = BlockStateProperties.HORIZONTAL_FACING;
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE; public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
private static final VoxelShape VSHAPE = Block.box(0, 0, 0, 16, 1, 16); private static final VoxelShape VSHAPE = Block.box(0, 0, 0, 16, 1, 16);
public EndLotusLeafBlock() { public EndLotusLeafBlock() {
super(FabricBlockSettings.of(Material.PLANT).noOcclusion().sound(SoundType.WET_GRASS)); super(FabricBlockSettings.of(Material.PLANT).noOcclusion().sound(SoundType.WET_GRASS));
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
BlockState down = world.getBlockState(pos.below()); BlockState down = world.getBlockState(pos.below());
return !down.getFluidState().isEmpty() && down.getFluidState().getType() instanceof WaterFluid; return !down.getFluidState().isEmpty() && down.getFluidState().getType() instanceof WaterFluid;
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(SHAPE, HORIZONTAL_FACING); builder.add(SHAPE, HORIZONTAL_FACING);
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return VSHAPE; return VSHAPE;
} }
@Override @Override
public BlockState rotate(BlockState state, Rotation rotation) { public BlockState rotate(BlockState state, Rotation rotation) {
return BlocksHelper.rotateHorizontal(state, rotation, HORIZONTAL_FACING); return BlocksHelper.rotateHorizontal(state, rotation, HORIZONTAL_FACING);
@ -62,12 +62,12 @@ public class EndLotusLeafBlock extends BaseBlockNotFull implements IRenderTyped
public BlockState mirror(BlockState state, Mirror mirror) { public BlockState mirror(BlockState state, Mirror mirror) {
return BlocksHelper.mirrorHorizontal(state, mirror, HORIZONTAL_FACING); return BlocksHelper.mirrorHorizontal(state, mirror, HORIZONTAL_FACING);
} }
@Override @Override
public BCLRenderLayer getRenderLayer() { public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT; return BCLRenderLayer.CUTOUT;
} }
@Override @Override
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) { public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) {

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
@ -14,6 +12,8 @@ import ru.bclib.blocks.UnderwaterPlantWithAgeBlock;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock { public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock {
@Override @Override
public void grow(WorldGenLevel world, Random random, BlockPos pos) { public void grow(WorldGenLevel world, Random random, BlockPos pos) {
@ -22,7 +22,7 @@ public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock {
BlockState roots = EndBlocks.END_LOTUS_STEM.defaultBlockState().setValue(EndLotusStemBlock.SHAPE, TripleShape.BOTTOM).setValue(EndLotusStemBlock.WATERLOGGED, true); BlockState roots = EndBlocks.END_LOTUS_STEM.defaultBlockState().setValue(EndLotusStemBlock.SHAPE, TripleShape.BOTTOM).setValue(EndLotusStemBlock.WATERLOGGED, true);
BlockState stem = EndBlocks.END_LOTUS_STEM.defaultBlockState(); BlockState stem = EndBlocks.END_LOTUS_STEM.defaultBlockState();
BlockState flower = EndBlocks.END_LOTUS_FLOWER.defaultBlockState(); BlockState flower = EndBlocks.END_LOTUS_FLOWER.defaultBlockState();
BlocksHelper.setWithoutUpdate(world, pos, roots); BlocksHelper.setWithoutUpdate(world, pos, roots);
MutableBlockPos bpos = new MutableBlockPos().set(pos); MutableBlockPos bpos = new MutableBlockPos().set(pos);
bpos.setY(bpos.getY() + 1); bpos.setY(bpos.getY() + 1);
@ -30,7 +30,7 @@ public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock {
BlocksHelper.setWithoutUpdate(world, bpos, stem.setValue(EndLotusStemBlock.WATERLOGGED, true)); BlocksHelper.setWithoutUpdate(world, bpos, stem.setValue(EndLotusStemBlock.WATERLOGGED, true));
bpos.setY(bpos.getY() + 1); bpos.setY(bpos.getY() + 1);
} }
int height = random.nextBoolean() ? 0 : random.nextBoolean() ? 1 : random.nextBoolean() ? 1 : -1; int height = random.nextBoolean() ? 0 : random.nextBoolean() ? 1 : random.nextBoolean() ? 1 : -1;
TripleShape shape = (height == 0) ? TripleShape.TOP : TripleShape.MIDDLE; TripleShape shape = (height == 0) ? TripleShape.TOP : TripleShape.MIDDLE;
Direction dir = BlocksHelper.randomHorizontal(random); Direction dir = BlocksHelper.randomHorizontal(random);
@ -42,7 +42,7 @@ public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock {
else { else {
BlocksHelper.setWithoutUpdate(world, bpos, stem.setValue(EndLotusStemBlock.SHAPE, shape)); BlocksHelper.setWithoutUpdate(world, bpos, stem.setValue(EndLotusStemBlock.SHAPE, shape));
} }
bpos.setY(bpos.getY() + 1); bpos.setY(bpos.getY() + 1);
for (int i = 1; i <= height; i++) { for (int i = 1; i <= height; i++) {
if (!world.isEmptyBlock(bpos)) { if (!world.isEmptyBlock(bpos)) {
@ -56,11 +56,11 @@ public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock {
BlocksHelper.setWithoutUpdate(world, bpos, stem); BlocksHelper.setWithoutUpdate(world, bpos, stem);
bpos.setY(bpos.getY() + 1); bpos.setY(bpos.getY() + 1);
} }
if (!world.isEmptyBlock(bpos) || height < 0) { if (!world.isEmptyBlock(bpos) || height < 0) {
bpos.setY(bpos.getY() - 1); bpos.setY(bpos.getY() - 1);
} }
BlocksHelper.setWithoutUpdate(world, bpos, flower); BlocksHelper.setWithoutUpdate(world, bpos, flower);
bpos.setY(bpos.getY() - 1); bpos.setY(bpos.getY() - 1);
stem = world.getBlockState(bpos); stem = world.getBlockState(bpos);
@ -70,15 +70,15 @@ public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock {
stem = stem.setValue(EndLotusStemBlock.WATERLOGGED, true); stem = stem.setValue(EndLotusStemBlock.WATERLOGGED, true);
} }
} }
if (world.getBlockState(bpos.relative(dir)).is(EndBlocks.END_LOTUS_LEAF)) { if (world.getBlockState(bpos.relative(dir)).is(EndBlocks.END_LOTUS_LEAF)) {
stem = stem.setValue(EndLotusStemBlock.LEAF, true).setValue(EndLotusStemBlock.FACING, dir); stem = stem.setValue(EndLotusStemBlock.LEAF, true).setValue(EndLotusStemBlock.FACING, dir);
} }
BlocksHelper.setWithoutUpdate(world, bpos, stem.setValue(EndLotusStemBlock.SHAPE, TripleShape.TOP)); BlocksHelper.setWithoutUpdate(world, bpos, stem.setValue(EndLotusStemBlock.SHAPE, TripleShape.TOP));
} }
} }
private boolean canGrow(WorldGenLevel world, BlockPos pos) { private boolean canGrow(WorldGenLevel world, BlockPos pos) {
MutableBlockPos bpos = new MutableBlockPos(); MutableBlockPos bpos = new MutableBlockPos();
bpos.set(pos); bpos.set(pos);
@ -87,31 +87,31 @@ public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock {
} }
return world.isEmptyBlock(bpos) && world.isEmptyBlock(bpos.above()); return world.isEmptyBlock(bpos) && world.isEmptyBlock(bpos.above());
} }
private void generateLeaf(WorldGenLevel world, BlockPos pos) { private void generateLeaf(WorldGenLevel world, BlockPos pos) {
MutableBlockPos p = new MutableBlockPos(); MutableBlockPos p = new MutableBlockPos();
BlockState leaf = EndBlocks.END_LOTUS_LEAF.defaultBlockState(); BlockState leaf = EndBlocks.END_LOTUS_LEAF.defaultBlockState();
BlocksHelper.setWithoutUpdate(world, pos, leaf.setValue(EndLotusLeafBlock.SHAPE, TripleShape.BOTTOM)); BlocksHelper.setWithoutUpdate(world, pos, leaf.setValue(EndLotusLeafBlock.SHAPE, TripleShape.BOTTOM));
for (Direction move: BlocksHelper.HORIZONTAL) { for (Direction move : BlocksHelper.HORIZONTAL) {
BlocksHelper.setWithoutUpdate(world, p.set(pos).move(move), leaf.setValue(EndLotusLeafBlock.HORIZONTAL_FACING, move).setValue(EndLotusLeafBlock.SHAPE, TripleShape.MIDDLE)); BlocksHelper.setWithoutUpdate(world, p.set(pos).move(move), leaf.setValue(EndLotusLeafBlock.HORIZONTAL_FACING, move).setValue(EndLotusLeafBlock.SHAPE, TripleShape.MIDDLE));
} }
for (int i = 0; i < 4; i ++) { for (int i = 0; i < 4; i++) {
Direction d1 = BlocksHelper.HORIZONTAL[i]; Direction d1 = BlocksHelper.HORIZONTAL[i];
Direction d2 = BlocksHelper.HORIZONTAL[(i + 1) & 3]; Direction d2 = BlocksHelper.HORIZONTAL[(i + 1) & 3];
BlocksHelper.setWithoutUpdate(world, p.set(pos).move(d1).move(d2), leaf.setValue(EndLotusLeafBlock.HORIZONTAL_FACING, d1).setValue(EndLotusLeafBlock.SHAPE, TripleShape.TOP)); BlocksHelper.setWithoutUpdate(world, p.set(pos).move(d1).move(d2), leaf.setValue(EndLotusLeafBlock.HORIZONTAL_FACING, d1).setValue(EndLotusLeafBlock.SHAPE, TripleShape.TOP));
} }
} }
private boolean hasLeaf(WorldGenLevel world, BlockPos pos) { private boolean hasLeaf(WorldGenLevel world, BlockPos pos) {
MutableBlockPos p = new MutableBlockPos(); MutableBlockPos p = new MutableBlockPos();
p.setY(pos.getY()); p.setY(pos.getY());
int count = 0; int count = 0;
for (int x = -1; x < 2; x ++) { for (int x = -1; x < 2; x++) {
p.setX(pos.getX() + x); p.setX(pos.getX() + x);
for (int z = -1; z < 2; z ++) { for (int z = -1; z < 2; z++) {
p.setZ(pos.getZ() + z); p.setZ(pos.getZ() + z);
if (world.isEmptyBlock(p) && !world.getFluidState(p.below()).isEmpty()) if (world.isEmptyBlock(p) && !world.getFluidState(p.below()).isEmpty())
count ++; count++;
} }
} }
return count == 9; return count == 9;

View file

@ -1,9 +1,6 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Map;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
@ -32,28 +29,30 @@ import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped; import ru.bclib.interfaces.IRenderTyped;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
import java.util.Map;
public class EndLotusStemBlock extends BaseBlock implements SimpleWaterloggedBlock, IRenderTyped { public class EndLotusStemBlock extends BaseBlock implements SimpleWaterloggedBlock, IRenderTyped {
public static final EnumProperty<Direction> FACING = BlockStateProperties.FACING; public static final EnumProperty<Direction> FACING = BlockStateProperties.FACING;
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public static final BooleanProperty LEAF = BooleanProperty.create("leaf"); public static final BooleanProperty LEAF = BooleanProperty.create("leaf");
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE; public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
private static final Map<Axis, VoxelShape> SHAPES = Maps.newEnumMap(Axis.class); private static final Map<Axis, VoxelShape> SHAPES = Maps.newEnumMap(Axis.class);
public EndLotusStemBlock() { public EndLotusStemBlock() {
super(FabricBlockSettings.copyOf(Blocks.OAK_PLANKS)); super(FabricBlockSettings.copyOf(Blocks.OAK_PLANKS));
this.registerDefaultState(defaultBlockState().setValue(WATERLOGGED, false).setValue(SHAPE, TripleShape.MIDDLE).setValue(LEAF, false).setValue(FACING, Direction.UP)); this.registerDefaultState(defaultBlockState().setValue(WATERLOGGED, false).setValue(SHAPE, TripleShape.MIDDLE).setValue(LEAF, false).setValue(FACING, Direction.UP));
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return state.getValue(LEAF) ? SHAPES.get(Axis.Y) : SHAPES.get(state.getValue(FACING).getAxis()); return state.getValue(LEAF) ? SHAPES.get(Axis.Y) : SHAPES.get(state.getValue(FACING).getAxis());
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(FACING, WATERLOGGED, SHAPE, LEAF); builder.add(FACING, WATERLOGGED, SHAPE, LEAF);
} }
@Override @Override
public FluidState getFluidState(BlockState state) { public FluidState getFluidState(BlockState state) {
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state); return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
@ -65,7 +64,7 @@ public class EndLotusStemBlock extends BaseBlock implements SimpleWaterloggedBlo
BlockPos blockPos = ctx.getClickedPos(); BlockPos blockPos = ctx.getClickedPos();
return this.defaultBlockState().setValue(WATERLOGGED, worldAccess.getFluidState(blockPos).getType() == Fluids.WATER).setValue(FACING, ctx.getClickedFace()); return this.defaultBlockState().setValue(WATERLOGGED, worldAccess.getFluidState(blockPos).getType() == Fluids.WATER).setValue(FACING, ctx.getClickedFace());
} }
@Override @Override
public BlockState rotate(BlockState state, Rotation rotation) { public BlockState rotate(BlockState state, Rotation rotation) {
return BlocksHelper.rotateHorizontal(state, rotation, FACING); return BlocksHelper.rotateHorizontal(state, rotation, FACING);
@ -83,12 +82,12 @@ public class EndLotusStemBlock extends BaseBlock implements SimpleWaterloggedBlo
} }
return state; return state;
} }
@Override @Override
public BCLRenderLayer getRenderLayer() { public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT; return BCLRenderLayer.CUTOUT;
} }
static { static {
SHAPES.put(Axis.X, Block.box(0, 6, 6, 16, 10, 10)); SHAPES.put(Axis.X, Block.box(0, 6, 6, 16, 10, 10));
SHAPES.put(Axis.Y, Block.box(6, 0, 6, 10, 16, 10)); SHAPES.put(Axis.Y, Block.box(6, 0, 6, 10, 16, 10));

View file

@ -1,14 +1,14 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import ru.betterend.BetterEnd; import ru.betterend.BetterEnd;
import ru.betterend.blocks.basis.PedestalBlock; import ru.betterend.blocks.basis.PedestalBlock;
import java.util.HashMap;
import java.util.Map;
public class EndPedestal extends PedestalBlock { public class EndPedestal extends PedestalBlock {
public EndPedestal(Block parent) { public EndPedestal(Block parent) {
@ -21,8 +21,9 @@ public class EndPedestal extends PedestalBlock {
String name = blockId.getPath(); String name = blockId.getPath();
return new HashMap<String, String>() { return new HashMap<String, String>() {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
{ {
put("%mod%", BetterEnd.MOD_ID ); put("%mod%", BetterEnd.MOD_ID);
put("%top%", name + "_polished"); put("%top%", name + "_polished");
put("%base%", name + "_polished"); put("%base%", name + "_polished");
put("%pillar%", name + "_pillar_side"); put("%pillar%", name + "_pillar_side");

View file

@ -1,9 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Objects;
import java.util.Optional;
import java.util.Random;
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.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -40,6 +36,10 @@ import ru.betterend.registry.EndParticles;
import ru.betterend.registry.EndPortals; import ru.betterend.registry.EndPortals;
import ru.betterend.rituals.EternalRitual; import ru.betterend.rituals.EternalRitual;
import java.util.Objects;
import java.util.Optional;
import java.util.Random;
public class EndPortalBlock extends NetherPortalBlock implements IRenderTyped, IColorProvider { public class EndPortalBlock extends NetherPortalBlock implements IRenderTyped, IColorProvider {
public static final IntegerProperty PORTAL = EndBlockProperties.PORTAL; public static final IntegerProperty PORTAL = EndBlockProperties.PORTAL;
@ -52,7 +52,7 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTyped, I
super.createBlockStateDefinition(builder); super.createBlockStateDefinition(builder);
builder.add(PORTAL); builder.add(PORTAL);
} }
@Override @Override
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) { public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
@ -66,7 +66,8 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTyped, I
int k = random.nextInt(2) * 2 - 1; int k = random.nextInt(2) * 2 - 1;
if (!world.getBlockState(pos.west()).is(this) && !world.getBlockState(pos.east()).is(this)) { if (!world.getBlockState(pos.west()).is(this) && !world.getBlockState(pos.east()).is(this)) {
x = pos.getX() + 0.5D + 0.25D * k; x = pos.getX() + 0.5D + 0.25D * k;
} else { }
else {
z = pos.getZ() + 0.5D + 0.25D * k; z = pos.getZ() + 0.5D + 0.25D * k;
} }
@ -74,13 +75,14 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTyped, I
} }
@Override @Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {} public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
}
@Override @Override
public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, BlockPos pos, BlockPos posFrom) { public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, BlockPos pos, BlockPos posFrom) {
return state; return state;
} }
@Override @Override
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
if (world.isClientSide || !validate(entity)) return; if (world.isClientSide || !validate(entity)) return;
@ -95,7 +97,8 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTyped, I
if (entity instanceof ServerPlayer && ((ServerPlayer) entity).isCreative()) { if (entity instanceof ServerPlayer && ((ServerPlayer) entity).isCreative()) {
((ServerPlayer) entity).teleportTo(destination, exitPos.getX() + 0.5, exitPos.getY(), ((ServerPlayer) entity).teleportTo(destination, exitPos.getX() + 0.5, exitPos.getY(),
exitPos.getZ() + 0.5, entity.getYRot(), entity.getXRot()); exitPos.getZ() + 0.5, entity.getYRot(), entity.getXRot());
} else { }
else {
((TeleportingEntity) entity).be_setExitPos(exitPos); ((TeleportingEntity) entity).be_setExitPos(exitPos);
Optional<Entity> teleported = Optional.ofNullable(entity.changeDimension(destination)); Optional<Entity> teleported = Optional.ofNullable(entity.changeDimension(destination));
teleported.ifPresent(Entity::setPortalCooldown); teleported.ifPresent(Entity::setPortalCooldown);
@ -106,12 +109,12 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTyped, I
return !entity.isPassenger() && !entity.isVehicle() && return !entity.isPassenger() && !entity.isVehicle() &&
entity.canChangeDimensions() && !entity.isOnPortalCooldown(); entity.canChangeDimensions() && !entity.isOnPortalCooldown();
} }
@Override @Override
public BCLRenderLayer getRenderLayer() { public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.TRANSLUCENT; return BCLRenderLayer.TRANSLUCENT;
} }
private BlockPos findExitPos(ServerLevel currentWorld, ServerLevel targetWorld, BlockPos currentPos, Entity entity) { private BlockPos findExitPos(ServerLevel currentWorld, ServerLevel targetWorld, BlockPos currentPos, Entity entity) {
if (targetWorld == null) return null; if (targetWorld == null) return null;
Registry<DimensionType> registry = targetWorld.registryAccess().registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY); Registry<DimensionType> registry = targetWorld.registryAccess().registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY);
@ -143,11 +146,11 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTyped, I
} }
return null; return null;
} }
private MutableBlockPos findCenter(Level world, MutableBlockPos pos, Direction.Axis axis) { private MutableBlockPos findCenter(Level world, MutableBlockPos pos, Direction.Axis axis) {
return findCenter(world, pos, axis, 1); return findCenter(world, pos, axis, 1);
} }
private MutableBlockPos findCenter(Level world, MutableBlockPos pos, Direction.Axis axis, int step) { private MutableBlockPos findCenter(Level world, MutableBlockPos pos, Direction.Axis axis, int step) {
if (step > 8) return pos; if (step > 8) return pos;
BlockState right, left; BlockState right, left;
@ -159,11 +162,14 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTyped, I
BlockState down = world.getBlockState(pos.below()); BlockState down = world.getBlockState(pos.below());
if (down.is(this)) { if (down.is(this)) {
return findCenter(world, pos.move(Direction.DOWN), axis, step); return findCenter(world, pos.move(Direction.DOWN), axis, step);
} else if (right.is(this) && left.is(this)) { }
else if (right.is(this) && left.is(this)) {
return pos; return pos;
} else if (right.is(this)) { }
else if (right.is(this)) {
return findCenter(world, pos.move(rightDir), axis, ++step); return findCenter(world, pos.move(rightDir), axis, ++step);
} else if (left.is(this)) { }
else if (left.is(this)) {
return findCenter(world, pos.move(leftDir), axis, ++step); return findCenter(world, pos.move(leftDir), axis, ++step);
} }
return pos; return pos;

View file

@ -16,7 +16,12 @@ import net.minecraft.world.inventory.AbstractContainerMenu;
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.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.*; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
@ -45,19 +50,19 @@ public class EndStoneSmelter extends BaseBlockWithEntity {
public EndStoneSmelter() { public EndStoneSmelter() {
super(FabricBlockSettings.of(Material.STONE, MaterialColor.COLOR_GRAY) super(FabricBlockSettings.of(Material.STONE, MaterialColor.COLOR_GRAY)
.luminance(state -> state.getValue(LIT) ? 15 : 0)
.hardness(4F) .hardness(4F)
.resistance(100F) .resistance(100F)
.requiresCorrectToolForDrops() .requiresCorrectToolForDrops()
.sound(SoundType.STONE)); .sound(SoundType.STONE));
registerDefaultState(this.stateDefinition.any() registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(LIT, false));
.setValue(FACING, Direction.NORTH)
.setValue(LIT, false));
} }
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if (world.isClientSide) { if (world.isClientSide) {
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} else { }
else {
this.openScreen(world, pos, player); this.openScreen(world, pos, player);
return InteractionResult.CONSUME; return InteractionResult.CONSUME;
} }
@ -69,17 +74,17 @@ public class EndStoneSmelter extends BaseBlockWithEntity {
player.openMenu((EndStoneSmelterBlockEntity) blockEntity); player.openMenu((EndStoneSmelterBlockEntity) blockEntity);
} }
} }
@Override @Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) { public BlockState getStateForPlacement(BlockPlaceContext ctx) {
return defaultBlockState().setValue(FACING, ctx.getHorizontalDirection().getOpposite()); return defaultBlockState().setValue(FACING, ctx.getHorizontalDirection().getOpposite());
} }
@Override @Override
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) { public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {
return new EndStoneSmelterBlockEntity(blockPos, blockState); return new EndStoneSmelterBlockEntity(blockPos, blockState);
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
List<ItemStack> drop = Lists.newArrayList(new ItemStack(this)); List<ItemStack> drop = Lists.newArrayList(new ItemStack(this));
@ -126,7 +131,7 @@ public class EndStoneSmelter extends BaseBlockWithEntity {
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(FACING, LIT); builder.add(FACING, LIT);
} }
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) { public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
if (state.getValue(LIT)) { if (state.getValue(LIT)) {
@ -134,7 +139,7 @@ public class EndStoneSmelter extends BaseBlockWithEntity {
double y = pos.getY(); double y = pos.getY();
double z = pos.getZ() + 0.5D; double z = pos.getZ() + 0.5D;
if (random.nextDouble() < 0.1D) { if (random.nextDouble() < 0.1D) {
world.playLocalSound(x, y, z, SoundEvents.BLASTFURNACE_FIRE_CRACKLE, SoundSource.BLOCKS, 1.0F, 1.0F, false); world.playLocalSound(x, y, z, SoundEvents.BLASTFURNACE_FIRE_CRACKLE, SoundSource.BLOCKS, 1.0F, 1.0F, false);
} }
Direction direction = state.getValue(FACING); Direction direction = state.getValue(FACING);

View file

@ -1,8 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
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.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -16,16 +13,19 @@ 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 ru.bclib.util.ColorUtil; import ru.bclib.util.ColorUtil;
import java.util.Collections;
import java.util.List;
public class EndstoneDustBlock extends FallingBlock { public class EndstoneDustBlock extends FallingBlock {
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
private static final int COLOR = ColorUtil.color(226, 239, 168); private static final int COLOR = ColorUtil.color(226, 239, 168);
public EndstoneDustBlock() { public EndstoneDustBlock() {
super(FabricBlockSettings.copyOf(Blocks.SAND) super(FabricBlockSettings.copyOf(Blocks.SAND)
.breakByTool(FabricToolTags.SHOVELS) .breakByTool(FabricToolTags.SHOVELS)
.materialColor(Blocks.END_STONE.defaultMaterialColor())); .materialColor(Blocks.END_STONE.defaultMaterialColor()));
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this)); return Collections.singletonList(new ItemStack(this));

View file

@ -1,9 +1,6 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.List;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
@ -28,14 +25,16 @@ import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndPortals; import ru.betterend.registry.EndPortals;
import ru.betterend.rituals.EternalRitual; import ru.betterend.rituals.EternalRitual;
import java.util.List;
public class EternalPedestal extends PedestalBlock { public class EternalPedestal extends PedestalBlock {
public static final BooleanProperty ACTIVATED = EndBlockProperties.ACTIVE; public static final BooleanProperty ACTIVATED = EndBlockProperties.ACTIVE;
public EternalPedestal() { public EternalPedestal() {
super(EndBlocks.FLAVOLITE_RUNED_ETERNAL); super(EndBlocks.FLAVOLITE_RUNED_ETERNAL);
this.registerDefaultState(defaultBlockState().setValue(ACTIVATED, false)); this.registerDefaultState(defaultBlockState().setValue(ACTIVATED, false));
} }
@Override @Override
public void checkRitual(Level world, BlockPos pos) { public void checkRitual(Level world, BlockPos pos) {
BlockEntity blockEntity = world.getBlockEntity(pos); BlockEntity blockEntity = world.getBlockEntity(pos);
@ -50,21 +49,24 @@ public class EternalPedestal extends PedestalBlock {
int portalId; int portalId;
if (targetWorld != null) { if (targetWorld != null) {
portalId = EndPortals.getPortalIdByWorld(targetWorld); portalId = EndPortals.getPortalIdByWorld(targetWorld);
} else { }
else {
portalId = EndPortals.getPortalIdByWorld(EndPortals.OVERWORLD_ID); portalId = EndPortals.getPortalIdByWorld(EndPortals.OVERWORLD_ID);
} }
ritual.disablePortal(portalId); ritual.disablePortal(portalId);
} }
} }
world.setBlockAndUpdate(pos, updatedState.setValue(ACTIVATED, false).setValue(HAS_LIGHT, false)); world.setBlockAndUpdate(pos, updatedState.setValue(ACTIVATED, false).setValue(HAS_LIGHT, false));
} else { }
else {
ItemStack itemStack = pedestal.getItem(0); ItemStack itemStack = pedestal.getItem(0);
ResourceLocation id = Registry.ITEM.getKey(itemStack.getItem()); ResourceLocation id = Registry.ITEM.getKey(itemStack.getItem());
if (EndPortals.isAvailableItem(id)) { if (EndPortals.isAvailableItem(id)) {
world.setBlockAndUpdate(pos, updatedState.setValue(ACTIVATED, true).setValue(HAS_LIGHT, true)); world.setBlockAndUpdate(pos, updatedState.setValue(ACTIVATED, true).setValue(HAS_LIGHT, true));
if (pedestal.hasRitual()) { if (pedestal.hasRitual()) {
pedestal.getRitual().checkStructure(); pedestal.getRitual().checkStructure();
} else { }
else {
EternalRitual ritual = new EternalRitual(world, pos); EternalRitual ritual = new EternalRitual(world, pos);
ritual.checkStructure(); ritual.checkStructure();
} }
@ -72,7 +74,7 @@ public class EternalPedestal extends PedestalBlock {
} }
} }
} }
@Override @Override
@Deprecated @Deprecated
public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, BlockPos pos, BlockPos posFrom) { public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, BlockPos pos, BlockPos posFrom) {
@ -83,23 +85,23 @@ public class EternalPedestal extends PedestalBlock {
} }
return updated; return updated;
} }
@Override @Override
@Deprecated @Deprecated
public float getDestroyProgress(BlockState state, Player player, BlockGetter world, BlockPos pos) { public float getDestroyProgress(BlockState state, Player player, BlockGetter world, BlockPos pos) {
return 0.0F; return 0.0F;
} }
@Override @Override
public float getExplosionResistance() { public float getExplosionResistance() {
return Blocks.BEDROCK.getExplosionResistance(); return Blocks.BEDROCK.getExplosionResistance();
} }
@Override @Override
public boolean dropFromExplosion(Explosion explosion) { public boolean dropFromExplosion(Explosion explosion) {
return false; return false;
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
if (state.is(this)) { if (state.is(this)) {
@ -118,7 +120,7 @@ public class EternalPedestal extends PedestalBlock {
} }
return drop; return drop;
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
super.createBlockStateDefinition(stateManager); super.createBlockStateDefinition(stateManager);

View file

@ -7,7 +7,7 @@ public class FilaluxBlock extends BaseVineBlock {
public FilaluxBlock() { public FilaluxBlock() {
super(15, true); super(15, true);
} }
@Override @Override
public BlockBehaviour.OffsetType getOffsetType() { public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE; return BlockBehaviour.OffsetType.NONE;

View file

@ -1,9 +1,6 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.EnumMap;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -19,9 +16,11 @@ import ru.bclib.blocks.BaseAttachedBlock;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped; import ru.bclib.interfaces.IRenderTyped;
import java.util.EnumMap;
public class FilaluxWingsBlock extends BaseAttachedBlock implements IRenderTyped { public class FilaluxWingsBlock extends BaseAttachedBlock implements IRenderTyped {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class); private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
public FilaluxWingsBlock() { public FilaluxWingsBlock() {
super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).sound(SoundType.WET_GRASS).noCollission()); super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).sound(SoundType.WET_GRASS).noCollission());
} }
@ -30,12 +29,12 @@ public class FilaluxWingsBlock extends BaseAttachedBlock implements IRenderTyped
public BCLRenderLayer getRenderLayer() { public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT; return BCLRenderLayer.CUTOUT;
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return BOUNDING_SHAPES.get(state.getValue(FACING)); return BOUNDING_SHAPES.get(state.getValue(FACING));
} }
static { static {
BOUNDING_SHAPES.put(Direction.UP, Shapes.box(0.0, 0.0, 0.0, 1.0, 0.5, 1.0)); BOUNDING_SHAPES.put(Direction.UP, Shapes.box(0.0, 0.0, 0.0, 1.0, 0.5, 1.0));
BOUNDING_SHAPES.put(Direction.DOWN, Shapes.box(0.0, 0.5, 0.0, 1.0, 1.0, 1.0)); BOUNDING_SHAPES.put(Direction.DOWN, Shapes.box(0.0, 0.5, 0.0, 1.0, 1.0, 1.0));

View file

@ -1,9 +1,6 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.List;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -21,21 +18,23 @@ import net.minecraft.world.phys.shapes.VoxelShape;
import ru.bclib.interfaces.ISpetialItem; import ru.bclib.interfaces.ISpetialItem;
import ru.betterend.blocks.basis.EndPlantBlock; import ru.betterend.blocks.basis.EndPlantBlock;
import java.util.List;
public class FlamaeaBlock extends EndPlantBlock implements ISpetialItem { public class FlamaeaBlock extends EndPlantBlock implements ISpetialItem {
private static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 1, 16); private static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 1, 16);
public FlamaeaBlock() { public FlamaeaBlock() {
super(FabricBlockSettings.of(Material.PLANT) super(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS) .breakByTool(FabricToolTags.SHEARS)
.breakByHand(true) .breakByHand(true)
.sound(SoundType.WET_GRASS)); .sound(SoundType.WET_GRASS));
} }
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
return state.is(Blocks.WATER); return state.is(Blocks.WATER);
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE; return SHAPE;
@ -45,7 +44,7 @@ public class FlamaeaBlock extends EndPlantBlock implements ISpetialItem {
public BlockBehaviour.OffsetType getOffsetType() { public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE; return BlockBehaviour.OffsetType.NONE;
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Lists.newArrayList(new ItemStack(this)); return Lists.newArrayList(new ItemStack(this));

View file

@ -12,19 +12,19 @@ public class GlowingMossBlock extends EndPlantBlock {
public GlowingMossBlock(int light) { public GlowingMossBlock(int light) {
super(light); super(light);
} }
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
return state.getBlock() == EndBlocks.END_MOSS || state.getBlock() == EndBlocks.END_MYCELIUM; return state.getBlock() == EndBlocks.END_MOSS || state.getBlock() == EndBlocks.END_MYCELIUM;
} }
@Environment(EnvType.CLIENT)
public boolean hasEmissiveLighting(BlockGetter world, BlockPos pos) {
return true;
}
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public float getAmbientOcclusionLightLevel(BlockGetter world, BlockPos pos) { public boolean hasEmissiveLighting(BlockGetter world, BlockPos pos) {
return 1F; return true;
} }
@Environment(EnvType.CLIENT)
public float getAmbientOcclusionLightLevel(BlockGetter world, BlockPos pos) {
return 1F;
}
} }

View file

@ -19,7 +19,7 @@ import ru.betterend.registry.EndBlocks;
public class GlowingPillarLuminophorBlock extends BaseBlock { public class GlowingPillarLuminophorBlock extends BaseBlock {
public static final BooleanProperty NATURAL = EndBlockProperties.NATURAL; public static final BooleanProperty NATURAL = EndBlockProperties.NATURAL;
public GlowingPillarLuminophorBlock() { public GlowingPillarLuminophorBlock() {
super(FabricBlockSettings.of(Material.LEAVES) super(FabricBlockSettings.of(Material.LEAVES)
.materialColor(MaterialColor.COLOR_ORANGE) .materialColor(MaterialColor.COLOR_ORANGE)
@ -29,12 +29,12 @@ public class GlowingPillarLuminophorBlock extends BaseBlock {
.sound(SoundType.GRASS)); .sound(SoundType.GRASS));
this.registerDefaultState(this.stateDefinition.any().setValue(NATURAL, false)); this.registerDefaultState(this.stateDefinition.any().setValue(NATURAL, false));
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return !state.getValue(NATURAL) || world.getBlockState(pos.below()).is(EndBlocks.GLOWING_PILLAR_ROOTS); return !state.getValue(NATURAL) || world.getBlockState(pos.below()).is(EndBlocks.GLOWING_PILLAR_ROOTS);
} }
@Override @Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (!canSurvive(state, world, pos)) { if (!canSurvive(state, world, pos)) {
@ -44,7 +44,7 @@ public class GlowingPillarLuminophorBlock extends BaseBlock {
return state; return state;
} }
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(NATURAL); stateManager.add(NATURAL);

View file

@ -16,17 +16,17 @@ import ru.betterend.registry.EndBlocks;
public class GlowingPillarRootsBlock extends UpDownPlantBlock { public class GlowingPillarRootsBlock extends UpDownPlantBlock {
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE; public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(SHAPE); stateManager.add(SHAPE);
} }
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.AMBER_MOSS); return state.is(EndBlocks.AMBER_MOSS);
} }
@Override @Override
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) { public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) {

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -20,6 +18,8 @@ import ru.bclib.util.MHelper;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock; import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class GlowingPillarSeedBlock extends EndPlantWithAgeBlock { public class GlowingPillarSeedBlock extends EndPlantWithAgeBlock {
public GlowingPillarSeedBlock() { public GlowingPillarSeedBlock() {
@ -31,7 +31,7 @@ public class GlowingPillarSeedBlock extends EndPlantWithAgeBlock {
.randomTicks() .randomTicks()
.noCollission()); .noCollission());
} }
@Override @Override
public void growAdult(WorldGenLevel world, Random random, BlockPos pos) { public void growAdult(WorldGenLevel world, Random random, BlockPos pos) {
int height = MHelper.randRange(1, 2, random); int height = MHelper.randRange(1, 2, random);
@ -39,19 +39,20 @@ public class GlowingPillarSeedBlock extends EndPlantWithAgeBlock {
if (h < height) { if (h < height) {
return; return;
} }
MutableBlockPos mut = new MutableBlockPos().set(pos); MutableBlockPos mut = new MutableBlockPos().set(pos);
BlockState roots = EndBlocks.GLOWING_PILLAR_ROOTS.defaultBlockState(); BlockState roots = EndBlocks.GLOWING_PILLAR_ROOTS.defaultBlockState();
if (height < 2) { if (height < 2) {
BlocksHelper.setWithUpdate(world, mut, roots.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE)); BlocksHelper.setWithUpdate(world, mut, roots.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE));
} else { }
else {
BlocksHelper.setWithUpdate(world, mut, roots.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM)); BlocksHelper.setWithUpdate(world, mut, roots.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM));
mut.move(Direction.UP); mut.move(Direction.UP);
BlocksHelper.setWithUpdate(world, mut, roots.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP)); BlocksHelper.setWithUpdate(world, mut, roots.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP));
} }
mut.move(Direction.UP); mut.move(Direction.UP);
BlocksHelper.setWithUpdate(world, mut, EndBlocks.GLOWING_PILLAR_LUMINOPHOR.defaultBlockState().setValue(BlueVineLanternBlock.NATURAL, true)); BlocksHelper.setWithUpdate(world, mut, EndBlocks.GLOWING_PILLAR_LUMINOPHOR.defaultBlockState().setValue(BlueVineLanternBlock.NATURAL, true));
for (Direction dir: BlocksHelper.DIRECTIONS) { for (Direction dir : BlocksHelper.DIRECTIONS) {
pos = mut.relative(dir); pos = mut.relative(dir);
if (world.isEmptyBlock(pos)) { if (world.isEmptyBlock(pos)) {
BlocksHelper.setWithUpdate(world, pos, EndBlocks.GLOWING_PILLAR_LEAVES.defaultBlockState().setValue(BlockStateProperties.FACING, dir)); BlocksHelper.setWithUpdate(world, pos, EndBlocks.GLOWING_PILLAR_LEAVES.defaultBlockState().setValue(BlockStateProperties.FACING, dir));
@ -62,12 +63,12 @@ public class GlowingPillarSeedBlock extends EndPlantWithAgeBlock {
BlocksHelper.setWithUpdate(world, mut, EndBlocks.GLOWING_PILLAR_LEAVES.defaultBlockState().setValue(BlockStateProperties.FACING, Direction.UP)); BlocksHelper.setWithUpdate(world, mut, EndBlocks.GLOWING_PILLAR_LEAVES.defaultBlockState().setValue(BlockStateProperties.FACING, Direction.UP));
} }
} }
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.AMBER_MOSS); return state.is(EndBlocks.AMBER_MOSS);
} }
@Override @Override
public BlockBehaviour.OffsetType getOffsetType() { public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE; return BlockBehaviour.OffsetType.NONE;

View file

@ -1,10 +1,6 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.client.color.block.BlockColor; import net.minecraft.client.color.block.BlockColor;
@ -30,10 +26,13 @@ import ru.bclib.util.MHelper;
import ru.betterend.noise.OpenSimplexNoise; import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Collections;
import java.util.List;
public class HelixTreeLeavesBlock extends BaseBlock implements IColorProvider { public class HelixTreeLeavesBlock extends BaseBlock implements IColorProvider {
public static final IntegerProperty COLOR = EndBlockProperties.COLOR; public static final IntegerProperty COLOR = EndBlockProperties.COLOR;
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(0); private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(0);
public HelixTreeLeavesBlock() { public HelixTreeLeavesBlock() {
super(FabricBlockSettings.of(Material.LEAVES) super(FabricBlockSettings.of(Material.LEAVES)
.materialColor(MaterialColor.COLOR_ORANGE) .materialColor(MaterialColor.COLOR_ORANGE)
@ -42,7 +41,7 @@ public class HelixTreeLeavesBlock extends BaseBlock implements IColorProvider {
.sound(SoundType.GRASS) .sound(SoundType.GRASS)
.strength(0.2F)); .strength(0.2F));
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(COLOR); stateManager.add(COLOR);
@ -61,7 +60,7 @@ public class HelixTreeLeavesBlock extends BaseBlock implements IColorProvider {
return ColorUtil.color(237, getGreen(4), 20); return ColorUtil.color(237, getGreen(4), 20);
}; };
} }
@Override @Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) { public BlockState getStateForPlacement(BlockPlaceContext ctx) {
double px = ctx.getClickedPos().getX() * 0.1; double px = ctx.getClickedPos().getX() * 0.1;
@ -69,12 +68,12 @@ public class HelixTreeLeavesBlock extends BaseBlock implements IColorProvider {
double pz = ctx.getClickedPos().getZ() * 0.1; double pz = ctx.getClickedPos().getZ() * 0.1;
return this.defaultBlockState().setValue(COLOR, MHelper.floor(NOISE.eval(px, py, pz) * 3.5 + 4)); return this.defaultBlockState().setValue(COLOR, MHelper.floor(NOISE.eval(px, py, pz) * 3.5 + 4));
} }
private int getGreen(int color) { private int getGreen(int color) {
float delta = color / 7F; float delta = color / 7F;
return (int) Mth.lerp(delta, 80, 158); return (int) Mth.lerp(delta, 80, 158);
} }
@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);

View file

@ -1,11 +1,6 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
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.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -29,10 +24,14 @@ import ru.betterend.blocks.EndBlockProperties.HydraluxShape;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems; import ru.betterend.registry.EndItems;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public class HydraluxBlock extends UnderwaterPlantBlock { public class HydraluxBlock extends UnderwaterPlantBlock {
public static final EnumProperty<HydraluxShape> SHAPE = EndBlockProperties.HYDRALUX_SHAPE; public static final EnumProperty<HydraluxShape> SHAPE = EndBlockProperties.HYDRALUX_SHAPE;
public HydraluxBlock() { public HydraluxBlock() {
super(FabricBlockSettings.of(Material.WATER_PLANT) super(FabricBlockSettings.of(Material.WATER_PLANT)
.breakByTool(FabricToolTags.SHEARS) .breakByTool(FabricToolTags.SHEARS)
@ -41,12 +40,12 @@ public class HydraluxBlock extends UnderwaterPlantBlock {
.lightLevel((state) -> state.getValue(SHAPE).hasGlow() ? 15 : 0) .lightLevel((state) -> state.getValue(SHAPE).hasGlow() ? 15 : 0)
.noCollission()); .noCollission());
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(SHAPE); stateManager.add(SHAPE);
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
BlockState down = world.getBlockState(pos.below()); BlockState down = world.getBlockState(pos.below());
@ -76,13 +75,13 @@ public class HydraluxBlock extends UnderwaterPlantBlock {
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) { public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
return false; return false;
} }
@Override @Override
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) { public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) {
return new ItemStack(EndBlocks.HYDRALUX_SAPLING); return new ItemStack(EndBlocks.HYDRALUX_SAPLING);
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
HydraluxShape shape = state.getValue(SHAPE); HydraluxShape shape = state.getValue(SHAPE);

View file

@ -21,11 +21,12 @@ public class HydraluxPetalBlock extends BaseBlock {
.materialColor(MaterialColor.PODZOL) .materialColor(MaterialColor.PODZOL)
.sound(SoundType.WART_BLOCK)); .sound(SoundType.WART_BLOCK));
} }
public HydraluxPetalBlock(Properties settings) { public HydraluxPetalBlock(Properties settings) {
super(settings); super(settings);
} }
@Override @Override
public void fallOn(Level level, BlockState blockState, BlockPos blockPos, Entity entity, float f) {} public void fallOn(Level level, BlockState blockState, BlockPos blockPos, Entity entity, float f) {
}
} }

View file

@ -1,9 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Optional;
import org.jetbrains.annotations.Nullable;
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.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -12,16 +8,19 @@ import net.minecraft.client.color.item.ItemColor;
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.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.interfaces.IColorProvider; import ru.bclib.interfaces.IColorProvider;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
import ru.betterend.client.models.Patterns; import ru.betterend.client.models.Patterns;
import java.util.Optional;
public class HydraluxPetalColoredBlock extends HydraluxPetalBlock implements IColorProvider { public class HydraluxPetalColoredBlock extends HydraluxPetalBlock implements IColorProvider {
public HydraluxPetalColoredBlock(FabricBlockSettings settings) { public HydraluxPetalColoredBlock(FabricBlockSettings settings) {
super(settings); super(settings);
} }
@Override @Override
public BlockColor getProvider() { public BlockColor getProvider() {
return (state, world, pos, tintIndex) -> BlocksHelper.getBlockColor(this); return (state, world, pos, tintIndex) -> BlocksHelper.getBlockColor(this);

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.WorldGenLevel;
@ -13,20 +11,22 @@ import ru.bclib.util.MHelper;
import ru.betterend.blocks.EndBlockProperties.HydraluxShape; import ru.betterend.blocks.EndBlockProperties.HydraluxShape;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class HydraluxSaplingBlock extends UnderwaterPlantWithAgeBlock { public class HydraluxSaplingBlock extends UnderwaterPlantWithAgeBlock {
@Override @Override
public void grow(WorldGenLevel world, Random random, BlockPos pos) { public void grow(WorldGenLevel world, Random random, BlockPos pos) {
int h = MHelper.randRange(4, 8, random); int h = MHelper.randRange(4, 8, random);
MutableBlockPos mut = new MutableBlockPos().set(pos); MutableBlockPos mut = new MutableBlockPos().set(pos);
for (int i = 1; i < h; i++) { for (int i = 1; i < h; i++) {
mut.setY(pos.getY() + i); mut.setY(pos.getY() + i);
if (!world.getBlockState(mut).is(Blocks.WATER)) { if (!world.getBlockState(mut).is(Blocks.WATER)) {
return; return;
} }
} }
mut.setY(pos.getY()); mut.setY(pos.getY());
BlockState state = EndBlocks.HYDRALUX.defaultBlockState(); BlockState state = EndBlocks.HYDRALUX.defaultBlockState();
BlocksHelper.setWithoutUpdate(world, pos, state.setValue(EndBlockProperties.HYDRALUX_SHAPE, HydraluxShape.ROOTS)); BlocksHelper.setWithoutUpdate(world, pos, state.setValue(EndBlockProperties.HYDRALUX_SHAPE, HydraluxShape.ROOTS));
@ -34,15 +34,15 @@ public class HydraluxSaplingBlock extends UnderwaterPlantWithAgeBlock {
mut.setY(pos.getY() + i); mut.setY(pos.getY() + i);
BlocksHelper.setWithoutUpdate(world, mut, state.setValue(EndBlockProperties.HYDRALUX_SHAPE, HydraluxShape.VINE)); BlocksHelper.setWithoutUpdate(world, mut, state.setValue(EndBlockProperties.HYDRALUX_SHAPE, HydraluxShape.VINE));
} }
mut.setY(mut.getY() + 1); mut.setY(mut.getY() + 1);
boolean big = random.nextBoolean(); boolean big = random.nextBoolean();
BlocksHelper.setWithoutUpdate(world, mut, state.setValue(EndBlockProperties.HYDRALUX_SHAPE, big ? HydraluxShape.FLOWER_BIG_BOTTOM : HydraluxShape.FLOWER_SMALL_BOTTOM)); BlocksHelper.setWithoutUpdate(world, mut, state.setValue(EndBlockProperties.HYDRALUX_SHAPE, big ? HydraluxShape.FLOWER_BIG_BOTTOM : HydraluxShape.FLOWER_SMALL_BOTTOM));
mut.setY(mut.getY() + 1); mut.setY(mut.getY() + 1);
BlocksHelper.setWithoutUpdate(world, mut, state.setValue(EndBlockProperties.HYDRALUX_SHAPE, big ? HydraluxShape.FLOWER_BIG_TOP : HydraluxShape.FLOWER_SMALL_TOP)); BlocksHelper.setWithoutUpdate(world, mut, state.setValue(EndBlockProperties.HYDRALUX_SHAPE, big ? HydraluxShape.FLOWER_BIG_TOP : HydraluxShape.FLOWER_SMALL_TOP));
} }
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.SULPHURIC_ROCK.stone); return state.is(EndBlocks.SULPHURIC_ROCK.stone);

View file

@ -1,9 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Random;
import org.jetbrains.annotations.Nullable;
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.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -26,6 +22,8 @@ import net.minecraft.world.level.block.LiquidBlockContainer;
import net.minecraft.world.level.block.SimpleWaterloggedBlock; import net.minecraft.world.level.block.SimpleWaterloggedBlock;
import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.BlockStateProperties;
@ -36,6 +34,7 @@ import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
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 org.jetbrains.annotations.Nullable;
import ru.bclib.blocks.BaseBlockNotFull; import ru.bclib.blocks.BaseBlockNotFull;
import ru.bclib.blocks.BlockProperties; import ru.bclib.blocks.BlockProperties;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
@ -43,12 +42,14 @@ import ru.betterend.blocks.entities.BlockEntityHydrothermalVent;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndParticles; import ru.betterend.registry.EndParticles;
import java.util.Random;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class HydrothermalVentBlock extends BaseBlockNotFull implements EntityBlock, LiquidBlockContainer, SimpleWaterloggedBlock { public class HydrothermalVentBlock extends BaseBlockNotFull implements EntityBlock, LiquidBlockContainer, SimpleWaterloggedBlock {
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVE; public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVE;
private static final VoxelShape SHAPE = Block.box(1, 1, 1, 15, 16, 15); private static final VoxelShape SHAPE = Block.box(1, 1, 1, 15, 16, 15);
public HydrothermalVentBlock() { public HydrothermalVentBlock() {
super(FabricBlockSettings.of(Material.STONE) super(FabricBlockSettings.of(Material.STONE)
.breakByTool(FabricToolTags.PICKAXES) .breakByTool(FabricToolTags.PICKAXES)
@ -57,17 +58,17 @@ public class HydrothermalVentBlock extends BaseBlockNotFull implements EntityBlo
.requiresCorrectToolForDrops()); .requiresCorrectToolForDrops());
this.registerDefaultState(defaultBlockState().setValue(WATERLOGGED, true).setValue(ACTIVATED, false)); this.registerDefaultState(defaultBlockState().setValue(WATERLOGGED, true).setValue(ACTIVATED, false));
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(WATERLOGGED, ACTIVATED); builder.add(WATERLOGGED, ACTIVATED);
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE; return SHAPE;
} }
@Override @Override
public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) { public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) {
return false; return false;
@ -77,13 +78,13 @@ public class HydrothermalVentBlock extends BaseBlockNotFull implements EntityBlo
public boolean placeLiquid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) { public boolean placeLiquid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
return false; return false;
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
state = world.getBlockState(pos.below()); state = world.getBlockState(pos.below());
return state.is(EndBlocks.SULPHURIC_ROCK.stone); return state.is(EndBlocks.SULPHURIC_ROCK.stone);
} }
@Override @Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (!canSurvive(state, world, pos)) { if (!canSurvive(state, world, pos)) {
@ -94,14 +95,14 @@ public class HydrothermalVentBlock extends BaseBlockNotFull implements EntityBlo
} }
return state; return state;
} }
@Override @Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) { public BlockState getStateForPlacement(BlockPlaceContext ctx) {
LevelAccessor worldAccess = ctx.getLevel(); LevelAccessor worldAccess = ctx.getLevel();
BlockPos blockPos = ctx.getClickedPos(); BlockPos blockPos = ctx.getClickedPos();
return this.defaultBlockState().setValue(WATERLOGGED, worldAccess.getFluidState(blockPos).getType() == Fluids.WATER); return this.defaultBlockState().setValue(WATERLOGGED, worldAccess.getFluidState(blockPos).getType() == Fluids.WATER);
} }
@Override @Override
public FluidState getFluidState(BlockState state) { public FluidState getFluidState(BlockState state) {
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state); return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
@ -120,27 +121,28 @@ public class HydrothermalVentBlock extends BaseBlockNotFull implements EntityBlo
world.getBlockTicks().scheduleTick(up, EndBlocks.VENT_BUBBLE_COLUMN, 5); world.getBlockTicks().scheduleTick(up, EndBlocks.VENT_BUBBLE_COLUMN, 5);
} }
} }
@Override @Override
public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) { public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) {
if (world instanceof ServerLevel && state.getValue(WATERLOGGED) && world.getBlockState(pos.above()).is(Blocks.WATER)) { if (world instanceof ServerLevel && state.getValue(WATERLOGGED) && world.getBlockState(pos.above()).is(Blocks.WATER)) {
tick(state,(ServerLevel) world, pos, world.random); tick(state, (ServerLevel) world, pos, world.random);
} }
} }
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) { public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
super.animateTick(state, world, pos, random);
if (!state.getValue(ACTIVATED) && random.nextBoolean()) { if (!state.getValue(ACTIVATED) && random.nextBoolean()) {
super.animateTick(state, world, pos, random);
double x = pos.getX() + random.nextDouble(); double x = pos.getX() + random.nextDouble();
double y = pos.getY() + 0.9 + random.nextDouble() * 0.3; double y = pos.getY() + 0.9 + random.nextDouble() * 0.3;
double z = pos.getZ() + random.nextDouble(); double z = pos.getZ() + random.nextDouble();
if (state.getValue(WATERLOGGED)) { world.addParticle(ParticleTypes.LARGE_SMOKE, x, y, z, 0, 0, 0);
world.addParticle(EndParticles.GEYSER_PARTICLE, x, y, z, 0, 0, 0);
}
else {
world.addParticle(ParticleTypes.SMOKE, x, y, z, 0, 0, 0);
}
} }
} }
@Nullable
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState blockState, BlockEntityType<T> blockEntityType) {
return BlockEntityHydrothermalVent::tick;
}
} }

View file

@ -23,7 +23,7 @@ public class InfusionPedestal extends PedestalBlock {
super(Blocks.OBSIDIAN); super(Blocks.OBSIDIAN);
this.height = 1.08F; this.height = 1.08F;
} }
@Override @Override
public void checkRitual(Level world, BlockPos pos) { public void checkRitual(Level world, BlockPos pos) {
BlockEntity blockEntity = world.getBlockEntity(pos); BlockEntity blockEntity = world.getBlockEntity(pos);
@ -35,14 +35,15 @@ public class InfusionPedestal extends PedestalBlock {
ritual.configure(); ritual.configure();
} }
pedestal.getRitual().checkRecipe(); pedestal.getRitual().checkRecipe();
} else { }
else {
InfusionRitual ritual = new InfusionRitual(pedestal, world, pos); InfusionRitual ritual = new InfusionRitual(pedestal, world, pos);
pedestal.linkRitual(ritual); pedestal.linkRitual(ritual);
ritual.checkRecipe(); ritual.checkRecipe();
} }
} }
} }
@Override @Override
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) { public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {
return new InfusionPedestalEntity(blockPos, blockState); return new InfusionPedestalEntity(blockPos, blockState);
@ -57,7 +58,7 @@ public class InfusionPedestal extends PedestalBlock {
@Deprecated @Deprecated
public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
if (state.is(this)) { if (state.is(this)) {
switch(state.getValue(STATE)) { switch (state.getValue(STATE)) {
case PEDESTAL_TOP: { case PEDESTAL_TOP: {
return SHAPE_PEDESTAL_TOP; return SHAPE_PEDESTAL_TOP;
} }

View file

@ -1,12 +1,6 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.List;
import java.util.Optional;
import org.jetbrains.annotations.Nullable;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
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.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -25,6 +19,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.IntegerProperty; import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootContext;
import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.BlockModelProvider; import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
@ -35,20 +30,23 @@ import ru.bclib.util.MHelper;
import ru.betterend.client.models.Patterns; import ru.betterend.client.models.Patterns;
import ru.betterend.noise.OpenSimplexNoise; import ru.betterend.noise.OpenSimplexNoise;
import java.util.List;
import java.util.Optional;
public class JellyshroomCapBlock extends SlimeBlock implements IRenderTyped, BlockModelProvider, IColorProvider { public class JellyshroomCapBlock extends SlimeBlock implements IRenderTyped, BlockModelProvider, IColorProvider {
public static final IntegerProperty COLOR = EndBlockProperties.COLOR; public static final IntegerProperty COLOR = EndBlockProperties.COLOR;
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(0); private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(0);
private final Vec3i colorStart; private final Vec3i colorStart;
private final Vec3i colorEnd; private final Vec3i colorEnd;
private final int coloritem; private final int coloritem;
public JellyshroomCapBlock(int r1, int g1, int b1, int r2, int g2, int b2) { public JellyshroomCapBlock(int r1, int g1, int b1, int r2, int g2, int b2) {
super(FabricBlockSettings.copyOf(Blocks.SLIME_BLOCK)); super(FabricBlockSettings.copyOf(Blocks.SLIME_BLOCK));
colorStart = new Vec3i(r1, g1, b1); colorStart = new Vec3i(r1, g1, b1);
colorEnd = new Vec3i(r2, g2, b2); colorEnd = new Vec3i(r2, g2, b2);
coloritem = ColorUtil.color((r1 + r2) >> 1, (g1 + g2) >> 1, (b1 + b2) >> 1); coloritem = ColorUtil.color((r1 + r2) >> 1, (g1 + g2) >> 1, (b1 + b2) >> 1);
} }
@Override @Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) { public BlockState getStateForPlacement(BlockPlaceContext ctx) {
double px = ctx.getClickedPos().getX() * 0.1; double px = ctx.getClickedPos().getX() * 0.1;
@ -56,17 +54,17 @@ public class JellyshroomCapBlock extends SlimeBlock implements IRenderTyped, Blo
double pz = ctx.getClickedPos().getZ() * 0.1; double pz = ctx.getClickedPos().getZ() * 0.1;
return this.defaultBlockState().setValue(COLOR, MHelper.floor(NOISE.eval(px, py, pz) * 3.5 + 4)); return this.defaultBlockState().setValue(COLOR, MHelper.floor(NOISE.eval(px, py, pz) * 3.5 + 4));
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(COLOR); stateManager.add(COLOR);
} }
@Override @Override
public BCLRenderLayer getRenderLayer() { public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.TRANSLUCENT; return BCLRenderLayer.TRANSLUCENT;
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Lists.newArrayList(new ItemStack(this)); return Lists.newArrayList(new ItemStack(this));

View file

@ -17,7 +17,7 @@ public class LacugroveSaplingBlock extends FeatureSaplingBlock {
protected Feature<?> getFeature() { protected Feature<?> getFeature() {
return EndFeatures.LACUGROVE.getFeature(); return EndFeatures.LACUGROVE.getFeature();
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return world.getBlockState(pos.below()).is(EndBlocks.END_MOSS) || world.getBlockState(pos.below()).is(EndBlocks.ENDSTONE_DUST); return world.getBlockState(pos.below()).is(EndBlocks.END_MOSS) || world.getBlockState(pos.below()).is(EndBlocks.ENDSTONE_DUST);

View file

@ -1,8 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
@ -21,11 +18,14 @@ import ru.bclib.util.MHelper;
import ru.betterend.blocks.basis.EndPlantBlock; import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Collections;
import java.util.List;
public class LanceleafBlock extends EndPlantBlock { public class LanceleafBlock extends EndPlantBlock {
public static final EnumProperty<PentaShape> SHAPE = BlockProperties.PENTA_SHAPE; public static final EnumProperty<PentaShape> SHAPE = BlockProperties.PENTA_SHAPE;
public static final IntegerProperty ROTATION = BlockProperties.ROTATION; public static final IntegerProperty ROTATION = BlockProperties.ROTATION;
public LanceleafBlock() { public LanceleafBlock() {
super(); super();
} }
@ -34,7 +34,7 @@ public class LanceleafBlock extends EndPlantBlock {
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(SHAPE, ROTATION); stateManager.add(SHAPE, ROTATION);
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
PentaShape shape = state.getValue(SHAPE); PentaShape shape = state.getValue(SHAPE);
@ -48,7 +48,7 @@ public class LanceleafBlock extends EndPlantBlock {
return world.getBlockState(pos.below()).is(this) && world.getBlockState(pos.above()).is(this); return world.getBlockState(pos.below()).is(this) && world.getBlockState(pos.above()).is(this);
} }
} }
@Override @Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (!canSurvive(state, world, pos)) { if (!canSurvive(state, world, pos)) {
@ -58,7 +58,7 @@ public class LanceleafBlock extends EndPlantBlock {
return state; return state;
} }
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
if (state.getValue(SHAPE) == PentaShape.BOTTOM) { if (state.getValue(SHAPE) == PentaShape.BOTTOM) {

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
@ -15,6 +13,8 @@ import ru.bclib.util.MHelper;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock; import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class LanceleafSeedBlock extends EndPlantWithAgeBlock { public class LanceleafSeedBlock extends EndPlantWithAgeBlock {
@Override @Override
public void growAdult(WorldGenLevel world, Random random, BlockPos pos) { public void growAdult(WorldGenLevel world, Random random, BlockPos pos) {
@ -34,12 +34,12 @@ public class LanceleafSeedBlock extends EndPlantWithAgeBlock {
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), plant.setValue(BlockProperties.PENTA_SHAPE, PentaShape.PRE_TOP)); BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), plant.setValue(BlockProperties.PENTA_SHAPE, PentaShape.PRE_TOP));
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), plant.setValue(BlockProperties.PENTA_SHAPE, PentaShape.TOP)); BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), plant.setValue(BlockProperties.PENTA_SHAPE, PentaShape.TOP));
} }
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.AMBER_MOSS); return state.is(EndBlocks.AMBER_MOSS);
} }
@Override @Override
public BlockBehaviour.OffsetType getOffsetType() { public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE; return BlockBehaviour.OffsetType.NONE;

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -22,11 +20,13 @@ import ru.bclib.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.EndPlantBlock; import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class LargeAmaranitaBlock extends EndPlantBlock { public class LargeAmaranitaBlock extends EndPlantBlock {
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE; public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
private static final VoxelShape SHAPE_BOTTOM = Block.box(4, 0, 4, 12, 14, 12); private static final VoxelShape SHAPE_BOTTOM = Block.box(4, 0, 4, 12, 14, 12);
private static final VoxelShape SHAPE_TOP = Shapes.or(Block.box(1, 3, 1, 15, 16, 15), SHAPE_BOTTOM); private static final VoxelShape SHAPE_TOP = Shapes.or(Block.box(1, 3, 1, 15, 16, 15), SHAPE_BOTTOM);
public LargeAmaranitaBlock() { public LargeAmaranitaBlock() {
super(FabricBlockSettings.of(Material.PLANT) super(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS) .breakByTool(FabricToolTags.SHEARS)
@ -34,22 +34,22 @@ public class LargeAmaranitaBlock extends EndPlantBlock {
.sound(SoundType.GRASS) .sound(SoundType.GRASS)
.lightLevel((state) -> (state.getValue(SHAPE) == TripleShape.TOP) ? 15 : 0)); .lightLevel((state) -> (state.getValue(SHAPE) == TripleShape.TOP) ? 15 : 0));
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return state.getValue(SHAPE) == TripleShape.TOP ? SHAPE_TOP : SHAPE_BOTTOM; return state.getValue(SHAPE) == TripleShape.TOP ? SHAPE_TOP : SHAPE_BOTTOM;
} }
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.SANGNUM) || state.is(EndBlocks.MOSSY_OBSIDIAN) || state.is(EndBlocks.MOSSY_DRAGON_BONE); return state.is(EndBlocks.SANGNUM) || state.is(EndBlocks.MOSSY_OBSIDIAN) || state.is(EndBlocks.MOSSY_DRAGON_BONE);
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(SHAPE); stateManager.add(SHAPE);
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
TripleShape shape = state.getValue(SHAPE); TripleShape shape = state.getValue(SHAPE);
@ -63,12 +63,12 @@ public class LargeAmaranitaBlock extends EndPlantBlock {
return world.getBlockState(pos.below()).is(this) && world.getBlockState(pos.above()).is(this); return world.getBlockState(pos.below()).is(this) && world.getBlockState(pos.above()).is(this);
} }
} }
@Override @Override
public OffsetType getOffsetType() { public OffsetType getOffsetType() {
return OffsetType.NONE; return OffsetType.NONE;
} }
@Override @Override
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) { public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
return false; return false;

View file

@ -17,7 +17,7 @@ public class LucerniaSaplingBlock extends FeatureSaplingBlock {
protected Feature<?> getFeature() { protected Feature<?> getFeature() {
return EndFeatures.LUCERNIA.getFeature(); return EndFeatures.LUCERNIA.getFeature();
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return world.getBlockState(pos.below()).is(EndBlocks.RUTISCUS); return world.getBlockState(pos.below()).is(EndBlocks.RUTISCUS);

View file

@ -1,8 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
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.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -31,19 +28,22 @@ import ru.betterend.blocks.EndBlockProperties.LumecornShape;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems; import ru.betterend.registry.EndItems;
import java.util.Collections;
import java.util.List;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class LumecornBlock extends BaseBlockNotFull implements IRenderTyped { public class LumecornBlock extends BaseBlockNotFull implements IRenderTyped {
public static final EnumProperty<LumecornShape> SHAPE = EnumProperty.create("shape", LumecornShape.class); public static final EnumProperty<LumecornShape> SHAPE = EnumProperty.create("shape", LumecornShape.class);
private static final VoxelShape SHAPE_BOTTOM = Block.box(6, 0, 6, 10, 16, 10); private static final VoxelShape SHAPE_BOTTOM = Block.box(6, 0, 6, 10, 16, 10);
private static final VoxelShape SHAPE_TOP = Block.box(6, 0, 6, 10, 8, 10); private static final VoxelShape SHAPE_TOP = Block.box(6, 0, 6, 10, 8, 10);
public LumecornBlock() { public LumecornBlock() {
super(FabricBlockSettings.of(Material.WOOD) super(FabricBlockSettings.of(Material.WOOD)
.breakByTool(FabricToolTags.AXES) .breakByTool(FabricToolTags.AXES)
.hardness(0.5F) .hardness(0.5F)
.luminance(state -> state.getValue(SHAPE).getLight())); .luminance(state -> state.getValue(SHAPE).getLight()));
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(SHAPE); stateManager.add(SHAPE);
@ -53,12 +53,12 @@ public class LumecornBlock extends BaseBlockNotFull implements IRenderTyped {
public BCLRenderLayer getRenderLayer() { public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT; return BCLRenderLayer.CUTOUT;
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return state.getValue(SHAPE) == LumecornShape.LIGHT_TOP ? SHAPE_TOP : SHAPE_BOTTOM; return state.getValue(SHAPE) == LumecornShape.LIGHT_TOP ? SHAPE_TOP : SHAPE_BOTTOM;
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
LumecornShape shape = state.getValue(SHAPE); LumecornShape shape = state.getValue(SHAPE);
@ -72,7 +72,7 @@ public class LumecornBlock extends BaseBlockNotFull implements IRenderTyped {
return world.getBlockState(pos.below()).is(this) && world.getBlockState(pos.above()).is(this); return world.getBlockState(pos.below()).is(this) && world.getBlockState(pos.above()).is(this);
} }
} }
@Override @Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (!canSurvive(state, world, pos)) { if (!canSurvive(state, world, pos)) {
@ -82,7 +82,7 @@ public class LumecornBlock extends BaseBlockNotFull implements IRenderTyped {
return state; return state;
} }
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
LumecornShape shape = state.getValue(SHAPE); LumecornShape shape = state.getValue(SHAPE);
@ -91,7 +91,7 @@ public class LumecornBlock extends BaseBlockNotFull implements IRenderTyped {
} }
return MHelper.RANDOM.nextBoolean() ? Collections.singletonList(new ItemStack(EndItems.LUMECORN_ROD)) : Collections.emptyList(); return MHelper.RANDOM.nextBoolean() ? Collections.singletonList(new ItemStack(EndItems.LUMECORN_ROD)) : Collections.emptyList();
} }
@Override @Override
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) { public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) {

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockBehaviour;
@ -11,18 +9,20 @@ import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndFeatures; import ru.betterend.registry.EndFeatures;
import java.util.Random;
public class LumecornSeedBlock extends EndPlantWithAgeBlock { public class LumecornSeedBlock extends EndPlantWithAgeBlock {
@Override @Override
public void growAdult(WorldGenLevel world, Random random, BlockPos pos) { public void growAdult(WorldGenLevel world, Random random, BlockPos pos) {
EndFeatures.LUMECORN.getFeature().place(new FeaturePlaceContext<>(world, null, random, pos, null)); EndFeatures.LUMECORN.getFeature().place(new FeaturePlaceContext<>(world, null, random, pos, null));
} }
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.END_MOSS); return state.is(EndBlocks.END_MOSS);
} }
@Override @Override
public BlockBehaviour.OffsetType getOffsetType() { public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE; return BlockBehaviour.OffsetType.NONE;

View file

@ -1,9 +1,6 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Queue;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
@ -17,26 +14,27 @@ import net.minecraft.world.level.block.LiquidBlock;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
import ru.bclib.blocks.BaseBlockNotFull; import ru.bclib.blocks.BaseBlockNotFull;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped; import ru.bclib.interfaces.IRenderTyped;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Queue;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class MengerSpongeBlock extends BaseBlockNotFull implements IRenderTyped { public class MengerSpongeBlock extends BaseBlockNotFull implements IRenderTyped {
public MengerSpongeBlock() { public MengerSpongeBlock() {
super(FabricBlockSettings.copyOf(Blocks.SPONGE).noOcclusion()); super(FabricBlockSettings.copyOf(Blocks.SPONGE).noOcclusion());
} }
@Override @Override
public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) { public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
if (absorbWater(world, pos)) { if (absorbWater(world, pos)) {
world.setBlockAndUpdate(pos, EndBlocks.MENGER_SPONGE_WET.defaultBlockState()); world.setBlockAndUpdate(pos, EndBlocks.MENGER_SPONGE_WET.defaultBlockState());
} }
} }
@Override @Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (absorbWater(world, pos)) { if (absorbWater(world, pos)) {
@ -66,13 +64,15 @@ public class MengerSpongeBlock extends BaseBlockNotFull implements IRenderTyped
if (j < 6) { if (j < 6) {
queue.add(new Tuple<>(blockPos2, j + 1)); queue.add(new Tuple<>(blockPos2, j + 1));
} }
} else if (blockState.getBlock() instanceof LiquidBlock) { }
else if (blockState.getBlock() instanceof LiquidBlock) {
world.setBlock(blockPos2, Blocks.AIR.defaultBlockState(), 3); world.setBlock(blockPos2, Blocks.AIR.defaultBlockState(), 3);
++i; ++i;
if (j < 6) { if (j < 6) {
queue.add(new Tuple<>(blockPos2, j + 1)); queue.add(new Tuple<>(blockPos2, j + 1));
} }
} else if (material == Material.WATER_PLANT || material == Material.REPLACEABLE_WATER_PLANT) { }
else if (material == Material.WATER_PLANT || material == Material.REPLACEABLE_WATER_PLANT) {
BlockEntity blockEntity = blockState.hasBlockEntity() ? world.getBlockEntity(blockPos2) : null; BlockEntity blockEntity = blockState.hasBlockEntity() ? world.getBlockEntity(blockPos2) : null;
dropResources(blockState, world, blockPos2, blockEntity); dropResources(blockState, world, blockPos2, blockEntity);
world.setBlock(blockPos2, Blocks.AIR.defaultBlockState(), 3); world.setBlock(blockPos2, Blocks.AIR.defaultBlockState(), 3);
@ -91,7 +91,7 @@ public class MengerSpongeBlock extends BaseBlockNotFull implements IRenderTyped
return i > 0; return i > 0;
} }
@Override @Override
public BCLRenderLayer getRenderLayer() { public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT; return BCLRenderLayer.CUTOUT;

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Random;
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.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -25,6 +23,8 @@ import ru.bclib.interfaces.IRenderTyped;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Random;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class MengerSpongeWetBlock extends BaseBlockNotFull implements IRenderTyped { public class MengerSpongeWetBlock extends BaseBlockNotFull implements IRenderTyped {
public MengerSpongeWetBlock() { public MengerSpongeWetBlock() {
@ -94,12 +94,12 @@ public class MengerSpongeWetBlock extends BaseBlockNotFull implements IRenderTyp
world.addFreshEntity(drop); world.addFreshEntity(drop);
} }
} }
@Override @Override
public BCLRenderLayer getRenderLayer() { public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT; return BCLRenderLayer.CUTOUT;
} }
@Override @Override
public FluidState getFluidState(BlockState state) { public FluidState getFluidState(BlockState state) {
return Fluids.WATER.getSource(false); return Fluids.WATER.getSource(false);

View file

@ -1,9 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
@ -21,12 +17,16 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import ru.bclib.blocks.BaseRotatedPillarBlock; import ru.bclib.blocks.BaseRotatedPillarBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Collections;
import java.util.List;
import java.util.Random;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class MossyDragonBoneBlock extends BaseRotatedPillarBlock { public class MossyDragonBoneBlock extends BaseRotatedPillarBlock {
public MossyDragonBoneBlock() { public MossyDragonBoneBlock() {
super(FabricBlockSettings.copyOf(Blocks.BONE_BLOCK).hardness(0.5F).randomTicks()); super(FabricBlockSettings.copyOf(Blocks.BONE_BLOCK).hardness(0.5F).randomTicks());
} }
@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);
@ -35,7 +35,7 @@ public class MossyDragonBoneBlock extends BaseRotatedPillarBlock {
} }
return Collections.singletonList(new ItemStack(EndBlocks.DRAGON_BONE_BLOCK)); return Collections.singletonList(new ItemStack(EndBlocks.DRAGON_BONE_BLOCK));
} }
@Override @Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
if (random.nextInt(16) == 0 && !canSurvive(state, world, pos)) { if (random.nextInt(16) == 0 && !canSurvive(state, world, pos)) {
@ -45,15 +45,17 @@ public class MossyDragonBoneBlock extends BaseRotatedPillarBlock {
@Override @Override
public boolean canSurvive(BlockState state, LevelReader worldView, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader worldView, BlockPos pos) {
BlockPos blockPos = pos.above(); BlockPos blockPos = pos.above();
BlockState blockState = worldView.getBlockState(blockPos); BlockState blockState = worldView.getBlockState(blockPos);
if (blockState.is(Blocks.SNOW) && blockState.getValue(SnowLayerBlock.LAYERS) == 1) { if (blockState.is(Blocks.SNOW) && blockState.getValue(SnowLayerBlock.LAYERS) == 1) {
return true; return true;
} else if (blockState.getFluidState().getAmount() == 8) { }
return false; else if (blockState.getFluidState().getAmount() == 8) {
} else { return false;
int i = LayerLightEngine.getLightBlockInto(worldView, state, pos, blockState, blockPos, Direction.UP, blockState.getLightBlock(worldView, blockPos)); }
return i < 5; else {
} int i = LayerLightEngine.getLightBlockInto(worldView, state, pos, blockState, blockPos, Direction.UP, blockState.getLightBlock(worldView, blockPos));
} return i < 5;
}
}
} }

View file

@ -14,12 +14,12 @@ import ru.betterend.registry.EndBlocks;
public class MossyGlowshroomCapBlock extends BaseBlock { public class MossyGlowshroomCapBlock extends BaseBlock {
public static final BooleanProperty TRANSITION = EndBlockProperties.TRANSITION; public static final BooleanProperty TRANSITION = EndBlockProperties.TRANSITION;
public MossyGlowshroomCapBlock() { public MossyGlowshroomCapBlock() {
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sound(SoundType.WOOD)); super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sound(SoundType.WOOD));
this.registerDefaultState(this.stateDefinition.any().setValue(TRANSITION, false)); this.registerDefaultState(this.stateDefinition.any().setValue(TRANSITION, false));
} }
public BlockState getStateForPlacement(BlockPlaceContext ctx) { public BlockState getStateForPlacement(BlockPlaceContext ctx) {
return this.defaultBlockState().setValue(TRANSITION, EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(ctx.getLevel().getBlockState(ctx.getClickedPos().below()))); return this.defaultBlockState().setValue(TRANSITION, EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(ctx.getLevel().getBlockState(ctx.getClickedPos().below())));
} }

View file

@ -18,7 +18,7 @@ public class MossyGlowshroomSaplingBlock extends FeatureSaplingBlock {
protected Feature<?> getFeature() { protected Feature<?> getFeature() {
return EndFeatures.MOSSY_GLOWSHROOM.getFeature(); return EndFeatures.MOSSY_GLOWSHROOM.getFeature();
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return world.getBlockState(pos.below()).is(EndBlocks.END_MOSS) || world.getBlockState(pos.below()).is(EndBlocks.END_MYCELIUM); return world.getBlockState(pos.below()).is(EndBlocks.END_MOSS) || world.getBlockState(pos.below()).is(EndBlocks.END_MYCELIUM);

View file

@ -1,9 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
@ -20,11 +16,15 @@ 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.blocks.BaseBlock; import ru.bclib.blocks.BaseBlock;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public class MossyObsidian extends BaseBlock { public class MossyObsidian extends BaseBlock {
public MossyObsidian() { public MossyObsidian() {
super(FabricBlockSettings.copyOf(Blocks.OBSIDIAN).hardness(3).randomTicks()); super(FabricBlockSettings.copyOf(Blocks.OBSIDIAN).hardness(3).randomTicks());
} }
@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);
@ -33,24 +33,26 @@ public class MossyObsidian extends BaseBlock {
} }
return Collections.singletonList(new ItemStack(Blocks.OBSIDIAN)); return Collections.singletonList(new ItemStack(Blocks.OBSIDIAN));
} }
@Override @Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
if (random.nextInt(16) == 0 && !canSurvive(state, world, pos)) { if (random.nextInt(16) == 0 && !canSurvive(state, world, pos)) {
world.setBlockAndUpdate(pos, Blocks.OBSIDIAN.defaultBlockState()); world.setBlockAndUpdate(pos, Blocks.OBSIDIAN.defaultBlockState());
} }
} }
public boolean canSurvive(BlockState state, LevelReader worldView, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader worldView, BlockPos pos) {
BlockPos blockPos = pos.above(); BlockPos blockPos = pos.above();
BlockState blockState = worldView.getBlockState(blockPos); BlockState blockState = worldView.getBlockState(blockPos);
if (blockState.is(Blocks.SNOW) && (Integer)blockState.getValue(SnowLayerBlock.LAYERS) == 1) { if (blockState.is(Blocks.SNOW) && (Integer) blockState.getValue(SnowLayerBlock.LAYERS) == 1) {
return true; return true;
} else if (blockState.getFluidState().getAmount() == 8) { }
return false; else if (blockState.getFluidState().getAmount() == 8) {
} else { return false;
int i = LayerLightEngine.getLightBlockInto(worldView, state, pos, blockState, blockPos, Direction.UP, blockState.getLightBlock(worldView, blockPos)); }
return i < 5; else {
} int i = LayerLightEngine.getLightBlockInto(worldView, state, pos, blockState, blockPos, Direction.UP, blockState.getLightBlock(worldView, blockPos));
} return i < 5;
}
}
} }

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -17,6 +15,8 @@ import net.minecraft.world.level.pathfinder.PathComputationType;
import ru.betterend.blocks.basis.EndPlantBlock; import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class MurkweedBlock extends EndPlantBlock { public class MurkweedBlock extends EndPlantBlock {
@Override @Override
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
@ -27,19 +27,19 @@ public class MurkweedBlock extends EndPlantBlock {
double v = random.nextDouble() * 0.1; double v = random.nextDouble() * 0.1;
world.addParticle(ParticleTypes.ENTITY_EFFECT, x, y, z, v, v, v); world.addParticle(ParticleTypes.ENTITY_EFFECT, x, y, z, v, v, v);
} }
@Override @Override
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
if (entity instanceof LivingEntity && !((LivingEntity) entity).hasEffect(MobEffects.BLINDNESS)) { if (entity instanceof LivingEntity && !((LivingEntity) entity).hasEffect(MobEffects.BLINDNESS)) {
((LivingEntity) entity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 50)); ((LivingEntity) entity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 50));
} }
} }
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.SHADOW_GRASS); return state.is(EndBlocks.SHADOW_GRASS);
} }
@Override @Override
public boolean isPathfindable(BlockState state, BlockGetter world, BlockPos pos, PathComputationType type) { public boolean isPathfindable(BlockState state, BlockGetter world, BlockPos pos, PathComputationType type) {
return false; return false;

View file

@ -1,9 +1,6 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.List;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.damagesource.DamageSource;
@ -23,6 +20,8 @@ import ru.bclib.util.MHelper;
import ru.betterend.blocks.basis.EndPlantBlock; import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.List;
public class NeedlegrassBlock extends EndPlantBlock { public class NeedlegrassBlock extends EndPlantBlock {
@Override @Override
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
@ -30,7 +29,7 @@ public class NeedlegrassBlock extends EndPlantBlock {
entity.hurt(DamageSource.CACTUS, 0.1F); entity.hurt(DamageSource.CACTUS, 0.1F);
} }
} }
@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);
@ -41,7 +40,7 @@ public class NeedlegrassBlock extends EndPlantBlock {
return Lists.newArrayList(new ItemStack(Items.STICK, MHelper.randRange(0, 2, MHelper.RANDOM))); return Lists.newArrayList(new ItemStack(Items.STICK, MHelper.randRange(0, 2, MHelper.RANDOM)));
} }
} }
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.SHADOW_GRASS); return state.is(EndBlocks.SHADOW_GRASS);

View file

@ -1,12 +1,7 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.EnumMap;
import java.util.List;
import java.util.Random;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.core.BlockPos.MutableBlockPos;
@ -48,13 +43,17 @@ import ru.bclib.util.MHelper;
import ru.betterend.blocks.EndBlockProperties.CactusBottom; import ru.betterend.blocks.EndBlockProperties.CactusBottom;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.EnumMap;
import java.util.List;
import java.util.Random;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWaterloggedBlock, IRenderTyped { public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWaterloggedBlock, IRenderTyped {
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE; public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
public static final EnumProperty<CactusBottom> CACTUS_BOTTOM = EndBlockProperties.CACTUS_BOTTOM; public static final EnumProperty<CactusBottom> CACTUS_BOTTOM = EndBlockProperties.CACTUS_BOTTOM;
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public static final DirectionProperty FACING = BlockStateProperties.FACING; public static final DirectionProperty FACING = BlockStateProperties.FACING;
private static final EnumMap<Direction, VoxelShape> BIG_SHAPES_OPEN = Maps.newEnumMap(Direction.class); private static final EnumMap<Direction, VoxelShape> BIG_SHAPES_OPEN = Maps.newEnumMap(Direction.class);
private static final EnumMap<Direction, VoxelShape> MEDIUM_SHAPES_OPEN = Maps.newEnumMap(Direction.class); private static final EnumMap<Direction, VoxelShape> MEDIUM_SHAPES_OPEN = Maps.newEnumMap(Direction.class);
private static final EnumMap<Direction, VoxelShape> SMALL_SHAPES_OPEN = Maps.newEnumMap(Direction.class); private static final EnumMap<Direction, VoxelShape> SMALL_SHAPES_OPEN = Maps.newEnumMap(Direction.class);
@ -62,17 +61,17 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
private static final EnumMap<Axis, VoxelShape> MEDIUM_SHAPES = Maps.newEnumMap(Axis.class); private static final EnumMap<Axis, VoxelShape> MEDIUM_SHAPES = Maps.newEnumMap(Axis.class);
private static final EnumMap<Axis, VoxelShape> SMALL_SHAPES = Maps.newEnumMap(Axis.class); private static final EnumMap<Axis, VoxelShape> SMALL_SHAPES = Maps.newEnumMap(Axis.class);
private static final int MAX_LENGTH = 12; private static final int MAX_LENGTH = 12;
public NeonCactusPlantBlock() { public NeonCactusPlantBlock() {
super(FabricBlockSettings.copyOf(Blocks.CACTUS).luminance(15).randomTicks()); super(FabricBlockSettings.copyOf(Blocks.CACTUS).luminance(15).randomTicks());
registerDefaultState(defaultBlockState().setValue(WATERLOGGED, false).setValue(FACING, Direction.UP).setValue(SHAPE, TripleShape.TOP)); registerDefaultState(defaultBlockState().setValue(WATERLOGGED, false).setValue(FACING, Direction.UP).setValue(SHAPE, TripleShape.TOP));
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(SHAPE, CACTUS_BOTTOM, WATERLOGGED, FACING); stateManager.add(SHAPE, CACTUS_BOTTOM, WATERLOGGED, FACING);
} }
@Override @Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) { public BlockState getStateForPlacement(BlockPlaceContext ctx) {
LevelAccessor world = ctx.getLevel(); LevelAccessor world = ctx.getLevel();
@ -91,7 +90,7 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
} }
return state; return state;
} }
@Override @Override
public BlockState rotate(BlockState state, Rotation rotation) { public BlockState rotate(BlockState state, Rotation rotation) {
return BlocksHelper.rotateHorizontal(state, rotation, FACING); return BlocksHelper.rotateHorizontal(state, rotation, FACING);
@ -101,12 +100,12 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
public BlockState mirror(BlockState state, Mirror mirror) { public BlockState mirror(BlockState state, Mirror mirror) {
return BlocksHelper.mirrorHorizontal(state, mirror, FACING); return BlocksHelper.mirrorHorizontal(state, mirror, FACING);
} }
@Override @Override
public FluidState getFluidState(BlockState state) { public FluidState getFluidState(BlockState state) {
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state); return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
} }
@Override @Override
public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, BlockPos pos, BlockPos posFrom) { public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, BlockPos pos, BlockPos posFrom) {
world.getBlockTicks().scheduleTick(pos, this, 2); world.getBlockTicks().scheduleTick(pos, this, 2);
@ -126,19 +125,19 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
} }
return state; return state;
} }
@Override @Override
public void tick(BlockState blockState, ServerLevel serverLevel, BlockPos blockPos, Random random) { public void tick(BlockState blockState, ServerLevel serverLevel, BlockPos blockPos, Random random) {
if (!blockState.canSurvive(serverLevel, blockPos)) { if (!blockState.canSurvive(serverLevel, blockPos)) {
serverLevel.destroyBlock(blockPos, true, null, 1); serverLevel.destroyBlock(blockPos, true, null, 1);
} }
} }
@Override @Override
public BCLRenderLayer getRenderLayer() { public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT; return BCLRenderLayer.CUTOUT;
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
TripleShape shape = state.getValue(SHAPE); TripleShape shape = state.getValue(SHAPE);
@ -158,7 +157,7 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
return shape == TripleShape.MIDDLE ? MEDIUM_SHAPES_OPEN.get(dir) : SMALL_SHAPES_OPEN.get(dir); return shape == TripleShape.MIDDLE ? MEDIUM_SHAPES_OPEN.get(dir) : SMALL_SHAPES_OPEN.get(dir);
} }
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader level, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader level, BlockPos pos) {
Direction dir = state.getValue(FACING); Direction dir = state.getValue(FACING);
@ -166,12 +165,12 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
BlockState support = level.getBlockState(supportPos); BlockState support = level.getBlockState(supportPos);
return support.is(this) || support.isFaceSturdy(level, supportPos, dir); return support.is(this) || support.isFaceSturdy(level, supportPos, dir);
} }
@Override @Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
if (!this.canSurvive(state, world, pos) || random.nextInt(8) > 0) { if (!this.canSurvive(state, world, pos) || random.nextInt(8) > 0) {
return; return;
} }
Direction dir = state.getValue(FACING); Direction dir = state.getValue(FACING);
if (!world.isEmptyBlock(pos.relative(dir))) { if (!world.isEmptyBlock(pos.relative(dir))) {
return; return;
@ -201,11 +200,11 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
BlocksHelper.setWithoutUpdate(world, pos.relative(dir), placement); BlocksHelper.setWithoutUpdate(world, pos.relative(dir), placement);
mutateStem(placement, world, pos, MAX_LENGTH); mutateStem(placement, world, pos, MAX_LENGTH);
} }
public void growPlant(WorldGenLevel world, BlockPos pos, Random random) { public void growPlant(WorldGenLevel world, BlockPos pos, Random random) {
growPlant(world, pos, random, MHelper.randRange(MAX_LENGTH >> 1, MAX_LENGTH, random)); growPlant(world, pos, random, MHelper.randRange(MAX_LENGTH >> 1, MAX_LENGTH, random));
} }
public void growPlant(WorldGenLevel world, BlockPos pos, Random random, int iterations) { public void growPlant(WorldGenLevel world, BlockPos pos, Random random, int iterations) {
BlockState state = defaultBlockState(); BlockState state = defaultBlockState();
BlockState downState = world.getBlockState(pos.below()); BlockState downState = world.getBlockState(pos.below());
@ -231,7 +230,7 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
} }
} }
} }
private boolean growIteration(WorldGenLevel world, MutableBlockPos pos, Random random, List<MutableBlockPos> ends, int length) { private boolean growIteration(WorldGenLevel world, MutableBlockPos pos, Random random, List<MutableBlockPos> ends, int length) {
BlockState state = world.getBlockState(pos); BlockState state = world.getBlockState(pos);
if (!state.is(this)) { if (!state.is(this)) {
@ -265,7 +264,7 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
pos.move(dir); pos.move(dir);
return true; return true;
} }
private Direction getSideDirection(WorldGenLevel world, BlockPos pos, BlockState iterState, Direction dir, Random random) { private Direction getSideDirection(WorldGenLevel world, BlockPos pos, BlockState iterState, Direction dir, Random random) {
MutableBlockPos iterPos = pos.mutable(); MutableBlockPos iterPos = pos.mutable();
Direction startDir = dir; Direction startDir = dir;
@ -273,7 +272,7 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
while (iterState.is(this) && startDir.getAxis().isVertical()) { while (iterState.is(this) && startDir.getAxis().isVertical()) {
startDir = iterState.getValue(FACING); startDir = iterState.getValue(FACING);
if (lastDir == null) { if (lastDir == null) {
for (Direction side: BlocksHelper.HORIZONTAL) { for (Direction side : BlocksHelper.HORIZONTAL) {
BlockState sideState = world.getBlockState(iterPos.relative(side)); BlockState sideState = world.getBlockState(iterPos.relative(side));
if (sideState.is(this)) { if (sideState.is(this)) {
Direction sideDir = sideState.getValue(FACING); Direction sideDir = sideState.getValue(FACING);
@ -287,7 +286,7 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
iterPos.move(dir); iterPos.move(dir);
iterState = world.getBlockState(iterPos); iterState = world.getBlockState(iterPos);
} }
Direction side = lastDir == null ? BlocksHelper.randomHorizontal(random) : lastDir.getClockWise(); Direction side = lastDir == null ? BlocksHelper.randomHorizontal(random) : lastDir.getClockWise();
if (side.getOpposite() == startDir) { if (side.getOpposite() == startDir) {
side = side.getOpposite(); side = side.getOpposite();
@ -299,12 +298,12 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
public boolean isPathfindable(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, PathComputationType pathComputationType) { public boolean isPathfindable(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, PathComputationType pathComputationType) {
return false; return false;
} }
@Override @Override
public void entityInside(BlockState blockState, Level level, BlockPos blockPos, Entity entity) { public void entityInside(BlockState blockState, Level level, BlockPos blockPos, Entity entity) {
entity.hurt(DamageSource.CACTUS, 1.0F); entity.hurt(DamageSource.CACTUS, 1.0F);
} }
private int getLength(BlockState state, ServerLevel world, BlockPos pos, int max) { private int getLength(BlockState state, ServerLevel world, BlockPos pos, int max) {
int length = 0; int length = 0;
Direction dir = state.getValue(FACING).getOpposite(); Direction dir = state.getValue(FACING).getOpposite();
@ -319,11 +318,11 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
break; break;
} }
dir = state.getValue(FACING).getOpposite(); dir = state.getValue(FACING).getOpposite();
length ++; length++;
} }
return length; return length;
} }
private int getHorizontal(BlockState state, WorldGenLevel world, BlockPos pos, int max) { private int getHorizontal(BlockState state, WorldGenLevel world, BlockPos pos, int max) {
int count = 0; int count = 0;
Direction dir = state.getValue(FACING).getOpposite(); Direction dir = state.getValue(FACING).getOpposite();
@ -338,11 +337,11 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
if (dir.getStepY() != 0) { if (dir.getStepY() != 0) {
break; break;
} }
count ++; count++;
} }
return count; return count;
} }
private void mutateStem(BlockState state, WorldGenLevel world, BlockPos pos, int max) { private void mutateStem(BlockState state, WorldGenLevel world, BlockPos pos, int max) {
Direction dir = state.getValue(FACING).getOpposite(); Direction dir = state.getValue(FACING).getOpposite();
MutableBlockPos mut = new MutableBlockPos().set(pos); MutableBlockPos mut = new MutableBlockPos().set(pos);
@ -361,39 +360,39 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
} }
} }
} }
static { static {
BIG_SHAPES.put(Axis.X, Block.box(0, 2, 2, 16, 14, 14)); BIG_SHAPES.put(Axis.X, Block.box(0, 2, 2, 16, 14, 14));
BIG_SHAPES.put(Axis.Y, Block.box(2, 0, 2, 14, 16, 14)); BIG_SHAPES.put(Axis.Y, Block.box(2, 0, 2, 14, 16, 14));
BIG_SHAPES.put(Axis.Z, Block.box(2, 2, 0, 14, 14, 16)); BIG_SHAPES.put(Axis.Z, Block.box(2, 2, 0, 14, 14, 16));
MEDIUM_SHAPES.put(Axis.X, Block.box(0, 3, 3, 16, 13, 13)); MEDIUM_SHAPES.put(Axis.X, Block.box(0, 3, 3, 16, 13, 13));
MEDIUM_SHAPES.put(Axis.Y, Block.box(3, 0, 3, 13, 16, 13)); MEDIUM_SHAPES.put(Axis.Y, Block.box(3, 0, 3, 13, 16, 13));
MEDIUM_SHAPES.put(Axis.Z, Block.box(3, 3, 0, 13, 13, 16)); MEDIUM_SHAPES.put(Axis.Z, Block.box(3, 3, 0, 13, 13, 16));
SMALL_SHAPES.put(Axis.X, Block.box(0, 4, 4, 16, 12, 12)); SMALL_SHAPES.put(Axis.X, Block.box(0, 4, 4, 16, 12, 12));
SMALL_SHAPES.put(Axis.Y, Block.box(4, 0, 4, 12, 16, 12)); SMALL_SHAPES.put(Axis.Y, Block.box(4, 0, 4, 12, 16, 12));
SMALL_SHAPES.put(Axis.Z, Block.box(4, 4, 0, 12, 12, 16)); SMALL_SHAPES.put(Axis.Z, Block.box(4, 4, 0, 12, 12, 16));
BIG_SHAPES_OPEN.put(Direction.UP, Block.box(2, 0, 2, 14, 14, 14)); BIG_SHAPES_OPEN.put(Direction.UP, Block.box(2, 0, 2, 14, 14, 14));
BIG_SHAPES_OPEN.put(Direction.DOWN, Block.box(2, 2, 2, 14, 16, 14)); BIG_SHAPES_OPEN.put(Direction.DOWN, Block.box(2, 2, 2, 14, 16, 14));
BIG_SHAPES_OPEN.put(Direction.NORTH, Block.box(2, 2, 2, 14, 14, 16)); BIG_SHAPES_OPEN.put(Direction.NORTH, Block.box(2, 2, 2, 14, 14, 16));
BIG_SHAPES_OPEN.put(Direction.SOUTH, Block.box(2, 2, 0, 14, 14, 14)); BIG_SHAPES_OPEN.put(Direction.SOUTH, Block.box(2, 2, 0, 14, 14, 14));
BIG_SHAPES_OPEN.put(Direction.WEST, Block.box(2, 2, 2, 16, 14, 14)); BIG_SHAPES_OPEN.put(Direction.WEST, Block.box(2, 2, 2, 16, 14, 14));
BIG_SHAPES_OPEN.put(Direction.EAST, Block.box(0, 2, 2, 14, 14, 14)); BIG_SHAPES_OPEN.put(Direction.EAST, Block.box(0, 2, 2, 14, 14, 14));
MEDIUM_SHAPES_OPEN.put(Direction.UP, Block.box(3, 0, 3, 13, 13, 13)); MEDIUM_SHAPES_OPEN.put(Direction.UP, Block.box(3, 0, 3, 13, 13, 13));
MEDIUM_SHAPES_OPEN.put(Direction.DOWN, Block.box(3, 3, 3, 13, 16, 13)); MEDIUM_SHAPES_OPEN.put(Direction.DOWN, Block.box(3, 3, 3, 13, 16, 13));
MEDIUM_SHAPES_OPEN.put(Direction.NORTH, Block.box(3, 3, 3, 13, 13, 16)); MEDIUM_SHAPES_OPEN.put(Direction.NORTH, Block.box(3, 3, 3, 13, 13, 16));
MEDIUM_SHAPES_OPEN.put(Direction.SOUTH, Block.box(3, 3, 0, 13, 13, 13)); MEDIUM_SHAPES_OPEN.put(Direction.SOUTH, Block.box(3, 3, 0, 13, 13, 13));
MEDIUM_SHAPES_OPEN.put(Direction.WEST, Block.box(3, 3, 3, 16, 13, 13)); MEDIUM_SHAPES_OPEN.put(Direction.WEST, Block.box(3, 3, 3, 16, 13, 13));
MEDIUM_SHAPES_OPEN.put(Direction.EAST, Block.box(0, 3, 3, 13, 13, 13)); MEDIUM_SHAPES_OPEN.put(Direction.EAST, Block.box(0, 3, 3, 13, 13, 13));
SMALL_SHAPES_OPEN.put(Direction.UP, Block.box(4, 0, 4, 12, 12, 12)); SMALL_SHAPES_OPEN.put(Direction.UP, Block.box(4, 0, 4, 12, 12, 12));
SMALL_SHAPES_OPEN.put(Direction.DOWN, Block.box(4, 4, 4, 12, 16, 12)); SMALL_SHAPES_OPEN.put(Direction.DOWN, Block.box(4, 4, 4, 12, 16, 12));
SMALL_SHAPES_OPEN.put(Direction.NORTH, Block.box(4, 4, 4, 12, 12, 16)); SMALL_SHAPES_OPEN.put(Direction.NORTH, Block.box(4, 4, 4, 12, 12, 16));
SMALL_SHAPES_OPEN.put(Direction.SOUTH, Block.box(4, 4, 0, 12, 12, 12)); SMALL_SHAPES_OPEN.put(Direction.SOUTH, Block.box(4, 4, 0, 12, 12, 12));
SMALL_SHAPES_OPEN.put(Direction.WEST, Block.box(4, 4, 4, 16, 12, 12)); SMALL_SHAPES_OPEN.put(Direction.WEST, Block.box(4, 4, 4, 16, 12, 12));
SMALL_SHAPES_OPEN.put(Direction.EAST, Block.box(0, 4, 4, 12, 12, 12)); SMALL_SHAPES_OPEN.put(Direction.EAST, Block.box(0, 4, 4, 12, 12, 12));
} }
} }

View file

@ -1,13 +1,13 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import ru.betterend.blocks.basis.PedestalBlock; import ru.betterend.blocks.basis.PedestalBlock;
import java.util.HashMap;
import java.util.Map;
public class PedestalVanilla extends PedestalBlock { public class PedestalVanilla extends PedestalBlock {
public PedestalVanilla(Block parent) { public PedestalVanilla(Block parent) {
@ -20,8 +20,9 @@ public class PedestalVanilla extends PedestalBlock {
String name = blockId.getPath().replace("_block", ""); String name = blockId.getPath().replace("_block", "");
return new HashMap<String, String>() { return new HashMap<String, String>() {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
{ {
put("%mod%", blockId.getNamespace() ); put("%mod%", blockId.getNamespace());
put("%top%", "polished_" + name); put("%top%", "polished_" + name);
put("%base%", "polished_" + name); put("%base%", "polished_" + name);
put("%pillar%", name + "_pillar"); put("%pillar%", name + "_pillar");

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Random;
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.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -19,9 +17,11 @@ import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.blocks.basis.EndUnderwaterPlantBlock; import ru.betterend.blocks.basis.EndUnderwaterPlantBlock;
import java.util.Random;
public class PondAnemoneBlock extends EndUnderwaterPlantBlock { public class PondAnemoneBlock extends EndUnderwaterPlantBlock {
private static final VoxelShape SHAPE = Block.box(2, 0, 2, 14, 14, 14); private static final VoxelShape SHAPE = Block.box(2, 0, 2, 14, 14, 14);
public PondAnemoneBlock() { public PondAnemoneBlock() {
super(FabricBlockSettings.of(Material.WATER_PLANT) super(FabricBlockSettings.of(Material.WATER_PLANT)
.breakByTool(FabricToolTags.SHEARS) .breakByTool(FabricToolTags.SHEARS)
@ -30,7 +30,7 @@ public class PondAnemoneBlock extends EndUnderwaterPlantBlock {
.sound(SoundType.CORAL_BLOCK) .sound(SoundType.CORAL_BLOCK)
.noCollission()); .noCollission());
} }
@Override @Override
public BlockBehaviour.OffsetType getOffsetType() { public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE; return BlockBehaviour.OffsetType.NONE;
@ -43,12 +43,12 @@ public class PondAnemoneBlock extends EndUnderwaterPlantBlock {
double z = pos.getZ() + random.nextDouble(); double z = pos.getZ() + random.nextDouble();
world.addParticle(ParticleTypes.BUBBLE, x, y, z, 0.0D, 0.0D, 0.0D); world.addParticle(ParticleTypes.BUBBLE, x, y, z, 0.0D, 0.0D, 0.0D);
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE; return SHAPE;
} }
@Override @Override
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) { public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
return false; return false;

View file

@ -17,7 +17,7 @@ public class PythadendronSaplingBlock extends FeatureSaplingBlock {
protected Feature<?> getFeature() { protected Feature<?> getFeature() {
return EndFeatures.PYTHADENDRON_TREE.getFeature(); return EndFeatures.PYTHADENDRON_TREE.getFeature();
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return world.getBlockState(pos.below()).is(EndBlocks.CHORUS_NYLIUM); return world.getBlockState(pos.below()).is(EndBlocks.CHORUS_NYLIUM);

View file

@ -1,11 +1,6 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.List;
import org.jetbrains.annotations.Nullable;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
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;
@ -35,6 +30,7 @@ import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.BlockHitResult;
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 org.jetbrains.annotations.Nullable;
import ru.bclib.blocks.BaseBlock; import ru.bclib.blocks.BaseBlock;
import ru.bclib.blocks.BlockProperties; import ru.bclib.blocks.BlockProperties;
import ru.bclib.blocks.BlockProperties.TripleShape; import ru.bclib.blocks.BlockProperties.TripleShape;
@ -47,28 +43,30 @@ import ru.betterend.particle.InfusionParticleType;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems; import ru.betterend.registry.EndItems;
import java.util.List;
public class RespawnObeliskBlock extends BaseBlock implements IColorProvider, IRenderTyped { public class RespawnObeliskBlock extends BaseBlock implements IColorProvider, IRenderTyped {
private static final VoxelShape VOXEL_SHAPE_BOTTOM = Block.box(1, 0, 1, 15, 16, 15); private static final VoxelShape VOXEL_SHAPE_BOTTOM = Block.box(1, 0, 1, 15, 16, 15);
private static final VoxelShape VOXEL_SHAPE_MIDDLE_TOP = Block.box(2, 0, 2, 14, 16, 14); private static final VoxelShape VOXEL_SHAPE_MIDDLE_TOP = Block.box(2, 0, 2, 14, 16, 14);
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE; public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
public RespawnObeliskBlock() { public RespawnObeliskBlock() {
super(FabricBlockSettings.copyOf(Blocks.END_STONE).luminance((state) -> { super(FabricBlockSettings.copyOf(Blocks.END_STONE).luminance((state) -> {
return (state.getValue(SHAPE) == TripleShape.BOTTOM) ? 0 : 15; return (state.getValue(SHAPE) == TripleShape.BOTTOM) ? 0 : 15;
})); }));
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return (state.getValue(SHAPE) == TripleShape.BOTTOM) ? VOXEL_SHAPE_BOTTOM : VOXEL_SHAPE_MIDDLE_TOP; return (state.getValue(SHAPE) == TripleShape.BOTTOM) ? VOXEL_SHAPE_BOTTOM : VOXEL_SHAPE_MIDDLE_TOP;
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(SHAPE); stateManager.add(SHAPE);
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
@ -78,7 +76,7 @@ public class RespawnObeliskBlock extends BaseBlock implements IColorProvider, IR
} }
return true; return true;
} }
@Override @Override
public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) { public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) {
state = this.defaultBlockState(); state = this.defaultBlockState();
@ -86,7 +84,7 @@ public class RespawnObeliskBlock extends BaseBlock implements IColorProvider, IR
BlocksHelper.setWithUpdate(world, pos.above(), state.setValue(SHAPE, TripleShape.MIDDLE)); BlocksHelper.setWithUpdate(world, pos.above(), state.setValue(SHAPE, TripleShape.MIDDLE));
BlocksHelper.setWithUpdate(world, pos.above(2), state.setValue(SHAPE, TripleShape.TOP)); BlocksHelper.setWithUpdate(world, pos.above(2), state.setValue(SHAPE, TripleShape.TOP));
} }
@Override @Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
TripleShape shape = state.getValue(SHAPE); TripleShape shape = state.getValue(SHAPE);
@ -115,7 +113,7 @@ public class RespawnObeliskBlock extends BaseBlock implements IColorProvider, IR
} }
} }
} }
@Override @Override
public void playerWillDestroy(Level world, BlockPos pos, BlockState state, Player player) { public void playerWillDestroy(Level world, BlockPos pos, BlockState state, Player player) {
if (player.isCreative()) { if (player.isCreative()) {
@ -129,7 +127,7 @@ public class RespawnObeliskBlock extends BaseBlock implements IColorProvider, IR
} }
super.playerWillDestroy(world, pos, state, player); super.playerWillDestroy(world, pos, state, player);
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
if (state.getValue(SHAPE) == TripleShape.BOTTOM) { if (state.getValue(SHAPE) == TripleShape.BOTTOM) {
@ -144,12 +142,12 @@ public class RespawnObeliskBlock extends BaseBlock implements IColorProvider, IR
public BCLRenderLayer getRenderLayer() { public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.TRANSLUCENT; return BCLRenderLayer.TRANSLUCENT;
} }
@Override @Override
public BlockColor getProvider() { public BlockColor getProvider() {
return ((IColorProvider) EndBlocks.AURORA_CRYSTAL).getProvider(); return ((IColorProvider) EndBlocks.AURORA_CRYSTAL).getProvider();
} }
@Override @Override
public ItemColor getItemProvider() { public ItemColor getItemProvider() {
return (stack, tintIndex) -> { return (stack, tintIndex) -> {
@ -193,10 +191,10 @@ public class RespawnObeliskBlock extends BaseBlock implements IColorProvider, IR
((ServerLevel) world).sendParticles(particle, px, py1, pz, 20, 0.14, 0.5, 0.14, 0.1); ((ServerLevel) world).sendParticles(particle, px, py1, pz, 20, 0.14, 0.5, 0.14, 0.1);
((ServerLevel) world).sendParticles(particle, px, py2, pz, 20, 0.14, 0.3, 0.14, 0.1); ((ServerLevel) world).sendParticles(particle, px, py2, pz, 20, 0.14, 0.3, 0.14, 0.1);
} }
world.playSound(null, px, py, py, SoundEvents.RESPAWN_ANCHOR_SET_SPAWN, SoundSource.BLOCKS, 1F, 1F); world.playSound(null, px, py, py, SoundEvents.RESPAWN_ANCHOR_SET_SPAWN, SoundSource.BLOCKS, 1F, 1F);
if (!player.isCreative()) { if (!player.isCreative()) {
itemStack.shrink(6); itemStack.shrink(6);
} }
} }
return player.isCreative() ? InteractionResult.PASS : InteractionResult.sidedSuccess(world.isClientSide); return player.isCreative() ? InteractionResult.PASS : InteractionResult.sidedSuccess(world.isClientSide);
} }

View file

@ -1,9 +1,6 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.List;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Explosion; import net.minecraft.world.level.Explosion;
@ -18,30 +15,32 @@ import ru.bclib.blocks.BlockProperties;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.List;
public class RunedFlavolite extends BaseBlock { public class RunedFlavolite extends BaseBlock {
public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVE; public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVE;
public RunedFlavolite(boolean unbreakable) { public RunedFlavolite(boolean unbreakable) {
super(FabricBlockSettings.copyOf(EndBlocks.FLAVOLITE.polished) super(FabricBlockSettings.copyOf(EndBlocks.FLAVOLITE.polished)
.strength( .strength(
unbreakable ? -1 : 1, unbreakable ? -1 : 1,
unbreakable ? Blocks.BEDROCK.getExplosionResistance() : Blocks.OBSIDIAN.getExplosionResistance() unbreakable ? Blocks.BEDROCK.getExplosionResistance() : Blocks.OBSIDIAN.getExplosionResistance()
).luminance(state -> { ).luminance(state -> {
return state.getValue(ACTIVATED) ? 8 : 0; return state.getValue(ACTIVATED) ? 8 : 0;
})); }));
this.registerDefaultState(stateDefinition.any().setValue(ACTIVATED, false)); this.registerDefaultState(stateDefinition.any().setValue(ACTIVATED, false));
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(ACTIVATED); stateManager.add(ACTIVATED);
} }
@Override @Override
public boolean dropFromExplosion(Explosion explosion) { public boolean dropFromExplosion(Explosion explosion) {
return !BlocksHelper.isInvulnerableUnsafe(this.defaultBlockState()); return !BlocksHelper.isInvulnerableUnsafe(this.defaultBlockState());
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
if (BlocksHelper.isInvulnerableUnsafe(this.defaultBlockState())) { if (BlocksHelper.isInvulnerableUnsafe(this.defaultBlockState())) {

View file

@ -12,11 +12,11 @@ import ru.betterend.registry.EndItems;
public class ShadowBerryBlock extends BaseCropBlock { public class ShadowBerryBlock extends BaseCropBlock {
private static final VoxelShape SHAPE = Block.box(1, 0, 1, 15, 8, 15); private static final VoxelShape SHAPE = Block.box(1, 0, 1, 15, 8, 15);
public ShadowBerryBlock() { public ShadowBerryBlock() {
super(EndItems.SHADOW_BERRY_RAW, EndBlocks.SHADOW_GRASS); super(EndItems.SHADOW_BERRY_RAW, EndBlocks.SHADOW_GRASS);
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE; return SHAPE;

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -11,6 +9,8 @@ import net.minecraft.world.level.material.MaterialColor;
import ru.betterend.blocks.basis.EndTerrainBlock; import ru.betterend.blocks.basis.EndTerrainBlock;
import ru.betterend.registry.EndParticles; import ru.betterend.registry.EndParticles;
import java.util.Random;
public class ShadowGrassBlock extends EndTerrainBlock { public class ShadowGrassBlock extends EndTerrainBlock {
public ShadowGrassBlock() { public ShadowGrassBlock() {
super(MaterialColor.COLOR_BLACK); super(MaterialColor.COLOR_BLACK);

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -36,26 +34,28 @@ import ru.betterend.entity.SilkMothEntity;
import ru.betterend.registry.EndEntities; import ru.betterend.registry.EndEntities;
import ru.betterend.registry.EndItems; import ru.betterend.registry.EndItems;
import java.util.Random;
public class SilkMothHiveBlock extends BaseBlock { public class SilkMothHiveBlock extends BaseBlock {
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING; public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
public static final IntegerProperty FULLNESS = EndBlockProperties.FULLNESS; public static final IntegerProperty FULLNESS = EndBlockProperties.FULLNESS;
public SilkMothHiveBlock() { public SilkMothHiveBlock() {
super(FabricBlockSettings.of(Material.WOOD).breakByHand(true).hardness(0.5F).resistance(0.1F).sound(SoundType.WOOL).noOcclusion().randomTicks()); super(FabricBlockSettings.of(Material.WOOD).breakByHand(true).hardness(0.5F).resistance(0.1F).sound(SoundType.WOOL).noOcclusion().randomTicks());
this.registerDefaultState(defaultBlockState().setValue(FULLNESS, 0)); this.registerDefaultState(defaultBlockState().setValue(FULLNESS, 0));
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(FACING, FULLNESS); stateManager.add(FACING, FULLNESS);
} }
@Override @Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) { public BlockState getStateForPlacement(BlockPlaceContext ctx) {
Direction dir = ctx.getHorizontalDirection().getOpposite(); Direction dir = ctx.getHorizontalDirection().getOpposite();
return this.defaultBlockState().setValue(FACING, dir); return this.defaultBlockState().setValue(FACING, dir);
} }
@Override @Override
public BlockState rotate(BlockState state, Rotation rotation) { public BlockState rotate(BlockState state, Rotation rotation) {
return BlocksHelper.rotateHorizontal(state, rotation, FACING); return BlocksHelper.rotateHorizontal(state, rotation, FACING);
@ -65,7 +65,7 @@ public class SilkMothHiveBlock extends BaseBlock {
public BlockState mirror(BlockState state, Mirror mirror) { public BlockState mirror(BlockState state, Mirror mirror) {
return BlocksHelper.mirrorHorizontal(state, mirror, FACING); return BlocksHelper.mirrorHorizontal(state, mirror, FACING);
} }
@Override @Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
Direction dir = state.getValue(FACING); Direction dir = state.getValue(FACING);
@ -73,7 +73,9 @@ public class SilkMothHiveBlock extends BaseBlock {
if (!world.getBlockState(spawn).isAir()) { if (!world.getBlockState(spawn).isAir()) {
return; return;
} }
int count = world.getEntities(EndEntities.SILK_MOTH, new AABB(pos).inflate(16), (entity) -> { return true; }).size(); int count = world.getEntities(EndEntities.SILK_MOTH, new AABB(pos).inflate(16), (entity) -> {
return true;
}).size();
if (count > 6) { if (count > 6) {
return; return;
} }
@ -84,7 +86,7 @@ public class SilkMothHiveBlock extends BaseBlock {
world.addFreshEntity(moth); world.addFreshEntity(moth);
world.playSound(null, pos, SoundEvents.BEEHIVE_EXIT, SoundSource.BLOCKS, 1, 1); world.playSound(null, pos, SoundEvents.BEEHIVE_EXIT, SoundSource.BLOCKS, 1, 1);
} }
@Override @Override
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if (hand == InteractionHand.MAIN_HAND) { if (hand == InteractionHand.MAIN_HAND) {

View file

@ -1,9 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -48,23 +44,27 @@ import ru.betterend.entity.SilkMothEntity;
import ru.betterend.registry.EndEntities; import ru.betterend.registry.EndEntities;
import ru.betterend.registry.EndItems; import ru.betterend.registry.EndItems;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public class SilkMothNestBlock extends BaseBlock implements IRenderTyped { public class SilkMothNestBlock extends BaseBlock implements IRenderTyped {
public static final BooleanProperty ACTIVE = EndBlockProperties.ACTIVE; public static final BooleanProperty ACTIVE = EndBlockProperties.ACTIVE;
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING; public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
public static final IntegerProperty FULLNESS = EndBlockProperties.FULLNESS; public static final IntegerProperty FULLNESS = EndBlockProperties.FULLNESS;
private static final VoxelShape TOP = box(6, 0, 6, 10, 16, 10); private static final VoxelShape TOP = box(6, 0, 6, 10, 16, 10);
private static final VoxelShape BOTTOM = box(0, 0, 0, 16, 16, 16); private static final VoxelShape BOTTOM = box(0, 0, 0, 16, 16, 16);
public SilkMothNestBlock() { public SilkMothNestBlock() {
super(FabricBlockSettings.of(Material.WOOL).hardness(0.5F).resistance(0.1F).sound(SoundType.WOOL).noOcclusion().randomTicks()); super(FabricBlockSettings.of(Material.WOOL).hardness(0.5F).resistance(0.1F).sound(SoundType.WOOL).noOcclusion().randomTicks());
this.registerDefaultState(defaultBlockState().setValue(ACTIVE, true).setValue(FULLNESS, 0)); this.registerDefaultState(defaultBlockState().setValue(ACTIVE, true).setValue(FULLNESS, 0));
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(ACTIVE, FACING, FULLNESS); stateManager.add(ACTIVE, FACING, FULLNESS);
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return state.getValue(ACTIVE) ? BOTTOM : TOP; return state.getValue(ACTIVE) ? BOTTOM : TOP;
@ -74,13 +74,13 @@ public class SilkMothNestBlock extends BaseBlock implements IRenderTyped {
public BCLRenderLayer getRenderLayer() { public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT; return BCLRenderLayer.CUTOUT;
} }
@Override @Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) { public BlockState getStateForPlacement(BlockPlaceContext ctx) {
Direction dir = ctx.getHorizontalDirection().getOpposite(); Direction dir = ctx.getHorizontalDirection().getOpposite();
return this.defaultBlockState().setValue(FACING, dir); return this.defaultBlockState().setValue(FACING, dir);
} }
@Override @Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (!state.getValue(ACTIVE)) { if (!state.getValue(ACTIVE)) {
@ -93,7 +93,7 @@ public class SilkMothNestBlock extends BaseBlock implements IRenderTyped {
} }
return state; return state;
} }
@Override @Override
public BlockState rotate(BlockState state, Rotation rotation) { public BlockState rotate(BlockState state, Rotation rotation) {
return BlocksHelper.rotateHorizontal(state, rotation, FACING); return BlocksHelper.rotateHorizontal(state, rotation, FACING);
@ -103,12 +103,12 @@ public class SilkMothNestBlock extends BaseBlock implements IRenderTyped {
public BlockState mirror(BlockState state, Mirror mirror) { public BlockState mirror(BlockState state, Mirror mirror) {
return BlocksHelper.mirrorHorizontal(state, mirror, FACING); return BlocksHelper.mirrorHorizontal(state, mirror, FACING);
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return state.getValue(ACTIVE) ? Collections.singletonList(new ItemStack(this)) : Collections.emptyList(); return state.getValue(ACTIVE) ? Collections.singletonList(new ItemStack(this)) : Collections.emptyList();
} }
@Override @Override
public void playerWillDestroy(Level world, BlockPos pos, BlockState state, Player player) { public void playerWillDestroy(Level world, BlockPos pos, BlockState state, Player player) {
if (!state.getValue(ACTIVE) && player.isCreative()) { if (!state.getValue(ACTIVE) && player.isCreative()) {
@ -120,7 +120,7 @@ public class SilkMothNestBlock extends BaseBlock implements IRenderTyped {
} }
super.playerWillDestroy(world, pos, state, player); super.playerWillDestroy(world, pos, state, player);
} }
@Override @Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
if (!state.getValue(ACTIVE)) { if (!state.getValue(ACTIVE)) {
@ -134,7 +134,9 @@ public class SilkMothNestBlock extends BaseBlock implements IRenderTyped {
if (!world.getBlockState(spawn).isAir()) { if (!world.getBlockState(spawn).isAir()) {
return; return;
} }
int count = world.getEntities(EndEntities.SILK_MOTH, new AABB(pos).inflate(16), (entity) -> { return true; }).size(); int count = world.getEntities(EndEntities.SILK_MOTH, new AABB(pos).inflate(16), (entity) -> {
return true;
}).size();
if (count > 6) { if (count > 6) {
return; return;
} }
@ -145,7 +147,7 @@ public class SilkMothNestBlock extends BaseBlock implements IRenderTyped {
world.addFreshEntity(moth); world.addFreshEntity(moth);
world.playSound(null, pos, SoundEvents.BEEHIVE_EXIT, SoundSource.BLOCKS, 1, 1); world.playSound(null, pos, SoundEvents.BEEHIVE_EXIT, SoundSource.BLOCKS, 1, 1);
} }
@Override @Override
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if (hand == InteractionHand.MAIN_HAND) { if (hand == InteractionHand.MAIN_HAND) {

View file

@ -20,12 +20,12 @@ import java.util.Random;
public class SmallAmaranitaBlock extends EndPlantBlock { public class SmallAmaranitaBlock extends EndPlantBlock {
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 10, 12); private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 10, 12);
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.SANGNUM) || state.is(EndBlocks.MOSSY_OBSIDIAN) || state.is(EndBlocks.MOSSY_DRAGON_BONE); return state.is(EndBlocks.SANGNUM) || state.is(EndBlocks.MOSSY_OBSIDIAN) || state.is(EndBlocks.MOSSY_DRAGON_BONE);
} }
@Override @Override
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) { public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) {
BlockPos bigPos = growBig(world, pos); BlockPos bigPos = growBig(world, pos);
@ -40,13 +40,13 @@ public class SmallAmaranitaBlock extends EndPlantBlock {
} }
EndFeatures.LARGE_AMARANITA.getFeature().place(new FeaturePlaceContext<>(world, null, random, pos, null)); EndFeatures.LARGE_AMARANITA.getFeature().place(new FeaturePlaceContext<>(world, null, random, pos, null));
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
Vec3 vec3d = state.getOffset(view, pos); Vec3 vec3d = state.getOffset(view, pos);
return SHAPE.move(vec3d.x, vec3d.y, vec3d.z); return SHAPE.move(vec3d.x, vec3d.y, vec3d.z);
} }
private BlockPos growBig(ServerLevel world, BlockPos pos) { private BlockPos growBig(ServerLevel world, BlockPos pos) {
for (int x = -1; x < 2; x++) { for (int x = -1; x < 2; x++) {
for (int z = -1; z < 2; z++) { for (int z = -1; z < 2; z++) {
@ -58,20 +58,20 @@ public class SmallAmaranitaBlock extends EndPlantBlock {
} }
return null; return null;
} }
private boolean checkFrame(ServerLevel world, BlockPos pos) { private boolean checkFrame(ServerLevel world, BlockPos pos) {
return world.getBlockState(pos).is(this) && return world.getBlockState(pos).is(this) &&
world.getBlockState(pos.south()).is(this) && world.getBlockState(pos.south()).is(this) &&
world.getBlockState(pos.east()).is(this) && world.getBlockState(pos.east()).is(this) &&
world.getBlockState(pos.south().east()).is(this); world.getBlockState(pos.south().east()).is(this);
} }
private void replaceMushroom(ServerLevel world, BlockPos pos) { private void replaceMushroom(ServerLevel world, BlockPos pos) {
if (world.getBlockState(pos).is(this)) { if (world.getBlockState(pos).is(this)) {
BlocksHelper.setWithUpdate(world, pos, Blocks.AIR); BlocksHelper.setWithUpdate(world, pos, Blocks.AIR);
} }
} }
@Override @Override
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) { public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
return random.nextInt(8) == 0; return random.nextInt(8) == 0;

View file

@ -1,12 +1,7 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.EnumMap;
import java.util.List;
import java.util.Random;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -37,9 +32,13 @@ import ru.bclib.interfaces.IRenderTyped;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
import ru.betterend.registry.EndFeatures; import ru.betterend.registry.EndFeatures;
import java.util.EnumMap;
import java.util.List;
import java.util.Random;
public class SmallJellyshroomBlock extends BaseAttachedBlock implements IRenderTyped, BonemealableBlock { public class SmallJellyshroomBlock extends BaseAttachedBlock implements IRenderTyped, BonemealableBlock {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class); private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
public SmallJellyshroomBlock() { public SmallJellyshroomBlock() {
super(FabricBlockSettings.of(Material.PLANT) super(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS) .breakByTool(FabricToolTags.SHEARS)
@ -53,7 +52,7 @@ public class SmallJellyshroomBlock extends BaseAttachedBlock implements IRenderT
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return BOUNDING_SHAPES.get(state.getValue(FACING)); return BOUNDING_SHAPES.get(state.getValue(FACING));
} }
@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);
@ -64,7 +63,7 @@ public class SmallJellyshroomBlock extends BaseAttachedBlock implements IRenderT
return Lists.newArrayList(); return Lists.newArrayList();
} }
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
Direction direction = state.getValue(FACING); Direction direction = state.getValue(FACING);
@ -72,12 +71,12 @@ public class SmallJellyshroomBlock extends BaseAttachedBlock implements IRenderT
BlockState support = world.getBlockState(blockPos); BlockState support = world.getBlockState(blockPos);
return canSupportCenter(world, blockPos, direction) && support.canOcclude() && support.getLightEmission() == 0; return canSupportCenter(world, blockPos, direction) && support.canOcclude() && support.getLightEmission() == 0;
} }
@Override @Override
public BCLRenderLayer getRenderLayer() { public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT; return BCLRenderLayer.CUTOUT;
} }
static { static {
BOUNDING_SHAPES.put(Direction.UP, Block.box(3, 0, 3, 13, 16, 13)); BOUNDING_SHAPES.put(Direction.UP, Block.box(3, 0, 3, 13, 16, 13));
BOUNDING_SHAPES.put(Direction.DOWN, Block.box(3, 0, 3, 13, 16, 13)); BOUNDING_SHAPES.put(Direction.DOWN, Block.box(3, 0, 3, 13, 16, 13));

View file

@ -1,9 +1,6 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.EnumMap;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -32,11 +29,13 @@ import ru.bclib.blocks.BaseAttachedBlock;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped; import ru.bclib.interfaces.IRenderTyped;
import java.util.EnumMap;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class SmaragdantCrystalShardBlock extends BaseAttachedBlock implements IRenderTyped, SimpleWaterloggedBlock, LiquidBlockContainer { public class SmaragdantCrystalShardBlock extends BaseAttachedBlock implements IRenderTyped, SimpleWaterloggedBlock, LiquidBlockContainer {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class); private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public SmaragdantCrystalShardBlock() { public SmaragdantCrystalShardBlock() {
super(FabricBlockSettings.of(Material.STONE) super(FabricBlockSettings.of(Material.STONE)
.materialColor(MaterialColor.COLOR_GREEN) .materialColor(MaterialColor.COLOR_GREEN)
@ -46,18 +45,18 @@ public class SmaragdantCrystalShardBlock extends BaseAttachedBlock implements IR
.requiresCorrectToolForDrops() .requiresCorrectToolForDrops()
.noCollission()); .noCollission());
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
super.createBlockStateDefinition(stateManager); super.createBlockStateDefinition(stateManager);
stateManager.add(WATERLOGGED); stateManager.add(WATERLOGGED);
} }
@Override @Override
public BCLRenderLayer getRenderLayer() { public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT; return BCLRenderLayer.CUTOUT;
} }
@Override @Override
public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) { public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) {
return !state.getValue(WATERLOGGED); return !state.getValue(WATERLOGGED);
@ -67,7 +66,7 @@ public class SmaragdantCrystalShardBlock extends BaseAttachedBlock implements IR
public boolean placeLiquid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) { public boolean placeLiquid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
return !state.getValue(WATERLOGGED); return !state.getValue(WATERLOGGED);
} }
@Override @Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) { public BlockState getStateForPlacement(BlockPlaceContext ctx) {
BlockState state = super.getStateForPlacement(ctx); BlockState state = super.getStateForPlacement(ctx);
@ -79,24 +78,24 @@ public class SmaragdantCrystalShardBlock extends BaseAttachedBlock implements IR
} }
return null; return null;
} }
@Override @Override
public FluidState getFluidState(BlockState state) { public FluidState getFluidState(BlockState state) {
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState(); return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState();
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return BOUNDING_SHAPES.get(state.getValue(FACING)); return BOUNDING_SHAPES.get(state.getValue(FACING));
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
Direction direction = state.getValue(FACING); Direction direction = state.getValue(FACING);
BlockPos blockPos = pos.relative(direction.getOpposite()); BlockPos blockPos = pos.relative(direction.getOpposite());
return world.getBlockState(blockPos).isFaceSturdy(world, blockPos, direction); return world.getBlockState(blockPos).isFaceSturdy(world, blockPos, direction);
} }
static { static {
BOUNDING_SHAPES.put(Direction.UP, Shapes.box(0.125, 0.0, 0.125, 0.875F, 0.875F, 0.875F)); BOUNDING_SHAPES.put(Direction.UP, Shapes.box(0.125, 0.0, 0.125, 0.875F, 0.875F, 0.875F));
BOUNDING_SHAPES.put(Direction.DOWN, Shapes.box(0.125, 0.125, 0.125, 0.875F, 1.0, 0.875F)); BOUNDING_SHAPES.put(Direction.DOWN, Shapes.box(0.125, 0.125, 0.125, 0.875F, 1.0, 0.875F));

View file

@ -1,12 +1,7 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Collections;
import java.util.EnumMap;
import java.util.List;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -41,12 +36,16 @@ import ru.bclib.util.MHelper;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems; import ru.betterend.registry.EndItems;
import java.util.Collections;
import java.util.EnumMap;
import java.util.List;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class SulphurCrystalBlock extends BaseAttachedBlock implements IRenderTyped, SimpleWaterloggedBlock, LiquidBlockContainer { public class SulphurCrystalBlock extends BaseAttachedBlock implements IRenderTyped, SimpleWaterloggedBlock, LiquidBlockContainer {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class); private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
public static final IntegerProperty AGE = IntegerProperty.create("age", 0, 2); public static final IntegerProperty AGE = IntegerProperty.create("age", 0, 2);
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public SulphurCrystalBlock() { public SulphurCrystalBlock() {
super(FabricBlockSettings.of(Material.STONE) super(FabricBlockSettings.of(Material.STONE)
.materialColor(MaterialColor.COLOR_YELLOW) .materialColor(MaterialColor.COLOR_YELLOW)
@ -55,23 +54,23 @@ public class SulphurCrystalBlock extends BaseAttachedBlock implements IRenderTyp
.requiresCorrectToolForDrops() .requiresCorrectToolForDrops()
.noCollission()); .noCollission());
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
super.createBlockStateDefinition(stateManager); super.createBlockStateDefinition(stateManager);
stateManager.add(AGE, WATERLOGGED); stateManager.add(AGE, WATERLOGGED);
} }
@Override @Override
public BCLRenderLayer getRenderLayer() { public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT; return BCLRenderLayer.CUTOUT;
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return state.getValue(AGE) < 2 ? Collections.emptyList() : Lists.newArrayList(new ItemStack(EndItems.CRYSTALLINE_SULPHUR, MHelper.randRange(1, 3, MHelper.RANDOM))); return state.getValue(AGE) < 2 ? Collections.emptyList() : Lists.newArrayList(new ItemStack(EndItems.CRYSTALLINE_SULPHUR, MHelper.randRange(1, 3, MHelper.RANDOM)));
} }
@Override @Override
public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) { public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) {
return !state.getValue(WATERLOGGED); return !state.getValue(WATERLOGGED);
@ -81,7 +80,7 @@ public class SulphurCrystalBlock extends BaseAttachedBlock implements IRenderTyp
public boolean placeLiquid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) { public boolean placeLiquid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
return !state.getValue(WATERLOGGED); return !state.getValue(WATERLOGGED);
} }
@Override @Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) { public BlockState getStateForPlacement(BlockPlaceContext ctx) {
BlockState state = super.getStateForPlacement(ctx); BlockState state = super.getStateForPlacement(ctx);
@ -93,24 +92,24 @@ public class SulphurCrystalBlock extends BaseAttachedBlock implements IRenderTyp
} }
return null; return null;
} }
@Override @Override
public FluidState getFluidState(BlockState state) { public FluidState getFluidState(BlockState state) {
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState(); return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState();
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return BOUNDING_SHAPES.get(state.getValue(FACING)); return BOUNDING_SHAPES.get(state.getValue(FACING));
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
Direction direction = state.getValue(FACING); Direction direction = state.getValue(FACING);
BlockPos blockPos = pos.relative(direction.getOpposite()); BlockPos blockPos = pos.relative(direction.getOpposite());
return world.getBlockState(blockPos).is(EndBlocks.BRIMSTONE); return world.getBlockState(blockPos).is(EndBlocks.BRIMSTONE);
} }
static { static {
BOUNDING_SHAPES.put(Direction.UP, Shapes.box(0.125, 0.0, 0.125, 0.875F, 0.5, 0.875F)); BOUNDING_SHAPES.put(Direction.UP, Shapes.box(0.125, 0.0, 0.125, 0.875F, 0.5, 0.875F));
BOUNDING_SHAPES.put(Direction.DOWN, Shapes.box(0.125, 0.5, 0.125, 0.875F, 1.0, 0.875F)); BOUNDING_SHAPES.put(Direction.DOWN, Shapes.box(0.125, 0.5, 0.125, 0.875F, 1.0, 0.875F));

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.client.color.block.BlockColor; import net.minecraft.client.color.block.BlockColor;
@ -18,9 +16,11 @@ import ru.bclib.util.ColorUtil;
import ru.bclib.util.MHelper; import ru.bclib.util.MHelper;
import ru.betterend.registry.EndParticles; import ru.betterend.registry.EndParticles;
import java.util.Random;
public class TenaneaFlowersBlock extends BaseVineBlock implements IColorProvider { public class TenaneaFlowersBlock extends BaseVineBlock implements IColorProvider {
public static final Vec3i[] COLORS; public static final Vec3i[] COLORS;
public TenaneaFlowersBlock() { public TenaneaFlowersBlock() {
super(15); super(15);
} }
@ -30,22 +30,23 @@ public class TenaneaFlowersBlock extends BaseVineBlock implements IColorProvider
return (state, world, pos, tintIndex) -> { return (state, world, pos, tintIndex) -> {
if (pos == null) { if (pos == null) {
pos = BlockPos.ZERO; pos = BlockPos.ZERO;
}; }
;
long i = (MHelper.getRandom(pos.getX(), pos.getZ()) & 63) + pos.getY(); long i = (MHelper.getRandom(pos.getX(), pos.getZ()) & 63) + pos.getY();
double delta = i * 0.1; double delta = i * 0.1;
int index = MHelper.floor(delta); int index = MHelper.floor(delta);
int index2 = (index + 1) & 3; int index2 = (index + 1) & 3;
delta -= index; delta -= index;
index &= 3; index &= 3;
Vec3i color1 = COLORS[index]; Vec3i color1 = COLORS[index];
Vec3i color2 = COLORS[index2]; Vec3i color2 = COLORS[index2];
int r = MHelper.floor(Mth.lerp(delta, color1.getX(), color2.getX())); int r = MHelper.floor(Mth.lerp(delta, color1.getX(), color2.getX()));
int g = MHelper.floor(Mth.lerp(delta, color1.getY(), color2.getY())); int g = MHelper.floor(Mth.lerp(delta, color1.getY(), color2.getY()));
int b = MHelper.floor(Mth.lerp(delta, color1.getZ(), color2.getZ())); int b = MHelper.floor(Mth.lerp(delta, color1.getZ(), color2.getZ()));
float[] hsb = ColorUtil.RGBtoHSB(r, g, b, new float[3]); float[] hsb = ColorUtil.RGBtoHSB(r, g, b, new float[3]);
return ColorUtil.HSBtoRGB(hsb[0], MHelper.max(0.5F, hsb[1]), hsb[2]); return ColorUtil.HSBtoRGB(hsb[0], MHelper.max(0.5F, hsb[1]), hsb[2]);
}; };
} }
@ -54,12 +55,12 @@ public class TenaneaFlowersBlock extends BaseVineBlock implements IColorProvider
public ItemColor getItemProvider() { public ItemColor getItemProvider() {
return (stack, tintIndex) -> ColorUtil.color(255, 255, 255); return (stack, tintIndex) -> ColorUtil.color(255, 255, 255);
} }
@Override @Override
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) { public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
return false; return false;
} }
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) { public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
super.animateTick(state, world, pos, random); super.animateTick(state, world, pos, random);
@ -70,13 +71,13 @@ public class TenaneaFlowersBlock extends BaseVineBlock implements IColorProvider
world.addParticle(EndParticles.TENANEA_PETAL, x, y, z, 0, 0, 0); world.addParticle(EndParticles.TENANEA_PETAL, x, y, z, 0, 0, 0);
} }
} }
static { static {
COLORS = new Vec3i[] { COLORS = new Vec3i[]{
new Vec3i(250, 111, 222), new Vec3i(250, 111, 222),
new Vec3i(167, 89, 255), new Vec3i(167, 89, 255),
new Vec3i(120, 207, 239), new Vec3i(120, 207, 239),
new Vec3i(255, 87, 182) new Vec3i(255, 87, 182)
}; };
} }
} }

View file

@ -17,7 +17,7 @@ public class TenaneaSaplingBlock extends FeatureSaplingBlock {
protected Feature<?> getFeature() { protected Feature<?> getFeature() {
return EndFeatures.TENANEA.getFeature(); return EndFeatures.TENANEA.getFeature();
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return world.getBlockState(pos.below()).is(EndBlocks.PINK_MOSS); return world.getBlockState(pos.below()).is(EndBlocks.PINK_MOSS);

View file

@ -6,15 +6,15 @@ import ru.betterend.blocks.basis.EndPlantBlock;
public class TerrainPlantBlock extends EndPlantBlock { public class TerrainPlantBlock extends EndPlantBlock {
private final Block[] ground; private final Block[] ground;
public TerrainPlantBlock(Block... ground) { public TerrainPlantBlock(Block... ground) {
super(true); super(true);
this.ground = ground; this.ground = ground;
} }
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
for (Block block: ground) { for (Block block : ground) {
if (state.is(block)) { if (state.is(block)) {
return true; return true;
} }

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -14,34 +12,36 @@ import ru.bclib.util.BlocksHelper;
import ru.betterend.blocks.basis.EndPlantBlock; import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class TwistedUmbrellaMossBlock extends EndPlantBlock { public class TwistedUmbrellaMossBlock extends EndPlantBlock {
public TwistedUmbrellaMossBlock() { public TwistedUmbrellaMossBlock() {
super(11); super(11);
} }
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.END_MOSS) || state.is(EndBlocks.END_MYCELIUM) || state.is(EndBlocks.JUNGLE_MOSS); return state.is(EndBlocks.END_MOSS) || state.is(EndBlocks.END_MYCELIUM) || state.is(EndBlocks.JUNGLE_MOSS);
} }
@Environment(EnvType.CLIENT)
public boolean hasEmissiveLighting(BlockGetter world, BlockPos pos) {
return true;
}
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public float getAmbientOcclusionLightLevel(BlockGetter world, BlockPos pos) { public boolean hasEmissiveLighting(BlockGetter world, BlockPos pos) {
return 1F; return true;
} }
@Override @Environment(EnvType.CLIENT)
public float getAmbientOcclusionLightLevel(BlockGetter world, BlockPos pos) {
return 1F;
}
@Override
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) { public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
return world.isEmptyBlock(pos.above()); return world.isEmptyBlock(pos.above());
} }
@Override @Override
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) { public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) {
int rot = world.random.nextInt(4); int rot = world.random.nextInt(4);
BlockState bs = EndBlocks.TWISTED_UMBRELLA_MOSS_TALL.defaultBlockState().setValue(BaseDoublePlantBlock.ROTATION, rot); BlockState bs = EndBlocks.TWISTED_UMBRELLA_MOSS_TALL.defaultBlockState().setValue(BaseDoublePlantBlock.ROTATION, rot);
BlocksHelper.setWithoutUpdate(world, pos, bs); BlocksHelper.setWithoutUpdate(world, pos, bs);
BlocksHelper.setWithoutUpdate(world, pos.above(), bs.setValue(BaseDoublePlantBlock.TOP, true)); BlocksHelper.setWithoutUpdate(world, pos.above(), bs.setValue(BaseDoublePlantBlock.TOP, true));

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.item.ItemEntity;
@ -10,17 +8,19 @@ import net.minecraft.world.level.block.state.BlockState;
import ru.bclib.blocks.BaseDoublePlantBlock; import ru.bclib.blocks.BaseDoublePlantBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class TwistedUmbrellaMossTallBlock extends BaseDoublePlantBlock { public class TwistedUmbrellaMossTallBlock extends BaseDoublePlantBlock {
public TwistedUmbrellaMossTallBlock() { public TwistedUmbrellaMossTallBlock() {
super(12); super(12);
} }
@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(EndBlocks.TWISTED_UMBRELLA_MOSS)); ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, new ItemStack(EndBlocks.TWISTED_UMBRELLA_MOSS));
world.addFreshEntity(item); world.addFreshEntity(item);
} }
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.END_MOSS) || state.is(EndBlocks.END_MYCELIUM) || state.is(EndBlocks.JUNGLE_MOSS); return state.is(EndBlocks.END_MOSS) || state.is(EndBlocks.END_MYCELIUM) || state.is(EndBlocks.JUNGLE_MOSS);

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -14,34 +12,36 @@ import ru.bclib.util.BlocksHelper;
import ru.betterend.blocks.basis.EndPlantBlock; import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class UmbrellaMossBlock extends EndPlantBlock { public class UmbrellaMossBlock extends EndPlantBlock {
public UmbrellaMossBlock() { public UmbrellaMossBlock() {
super(11); super(11);
} }
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.END_MOSS) || state.is(EndBlocks.END_MYCELIUM) || state.is(EndBlocks.JUNGLE_MOSS); return state.is(EndBlocks.END_MOSS) || state.is(EndBlocks.END_MYCELIUM) || state.is(EndBlocks.JUNGLE_MOSS);
} }
@Environment(EnvType.CLIENT)
public boolean hasEmissiveLighting(BlockGetter world, BlockPos pos) {
return true;
}
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public float getAmbientOcclusionLightLevel(BlockGetter world, BlockPos pos) { public boolean hasEmissiveLighting(BlockGetter world, BlockPos pos) {
return 1F; return true;
} }
@Override @Environment(EnvType.CLIENT)
public float getAmbientOcclusionLightLevel(BlockGetter world, BlockPos pos) {
return 1F;
}
@Override
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) { public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
return world.isEmptyBlock(pos.above()); return world.isEmptyBlock(pos.above());
} }
@Override @Override
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) { public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) {
int rot = world.random.nextInt(4); int rot = world.random.nextInt(4);
BlockState bs = EndBlocks.UMBRELLA_MOSS_TALL.defaultBlockState().setValue(BaseDoublePlantBlock.ROTATION, rot); BlockState bs = EndBlocks.UMBRELLA_MOSS_TALL.defaultBlockState().setValue(BaseDoublePlantBlock.ROTATION, rot);
BlocksHelper.setWithoutUpdate(world, pos, bs); BlocksHelper.setWithoutUpdate(world, pos, bs);
BlocksHelper.setWithoutUpdate(world, pos.above(), bs.setValue(BaseDoublePlantBlock.TOP, true)); BlocksHelper.setWithoutUpdate(world, pos.above(), bs.setValue(BaseDoublePlantBlock.TOP, true));

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.item.ItemEntity;
@ -10,17 +8,19 @@ import net.minecraft.world.level.block.state.BlockState;
import ru.bclib.blocks.BaseDoublePlantBlock; import ru.bclib.blocks.BaseDoublePlantBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class UmbrellaMossTallBlock extends BaseDoublePlantBlock { public class UmbrellaMossTallBlock extends BaseDoublePlantBlock {
public UmbrellaMossTallBlock() { public UmbrellaMossTallBlock() {
super(12); super(12);
} }
@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(EndBlocks.UMBRELLA_MOSS)); ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, new ItemStack(EndBlocks.UMBRELLA_MOSS));
world.addFreshEntity(item); world.addFreshEntity(item);
} }
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.END_MOSS) || state.is(EndBlocks.END_MYCELIUM) || state.is(EndBlocks.JUNGLE_MOSS); return state.is(EndBlocks.END_MOSS) || state.is(EndBlocks.END_MYCELIUM) || state.is(EndBlocks.JUNGLE_MOSS);

View file

@ -25,19 +25,19 @@ import ru.betterend.registry.EndItems;
public class UmbrellaTreeClusterBlock extends BaseBlock { public class UmbrellaTreeClusterBlock extends BaseBlock {
public static final BooleanProperty NATURAL = BlockProperties.NATURAL; public static final BooleanProperty NATURAL = BlockProperties.NATURAL;
public UmbrellaTreeClusterBlock() { public UmbrellaTreeClusterBlock() {
super(FabricBlockSettings.copyOf(Blocks.NETHER_WART_BLOCK) super(FabricBlockSettings.copyOf(Blocks.NETHER_WART_BLOCK)
.materialColor(MaterialColor.COLOR_PURPLE) .materialColor(MaterialColor.COLOR_PURPLE)
.luminance(15)); .luminance(15));
registerDefaultState(stateDefinition.any().setValue(NATURAL, false)); registerDefaultState(stateDefinition.any().setValue(NATURAL, false));
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(NATURAL); stateManager.add(NATURAL);
} }
@Override @Override
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
ItemStack stack = player.getMainHandItem(); ItemStack stack = player.getMainHandItem();

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
@ -15,21 +13,23 @@ import ru.bclib.blocks.BaseBlock;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class UmbrellaTreeClusterEmptyBlock extends BaseBlock { public class UmbrellaTreeClusterEmptyBlock extends BaseBlock {
public static final BooleanProperty NATURAL = EndBlockProperties.NATURAL; public static final BooleanProperty NATURAL = EndBlockProperties.NATURAL;
public UmbrellaTreeClusterEmptyBlock() { public UmbrellaTreeClusterEmptyBlock() {
super(FabricBlockSettings.copyOf(Blocks.NETHER_WART_BLOCK) super(FabricBlockSettings.copyOf(Blocks.NETHER_WART_BLOCK)
.materialColor(MaterialColor.COLOR_PURPLE) .materialColor(MaterialColor.COLOR_PURPLE)
.randomTicks()); .randomTicks());
registerDefaultState(stateDefinition.any().setValue(NATURAL, false)); registerDefaultState(stateDefinition.any().setValue(NATURAL, false));
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(NATURAL); stateManager.add(NATURAL);
} }
@Override @Override
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) { public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
if (state.getValue(NATURAL) && random.nextInt(16) == 0) { if (state.getValue(NATURAL) && random.nextInt(16) == 0) {

View file

@ -1,10 +1,6 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
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.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -29,14 +25,17 @@ import ru.bclib.util.MHelper;
import ru.betterend.noise.OpenSimplexNoise; import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Collections;
import java.util.List;
public class UmbrellaTreeMembraneBlock extends SlimeBlock implements IRenderTyped, BlockModelProvider { public class UmbrellaTreeMembraneBlock extends SlimeBlock implements IRenderTyped, BlockModelProvider {
public static final IntegerProperty COLOR = EndBlockProperties.COLOR; public static final IntegerProperty COLOR = EndBlockProperties.COLOR;
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(0); private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(0);
public UmbrellaTreeMembraneBlock() { public UmbrellaTreeMembraneBlock() {
super(FabricBlockSettings.copyOf(Blocks.SLIME_BLOCK)); super(FabricBlockSettings.copyOf(Blocks.SLIME_BLOCK));
} }
@Override @Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) { public BlockState getStateForPlacement(BlockPlaceContext ctx) {
double px = ctx.getClickedPos().getX() * 0.1; double px = ctx.getClickedPos().getX() * 0.1;
@ -44,17 +43,17 @@ public class UmbrellaTreeMembraneBlock extends SlimeBlock implements IRenderType
double pz = ctx.getClickedPos().getZ() * 0.1; double pz = ctx.getClickedPos().getZ() * 0.1;
return this.defaultBlockState().setValue(COLOR, MHelper.floor(NOISE.eval(px, py, pz) * 3.5 + 4)); return this.defaultBlockState().setValue(COLOR, MHelper.floor(NOISE.eval(px, py, pz) * 3.5 + 4));
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(COLOR); stateManager.add(COLOR);
} }
@Override @Override
public BCLRenderLayer getRenderLayer() { public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.TRANSLUCENT; return BCLRenderLayer.TRANSLUCENT;
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
if (state.getValue(COLOR) > 0) { if (state.getValue(COLOR) > 0) {
@ -69,7 +68,7 @@ public class UmbrellaTreeMembraneBlock extends SlimeBlock implements IRenderType
public boolean propagatesSkylightDown(BlockState state, BlockGetter world, BlockPos pos) { public boolean propagatesSkylightDown(BlockState state, BlockGetter world, BlockPos pos) {
return state.getValue(COLOR) > 0; return state.getValue(COLOR) > 0;
} }
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public boolean skipRendering(BlockState state, BlockState stateFrom, Direction direction) { public boolean skipRendering(BlockState state, BlockState stateFrom, Direction direction) {
if (state.getValue(COLOR) > 0) { if (state.getValue(COLOR) > 0) {

View file

@ -18,12 +18,12 @@ public class UmbrellaTreeSaplingBlock extends FeatureSaplingBlock {
protected Feature<?> getFeature() { protected Feature<?> getFeature() {
return EndFeatures.UMBRELLA_TREE.getFeature(); return EndFeatures.UMBRELLA_TREE.getFeature();
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return world.getBlockState(pos.below()).is(EndBlocks.JUNGLE_MOSS); return world.getBlockState(pos.below()).is(EndBlocks.JUNGLE_MOSS);
} }
@Override @Override
public BCLRenderLayer getRenderLayer() { public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.TRANSLUCENT; return BCLRenderLayer.TRANSLUCENT;

View file

@ -1,8 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Optional;
import java.util.Random;
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.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -36,6 +33,9 @@ import net.minecraft.world.phys.shapes.VoxelShape;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Optional;
import java.util.Random;
public class VentBubbleColumnBlock extends Block implements BucketPickup, LiquidBlockContainer { public class VentBubbleColumnBlock extends Block implements BucketPickup, LiquidBlockContainer {
public VentBubbleColumnBlock() { public VentBubbleColumnBlock() {
super(FabricBlockSettings.of(Material.BUBBLE_COLUMN).noOcclusion().noCollission().noDrops()); super(FabricBlockSettings.of(Material.BUBBLE_COLUMN).noOcclusion().noCollission().noDrops());
@ -46,7 +46,7 @@ public class VentBubbleColumnBlock extends Block implements BucketPickup, Liquid
world.setBlock(pos, Blocks.AIR.defaultBlockState(), 11); world.setBlock(pos, Blocks.AIR.defaultBlockState(), 11);
return new ItemStack(Items.WATER_BUCKET); return new ItemStack(Items.WATER_BUCKET);
} }
@Override @Override
public RenderShape getRenderShape(BlockState state) { public RenderShape getRenderShape(BlockState state) {
return RenderShape.INVISIBLE; return RenderShape.INVISIBLE;
@ -109,7 +109,7 @@ public class VentBubbleColumnBlock extends Block implements BucketPickup, Liquid
entity.onInsideBubbleColumn(false); entity.onInsideBubbleColumn(false);
} }
} }
@Override @Override
public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) { public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) {
return false; return false;
@ -119,14 +119,13 @@ public class VentBubbleColumnBlock extends Block implements BucketPickup, Liquid
public boolean placeLiquid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) { public boolean placeLiquid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
return false; return false;
} }
@Override @Override
public FluidState getFluidState(BlockState state) { public FluidState getFluidState(BlockState state) {
return Fluids.WATER.getSource(false); return Fluids.WATER.getSource(false);
} }
@Override @Override
public Optional<SoundEvent> getPickupSound() { public Optional<SoundEvent> getPickupSound() {
return Fluids.WATER.getPickupSound(); return Fluids.WATER.getPickupSound();

View file

@ -1,8 +1,5 @@
package ru.betterend.blocks.basis; package ru.betterend.blocks.basis;
import java.util.List;
import java.util.Objects;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.item.context.BlockPlaceContext;
@ -17,13 +14,16 @@ import ru.bclib.blocks.BaseAnvilBlock;
import ru.betterend.blocks.complex.MetalMaterial; import ru.betterend.blocks.complex.MetalMaterial;
import ru.betterend.item.EndAnvilItem; import ru.betterend.item.EndAnvilItem;
import java.util.List;
import java.util.Objects;
public class EndAnvilBlock extends BaseAnvilBlock { public class EndAnvilBlock extends BaseAnvilBlock {
protected final int level; protected final int level;
protected IntegerProperty durability; protected IntegerProperty durability;
protected MetalMaterial metalMaterial; protected MetalMaterial metalMaterial;
protected int maxDurability; protected int maxDurability;
public EndAnvilBlock(MaterialColor color, int level) { public EndAnvilBlock(MaterialColor color, int level) {
super(color); super(color);
this.level = level; this.level = level;
@ -81,7 +81,7 @@ public class EndAnvilBlock extends BaseAnvilBlock {
super.createBlockStateDefinition(builder); super.createBlockStateDefinition(builder);
builder.add(getDurability()); builder.add(getDurability());
} }
public int getCraftingLevel() { public int getCraftingLevel() {
return level; return level;
} }
@ -109,7 +109,8 @@ public class EndAnvilBlock extends BaseAnvilBlock {
if (destructionProperty.getPossibleValues().contains(destruction)) { if (destructionProperty.getPossibleValues().contains(destruction)) {
try { try {
return fallingState.setValue(destructionProperty, destruction); return fallingState.setValue(destructionProperty, destruction);
} catch (Exception ex) { }
catch (Exception ex) {
return null; return null;
} }
} }

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks.basis; package ru.betterend.blocks.basis;
import java.util.Map;
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.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -28,24 +26,26 @@ import ru.bclib.blocks.BaseBlockNotFull;
import ru.bclib.blocks.BlockProperties; import ru.bclib.blocks.BlockProperties;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import java.util.Map;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class EndLanternBlock extends BaseBlockNotFull implements SimpleWaterloggedBlock, LiquidBlockContainer { public class EndLanternBlock extends BaseBlockNotFull implements SimpleWaterloggedBlock, LiquidBlockContainer {
public static final BooleanProperty IS_FLOOR = BlockProperties.IS_FLOOR; public static final BooleanProperty IS_FLOOR = BlockProperties.IS_FLOOR;
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public EndLanternBlock(Block source) { public EndLanternBlock(Block source) {
this(FabricBlockSettings.copyOf(source).luminance(15).noOcclusion()); this(FabricBlockSettings.copyOf(source).luminance(15).noOcclusion());
} }
public EndLanternBlock(Properties settings) { public EndLanternBlock(Properties settings) {
super(settings.noOcclusion()); super(settings.noOcclusion());
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(IS_FLOOR, WATERLOGGED); stateManager.add(IS_FLOOR, WATERLOGGED);
} }
@Override @Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) { public BlockState getStateForPlacement(BlockPlaceContext ctx) {
LevelReader worldView = ctx.getLevel(); LevelReader worldView = ctx.getLevel();
@ -86,7 +86,7 @@ public class EndLanternBlock extends BaseBlockNotFull implements SimpleWaterlogg
} }
} }
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
if (state.getValue(IS_FLOOR)) { if (state.getValue(IS_FLOOR)) {
@ -96,7 +96,7 @@ public class EndLanternBlock extends BaseBlockNotFull implements SimpleWaterlogg
return canSupportCenter(world, pos.above(), Direction.DOWN); return canSupportCenter(world, pos.above(), Direction.DOWN);
} }
} }
@Override @Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
Boolean water = state.getValue(WATERLOGGED); Boolean water = state.getValue(WATERLOGGED);
@ -110,7 +110,7 @@ public class EndLanternBlock extends BaseBlockNotFull implements SimpleWaterlogg
return state; return state;
} }
} }
@Override @Override
public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) { public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) {
return false; return false;
@ -120,7 +120,7 @@ public class EndLanternBlock extends BaseBlockNotFull implements SimpleWaterlogg
public boolean placeLiquid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) { public boolean placeLiquid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
return false; return false;
} }
@Override @Override
public FluidState getFluidState(BlockState state) { public FluidState getFluidState(BlockState state) {
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState(); return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState();

View file

@ -6,7 +6,8 @@ import ru.bclib.blocks.BasePlantWithAgeBlock;
public abstract class EndPlantWithAgeBlock extends BasePlantWithAgeBlock { public abstract class EndPlantWithAgeBlock extends BasePlantWithAgeBlock {
public EndPlantWithAgeBlock() {} public EndPlantWithAgeBlock() {
}
public EndPlantWithAgeBlock(Properties settings) { public EndPlantWithAgeBlock(Properties settings) {
super(settings); super(settings);

View file

@ -6,7 +6,8 @@ import ru.bclib.blocks.UnderwaterPlantBlock;
public class EndUnderwaterPlantBlock extends UnderwaterPlantBlock { public class EndUnderwaterPlantBlock extends UnderwaterPlantBlock {
public EndUnderwaterPlantBlock() {} public EndUnderwaterPlantBlock() {
}
public EndUnderwaterPlantBlock(int light) { public EndUnderwaterPlantBlock(int light) {
super(light); super(light);

View file

@ -6,7 +6,8 @@ import ru.bclib.blocks.BaseUnderwaterWallPlantBlock;
public class EndUnderwaterWallPlantBlock extends BaseUnderwaterWallPlantBlock { public class EndUnderwaterWallPlantBlock extends BaseUnderwaterWallPlantBlock {
public EndUnderwaterWallPlantBlock() {} public EndUnderwaterWallPlantBlock() {
}
public EndUnderwaterWallPlantBlock(int light) { public EndUnderwaterWallPlantBlock(int light) {
super(light); super(light);

View file

@ -5,7 +5,8 @@ import ru.bclib.api.TagAPI;
import ru.bclib.blocks.BaseWallPlantBlock; import ru.bclib.blocks.BaseWallPlantBlock;
public class EndWallPlantBlock extends BaseWallPlantBlock { public class EndWallPlantBlock extends BaseWallPlantBlock {
public EndWallPlantBlock() {} public EndWallPlantBlock() {
}
public EndWallPlantBlock(int light) { public EndWallPlantBlock(int light) {
super(light); super(light);

View file

@ -1,11 +1,7 @@
package ru.betterend.blocks.basis; package ru.betterend.blocks.basis;
import java.util.EnumMap;
import java.util.List;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -28,11 +24,14 @@ import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped; import ru.bclib.interfaces.IRenderTyped;
import ru.bclib.util.MHelper; import ru.bclib.util.MHelper;
import java.util.EnumMap;
import java.util.List;
public class FurBlock extends BaseAttachedBlock implements IRenderTyped { public class FurBlock extends BaseAttachedBlock implements IRenderTyped {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class); private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
private final ItemLike drop; private final ItemLike drop;
private final int dropChance; private final int dropChance;
public FurBlock(ItemLike drop, int light, int dropChance, boolean wet) { public FurBlock(ItemLike drop, int light, int dropChance, boolean wet) {
super(FabricBlockSettings.of(Material.REPLACEABLE_PLANT) super(FabricBlockSettings.of(Material.REPLACEABLE_PLANT)
.breakByTool(FabricToolTags.SHEARS) .breakByTool(FabricToolTags.SHEARS)
@ -43,7 +42,7 @@ public class FurBlock extends BaseAttachedBlock implements IRenderTyped {
this.drop = drop; this.drop = drop;
this.dropChance = dropChance; this.dropChance = dropChance;
} }
public FurBlock(ItemLike drop, int dropChance) { public FurBlock(ItemLike drop, int dropChance) {
super(FabricBlockSettings.of(Material.REPLACEABLE_PLANT) super(FabricBlockSettings.of(Material.REPLACEABLE_PLANT)
.breakByTool(FabricToolTags.SHEARS) .breakByTool(FabricToolTags.SHEARS)
@ -58,7 +57,7 @@ public class FurBlock extends BaseAttachedBlock implements IRenderTyped {
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return BOUNDING_SHAPES.get(state.getValue(FACING)); return BOUNDING_SHAPES.get(state.getValue(FACING));
} }
@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);
@ -72,12 +71,12 @@ public class FurBlock extends BaseAttachedBlock implements IRenderTyped {
return Lists.newArrayList(); return Lists.newArrayList();
} }
} }
@Override @Override
public BCLRenderLayer getRenderLayer() { public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT; return BCLRenderLayer.CUTOUT;
} }
static { static {
BOUNDING_SHAPES.put(Direction.UP, Shapes.box(0.0, 0.0, 0.0, 1.0, 0.5, 1.0)); BOUNDING_SHAPES.put(Direction.UP, Shapes.box(0.0, 0.0, 0.0, 1.0, 0.5, 1.0));
BOUNDING_SHAPES.put(Direction.DOWN, Shapes.box(0.0, 0.5, 0.0, 1.0, 1.0, 1.0)); BOUNDING_SHAPES.put(Direction.DOWN, Shapes.box(0.0, 0.5, 0.0, 1.0, 1.0, 1.0));

View file

@ -1,17 +1,6 @@
package ru.betterend.blocks.basis; package ru.betterend.blocks.basis;
import java.awt.Point;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
import org.jetbrains.annotations.Nullable;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
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.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -34,6 +23,8 @@ import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock; import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BooleanProperty; import net.minecraft.world.level.block.state.properties.BooleanProperty;
@ -44,12 +35,14 @@ import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.Nullable;
import ru.bclib.blocks.BaseBlockNotFull; import ru.bclib.blocks.BaseBlockNotFull;
import ru.bclib.blocks.BlockProperties; import ru.bclib.blocks.BlockProperties;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.betterend.blocks.EndBlockProperties; import ru.betterend.blocks.EndBlockProperties;
import ru.betterend.blocks.EndBlockProperties.PedestalState; import ru.betterend.blocks.EndBlockProperties.PedestalState;
import ru.betterend.blocks.InfusionPedestal; import ru.betterend.blocks.InfusionPedestal;
import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity;
import ru.betterend.blocks.entities.InfusionPedestalEntity; import ru.betterend.blocks.entities.InfusionPedestalEntity;
import ru.betterend.blocks.entities.PedestalBlockEntity; import ru.betterend.blocks.entities.PedestalBlockEntity;
import ru.betterend.client.models.Patterns; import ru.betterend.client.models.Patterns;
@ -57,59 +50,63 @@ import ru.betterend.registry.EndBlockEntities;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import ru.betterend.rituals.InfusionRitual; import ru.betterend.rituals.InfusionRitual;
import java.awt.Point;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@SuppressWarnings({"deprecation"}) @SuppressWarnings({"deprecation"})
public class PedestalBlock extends BaseBlockNotFull implements EntityBlock { public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
public final static EnumProperty<PedestalState> STATE = EndBlockProperties.PEDESTAL_STATE; public final static EnumProperty<PedestalState> STATE = EndBlockProperties.PEDESTAL_STATE;
public static final BooleanProperty HAS_ITEM = EndBlockProperties.HAS_ITEM; public static final BooleanProperty HAS_ITEM = EndBlockProperties.HAS_ITEM;
public static final BooleanProperty HAS_LIGHT = BlockProperties.HAS_LIGHT; public static final BooleanProperty HAS_LIGHT = BlockProperties.HAS_LIGHT;
private static final VoxelShape SHAPE_DEFAULT; private static final VoxelShape SHAPE_DEFAULT;
private static final VoxelShape SHAPE_COLUMN; private static final VoxelShape SHAPE_COLUMN;
private static final VoxelShape SHAPE_PILLAR; private static final VoxelShape SHAPE_PILLAR;
private static final VoxelShape SHAPE_PEDESTAL_TOP; private static final VoxelShape SHAPE_PEDESTAL_TOP;
private static final VoxelShape SHAPE_COLUMN_TOP; private static final VoxelShape SHAPE_COLUMN_TOP;
private static final VoxelShape SHAPE_BOTTOM; private static final VoxelShape SHAPE_BOTTOM;
/** /**
*
* Register new Pedestal block with Better End mod id. * Register new Pedestal block with Better End mod id.
* *
* @param name pedestal name * @param name pedestal name
* @param source source block * @param source source block
* @return new Pedestal block with Better End id. * @return new Pedestal block with Better End id.
*/ */
public static Block registerPedestal(String name, Block source) { public static Block registerPedestal(String name, Block source) {
return EndBlocks.registerBlock(name, new PedestalBlock(source)); return EndBlocks.registerBlock(name, new PedestalBlock(source));
} }
/** /**
*
* Register new Pedestal block with specified mod id. * Register new Pedestal block with specified mod id.
* *
* @param id pedestal id * @param id pedestal id
* @param source source block * @param source source block
* @return new Pedestal block with specified id. * @return new Pedestal block with specified id.
*/ */
public static Block registerPedestal(ResourceLocation id, Block source) { public static Block registerPedestal(ResourceLocation id, Block source) {
return EndBlocks.registerBlock(id, new PedestalBlock(source)); return EndBlocks.registerBlock(id, new PedestalBlock(source));
} }
protected final Block parent; protected final Block parent;
protected float height = 1.0F; protected float height = 1.0F;
public PedestalBlock(Block parent) { public PedestalBlock(Block parent) {
super(FabricBlockSettings.copyOf(parent).luminance(state -> state.getValue(HAS_LIGHT) ? 12 : 0)); super(FabricBlockSettings.copyOf(parent).luminance(state -> state.getValue(HAS_LIGHT) ? 12 : 0));
this.registerDefaultState(stateDefinition.any().setValue(STATE, PedestalState.DEFAULT).setValue(HAS_ITEM, false).setValue(HAS_LIGHT, false)); this.registerDefaultState(stateDefinition.any().setValue(STATE, PedestalState.DEFAULT).setValue(HAS_ITEM, false).setValue(HAS_LIGHT, false));
this.parent = parent; this.parent = parent;
} }
public float getHeight(BlockState state) { public float getHeight(BlockState state) {
if (state.getBlock() instanceof PedestalBlock && state.getValue(STATE) == PedestalState.PEDESTAL_TOP) { if (state.getBlock() instanceof PedestalBlock && state.getValue(STATE) == PedestalState.PEDESTAL_TOP) {
return this.height - 0.2F; return this.height - 0.2F;
} }
return this.height; return this.height;
} }
@Override @Override
@Deprecated @Deprecated
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
@ -126,7 +123,8 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
pedestal.setItem(0, itemStack); pedestal.setItem(0, itemStack);
checkRitual(world, pos); checkRitual(world, pos);
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} else { }
else {
ItemStack itemStack = pedestal.getItem(0); ItemStack itemStack = pedestal.getItem(0);
if (player.addItem(itemStack)) { if (player.addItem(itemStack)) {
pedestal.removeItemNoUpdate(0); pedestal.removeItemNoUpdate(0);
@ -142,7 +140,7 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
@Override @Override
public void destroy(LevelAccessor levelAccessor, BlockPos blockPos, BlockState blockState) { public void destroy(LevelAccessor levelAccessor, BlockPos blockPos, BlockState blockState) {
MutableBlockPos posMutable = new MutableBlockPos(); MutableBlockPos posMutable = new MutableBlockPos();
for (Point point: InfusionRitual.getMap()) { for (Point point : InfusionRitual.getMap()) {
posMutable.set(blockPos).move(point.x, 0, point.y); posMutable.set(blockPos).move(point.x, 0, point.y);
BlockState state = levelAccessor.getBlockState(posMutable); BlockState state = levelAccessor.getBlockState(posMutable);
if (state.getBlock() instanceof InfusionPedestal) { if (state.getBlock() instanceof InfusionPedestal) {
@ -160,7 +158,7 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
public void checkRitual(Level world, BlockPos pos) { public void checkRitual(Level world, BlockPos pos) {
MutableBlockPos posMutable = new MutableBlockPos(); MutableBlockPos posMutable = new MutableBlockPos();
for (Point point: InfusionRitual.getMap()) { for (Point point : InfusionRitual.getMap()) {
posMutable.set(pos).move(point.x, 0, point.y); posMutable.set(pos).move(point.x, 0, point.y);
BlockState state = world.getBlockState(posMutable); BlockState state = world.getBlockState(posMutable);
if (state.getBlock() instanceof InfusionPedestal) { if (state.getBlock() instanceof InfusionPedestal) {
@ -169,7 +167,7 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
} }
} }
} }
@Override @Override
@Nullable @Nullable
public BlockState getStateForPlacement(BlockPlaceContext context) { public BlockState getStateForPlacement(BlockPlaceContext context) {
@ -182,18 +180,22 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
boolean hasPedestalUnder = downState.getBlock() instanceof PedestalBlock; boolean hasPedestalUnder = downState.getBlock() instanceof PedestalBlock;
if (!hasPedestalOver && hasPedestalUnder && upSideSolid) { if (!hasPedestalOver && hasPedestalUnder && upSideSolid) {
return defaultBlockState().setValue(STATE, PedestalState.COLUMN_TOP); return defaultBlockState().setValue(STATE, PedestalState.COLUMN_TOP);
} else if (!hasPedestalOver && !hasPedestalUnder && upSideSolid) { }
else if (!hasPedestalOver && !hasPedestalUnder && upSideSolid) {
return defaultBlockState().setValue(STATE, PedestalState.COLUMN); return defaultBlockState().setValue(STATE, PedestalState.COLUMN);
} else if (hasPedestalUnder && hasPedestalOver) { }
else if (hasPedestalUnder && hasPedestalOver) {
return defaultBlockState().setValue(STATE, PedestalState.PILLAR); return defaultBlockState().setValue(STATE, PedestalState.PILLAR);
} else if (hasPedestalUnder) { }
else if (hasPedestalUnder) {
return defaultBlockState().setValue(STATE, PedestalState.PEDESTAL_TOP); return defaultBlockState().setValue(STATE, PedestalState.PEDESTAL_TOP);
} else if (hasPedestalOver) { }
else if (hasPedestalOver) {
return defaultBlockState().setValue(STATE, PedestalState.BOTTOM); return defaultBlockState().setValue(STATE, PedestalState.BOTTOM);
} }
return defaultBlockState(); return defaultBlockState();
} }
@Override @Override
@Deprecated @Deprecated
public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, BlockPos pos, BlockPos posFrom) { public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, BlockPos pos, BlockPos posFrom) {
@ -204,7 +206,7 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
} }
return updated; return updated;
} }
private BlockState getUpdatedState(BlockState state, Direction direction, BlockState newState, LevelAccessor world, BlockPos pos, BlockPos posFrom) { private BlockState getUpdatedState(BlockState state, Direction direction, BlockState newState, LevelAccessor world, BlockPos pos, BlockPos posFrom) {
if (!state.is(this)) return state.updateShape(direction, newState, world, pos, posFrom); if (!state.is(this)) return state.updateShape(direction, newState, world, pos, posFrom);
if (direction != Direction.UP && direction != Direction.DOWN) return state; if (direction != Direction.UP && direction != Direction.DOWN) return state;
@ -216,21 +218,27 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
if (direction == Direction.UP) { if (direction == Direction.UP) {
upSideSolid = newState.isFaceSturdy(world, posFrom, Direction.DOWN) || newState.is(BlockTags.WALLS); upSideSolid = newState.isFaceSturdy(world, posFrom, Direction.DOWN) || newState.is(BlockTags.WALLS);
hasPedestalOver = newState.getBlock() instanceof PedestalBlock; hasPedestalOver = newState.getBlock() instanceof PedestalBlock;
} else { }
else {
hasPedestalUnder = newState.getBlock() instanceof PedestalBlock; hasPedestalUnder = newState.getBlock() instanceof PedestalBlock;
} }
BlockState updatedState; BlockState updatedState;
if (!hasPedestalOver && hasPedestalUnder && upSideSolid) { if (!hasPedestalOver && hasPedestalUnder && upSideSolid) {
updatedState = state.setValue(STATE, PedestalState.COLUMN_TOP); updatedState = state.setValue(STATE, PedestalState.COLUMN_TOP);
} else if (!hasPedestalOver && !hasPedestalUnder && upSideSolid) { }
else if (!hasPedestalOver && !hasPedestalUnder && upSideSolid) {
updatedState = state.setValue(STATE, PedestalState.COLUMN); updatedState = state.setValue(STATE, PedestalState.COLUMN);
} else if (hasPedestalUnder && hasPedestalOver) { }
else if (hasPedestalUnder && hasPedestalOver) {
updatedState = state.setValue(STATE, PedestalState.PILLAR); updatedState = state.setValue(STATE, PedestalState.PILLAR);
} else if (hasPedestalUnder) { }
else if (hasPedestalUnder) {
updatedState = state.setValue(STATE, PedestalState.PEDESTAL_TOP); updatedState = state.setValue(STATE, PedestalState.PEDESTAL_TOP);
} else if (hasPedestalOver) { }
else if (hasPedestalOver) {
updatedState = state.setValue(STATE, PedestalState.BOTTOM); updatedState = state.setValue(STATE, PedestalState.BOTTOM);
} else { }
else {
updatedState = state.setValue(STATE, PedestalState.DEFAULT); updatedState = state.setValue(STATE, PedestalState.DEFAULT);
} }
if (!isPlaceable(updatedState)) { if (!isPlaceable(updatedState)) {
@ -238,7 +246,7 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
} }
return updatedState; return updatedState;
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
List<ItemStack> drop = Lists.newArrayList(super.getDrops(state, builder)); List<ItemStack> drop = Lists.newArrayList(super.getDrops(state, builder));
@ -251,13 +259,14 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
drop.add(pedestal.getItem(0)); drop.add(pedestal.getItem(0));
} }
} }
} else { }
else {
return drop; return drop;
} }
} }
return drop; return drop;
} }
private void moveStoredStack(LevelAccessor world, BlockState state, BlockPos pos) { private void moveStoredStack(LevelAccessor world, BlockState state, BlockPos pos) {
BlockEntity blockEntity = world.getBlockEntity(pos); BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity instanceof PedestalBlockEntity && state.is(this)) { if (blockEntity instanceof PedestalBlockEntity && state.is(this)) {
@ -268,34 +277,39 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
} }
} }
} }
private void moveStoredStack(BlockEntity blockEntity, LevelAccessor world, ItemStack stack, BlockPos pos) { private void moveStoredStack(BlockEntity blockEntity, LevelAccessor world, ItemStack stack, BlockPos pos) {
BlockState state = world.getBlockState(pos); BlockState state = world.getBlockState(pos);
if (!state.is(this)) { if (!state.is(this)) {
dropStoredStack(blockEntity, stack, pos); dropStoredStack(blockEntity, stack, pos);
} else if (state.getValue(STATE).equals(PedestalState.PILLAR)) { }
else if (state.getValue(STATE).equals(PedestalState.PILLAR)) {
moveStoredStack(blockEntity, world, stack, pos.above()); moveStoredStack(blockEntity, world, stack, pos.above());
} else if (!isPlaceable(state)) { }
else if (!isPlaceable(state)) {
dropStoredStack(blockEntity, stack, pos); dropStoredStack(blockEntity, stack, pos);
} else if (blockEntity instanceof PedestalBlockEntity) { }
else if (blockEntity instanceof PedestalBlockEntity) {
PedestalBlockEntity pedestal = (PedestalBlockEntity) blockEntity; PedestalBlockEntity pedestal = (PedestalBlockEntity) blockEntity;
if (pedestal.isEmpty()) { if (pedestal.isEmpty()) {
pedestal.setItem(0, stack); pedestal.setItem(0, stack);
} else { }
else {
dropStoredStack(blockEntity, stack, pos); dropStoredStack(blockEntity, stack, pos);
} }
} else { }
else {
dropStoredStack(blockEntity, stack, pos); dropStoredStack(blockEntity, stack, pos);
} }
} }
private void dropStoredStack(BlockEntity blockEntity, ItemStack stack, BlockPos pos) { private void dropStoredStack(BlockEntity blockEntity, ItemStack stack, BlockPos pos) {
if (blockEntity != null && blockEntity.getLevel() != null) { if (blockEntity != null && blockEntity.getLevel() != null) {
Level world = blockEntity.getLevel(); Level world = blockEntity.getLevel();
Block.popResource(world, getDropPos(world, pos), stack); Block.popResource(world, getDropPos(world, pos), stack);
} }
} }
private BlockPos getDropPos(LevelAccessor world, BlockPos pos) { private BlockPos getDropPos(LevelAccessor world, BlockPos pos) {
BlockPos dropPos; BlockPos dropPos;
if (world.getBlockState(pos).isAir()) { if (world.getBlockState(pos).isAir()) {
@ -304,7 +318,7 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
if (world.getBlockState(pos.above()).isAir()) { if (world.getBlockState(pos.above()).isAir()) {
return pos.above(); return pos.above();
} }
for(int i = 2; i < Direction.values().length; i++) { for (int i = 2; i < Direction.values().length; i++) {
dropPos = pos.relative(Direction.from3DDataValue(i)); dropPos = pos.relative(Direction.from3DDataValue(i));
if (world.getBlockState(dropPos).isAir()) { if (world.getBlockState(dropPos).isAir()) {
return dropPos.immutable(); return dropPos.immutable();
@ -312,19 +326,19 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
} }
return getDropPos(world, pos.above()); return getDropPos(world, pos.above());
} }
public boolean isPlaceable(BlockState state) { public boolean isPlaceable(BlockState state) {
if (!state.is(this)) return false; if (!state.is(this)) return false;
PedestalState currentState = state.getValue(STATE); PedestalState currentState = state.getValue(STATE);
return currentState == PedestalState.DEFAULT || return currentState == PedestalState.DEFAULT ||
currentState == PedestalState.PEDESTAL_TOP; currentState == PedestalState.PEDESTAL_TOP;
} }
@Override @Override
@Deprecated @Deprecated
public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
if (state.is(this)) { if (state.is(this)) {
switch(state.getValue(STATE)) { switch (state.getValue(STATE)) {
case BOTTOM: { case BOTTOM: {
return SHAPE_BOTTOM; return SHAPE_BOTTOM;
} }
@ -347,7 +361,7 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
} }
return super.getShape(state, world, pos, context); return super.getShape(state, world, pos, context);
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(STATE, HAS_ITEM, HAS_LIGHT); stateManager.add(STATE, HAS_ITEM, HAS_LIGHT);
@ -361,13 +375,13 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
public boolean hasUniqueEntity() { public boolean hasUniqueEntity() {
return false; return false;
} }
@Override @Override
@Deprecated @Deprecated
public boolean hasAnalogOutputSignal(BlockState state) { public boolean hasAnalogOutputSignal(BlockState state) {
return state.getBlock() instanceof PedestalBlock; return state.getBlock() instanceof PedestalBlock;
} }
@Override @Override
@Deprecated @Deprecated
public int getAnalogOutputSignal(BlockState state, Level world, BlockPos pos) { public int getAnalogOutputSignal(BlockState state, Level world, BlockPos pos) {
@ -402,7 +416,8 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
case PILLAR: case PILLAR:
pattern = Patterns.createJson(Patterns.BLOCK_PEDESTAL_PILLAR, textures); pattern = Patterns.createJson(Patterns.BLOCK_PEDESTAL_PILLAR, textures);
break; break;
default: break; default:
break;
} }
return ModelsHelper.fromPattern(pattern); return ModelsHelper.fromPattern(pattern);
} }
@ -422,8 +437,9 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
String name = blockId.getPath(); String name = blockId.getPath();
return new HashMap<String, String>() { return new HashMap<String, String>() {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
{ {
put("%mod%", blockId.getNamespace() ); put("%mod%", blockId.getNamespace());
put("%top%", name + "_top"); put("%top%", name + "_top");
put("%base%", name + "_base"); put("%base%", name + "_base");
put("%pillar%", name + "_pillar"); put("%pillar%", name + "_pillar");
@ -432,22 +448,6 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
}; };
} }
@Override
@Nullable
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState blockState, BlockEntityType<T> blockEntityType) {
if (level.isClientSide) return null;
BlockEntityTicker<T> ticker = createTickerHelper(blockEntityType, EndBlockEntities.PEDESTAL, PedestalBlockEntity::tick);
if (ticker!=null) return ticker;
return createTickerHelper(blockEntityType, EndBlockEntities.INFUSION_PEDESTAL, InfusionPedestalEntity::tick);
}
@Nullable
protected static <E extends BlockEntity, A extends BlockEntity> BlockEntityTicker<A> createTickerHelper(BlockEntityType<A> blockEntityType, BlockEntityType<E> blockEntityType2, BlockEntityTicker<? super E> blockEntityTicker) {
return blockEntityType2 == blockEntityType ? (BlockEntityTicker<A>) blockEntityTicker : null;
}
static { static {
VoxelShape basinUp = Block.box(2, 3, 2, 14, 4, 14); VoxelShape basinUp = Block.box(2, 3, 2, 14, 4, 14);
VoxelShape basinDown = Block.box(0, 0, 0, 16, 3, 16); VoxelShape basinDown = Block.box(0, 0, 0, 16, 3, 16);
@ -466,4 +466,10 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
SHAPE_COLUMN = Shapes.or(basin, SHAPE_PILLAR, columnTop); SHAPE_COLUMN = Shapes.or(basin, SHAPE_PILLAR, columnTop);
SHAPE_BOTTOM = Shapes.or(basin, SHAPE_PILLAR); SHAPE_BOTTOM = Shapes.or(basin, SHAPE_PILLAR);
} }
@Override
@Nullable
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState blockState, BlockEntityType<T> blockEntityType) {
return level.isClientSide() ? PedestalBlockEntity::tick : null;
}
} }

View file

@ -1,9 +1,5 @@
package ru.betterend.blocks.basis; package ru.betterend.blocks.basis;
import java.util.Optional;
import org.jetbrains.annotations.Nullable;
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.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -17,19 +13,22 @@ 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.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 org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.interfaces.IColorProvider; import ru.bclib.interfaces.IColorProvider;
import ru.betterend.client.models.Patterns; import ru.betterend.client.models.Patterns;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Optional;
public class StoneLanternBlock extends EndLanternBlock implements IColorProvider { public class StoneLanternBlock extends EndLanternBlock implements IColorProvider {
private static final VoxelShape SHAPE_CEIL = Block.box(3, 1, 3, 13, 16, 13); private static final VoxelShape SHAPE_CEIL = Block.box(3, 1, 3, 13, 16, 13);
private static final VoxelShape SHAPE_FLOOR = Block.box(3, 0, 3, 13, 15, 13); private static final VoxelShape SHAPE_FLOOR = Block.box(3, 0, 3, 13, 15, 13);
public StoneLanternBlock(Block source) { public StoneLanternBlock(Block source) {
super(FabricBlockSettings.copyOf(source).luminance(15)); super(FabricBlockSettings.copyOf(source).luminance(15));
} }
@Override @Override
public BlockColor getProvider() { public BlockColor getProvider() {
return ((IColorProvider) EndBlocks.AURORA_CRYSTAL).getProvider(); return ((IColorProvider) EndBlocks.AURORA_CRYSTAL).getProvider();
@ -39,7 +38,7 @@ public class StoneLanternBlock extends EndLanternBlock implements IColorProvider
public ItemColor getItemProvider() { public ItemColor getItemProvider() {
return ((IColorProvider) EndBlocks.AURORA_CRYSTAL).getItemProvider(); return ((IColorProvider) EndBlocks.AURORA_CRYSTAL).getItemProvider();
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return state.getValue(IS_FLOOR) ? SHAPE_FLOOR : SHAPE_CEIL; return state.getValue(IS_FLOOR) ? SHAPE_FLOOR : SHAPE_CEIL;

View file

@ -1,10 +1,6 @@
package ru.betterend.blocks.complex; package ru.betterend.blocks.complex;
import java.util.Map;
import java.util.function.Function;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.world.item.DyeColor; import net.minecraft.world.item.DyeColor;
@ -18,15 +14,18 @@ import ru.betterend.BetterEnd;
import ru.betterend.config.Configs; import ru.betterend.config.Configs;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Map;
import java.util.function.Function;
public class ColoredMaterial { public class ColoredMaterial {
private static final Map<Integer, ItemLike> DYES = Maps.newHashMap(); private static final Map<Integer, ItemLike> DYES = Maps.newHashMap();
private static final Map<Integer, String> COLORS = Maps.newHashMap(); private static final Map<Integer, String> COLORS = Maps.newHashMap();
private final Map<Integer, Block> colors = Maps.newHashMap(); private final Map<Integer, Block> colors = Maps.newHashMap();
public ColoredMaterial(Function<FabricBlockSettings, Block> constructor, Block source, boolean craftEight) { public ColoredMaterial(Function<FabricBlockSettings, Block> constructor, Block source, boolean craftEight) {
this(constructor, source, COLORS, DYES, craftEight); this(constructor, source, COLORS, DYES, craftEight);
} }
public ColoredMaterial(Function<FabricBlockSettings, Block> constructor, Block source, Map<Integer, String> colors, Map<Integer, ItemLike> dyes, boolean craftEight) { public ColoredMaterial(Function<FabricBlockSettings, Block> constructor, Block source, Map<Integer, String> colors, Map<Integer, ItemLike> dyes, boolean craftEight) {
String id = Registry.BLOCK.getKey(source).getPath(); String id = Registry.BLOCK.getKey(source).getPath();
colors.forEach((color, name) -> { colors.forEach((color, name) -> {
@ -43,17 +42,17 @@ public class ColoredMaterial {
BlocksHelper.addBlockColor(block, color); BlocksHelper.addBlockColor(block, color);
}); });
} }
public Block getByColor(DyeColor color) { public Block getByColor(DyeColor color) {
return colors.get(color.getMaterialColor().col); return colors.get(color.getMaterialColor().col);
} }
public Block getByColor(int color) { public Block getByColor(int color) {
return colors.get(color); return colors.get(color);
} }
static { static {
for (DyeColor color: DyeColor.values()) { for (DyeColor color : DyeColor.values()) {
int colorRGB = color.getMaterialColor().col; int colorRGB = color.getMaterialColor().col;
COLORS.put(colorRGB, color.getName()); COLORS.put(colorRGB, color.getName());
DYES.put(colorRGB, DyeItem.byColor(color)); DYES.put(colorRGB, DyeItem.byColor(color));

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