Code style changes, entities fixes

This commit is contained in:
paulevsGitch 2021-07-08 00:21:47 +03:00
parent 9d604b2d25
commit 44962e18b6
377 changed files with 5038 additions and 4914 deletions

View file

@ -1,9 +1,5 @@
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.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
@ -21,15 +17,19 @@ import ru.bclib.util.MHelper;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndParticles;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public class AncientEmeraldIceBlock extends BaseBlock {
public AncientEmeraldIceBlock() {
super(FabricBlockSettings.copyOf(Blocks.BLUE_ICE).randomTicks());
}
@Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
Direction dir = BlocksHelper.randomDirection(random);
if (random.nextBoolean()) {
int x = 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);
}
}
pos = pos.relative(dir);
state = world.getBlockState(pos);
if (state.is(Blocks.WATER)) {
@ -52,11 +52,11 @@ public class AncientEmeraldIceBlock extends BaseBlock {
makeParticles(world, pos, 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);
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getOptionalParameter(LootContextParams.TOOL);

View file

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

View file

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

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
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.registry.EndBlocks;
import java.util.Random;
public class BlueVineSeedBlock extends EndPlantWithAgeBlock {
@Override
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));
placeLantern(world, pos.above(height + 1));
}
private void placeLantern(WorldGenLevel world, BlockPos pos) {
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);
if (world.isEmptyBlock(p)) {
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));
}
}
@Override
protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.END_MOSS) || state.is(EndBlocks.END_MYCELIUM);
}
@Override
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,13 +1,6 @@
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 net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
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.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.Nullable;
import ru.bclib.blocks.BaseAttachedBlock;
import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.models.ModelsHelper;
@ -30,18 +24,22 @@ import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped;
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 {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
public ChandelierBlock(Block source) {
super(FabricBlockSettings.copyOf(source).luminance(15).noCollission().noOcclusion().requiresCorrectToolForDrops());
}
@Override
public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT;
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return BOUNDING_SHAPES.get(state.getValue(FACING));

View file

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

View file

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

View file

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

View file

@ -1,11 +1,5 @@
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.Environment;
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.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.render.BCLRenderLayer;
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 EmeraldIceBlock() {
super(FabricBlockSettings.copyOf(Blocks.ICE));
@ -74,7 +73,7 @@ public class EmeraldIceBlock extends HalfTransparentBlock implements IRenderType
world.neighborChanged(pos, Blocks.WATER, pos);
}
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
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<PedestalState> PEDESTAL_STATE = EnumProperty.create("state", PedestalState.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 IntegerProperty PORTAL = IntegerProperty.create("portal", 0, EndPortals.getCount());
public enum PedestalState implements StringRepresentable {
PEDESTAL_TOP("pedestal_top"),
COLUMN_TOP("column_top"),
@ -22,24 +22,24 @@ public class EndBlockProperties extends BlockProperties {
PILLAR("pillar"),
COLUMN("column"),
DEFAULT("default");
private final String name;
PedestalState(String name) {
this.name = name;
}
@Override
public String getSerializedName() {
return this.name;
}
@Override
public String toString() {
return this.name;
}
}
public enum HydraluxShape implements StringRepresentable {
FLOWER_BIG_BOTTOM("flower_big_bottom", true),
FLOWER_BIG_TOP("flower_big_top", true),
@ -47,10 +47,10 @@ public class EndBlockProperties extends BlockProperties {
FLOWER_SMALL_TOP("flower_small_top", true),
VINE("vine", false),
ROOTS("roots", false);
private final String name;
private final boolean glow;
HydraluxShape(String name, boolean glow) {
this.name = name;
this.glow = glow;
@ -60,17 +60,17 @@ public class EndBlockProperties extends BlockProperties {
public String getSerializedName() {
return name;
}
@Override
public String toString() {
return name;
}
public boolean hasGlow() {
return glow;
}
}
public enum LumecornShape implements StringRepresentable {
LIGHT_TOP("light_top", 15),
LIGHT_TOP_MIDDLE("light_top_middle", 15),
@ -79,10 +79,10 @@ public class EndBlockProperties extends BlockProperties {
MIDDLE("middle", 0),
BOTTOM_BIG("bottom_big", 0),
BOTTOM_SMALL("bottom_small", 0);
private final String name;
private final int light;
LumecornShape(String name, int light) {
this.name = name;
this.light = light;
@ -92,24 +92,24 @@ public class EndBlockProperties extends BlockProperties {
public String getSerializedName() {
return name;
}
@Override
public String toString() {
return name;
}
public int getLight() {
return light;
}
}
public enum CactusBottom implements StringRepresentable {
EMPTY("empty"),
SAND("sand"),
MOSS("moss");
private final String name;
CactusBottom(String name) {
this.name = name;
}
@ -118,7 +118,7 @@ public class EndBlockProperties extends BlockProperties {
public String getSerializedName() {
return name;
}
@Override
public String toString() {
return name;

View file

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

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
@ -12,6 +10,8 @@ import ru.bclib.blocks.UnderwaterPlantWithAgeBlock;
import ru.bclib.util.BlocksHelper;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class EndLilySeedBlock extends UnderwaterPlantWithAgeBlock {
@Override
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));
}
}
private boolean canGrow(WorldGenLevel world, BlockPos pos) {
BlockPos up = pos.above();
while (world.getBlockState(up).getFluidState().getType().equals(Fluids.WATER.getSource())) {

View file

@ -1,9 +1,6 @@
package ru.betterend.blocks;
import java.util.List;
import com.google.common.collect.Lists;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
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.registry.EndBlocks;
import java.util.List;
public class EndLotusFlowerBlock extends EndPlantBlock {
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);
public EndLotusFlowerBlock() {
super(FabricBlockSettings.of(Material.PLANT).luminance(15).noOcclusion());
}
@Override
protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.END_LOTUS_STEM);
}
@Override
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE_OUTLINE;
}
@Override
public VoxelShape getCollisionShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE_COLLISION;
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
int count = MHelper.randRange(1, 2, MHelper.RANDOM);
return Lists.newArrayList(new ItemStack(EndBlocks.END_LOTUS_SEED, count));
}
@Override
@Environment(EnvType.CLIENT)
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<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
private static final VoxelShape VSHAPE = Block.box(0, 0, 0, 16, 1, 16);
public EndLotusLeafBlock() {
super(FabricBlockSettings.of(Material.PLANT).noOcclusion().sound(SoundType.WET_GRASS));
}
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
BlockState down = world.getBlockState(pos.below());
return !down.getFluidState().isEmpty() && down.getFluidState().getType() instanceof WaterFluid;
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(SHAPE, HORIZONTAL_FACING);
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return VSHAPE;
}
@Override
public BlockState rotate(BlockState state, Rotation rotation) {
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) {
return BlocksHelper.mirrorHorizontal(state, mirror, HORIZONTAL_FACING);
}
@Override
public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT;
}
@Override
@Environment(EnvType.CLIENT)
public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) {

View file

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

View file

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

View file

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

View file

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

View file

@ -16,7 +16,12 @@ import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext;
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.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
@ -52,11 +57,12 @@ public class EndStoneSmelter extends BaseBlockWithEntity {
.sound(SoundType.STONE));
registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(LIT, false));
}
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if (world.isClientSide) {
return InteractionResult.SUCCESS;
} else {
}
else {
this.openScreen(world, pos, player);
return InteractionResult.CONSUME;
}
@ -68,17 +74,17 @@ public class EndStoneSmelter extends BaseBlockWithEntity {
player.openMenu((EndStoneSmelterBlockEntity) blockEntity);
}
}
@Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
return defaultBlockState().setValue(FACING, ctx.getHorizontalDirection().getOpposite());
}
@Override
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {
return new EndStoneSmelterBlockEntity(blockPos, blockState);
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
List<ItemStack> drop = Lists.newArrayList(new ItemStack(this));
@ -125,7 +131,7 @@ public class EndStoneSmelter extends BaseBlockWithEntity {
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(FACING, LIT);
}
@Environment(EnvType.CLIENT)
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
if (state.getValue(LIT)) {
@ -133,7 +139,7 @@ public class EndStoneSmelter extends BaseBlockWithEntity {
double y = pos.getY();
double z = pos.getZ() + 0.5D;
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);

View file

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

View file

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

View file

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

View file

@ -1,9 +1,6 @@
package ru.betterend.blocks;
import java.util.EnumMap;
import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos;
@ -19,9 +16,11 @@ import ru.bclib.blocks.BaseAttachedBlock;
import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped;
import java.util.EnumMap;
public class FilaluxWingsBlock extends BaseAttachedBlock implements IRenderTyped {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
public FilaluxWingsBlock() {
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() {
return BCLRenderLayer.CUTOUT;
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return BOUNDING_SHAPES.get(state.getValue(FACING));
}
static {
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));

View file

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

View file

@ -12,19 +12,19 @@ public class GlowingMossBlock extends EndPlantBlock {
public GlowingMossBlock(int light) {
super(light);
}
@Override
protected boolean isTerrain(BlockState state) {
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)
public float getAmbientOcclusionLightLevel(BlockGetter world, BlockPos pos) {
return 1F;
}
@Environment(EnvType.CLIENT)
public boolean hasEmissiveLighting(BlockGetter world, BlockPos pos) {
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 static final BooleanProperty NATURAL = EndBlockProperties.NATURAL;
public GlowingPillarLuminophorBlock() {
super(FabricBlockSettings.of(Material.LEAVES)
.materialColor(MaterialColor.COLOR_ORANGE)
@ -29,12 +29,12 @@ public class GlowingPillarLuminophorBlock extends BaseBlock {
.sound(SoundType.GRASS));
this.registerDefaultState(this.stateDefinition.any().setValue(NATURAL, false));
}
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return !state.getValue(NATURAL) || world.getBlockState(pos.below()).is(EndBlocks.GLOWING_PILLAR_ROOTS);
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (!canSurvive(state, world, pos)) {
@ -44,7 +44,7 @@ public class GlowingPillarLuminophorBlock extends BaseBlock {
return state;
}
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(NATURAL);

View file

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

View file

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

View file

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

View file

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

View file

@ -21,11 +21,12 @@ public class HydraluxPetalBlock extends BaseBlock {
.materialColor(MaterialColor.PODZOL)
.sound(SoundType.WART_BLOCK));
}
public HydraluxPetalBlock(Properties settings) {
super(settings);
}
@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;
import java.util.Optional;
import org.jetbrains.annotations.Nullable;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -12,16 +8,19 @@ import net.minecraft.client.color.item.ItemColor;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.ModelsHelper;
import ru.bclib.interfaces.IColorProvider;
import ru.bclib.util.BlocksHelper;
import ru.betterend.client.models.Patterns;
import java.util.Optional;
public class HydraluxPetalColoredBlock extends HydraluxPetalBlock implements IColorProvider {
public HydraluxPetalColoredBlock(FabricBlockSettings settings) {
super(settings);
}
@Override
public BlockColor getProvider() {
return (state, world, pos, tintIndex) -> BlocksHelper.getBlockColor(this);

View file

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

View file

@ -1,9 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import org.jetbrains.annotations.Nullable;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -36,6 +32,7 @@ import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.Nullable;
import ru.bclib.blocks.BaseBlockNotFull;
import ru.bclib.blocks.BlockProperties;
import ru.bclib.util.BlocksHelper;
@ -43,12 +40,14 @@ import ru.betterend.blocks.entities.BlockEntityHydrothermalVent;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndParticles;
import java.util.Random;
@SuppressWarnings("deprecation")
public class HydrothermalVentBlock extends BaseBlockNotFull implements EntityBlock, LiquidBlockContainer, SimpleWaterloggedBlock {
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVE;
private static final VoxelShape SHAPE = Block.box(1, 1, 1, 15, 16, 15);
public HydrothermalVentBlock() {
super(FabricBlockSettings.of(Material.STONE)
.breakByTool(FabricToolTags.PICKAXES)
@ -57,17 +56,17 @@ public class HydrothermalVentBlock extends BaseBlockNotFull implements EntityBlo
.requiresCorrectToolForDrops());
this.registerDefaultState(defaultBlockState().setValue(WATERLOGGED, true).setValue(ACTIVATED, false));
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(WATERLOGGED, ACTIVATED);
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE;
}
@Override
public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) {
return false;
@ -77,13 +76,13 @@ public class HydrothermalVentBlock extends BaseBlockNotFull implements EntityBlo
public boolean placeLiquid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
return false;
}
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
state = world.getBlockState(pos.below());
return state.is(EndBlocks.SULPHURIC_ROCK.stone);
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (!canSurvive(state, world, pos)) {
@ -94,14 +93,14 @@ public class HydrothermalVentBlock extends BaseBlockNotFull implements EntityBlo
}
return state;
}
@Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
LevelAccessor worldAccess = ctx.getLevel();
BlockPos blockPos = ctx.getClickedPos();
return this.defaultBlockState().setValue(WATERLOGGED, worldAccess.getFluidState(blockPos).getType() == Fluids.WATER);
}
@Override
public FluidState getFluidState(BlockState state) {
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
@ -120,14 +119,14 @@ public class HydrothermalVentBlock extends BaseBlockNotFull implements EntityBlo
world.getBlockTicks().scheduleTick(up, EndBlocks.VENT_BUBBLE_COLUMN, 5);
}
}
@Override
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)) {
tick(state,(ServerLevel) world, pos, world.random);
tick(state, (ServerLevel) world, pos, world.random);
}
}
@Environment(EnvType.CLIENT)
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
if (!state.getValue(ACTIVATED) && random.nextBoolean()) {

View file

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

View file

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

View file

@ -17,7 +17,7 @@ public class LacugroveSaplingBlock extends FeatureSaplingBlock {
protected Feature<?> getFeature() {
return EndFeatures.LACUGROVE.getFeature();
}
@Override
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);

View file

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

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
@ -15,6 +13,8 @@ import ru.bclib.util.MHelper;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class LanceleafSeedBlock extends EndPlantWithAgeBlock {
@Override
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.TOP));
}
@Override
protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.AMBER_MOSS);
}
@Override
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;

View file

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

View file

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

View file

@ -1,8 +1,5 @@
package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
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.EndItems;
import java.util.Collections;
import java.util.List;
@SuppressWarnings("deprecation")
public class LumecornBlock extends BaseBlockNotFull implements IRenderTyped {
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_TOP = Block.box(6, 0, 6, 10, 8, 10);
public LumecornBlock() {
super(FabricBlockSettings.of(Material.WOOD)
.breakByTool(FabricToolTags.AXES)
.hardness(0.5F)
.luminance(state -> state.getValue(SHAPE).getLight()));
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(SHAPE);
@ -53,12 +53,12 @@ public class LumecornBlock extends BaseBlockNotFull implements IRenderTyped {
public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT;
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return state.getValue(SHAPE) == LumecornShape.LIGHT_TOP ? SHAPE_TOP : SHAPE_BOTTOM;
}
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
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);
}
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (!canSurvive(state, world, pos)) {
@ -82,7 +82,7 @@ public class LumecornBlock extends BaseBlockNotFull implements IRenderTyped {
return state;
}
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
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();
}
@Override
@Environment(EnvType.CLIENT)
public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) {

View file

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

View file

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

View file

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

View file

@ -1,9 +1,5 @@
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.minecraft.core.BlockPos;
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.betterend.registry.EndBlocks;
import java.util.Collections;
import java.util.List;
import java.util.Random;
@SuppressWarnings("deprecation")
public class MossyDragonBoneBlock extends BaseRotatedPillarBlock {
public MossyDragonBoneBlock() {
super(FabricBlockSettings.copyOf(Blocks.BONE_BLOCK).hardness(0.5F).randomTicks());
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
@ -35,7 +35,7 @@ public class MossyDragonBoneBlock extends BaseRotatedPillarBlock {
}
return Collections.singletonList(new ItemStack(EndBlocks.DRAGON_BONE_BLOCK));
}
@Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
if (random.nextInt(16) == 0 && !canSurvive(state, world, pos)) {
@ -45,15 +45,17 @@ public class MossyDragonBoneBlock extends BaseRotatedPillarBlock {
@Override
public boolean canSurvive(BlockState state, LevelReader worldView, BlockPos pos) {
BlockPos blockPos = pos.above();
BlockState blockState = worldView.getBlockState(blockPos);
if (blockState.is(Blocks.SNOW) && blockState.getValue(SnowLayerBlock.LAYERS) == 1) {
return true;
} else if (blockState.getFluidState().getAmount() == 8) {
return false;
} else {
int i = LayerLightEngine.getLightBlockInto(worldView, state, pos, blockState, blockPos, Direction.UP, blockState.getLightBlock(worldView, blockPos));
return i < 5;
}
}
BlockPos blockPos = pos.above();
BlockState blockState = worldView.getBlockState(blockPos);
if (blockState.is(Blocks.SNOW) && blockState.getValue(SnowLayerBlock.LAYERS) == 1) {
return true;
}
else if (blockState.getFluidState().getAmount() == 8) {
return false;
}
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 static final BooleanProperty TRANSITION = EndBlockProperties.TRANSITION;
public MossyGlowshroomCapBlock() {
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sound(SoundType.WOOD));
this.registerDefaultState(this.stateDefinition.any().setValue(TRANSITION, false));
}
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
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() {
return EndFeatures.MOSSY_GLOWSHROOM.getFeature();
}
@Override
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);

View file

@ -1,9 +1,5 @@
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.minecraft.core.BlockPos;
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 ru.bclib.blocks.BaseBlock;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public class MossyObsidian extends BaseBlock {
public MossyObsidian() {
super(FabricBlockSettings.copyOf(Blocks.OBSIDIAN).hardness(3).randomTicks());
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
@ -33,24 +33,26 @@ public class MossyObsidian extends BaseBlock {
}
return Collections.singletonList(new ItemStack(Blocks.OBSIDIAN));
}
@Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
if (random.nextInt(16) == 0 && !canSurvive(state, world, pos)) {
world.setBlockAndUpdate(pos, Blocks.OBSIDIAN.defaultBlockState());
}
}
public boolean canSurvive(BlockState state, LevelReader worldView, BlockPos pos) {
BlockPos blockPos = pos.above();
BlockState blockState = worldView.getBlockState(blockPos);
if (blockState.is(Blocks.SNOW) && (Integer)blockState.getValue(SnowLayerBlock.LAYERS) == 1) {
return true;
} else if (blockState.getFluidState().getAmount() == 8) {
return false;
} else {
int i = LayerLightEngine.getLightBlockInto(worldView, state, pos, blockState, blockPos, Direction.UP, blockState.getLightBlock(worldView, blockPos));
return i < 5;
}
}
BlockPos blockPos = pos.above();
BlockState blockState = worldView.getBlockState(blockPos);
if (blockState.is(Blocks.SNOW) && (Integer) blockState.getValue(SnowLayerBlock.LAYERS) == 1) {
return true;
}
else if (blockState.getFluidState().getAmount() == 8) {
return false;
}
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;
import java.util.Random;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
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.registry.EndBlocks;
import java.util.Random;
public class MurkweedBlock extends EndPlantBlock {
@Override
@Environment(EnvType.CLIENT)
@ -27,19 +27,19 @@ public class MurkweedBlock extends EndPlantBlock {
double v = random.nextDouble() * 0.1;
world.addParticle(ParticleTypes.ENTITY_EFFECT, x, y, z, v, v, v);
}
@Override
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
if (entity instanceof LivingEntity && !((LivingEntity) entity).hasEffect(MobEffects.BLINDNESS)) {
((LivingEntity) entity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 50));
}
}
@Override
protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.SHADOW_GRASS);
}
@Override
public boolean isPathfindable(BlockState state, BlockGetter world, BlockPos pos, PathComputationType type) {
return false;

View file

@ -1,9 +1,6 @@
package ru.betterend.blocks;
import java.util.List;
import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos;
import net.minecraft.world.damagesource.DamageSource;
@ -23,6 +20,8 @@ import ru.bclib.util.MHelper;
import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks;
import java.util.List;
public class NeedlegrassBlock extends EndPlantBlock {
@Override
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);
}
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
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)));
}
}
@Override
protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.SHADOW_GRASS);

View file

@ -1,12 +1,7 @@
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.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
@ -48,13 +43,17 @@ import ru.bclib.util.MHelper;
import ru.betterend.blocks.EndBlockProperties.CactusBottom;
import ru.betterend.registry.EndBlocks;
import java.util.EnumMap;
import java.util.List;
import java.util.Random;
@SuppressWarnings("deprecation")
public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWaterloggedBlock, IRenderTyped {
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
public static final EnumProperty<CactusBottom> CACTUS_BOTTOM = EndBlockProperties.CACTUS_BOTTOM;
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
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> MEDIUM_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> SMALL_SHAPES = Maps.newEnumMap(Axis.class);
private static final int MAX_LENGTH = 12;
public NeonCactusPlantBlock() {
super(FabricBlockSettings.copyOf(Blocks.CACTUS).luminance(15).randomTicks());
registerDefaultState(defaultBlockState().setValue(WATERLOGGED, false).setValue(FACING, Direction.UP).setValue(SHAPE, TripleShape.TOP));
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(SHAPE, CACTUS_BOTTOM, WATERLOGGED, FACING);
}
@Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
LevelAccessor world = ctx.getLevel();
@ -91,7 +90,7 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
}
return state;
}
@Override
public BlockState rotate(BlockState state, Rotation rotation) {
return BlocksHelper.rotateHorizontal(state, rotation, FACING);
@ -101,12 +100,12 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
public BlockState mirror(BlockState state, Mirror mirror) {
return BlocksHelper.mirrorHorizontal(state, mirror, FACING);
}
@Override
public FluidState getFluidState(BlockState state) {
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
}
@Override
public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, BlockPos pos, BlockPos posFrom) {
world.getBlockTicks().scheduleTick(pos, this, 2);
@ -126,19 +125,19 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
}
return state;
}
@Override
public void tick(BlockState blockState, ServerLevel serverLevel, BlockPos blockPos, Random random) {
if (!blockState.canSurvive(serverLevel, blockPos)) {
serverLevel.destroyBlock(blockPos, true, null, 1);
}
}
@Override
public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT;
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
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);
}
}
@Override
public boolean canSurvive(BlockState state, LevelReader level, BlockPos pos) {
Direction dir = state.getValue(FACING);
@ -166,12 +165,12 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
BlockState support = level.getBlockState(supportPos);
return support.is(this) || support.isFaceSturdy(level, supportPos, dir);
}
@Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
if (!this.canSurvive(state, world, pos) || random.nextInt(8) > 0) {
return;
}
}
Direction dir = state.getValue(FACING);
if (!world.isEmptyBlock(pos.relative(dir))) {
return;
@ -201,11 +200,11 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
BlocksHelper.setWithoutUpdate(world, pos.relative(dir), placement);
mutateStem(placement, world, pos, MAX_LENGTH);
}
public void growPlant(WorldGenLevel world, BlockPos pos, Random random) {
growPlant(world, pos, random, MHelper.randRange(MAX_LENGTH >> 1, MAX_LENGTH, random));
}
public void growPlant(WorldGenLevel world, BlockPos pos, Random random, int iterations) {
BlockState state = defaultBlockState();
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) {
BlockState state = world.getBlockState(pos);
if (!state.is(this)) {
@ -265,7 +264,7 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
pos.move(dir);
return true;
}
private Direction getSideDirection(WorldGenLevel world, BlockPos pos, BlockState iterState, Direction dir, Random random) {
MutableBlockPos iterPos = pos.mutable();
Direction startDir = dir;
@ -273,7 +272,7 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
while (iterState.is(this) && startDir.getAxis().isVertical()) {
startDir = iterState.getValue(FACING);
if (lastDir == null) {
for (Direction side: BlocksHelper.HORIZONTAL) {
for (Direction side : BlocksHelper.HORIZONTAL) {
BlockState sideState = world.getBlockState(iterPos.relative(side));
if (sideState.is(this)) {
Direction sideDir = sideState.getValue(FACING);
@ -287,7 +286,7 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
iterPos.move(dir);
iterState = world.getBlockState(iterPos);
}
Direction side = lastDir == null ? BlocksHelper.randomHorizontal(random) : lastDir.getClockWise();
if (side.getOpposite() == startDir) {
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) {
return false;
}
@Override
public void entityInside(BlockState blockState, Level level, BlockPos blockPos, Entity entity) {
entity.hurt(DamageSource.CACTUS, 1.0F);
}
private int getLength(BlockState state, ServerLevel world, BlockPos pos, int max) {
int length = 0;
Direction dir = state.getValue(FACING).getOpposite();
@ -319,11 +318,11 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
break;
}
dir = state.getValue(FACING).getOpposite();
length ++;
length++;
}
return length;
}
private int getHorizontal(BlockState state, WorldGenLevel world, BlockPos pos, int max) {
int count = 0;
Direction dir = state.getValue(FACING).getOpposite();
@ -338,11 +337,11 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
if (dir.getStepY() != 0) {
break;
}
count ++;
count++;
}
return count;
}
private void mutateStem(BlockState state, WorldGenLevel world, BlockPos pos, int max) {
Direction dir = state.getValue(FACING).getOpposite();
MutableBlockPos mut = new MutableBlockPos().set(pos);
@ -361,39 +360,39 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
}
}
}
static {
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.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.Y, Block.box(3, 0, 3, 13, 16, 13));
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.Y, Block.box(4, 0, 4, 12, 16, 12));
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.DOWN, Block.box(2, 2, 2, 14, 16, 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.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.WEST, Block.box(2, 2, 2, 16, 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.DOWN, Block.box(3, 3, 3, 13, 16, 13));
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));
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.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.WEST, Block.box(3, 3, 3, 16, 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.DOWN, Block.box(4, 4, 4, 12, 16, 12));
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));
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.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.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.WEST, Block.box(4, 4, 4, 16, 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;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import ru.betterend.blocks.basis.PedestalBlock;
import java.util.HashMap;
import java.util.Map;
public class PedestalVanilla extends PedestalBlock {
public PedestalVanilla(Block parent) {
@ -20,8 +20,9 @@ public class PedestalVanilla extends PedestalBlock {
String name = blockId.getPath().replace("_block", "");
return new HashMap<String, String>() {
private static final long serialVersionUID = 1L;
{
put("%mod%", blockId.getNamespace() );
put("%mod%", blockId.getNamespace());
put("%top%", "polished_" + name);
put("%base%", "polished_" + name);
put("%pillar%", name + "_pillar");

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
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.registry.EndParticles;
import java.util.Random;
public class ShadowGrassBlock extends EndTerrainBlock {
public ShadowGrassBlock() {
super(MaterialColor.COLOR_BLACK);

View file

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

View file

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

View file

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

View file

@ -1,12 +1,7 @@
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.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos;
@ -37,9 +32,13 @@ import ru.bclib.interfaces.IRenderTyped;
import ru.bclib.util.BlocksHelper;
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 {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
public SmallJellyshroomBlock() {
super(FabricBlockSettings.of(Material.PLANT)
.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) {
return BOUNDING_SHAPES.get(state.getValue(FACING));
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
@ -64,7 +63,7 @@ public class SmallJellyshroomBlock extends BaseAttachedBlock implements IRenderT
return Lists.newArrayList();
}
}
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
Direction direction = state.getValue(FACING);
@ -72,12 +71,12 @@ public class SmallJellyshroomBlock extends BaseAttachedBlock implements IRenderT
BlockState support = world.getBlockState(blockPos);
return canSupportCenter(world, blockPos, direction) && support.canOcclude() && support.getLightEmission() == 0;
}
@Override
public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT;
}
static {
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));

View file

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

View file

@ -1,12 +1,7 @@
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.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos;
@ -41,12 +36,16 @@ import ru.bclib.util.MHelper;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems;
import java.util.Collections;
import java.util.EnumMap;
import java.util.List;
@SuppressWarnings("deprecation")
public class SulphurCrystalBlock extends BaseAttachedBlock implements IRenderTyped, SimpleWaterloggedBlock, LiquidBlockContainer {
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 BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public SulphurCrystalBlock() {
super(FabricBlockSettings.of(Material.STONE)
.materialColor(MaterialColor.COLOR_YELLOW)
@ -55,23 +54,23 @@ public class SulphurCrystalBlock extends BaseAttachedBlock implements IRenderTyp
.requiresCorrectToolForDrops()
.noCollission());
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
super.createBlockStateDefinition(stateManager);
stateManager.add(AGE, WATERLOGGED);
}
@Override
public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT;
}
@Override
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)));
}
@Override
public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) {
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) {
return !state.getValue(WATERLOGGED);
}
@Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
BlockState state = super.getStateForPlacement(ctx);
@ -93,24 +92,24 @@ public class SulphurCrystalBlock extends BaseAttachedBlock implements IRenderTyp
}
return null;
}
@Override
public FluidState getFluidState(BlockState state) {
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState();
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return BOUNDING_SHAPES.get(state.getValue(FACING));
}
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
Direction direction = state.getValue(FACING);
BlockPos blockPos = pos.relative(direction.getOpposite());
return world.getBlockState(blockPos).is(EndBlocks.BRIMSTONE);
}
static {
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));

View file

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

View file

@ -17,7 +17,7 @@ public class TenaneaSaplingBlock extends FeatureSaplingBlock {
protected Feature<?> getFeature() {
return EndFeatures.TENANEA.getFeature();
}
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
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 {
private final Block[] ground;
public TerrainPlantBlock(Block... ground) {
super(true);
this.ground = ground;
}
@Override
protected boolean isTerrain(BlockState state) {
for (Block block: ground) {
for (Block block : ground) {
if (state.is(block)) {
return true;
}

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.core.BlockPos;
@ -14,34 +12,36 @@ import ru.bclib.util.BlocksHelper;
import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class TwistedUmbrellaMossBlock extends EndPlantBlock {
public TwistedUmbrellaMossBlock() {
super(11);
}
@Override
protected boolean isTerrain(BlockState state) {
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)
public float getAmbientOcclusionLightLevel(BlockGetter world, BlockPos pos) {
return 1F;
}
@Override
@Environment(EnvType.CLIENT)
public boolean hasEmissiveLighting(BlockGetter world, BlockPos pos) {
return true;
}
@Environment(EnvType.CLIENT)
public float getAmbientOcclusionLightLevel(BlockGetter world, BlockPos pos) {
return 1F;
}
@Override
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
return world.isEmptyBlock(pos.above());
}
@Override
@Override
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);
BlocksHelper.setWithoutUpdate(world, pos, bs);
BlocksHelper.setWithoutUpdate(world, pos.above(), bs.setValue(BaseDoublePlantBlock.TOP, true));

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
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.betterend.registry.EndBlocks;
import java.util.Random;
public class TwistedUmbrellaMossTallBlock extends BaseDoublePlantBlock {
public TwistedUmbrellaMossTallBlock() {
super(12);
}
@Override
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));
world.addFreshEntity(item);
}
@Override
protected boolean isTerrain(BlockState state) {
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;
import java.util.Random;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.core.BlockPos;
@ -14,34 +12,36 @@ import ru.bclib.util.BlocksHelper;
import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class UmbrellaMossBlock extends EndPlantBlock {
public UmbrellaMossBlock() {
super(11);
}
@Override
protected boolean isTerrain(BlockState state) {
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)
public float getAmbientOcclusionLightLevel(BlockGetter world, BlockPos pos) {
return 1F;
}
@Override
@Environment(EnvType.CLIENT)
public boolean hasEmissiveLighting(BlockGetter world, BlockPos pos) {
return true;
}
@Environment(EnvType.CLIENT)
public float getAmbientOcclusionLightLevel(BlockGetter world, BlockPos pos) {
return 1F;
}
@Override
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
return world.isEmptyBlock(pos.above());
}
@Override
@Override
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);
BlocksHelper.setWithoutUpdate(world, pos, bs);
BlocksHelper.setWithoutUpdate(world, pos.above(), bs.setValue(BaseDoublePlantBlock.TOP, true));

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
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.betterend.registry.EndBlocks;
import java.util.Random;
public class UmbrellaMossTallBlock extends BaseDoublePlantBlock {
public UmbrellaMossTallBlock() {
super(12);
}
@Override
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));
world.addFreshEntity(item);
}
@Override
protected boolean isTerrain(BlockState state) {
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 static final BooleanProperty NATURAL = BlockProperties.NATURAL;
public UmbrellaTreeClusterBlock() {
super(FabricBlockSettings.copyOf(Blocks.NETHER_WART_BLOCK)
.materialColor(MaterialColor.COLOR_PURPLE)
.luminance(15));
registerDefaultState(stateDefinition.any().setValue(NATURAL, false));
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(NATURAL);
}
@Override
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
ItemStack stack = player.getMainHandItem();

View file

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

View file

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

View file

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

View file

@ -1,8 +1,5 @@
package ru.betterend.blocks;
import java.util.Optional;
import java.util.Random;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
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.betterend.registry.EndBlocks;
import java.util.Optional;
import java.util.Random;
public class VentBubbleColumnBlock extends Block implements BucketPickup, LiquidBlockContainer {
public VentBubbleColumnBlock() {
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);
return new ItemStack(Items.WATER_BUCKET);
}
@Override
public RenderShape getRenderShape(BlockState state) {
return RenderShape.INVISIBLE;
@ -109,7 +109,7 @@ public class VentBubbleColumnBlock extends Block implements BucketPickup, Liquid
entity.onInsideBubbleColumn(false);
}
}
@Override
public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) {
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) {
return false;
}
@Override
public FluidState getFluidState(BlockState state) {
return Fluids.WATER.getSource(false);
}
@Override
public Optional<SoundEvent> getPickupSound() {
return Fluids.WATER.getPickupSound();

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,17 +1,6 @@
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 net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
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.EntityBlock;
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.StateDefinition;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
@ -44,6 +35,7 @@ import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.Nullable;
import ru.bclib.blocks.BaseBlockNotFull;
import ru.bclib.blocks.BlockProperties;
import ru.bclib.client.models.ModelsHelper;
@ -57,59 +49,63 @@ import ru.betterend.registry.EndBlockEntities;
import ru.betterend.registry.EndBlocks;
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"})
public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
public final static EnumProperty<PedestalState> STATE = EndBlockProperties.PEDESTAL_STATE;
public static final BooleanProperty HAS_ITEM = EndBlockProperties.HAS_ITEM;
public static final BooleanProperty HAS_LIGHT = BlockProperties.HAS_LIGHT;
private static final VoxelShape SHAPE_DEFAULT;
private static final VoxelShape SHAPE_COLUMN;
private static final VoxelShape SHAPE_PILLAR;
private static final VoxelShape SHAPE_PEDESTAL_TOP;
private static final VoxelShape SHAPE_COLUMN_TOP;
private static final VoxelShape SHAPE_BOTTOM;
/**
*
* Register new Pedestal block with Better End mod id.
*
* @param name pedestal name
*
* @param name pedestal name
* @param source source block
* @return new Pedestal block with Better End id.
*/
public static Block registerPedestal(String name, Block source) {
return EndBlocks.registerBlock(name, new PedestalBlock(source));
}
/**
*
* Register new Pedestal block with specified mod id.
*
* @param id pedestal id
*
* @param id pedestal id
* @param source source block
* @return new Pedestal block with specified id.
*/
public static Block registerPedestal(ResourceLocation id, Block source) {
return EndBlocks.registerBlock(id, new PedestalBlock(source));
}
protected final Block parent;
protected float height = 1.0F;
public PedestalBlock(Block parent) {
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.parent = parent;
}
public float getHeight(BlockState state) {
if (state.getBlock() instanceof PedestalBlock && state.getValue(STATE) == PedestalState.PEDESTAL_TOP) {
return this.height - 0.2F;
}
return this.height;
}
@Override
@Deprecated
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
@ -126,7 +122,8 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
pedestal.setItem(0, itemStack);
checkRitual(world, pos);
return InteractionResult.SUCCESS;
} else {
}
else {
ItemStack itemStack = pedestal.getItem(0);
if (player.addItem(itemStack)) {
pedestal.removeItemNoUpdate(0);
@ -142,7 +139,7 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
@Override
public void destroy(LevelAccessor levelAccessor, BlockPos blockPos, BlockState blockState) {
MutableBlockPos posMutable = new MutableBlockPos();
for (Point point: InfusionRitual.getMap()) {
for (Point point : InfusionRitual.getMap()) {
posMutable.set(blockPos).move(point.x, 0, point.y);
BlockState state = levelAccessor.getBlockState(posMutable);
if (state.getBlock() instanceof InfusionPedestal) {
@ -160,7 +157,7 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
public void checkRitual(Level world, BlockPos pos) {
MutableBlockPos posMutable = new MutableBlockPos();
for (Point point: InfusionRitual.getMap()) {
for (Point point : InfusionRitual.getMap()) {
posMutable.set(pos).move(point.x, 0, point.y);
BlockState state = world.getBlockState(posMutable);
if (state.getBlock() instanceof InfusionPedestal) {
@ -169,7 +166,7 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
}
}
}
@Override
@Nullable
public BlockState getStateForPlacement(BlockPlaceContext context) {
@ -182,18 +179,22 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
boolean hasPedestalUnder = downState.getBlock() instanceof PedestalBlock;
if (!hasPedestalOver && hasPedestalUnder && upSideSolid) {
return defaultBlockState().setValue(STATE, PedestalState.COLUMN_TOP);
} else if (!hasPedestalOver && !hasPedestalUnder && upSideSolid) {
}
else if (!hasPedestalOver && !hasPedestalUnder && upSideSolid) {
return defaultBlockState().setValue(STATE, PedestalState.COLUMN);
} else if (hasPedestalUnder && hasPedestalOver) {
}
else if (hasPedestalUnder && hasPedestalOver) {
return defaultBlockState().setValue(STATE, PedestalState.PILLAR);
} else if (hasPedestalUnder) {
}
else if (hasPedestalUnder) {
return defaultBlockState().setValue(STATE, PedestalState.PEDESTAL_TOP);
} else if (hasPedestalOver) {
}
else if (hasPedestalOver) {
return defaultBlockState().setValue(STATE, PedestalState.BOTTOM);
}
return defaultBlockState();
}
@Override
@Deprecated
public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, BlockPos pos, BlockPos posFrom) {
@ -204,7 +205,7 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
}
return updated;
}
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 (direction != Direction.UP && direction != Direction.DOWN) return state;
@ -216,21 +217,27 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
if (direction == Direction.UP) {
upSideSolid = newState.isFaceSturdy(world, posFrom, Direction.DOWN) || newState.is(BlockTags.WALLS);
hasPedestalOver = newState.getBlock() instanceof PedestalBlock;
} else {
}
else {
hasPedestalUnder = newState.getBlock() instanceof PedestalBlock;
}
BlockState updatedState;
if (!hasPedestalOver && hasPedestalUnder && upSideSolid) {
updatedState = state.setValue(STATE, PedestalState.COLUMN_TOP);
} else if (!hasPedestalOver && !hasPedestalUnder && upSideSolid) {
}
else if (!hasPedestalOver && !hasPedestalUnder && upSideSolid) {
updatedState = state.setValue(STATE, PedestalState.COLUMN);
} else if (hasPedestalUnder && hasPedestalOver) {
}
else if (hasPedestalUnder && hasPedestalOver) {
updatedState = state.setValue(STATE, PedestalState.PILLAR);
} else if (hasPedestalUnder) {
}
else if (hasPedestalUnder) {
updatedState = state.setValue(STATE, PedestalState.PEDESTAL_TOP);
} else if (hasPedestalOver) {
}
else if (hasPedestalOver) {
updatedState = state.setValue(STATE, PedestalState.BOTTOM);
} else {
}
else {
updatedState = state.setValue(STATE, PedestalState.DEFAULT);
}
if (!isPlaceable(updatedState)) {
@ -238,7 +245,7 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
}
return updatedState;
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
List<ItemStack> drop = Lists.newArrayList(super.getDrops(state, builder));
@ -251,13 +258,14 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
drop.add(pedestal.getItem(0));
}
}
} else {
}
else {
return drop;
}
}
return drop;
}
private void moveStoredStack(LevelAccessor world, BlockState state, BlockPos pos) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity instanceof PedestalBlockEntity && state.is(this)) {
@ -268,34 +276,39 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
}
}
}
private void moveStoredStack(BlockEntity blockEntity, LevelAccessor world, ItemStack stack, BlockPos pos) {
BlockState state = world.getBlockState(pos);
if (!state.is(this)) {
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());
} else if (!isPlaceable(state)) {
}
else if (!isPlaceable(state)) {
dropStoredStack(blockEntity, stack, pos);
} else if (blockEntity instanceof PedestalBlockEntity) {
}
else if (blockEntity instanceof PedestalBlockEntity) {
PedestalBlockEntity pedestal = (PedestalBlockEntity) blockEntity;
if (pedestal.isEmpty()) {
pedestal.setItem(0, stack);
} else {
}
else {
dropStoredStack(blockEntity, stack, pos);
}
} else {
}
else {
dropStoredStack(blockEntity, stack, pos);
}
}
private void dropStoredStack(BlockEntity blockEntity, ItemStack stack, BlockPos pos) {
if (blockEntity != null && blockEntity.getLevel() != null) {
Level world = blockEntity.getLevel();
Block.popResource(world, getDropPos(world, pos), stack);
}
}
private BlockPos getDropPos(LevelAccessor world, BlockPos pos) {
BlockPos dropPos;
if (world.getBlockState(pos).isAir()) {
@ -304,7 +317,7 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
if (world.getBlockState(pos.above()).isAir()) {
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));
if (world.getBlockState(dropPos).isAir()) {
return dropPos.immutable();
@ -312,19 +325,19 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
}
return getDropPos(world, pos.above());
}
public boolean isPlaceable(BlockState state) {
if (!state.is(this)) return false;
PedestalState currentState = state.getValue(STATE);
return currentState == PedestalState.DEFAULT ||
currentState == PedestalState.PEDESTAL_TOP;
currentState == PedestalState.PEDESTAL_TOP;
}
@Override
@Deprecated
public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
if (state.is(this)) {
switch(state.getValue(STATE)) {
switch (state.getValue(STATE)) {
case BOTTOM: {
return SHAPE_BOTTOM;
}
@ -347,7 +360,7 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
}
return super.getShape(state, world, pos, context);
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(STATE, HAS_ITEM, HAS_LIGHT);
@ -361,13 +374,13 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
public boolean hasUniqueEntity() {
return false;
}
@Override
@Deprecated
public boolean hasAnalogOutputSignal(BlockState state) {
return state.getBlock() instanceof PedestalBlock;
}
@Override
@Deprecated
public int getAnalogOutputSignal(BlockState state, Level world, BlockPos pos) {
@ -402,7 +415,8 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
case PILLAR:
pattern = Patterns.createJson(Patterns.BLOCK_PEDESTAL_PILLAR, textures);
break;
default: break;
default:
break;
}
return ModelsHelper.fromPattern(pattern);
}
@ -422,8 +436,9 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
String name = blockId.getPath();
return new HashMap<String, String>() {
private static final long serialVersionUID = 1L;
{
put("%mod%", blockId.getNamespace() );
put("%mod%", blockId.getNamespace());
put("%top%", name + "_top");
put("%base%", name + "_base");
put("%pillar%", name + "_pillar");
@ -438,7 +453,7 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
if (level.isClientSide) return null;
BlockEntityTicker<T> ticker = createTickerHelper(blockEntityType, EndBlockEntities.PEDESTAL, PedestalBlockEntity::tick);
if (ticker!=null) return ticker;
if (ticker != null) return ticker;
return createTickerHelper(blockEntityType, EndBlockEntities.INFUSION_PEDESTAL, InfusionPedestalEntity::tick);
}
@ -447,7 +462,7 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
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 {
VoxelShape basinUp = Block.box(2, 3, 2, 14, 4, 14);
VoxelShape basinDown = Block.box(0, 0, 0, 16, 3, 16);

View file

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

View file

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

View file

@ -29,7 +29,7 @@ public class CrystalSubblocksMaterial {
public final Block brick_stairs;
public final Block brick_slab;
public final Block brick_wall;
public CrystalSubblocksMaterial(String name, Block source) {
FabricBlockSettings material = FabricBlockSettings.copyOf(source);
polished = EndBlocks.registerBlock(name + "_polished", new BaseBlock(material));
@ -43,29 +43,29 @@ public class CrystalSubblocksMaterial {
brick_stairs = EndBlocks.registerBlock(name + "_bricks_stairs", new BaseStairsBlock(bricks));
brick_slab = EndBlocks.registerBlock(name + "_bricks_slab", new BaseSlabBlock(bricks));
brick_wall = EndBlocks.registerBlock(name + "_bricks_wall", new BaseWallBlock(bricks));
// Recipes //
GridRecipe.make(BetterEnd.MOD_ID, name + "_bricks", bricks).checkConfig(Configs.RECIPE_CONFIG).setOutputCount(4).setShape("##", "##").addMaterial('#', source).setGroup("end_bricks").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_polished", polished).checkConfig(Configs.RECIPE_CONFIG).setOutputCount(4).setShape("##", "##").addMaterial('#', bricks).setGroup("end_tile").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_tiles", tiles).checkConfig(Configs.RECIPE_CONFIG).setOutputCount(4).setShape("##", "##").addMaterial('#', polished).setGroup("end_small_tile").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_pillar", pillar).checkConfig(Configs.RECIPE_CONFIG).setShape("#", "#").addMaterial('#', slab).setGroup("end_pillar").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_stairs", stairs).checkConfig(Configs.RECIPE_CONFIG).setOutputCount(4).setShape("# ", "## ", "###").addMaterial('#', source).setGroup("end_stone_stairs").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_slab", slab).checkConfig(Configs.RECIPE_CONFIG).setOutputCount(6).setShape("###").addMaterial('#', source).setGroup("end_stone_slabs").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_bricks_stairs", brick_stairs).checkConfig(Configs.RECIPE_CONFIG).setOutputCount(4).setShape("# ", "## ", "###").addMaterial('#', bricks).setGroup("end_stone_stairs").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_bricks_slab", brick_slab).checkConfig(Configs.RECIPE_CONFIG).setOutputCount(6).setShape("###").addMaterial('#', bricks).setGroup("end_stone_slabs").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_wall", wall).checkConfig(Configs.RECIPE_CONFIG).setOutputCount(6).setShape("###", "###").addMaterial('#', source).setGroup("end_wall").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_bricks_wall", brick_wall).checkConfig(Configs.RECIPE_CONFIG).setOutputCount(6).setShape("###", "###").addMaterial('#', bricks).setGroup("end_wall").build();
CraftingRecipes.registerPedestal(name + "_pedestal", pedestal, slab, pillar);
// Item Tags //
TagHelper.addTag(ItemTags.SLABS, slab, brick_slab);
TagHelper.addTag(ItemTags.STONE_BRICKS, bricks);
TagHelper.addTag(ItemTags.STONE_CRAFTING_MATERIALS, source);
TagHelper.addTag(ItemTags.STONE_TOOL_MATERIALS, source);
// Block Tags //
TagHelper.addTag(BlockTags.STONE_BRICKS, bricks);
TagHelper.addTag(BlockTags.WALLS, wall, brick_wall);

View file

@ -28,7 +28,6 @@ import ru.bclib.blocks.WoodenPressurePlateBlock;
import ru.bclib.items.ModelProviderItem;
import ru.bclib.items.tool.BaseAxeItem;
import ru.bclib.items.tool.BaseHoeItem;
import ru.bclib.items.tool.BasePickaxeItem;
import ru.bclib.items.tool.BaseShovelItem;
import ru.bclib.items.tool.BaseSwordItem;
import ru.bclib.recipes.FurnaceRecipe;
@ -49,7 +48,6 @@ import ru.betterend.recipe.builders.AlloyingRecipe;
import ru.betterend.recipe.builders.AnvilRecipe;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems;
import ru.betterend.registry.EndTags;
public class MetalMaterial {
public final Block ore;
@ -62,7 +60,7 @@ public class MetalMaterial {
public final Block chain;
public final Block stairs;
public final Block slab;
public final Block chandelier;
public final Block bulb_lantern;
public final ColoredMaterial bulb_lantern_colored;
@ -73,21 +71,21 @@ public class MetalMaterial {
public final Item rawOre;
public final Item nugget;
public final Item ingot;
public final Item shovelHead;
public final Item pickaxeHead;
public final Item axeHead;
public final Item hoeHead;
public final Item swordBlade;
public final Item swordHandle;
public final Item shovel;
public final Item sword;
public final Item pickaxe;
public final Item axe;
public final Item hoe;
public final Item hammer;
public final Item forgedPlate;
public final Item helmet;
public final Item chestplate;
@ -95,23 +93,23 @@ public class MetalMaterial {
public final Item boots;
public final Tag.Named<Item> alloyingOre;
public static MetalMaterial makeNormal(String name, MaterialColor color, Tier material, ArmorMaterial armor) {
return new MetalMaterial(name, true, FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).materialColor(color), EndItems.makeEndItemSettings(), material, armor);
}
public static MetalMaterial makeNormal(String name, MaterialColor color, float hardness, float resistance, Tier material, ArmorMaterial armor) {
return new MetalMaterial(name, true, FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).materialColor(color).hardness(hardness).resistance(resistance), EndItems.makeEndItemSettings(), material, armor);
}
public static MetalMaterial makeOreless(String name, MaterialColor color, Tier material, ArmorMaterial armor) {
return new MetalMaterial(name, false, FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).materialColor(color), EndItems.makeEndItemSettings(), material, armor);
}
public static MetalMaterial makeOreless(String name, MaterialColor color, float hardness, float resistance, Tier material, ArmorMaterial armor) {
return new MetalMaterial(name, false, FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).materialColor(color).hardness(hardness).resistance(resistance), EndItems.makeEndItemSettings(), material, armor);
}
private MetalMaterial(String name, boolean hasOre, FabricBlockSettings settings, Properties itemSettings, Tier material, ArmorMaterial armor) {
BlockBehaviour.Properties lanternProperties = FabricBlockSettings.copyOf(settings).hardness(1).resistance(1).luminance(15).sound(SoundType.LANTERN);
final int level = material.getLevel();
@ -132,28 +130,28 @@ public class MetalMaterial {
bars = EndBlocks.registerBlock(name + "_bars", new BaseMetalBarsBlock(block));
chain = EndBlocks.registerBlock(name + "_chain", new BaseChainBlock(block.defaultMaterialColor()));
pressurePlate = EndBlocks.registerBlock(name + "_plate", new WoodenPressurePlateBlock(block));
chandelier = EndBlocks.registerBlock(name + "_chandelier", new ChandelierBlock(block));
bulb_lantern = EndBlocks.registerBlock(name + "_bulb_lantern", new BulbVineLanternBlock(lanternProperties));
bulb_lantern_colored = new ColoredMaterial(BulbVineLanternColoredBlock::new, bulb_lantern, false);
nugget = EndItems.registerEndItem(name + "_nugget", new ModelProviderItem(itemSettings));
ingot = EndItems.registerEndItem(name + "_ingot", new ModelProviderItem(itemSettings));
shovelHead = EndItems.registerEndItem(name + "_shovel_head");
pickaxeHead = EndItems.registerEndItem(name + "_pickaxe_head");
axeHead = EndItems.registerEndItem(name + "_axe_head");
hoeHead = EndItems.registerEndItem(name + "_hoe_head");
swordBlade = EndItems.registerEndItem(name + "_sword_blade");
swordHandle = EndItems.registerEndItem(name + "_sword_handle");
shovel = EndItems.registerEndTool(name + "_shovel", new BaseShovelItem(material, 1.5F, -3.0F, itemSettings));
sword = EndItems.registerEndTool(name + "_sword", new BaseSwordItem(material, 3, -2.4F, itemSettings));
pickaxe = EndItems.registerEndTool(name + "_pickaxe", new EndPickaxe(material, 1, -2.8F, itemSettings));
axe = EndItems.registerEndTool(name + "_axe", new BaseAxeItem(material, 6.0F, -3.0F, itemSettings));
hoe = EndItems.registerEndTool(name + "_hoe", new BaseHoeItem(material, -3, 0.0F, itemSettings));
hammer = EndItems.registerEndTool(name + "_hammer", new EndHammerItem(material, 5.0F, -3.2F, 0.3D, itemSettings));
forgedPlate = EndItems.registerEndItem(name + "_forged_plate");
helmet = EndItems.registerEndItem(name + "_helmet", new EndArmorItem(armor, EquipmentSlot.HEAD, itemSettings));
chestplate = EndItems.registerEndItem(name + "_chestplate", new EndArmorItem(armor, EquipmentSlot.CHEST, itemSettings));
@ -162,19 +160,19 @@ public class MetalMaterial {
anvilBlock = EndBlocks.registerBlock(name + "_anvil", new EndAnvilBlock(this, block.defaultMaterialColor(), level));
anvilItem = EndItems.registerEndItem(name + "_anvil_item", new EndAnvilItem(anvilBlock));
if (hasOre) {
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_ingot_furnace_ore", ore, ingot).checkConfig(Configs.RECIPE_CONFIG).setGroup("end_ingot").buildWithBlasting();
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_ingot_furnace_raw", rawOre, ingot).checkConfig(Configs.RECIPE_CONFIG).setGroup("end_ingot").buildWithBlasting();
AlloyingRecipe.Builder.create(name + "_ingot_alloy").setInput(alloyingOre, alloyingOre).setOutput(ingot, 3).setExpiriense(2.1F).build();
}
// Basic recipes
GridRecipe.make(BetterEnd.MOD_ID, name + "_ingot_from_nuggets", ingot).checkConfig(Configs.RECIPE_CONFIG).setShape("###", "###", "###").addMaterial('#', nugget).setGroup("end_metal_ingots_nug").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_nuggets_from_ingot", nugget).checkConfig(Configs.RECIPE_CONFIG).setOutputCount(9).setList("#").addMaterial('#', ingot).setGroup("end_metal_nuggets_ing").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_block", block).checkConfig(Configs.RECIPE_CONFIG).setShape("###", "###", "###").addMaterial('#', ingot).setGroup("end_metal_blocks").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_ingot_from_block", ingot).checkConfig(Configs.RECIPE_CONFIG).setOutputCount(9).setList("#").addMaterial('#', block).setGroup("end_metal_ingots").build();
// Block recipes
GridRecipe.make(BetterEnd.MOD_ID, name + "_tile", tile).checkConfig(Configs.RECIPE_CONFIG).setOutputCount(4).setShape("##", "##").addMaterial('#', block).setGroup("end_metal_tiles").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_bars", bars).checkConfig(Configs.RECIPE_CONFIG).setOutputCount(16).setShape("###", "###").addMaterial('#', ingot).setGroup("end_metal_bars").build();
@ -186,9 +184,9 @@ public class MetalMaterial {
GridRecipe.make(BetterEnd.MOD_ID, name + "_chain", chain).checkConfig(Configs.RECIPE_CONFIG).setShape("N", "#", "N").addMaterial('#', ingot).addMaterial('N', nugget).setGroup("end_metal_chain").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_anvil", anvilBlock).checkConfig(Configs.RECIPE_CONFIG).setShape("###", " I ", "III").addMaterial('#', block, tile).addMaterial('I', ingot).setGroup("end_metal_anvil").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_bulb_lantern", bulb_lantern).checkConfig(Configs.RECIPE_CONFIG).setShape("C", "I", "#").addMaterial('C', chain).addMaterial('I', ingot).addMaterial('#', EndItems.GLOWING_BULB).build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_chandelier", chandelier).checkConfig(Configs.RECIPE_CONFIG).setShape("I#I", " # ").addMaterial('#', ingot).addMaterial('I', EndItems.LUMECORN_ROD).setGroup("end_metal_chandelier").build();
// Tools & armor into nuggets
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_axe_nugget", axe, nugget).checkConfig(Configs.RECIPE_CONFIG).setGroup("end_nugget").buildWithBlasting();
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_hoe_nugget", hoe, nugget).checkConfig(Configs.RECIPE_CONFIG).setGroup("end_nugget").buildWithBlasting();
@ -199,7 +197,7 @@ public class MetalMaterial {
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_chestplate_nugget", chestplate, nugget).checkConfig(Configs.RECIPE_CONFIG).setGroup("end_nugget").buildWithBlasting();
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_leggings_nugget", leggings, nugget).checkConfig(Configs.RECIPE_CONFIG).setGroup("end_nugget").buildWithBlasting();
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_boots_nugget", boots, nugget).checkConfig(Configs.RECIPE_CONFIG).setGroup("end_nugget").buildWithBlasting();
// Tool parts from ingots
AnvilRecipe.Builder.create(name + "_shovel_head").setInput(ingot).setOutput(shovelHead).setAnvilLevel(level).setToolLevel(level).setDamage(level).build();
AnvilRecipe.Builder.create(name + "_pickaxe_head").setInput(ingot).setInputCount(3).setOutput(pickaxeHead).setAnvilLevel(level).setToolLevel(level).setDamage(level).build();
@ -207,7 +205,7 @@ public class MetalMaterial {
AnvilRecipe.Builder.create(name + "_hoe_head").setInput(ingot).setInputCount(2).setOutput(hoeHead).setAnvilLevel(level).setToolLevel(level).setDamage(level).build();
AnvilRecipe.Builder.create(name + "_sword_blade").setInput(ingot).setOutput(swordBlade).setAnvilLevel(level).setToolLevel(level).setDamage(level).build();
AnvilRecipe.Builder.create(name + "_forged_plate").setInput(ingot).setOutput(forgedPlate).setAnvilLevel(level).setToolLevel(level).setDamage(level).build();
// Tools from parts
SmithingTableRecipe.create(BetterEnd.MOD_ID, name + "_hammer").checkConfig(Configs.RECIPE_CONFIG).setResult(hammer).setBase(block).setAddition(Items.STICK).build();
SmithingTableRecipe.create(BetterEnd.MOD_ID, name + "_axe").checkConfig(Configs.RECIPE_CONFIG).setResult(axe).setBase(axeHead).setAddition(Items.STICK).build();
@ -216,13 +214,13 @@ public class MetalMaterial {
SmithingTableRecipe.create(BetterEnd.MOD_ID, name + "_sword_handle").checkConfig(Configs.RECIPE_CONFIG).setResult(swordHandle).setBase(ingot).setAddition(Items.STICK).build();
SmithingTableRecipe.create(BetterEnd.MOD_ID, name + "_sword").checkConfig(Configs.RECIPE_CONFIG).setResult(sword).setBase(swordBlade).setAddition(swordHandle).build();
SmithingTableRecipe.create(BetterEnd.MOD_ID, name + "_shovel").checkConfig(Configs.RECIPE_CONFIG).setResult(shovel).setBase(shovelHead).setAddition(Items.STICK).build();
// Armor crafting
GridRecipe.make(BetterEnd.MOD_ID, name + "_helmet", helmet).checkConfig(Configs.RECIPE_CONFIG).setShape("###", "# #").addMaterial('#', forgedPlate).setGroup("end_metal_helmets").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_chestplate", chestplate).checkConfig(Configs.RECIPE_CONFIG).setShape("# #", "###", "###").addMaterial('#', forgedPlate).setGroup("end_metal_chestplates").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_leggings", leggings).checkConfig(Configs.RECIPE_CONFIG).setShape("###", "# #", "# #").addMaterial('#', forgedPlate).setGroup("end_metal_leggings").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_boots", boots).checkConfig(Configs.RECIPE_CONFIG).setShape("# #", "# #").addMaterial('#', forgedPlate).setGroup("end_metal_boots").build();
TagHelper.addTag(BlockTags.ANVIL, anvilBlock);
TagHelper.addTag(BlockTags.BEACON_BASE_BLOCKS, block);
TagHelper.addTag(ItemTags.BEACON_PAYMENT_ITEMS, ingot);

View file

@ -27,7 +27,7 @@ import ru.betterend.registry.EndItems;
public class StoneMaterial {
public final Block stone;
public final Block polished;
public final Block tiles;
public final Block pillar;
@ -38,16 +38,16 @@ public class StoneMaterial {
public final Block pressure_plate;
public final Block pedestal;
public final Block lantern;
public final Block bricks;
public final Block brick_stairs;
public final Block brick_slab;
public final Block brick_wall;
public final Block furnace;
public StoneMaterial(String name, MaterialColor color) {
FabricBlockSettings material = FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(color);
stone = EndBlocks.registerBlock(name, new BaseBlock(material));
polished = EndBlocks.registerBlock(name + "_polished", new BaseBlock(material));
tiles = EndBlocks.registerBlock(name + "_tiles", new BaseBlock(material));
@ -59,48 +59,48 @@ public class StoneMaterial {
pressure_plate = EndBlocks.registerBlock(name + "_plate", new StonePressurePlateBlock(stone));
pedestal = EndBlocks.registerBlock(name + "_pedestal", new EndPedestal(stone));
lantern = EndBlocks.registerBlock(name + "_lantern", new StoneLanternBlock(stone));
bricks = EndBlocks.registerBlock(name + "_bricks", new BaseBlock(material));
brick_stairs = EndBlocks.registerBlock(name + "_bricks_stairs", new BaseStairsBlock(bricks));
brick_slab = EndBlocks.registerBlock(name + "_bricks_slab", new BaseSlabBlock(bricks));
brick_wall = EndBlocks.registerBlock(name + "_bricks_wall", new BaseWallBlock(bricks));
furnace = EndBlocks.registerBlock(name + "_furnace", new BaseFurnaceBlock(bricks));
// Recipes //
GridRecipe.make(BetterEnd.MOD_ID, name + "_bricks", bricks).checkConfig(Configs.RECIPE_CONFIG).setOutputCount(4).setShape("##", "##").addMaterial('#', stone).setGroup("end_bricks").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_polished", polished).checkConfig(Configs.RECIPE_CONFIG).setOutputCount(4).setShape("##", "##").addMaterial('#', bricks).setGroup("end_tile").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_tiles", tiles).checkConfig(Configs.RECIPE_CONFIG).setOutputCount(4).setShape("##", "##").addMaterial('#', polished).setGroup("end_small_tile").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_pillar", pillar).checkConfig(Configs.RECIPE_CONFIG).setShape("#", "#").addMaterial('#', slab).setGroup("end_pillar").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_stairs", stairs).checkConfig(Configs.RECIPE_CONFIG).setOutputCount(4).setShape("# ", "## ", "###").addMaterial('#', stone).setGroup("end_stone_stairs").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_slab", slab).checkConfig(Configs.RECIPE_CONFIG).setOutputCount(6).setShape("###").addMaterial('#', stone).setGroup("end_stone_slabs").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_bricks_stairs", brick_stairs).checkConfig(Configs.RECIPE_CONFIG).setOutputCount(4).setShape("# ", "## ", "###").addMaterial('#', bricks).setGroup("end_stone_stairs").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_bricks_slab", brick_slab).checkConfig(Configs.RECIPE_CONFIG).setOutputCount(6).setShape("###").addMaterial('#', bricks).setGroup("end_stone_slabs").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_wall", wall).checkConfig(Configs.RECIPE_CONFIG).setOutputCount(6).setShape("###", "###").addMaterial('#', stone).setGroup("end_wall").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_bricks_wall", brick_wall).checkConfig(Configs.RECIPE_CONFIG).setOutputCount(6).setShape("###", "###").addMaterial('#', bricks).setGroup("end_wall").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_button", button).checkConfig(Configs.RECIPE_CONFIG).setList("#").addMaterial('#', stone).setGroup("end_stone_buttons").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_pressure_plate", pressure_plate).checkConfig(Configs.RECIPE_CONFIG).setShape("##").addMaterial('#', stone).setGroup("end_stone_plates").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_lantern", lantern).checkConfig(Configs.RECIPE_CONFIG).setShape("S", "#", "S").addMaterial('#', EndItems.CRYSTAL_SHARDS).addMaterial('S', slab, brick_slab).setGroup("end_stone_lanterns").build();
GridRecipe.make(BetterEnd.MOD_ID, name + "_furnace", furnace).checkConfig(Configs.RECIPE_CONFIG).setShape("###", "# #", "###").addMaterial('#', stone).setGroup("end_stone_furnaces").build();
CraftingRecipes.registerPedestal(name + "_pedestal", pedestal, slab, pillar);
// Item Tags //
TagHelper.addTag(ItemTags.SLABS, slab, brick_slab);
TagHelper.addTag(ItemTags.STONE_BRICKS, bricks);
TagHelper.addTag(ItemTags.STONE_CRAFTING_MATERIALS, stone);
TagHelper.addTag(ItemTags.STONE_TOOL_MATERIALS, stone);
TagHelper.addTag(TagAPI.FURNACES, furnace);
// Block Tags //
TagHelper.addTag(BlockTags.STONE_BRICKS, bricks);
TagHelper.addTag(BlockTags.WALLS, wall, brick_wall);
TagHelper.addTag(BlockTags.SLABS, slab, brick_slab);
TagHelper.addTags(pressure_plate, BlockTags.PRESSURE_PLATES, BlockTags.STONE_PRESSURE_PLATES);
TagHelper.addTag(TagAPI.END_STONES, stone);
TagHelper.addTag(TagAPI.DRAGON_IMMUNE, stone, stairs, slab, wall);
}
}

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