Tube worms, floating block fixes
This commit is contained in:
parent
08e31b8743
commit
e3769bb20b
17 changed files with 413 additions and 9 deletions
|
@ -0,0 +1,59 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.FluidFillable;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.WorldView;
|
||||
|
||||
public class BlockUnderwaterWallPlant extends BlockWallPlant implements FluidFillable {
|
||||
|
||||
public BlockUnderwaterWallPlant() {
|
||||
super(FabricBlockSettings.of(Material.UNDERWATER_PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.sounds(BlockSoundGroup.WET_GRASS)
|
||||
.breakByHand(true)
|
||||
.noCollision());
|
||||
}
|
||||
|
||||
public BlockUnderwaterWallPlant(int light) {
|
||||
super(FabricBlockSettings.of(Material.UNDERWATER_PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.sounds(BlockSoundGroup.WET_GRASS)
|
||||
.luminance(light)
|
||||
.breakByHand(true)
|
||||
.noCollision());
|
||||
}
|
||||
|
||||
public BlockUnderwaterWallPlant(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state, Fluid fluid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, BlockState state, FluidState fluidState) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidState getFluidState(BlockState state) {
|
||||
return Fluids.WATER.getStill(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||
return world.getFluidState(pos).getFluid() == Fluids.WATER && super.canPlaceAt(state, world, pos);
|
||||
}
|
||||
}
|
|
@ -37,7 +37,11 @@ public class BlockWallPlant extends BlockPlant {
|
|||
public static final DirectionProperty FACING = HorizontalFacingBlock.FACING;
|
||||
|
||||
public BlockWallPlant() {
|
||||
this(0);
|
||||
this(FabricBlockSettings.of(Material.PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.sounds(BlockSoundGroup.GRASS)
|
||||
.breakByHand(true)
|
||||
.noCollision());
|
||||
}
|
||||
|
||||
public BlockWallPlant(int light) {
|
||||
|
|
|
@ -16,13 +16,18 @@ import ru.betterend.registry.EndBlocks;
|
|||
public class ColoredMaterial {
|
||||
private final Map<DyeColor, Block> colors = Maps.newEnumMap(DyeColor.class);
|
||||
|
||||
public ColoredMaterial(Function<FabricBlockSettings, Block> constructor, Block source) {
|
||||
public ColoredMaterial(Function<FabricBlockSettings, Block> constructor, Block source, boolean craftEight) {
|
||||
String id = Registry.BLOCK.getId(source).getPath();
|
||||
for (DyeColor color: DyeColor.values()) {
|
||||
Block block = constructor.apply(FabricBlockSettings.copyOf(source).materialColor(color));
|
||||
String blockName = id + "_" + color.getName();
|
||||
EndBlocks.registerBlock(blockName, block);
|
||||
GridRecipe.make(blockName, block).setList("#D").addMaterial('#', source).addMaterial('D', DyeItem.byColor(color)).build();
|
||||
if (craftEight) {
|
||||
GridRecipe.make(blockName, block).setOutputCount(8).setShape("###", "#D#", "###").addMaterial('#', source).addMaterial('D', DyeItem.byColor(color)).build();
|
||||
}
|
||||
else {
|
||||
GridRecipe.make(blockName, block).setList("#D").addMaterial('#', source).addMaterial('D', DyeItem.byColor(color)).build();
|
||||
}
|
||||
colors.put(color, block);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ import ru.betterend.blocks.basis.BlockLeaves;
|
|||
import ru.betterend.blocks.basis.BlockOre;
|
||||
import ru.betterend.blocks.basis.BlockSimpleLeaves;
|
||||
import ru.betterend.blocks.basis.BlockStoneLantern;
|
||||
import ru.betterend.blocks.basis.BlockUnderwaterWallPlant;
|
||||
import ru.betterend.blocks.basis.BlockVine;
|
||||
import ru.betterend.blocks.basis.BlockWallMushroom;
|
||||
import ru.betterend.blocks.basis.BlockWallPlant;
|
||||
|
@ -169,7 +170,7 @@ public class EndBlocks {
|
|||
public static final Block HYDRALUX_SAPLING = registerBlock("hydralux_sapling", new BlockHydraluxSapling());
|
||||
public static final Block HYDRALUX = registerBlockNI("hydralux", new BlockHydralux());
|
||||
public static final Block HYDRALUX_PETAL_BLOCK = registerBlock("hydralux_petal_block", new BlockHydraluxPetal());
|
||||
public static final ColoredMaterial HYDRALUX_PETAL_BLOCK_COLORED = new ColoredMaterial(BlockHydraluxPetalColored::new, HYDRALUX_PETAL_BLOCK);
|
||||
public static final ColoredMaterial HYDRALUX_PETAL_BLOCK_COLORED = new ColoredMaterial(BlockHydraluxPetalColored::new, HYDRALUX_PETAL_BLOCK, true);
|
||||
|
||||
public static final Block CAVE_BUSH = registerBlock("cave_bush", new BlockSimpleLeaves(MaterialColor.MAGENTA));
|
||||
|
||||
|
@ -181,6 +182,7 @@ public class EndBlocks {
|
|||
public static final Block TAIL_MOSS = registerBlock("tail_moss", new BlockWallPlant());
|
||||
public static final Block CYAN_MOSS = registerBlock("cyan_moss", new BlockWallPlant());
|
||||
public static final Block TWISTED_MOSS = registerBlock("twisted_moss", new BlockWallPlant());
|
||||
public static final Block TUBE_WORM = registerBlock("tube_worm", new BlockUnderwaterWallPlant());
|
||||
|
||||
// Crops //
|
||||
public static final Block SHADOW_BERRY = registerBlock("shadow_berry", new BlockShadowBerry());
|
||||
|
@ -212,7 +214,7 @@ public class EndBlocks {
|
|||
public static final Block BLACKSTONE_LANTERN = registerBlock("blackstone_lantern", new BlockStoneLantern(Blocks.BLACKSTONE));
|
||||
|
||||
public static final Block BULB_LANTERN = registerBlock("bulb_lantern", new BlockBulbVineLantern());
|
||||
public static final ColoredMaterial BULB_LANTERN_COLORED = new ColoredMaterial(BlockBulbVineLanternColored::new, BULB_LANTERN);
|
||||
public static final ColoredMaterial BULB_LANTERN_COLORED = new ColoredMaterial(BlockBulbVineLanternColored::new, BULB_LANTERN, false);
|
||||
|
||||
// Blocks With Entity //
|
||||
public static final Block END_STONE_SMELTER = registerBlock("end_stone_smelter", new EndStoneSmelter());
|
||||
|
|
|
@ -89,6 +89,7 @@ public class EndFeatures {
|
|||
public static final EndFeature END_LOTUS = new EndFeature("end_lotus", new EndLotusFeature(7), 5);
|
||||
public static final EndFeature END_LOTUS_LEAF = new EndFeature("end_lotus_leaf", new EndLotusLeafFeature(20), 25);
|
||||
public static final EndFeature HYDRALUX = new EndFeature("hydralux", new HydraluxFeature(5), 5);
|
||||
public static final EndFeature TUBE_WORM = new EndFeature("tube_worm", new WallPlantFeature(EndBlocks.TUBE_WORM, 6), 15);
|
||||
|
||||
// Terrain //
|
||||
public static final EndFeature END_LAKE = EndFeature.makeLakeFeature("end_lake", new EndLakeFeature(), 4);
|
||||
|
|
|
@ -43,6 +43,7 @@ public class BlocksHelper {
|
|||
|
||||
private static final Mutable POS = new Mutable();
|
||||
protected static final BlockState AIR = Blocks.AIR.getDefaultState();
|
||||
protected static final BlockState WATER = Blocks.WATER.getDefaultState();
|
||||
|
||||
private static final Vec3i[] OFFSETS = new Vec3i[] {
|
||||
new Vec3i(-1, -1, -1), new Vec3i(-1, -1, 0), new Vec3i(-1, -1, 1),
|
||||
|
@ -159,6 +160,9 @@ public class BlocksHelper {
|
|||
}
|
||||
// Liquids
|
||||
else if (!state.getFluidState().isEmpty()) {
|
||||
if (!state.canPlaceAt(world, POS)) {
|
||||
setWithoutUpdate(world, POS, WATER);
|
||||
}
|
||||
POS.setY(y - 1);
|
||||
if (world.isAir(POS)) {
|
||||
POS.setY(y);
|
||||
|
|
|
@ -19,6 +19,7 @@ public class BiomeSulfurSprings extends EndBiome {
|
|||
.addFeature(EndFeatures.SULPHURIC_LAKE)
|
||||
.addFeature(EndFeatures.SULPHURIC_CAVE)
|
||||
.addFeature(EndFeatures.HYDRALUX)
|
||||
.addFeature(EndFeatures.TUBE_WORM)
|
||||
.addMobSpawn(EntityType.ENDERMAN, 50, 1, 4));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,13 +20,13 @@ public class WallPlantFeature extends WallScatterFeature {
|
|||
|
||||
@Override
|
||||
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos pos, Direction dir) {
|
||||
BlockPos blockPos = pos.offset(dir.getOpposite());
|
||||
BlockState blockState = world.getBlockState(blockPos);
|
||||
return ((BlockWallPlant) block).isSupport(world, blockPos, blockState, dir);
|
||||
BlockState state = block.getDefaultState().with(BlockWallPlant.FACING, dir);
|
||||
return block.canPlaceAt(state, world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(StructureWorldAccess world, Random random, BlockPos pos, Direction dir) {
|
||||
BlocksHelper.setWithoutUpdate(world, pos, block.getDefaultState().with(BlockWallPlant.FACING, dir));
|
||||
BlockState state = block.getDefaultState().with(BlockWallPlant.FACING, dir);
|
||||
BlocksHelper.setWithoutUpdate(world, pos, state);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue