Skip to content

Commit

Permalink
new plants #40
Browse files Browse the repository at this point in the history
  • Loading branch information
MBatt1 committed Aug 19, 2023
1 parent afda08c commit 52191b7
Show file tree
Hide file tree
Showing 33 changed files with 377 additions and 36 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx2G
# check these on https://fabricmc.net/develop/
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.3
loader_version=0.14.9
loader_version=0.14.11

#Fabric api
fabric_version=0.59.0+1.19.2
Expand Down
25 changes: 18 additions & 7 deletions src/main/java/net/cr24/primeval/block/PrimevalBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,21 @@ public class PrimevalBlocks {
public static final Block OAK_SAPLING = registerBlock("oak_sapling", new GrowingSaplingBlock(SETTINGS_PLANT().ticksRandomly(), OakTrunker.INSTANCE), Weight.HEAVY, Size.LARGE, PRIMEVAL_BLOCKS);
public static final Block BIRCH_SAPLING = registerBlock("birch_sapling", new GrowingSaplingBlock(SETTINGS_PLANT().ticksRandomly(), BirchTrunker.INSTANCE), Weight.HEAVY, Size.LARGE, PRIMEVAL_BLOCKS);
public static final Block SPRUCE_SAPLING = registerBlock("spruce_sapling", new GrowingSaplingBlock(SETTINGS_PLANT().ticksRandomly(), SpruceTrunker.INSTANCE), Weight.HEAVY, Size.LARGE, PRIMEVAL_BLOCKS);
public static final Block GRASS = registerBlock("grass", new GrowingGrassBlock(SETTINGS_PLANT().ticksRandomly()), Weight.VERY_LIGHT, Size.SMALL, PRIMEVAL_BLOCKS);
public static final Block BUSH = registerBlock("bush", new PrimevalPlantBlock(SETTINGS_PLANT()), Weight.VERY_LIGHT, Size.SMALL, PRIMEVAL_BLOCKS);
public static final Block SHRUB = registerBlock("shrub", new PrimevalPlantBlock(SETTINGS_PLANT()), Weight.LIGHT, Size.MEDIUM, PRIMEVAL_BLOCKS);
public static final Block GRASS = registerBlock("grass", new GrowingGrassBlock(SETTINGS_PLANT().ticksRandomly().offsetType(AbstractBlock.OffsetType.XZ)), Weight.VERY_LIGHT, Size.SMALL, PRIMEVAL_BLOCKS);
public static final Block BUSH = registerBlock("bush", new PrimevalPlantBlock(SETTINGS_PLANT().offsetType(AbstractBlock.OffsetType.XZ)), Weight.VERY_LIGHT, Size.SMALL, PRIMEVAL_BLOCKS);
public static final Block SPIKED_PLANT = registerBlock("plant_0", new PrimevalPlantBlock(SETTINGS_PLANT().offsetType(AbstractBlock.OffsetType.XZ)), Weight.VERY_LIGHT, Size.SMALL, PRIMEVAL_BLOCKS);
public static final Block LEAFY_PLANT = registerBlock("plant_1", new PrimevalPlantBlock(SETTINGS_PLANT().offsetType(AbstractBlock.OffsetType.XZ)), Weight.VERY_LIGHT, Size.SMALL, PRIMEVAL_BLOCKS);
public static final Block SHRUB = registerBlock("shrub", new PrimevalPlantBlock(SETTINGS_PLANT().offsetType(AbstractBlock.OffsetType.XZ)), Weight.LIGHT, Size.MEDIUM, PRIMEVAL_BLOCKS);
public static final Block MOSS = registerBlock("moss", new SpreadingMossBlock(SETTINGS_PLANT().ticksRandomly()), Weight.VERY_LIGHT, Size.SMALL, PRIMEVAL_BLOCKS);
// Flowers
public static final Block POPPY = registerBlock("poppy", new PrimevalPlantBlock(SETTINGS_PLANT()), Weight.VERY_LIGHT, Size.SMALL, PRIMEVAL_BLOCKS);
public static final Block DANDELION = registerBlock("dandelion", new PrimevalPlantBlock(SETTINGS_PLANT()), Weight.VERY_LIGHT, Size.SMALL, PRIMEVAL_BLOCKS);
public static final Block OXEYE_DAISY = registerBlock("oxeye_daisy", new PrimevalPlantBlock(SETTINGS_PLANT()), Weight.VERY_LIGHT, Size.SMALL, PRIMEVAL_BLOCKS);
public static final Block CORNFLOWER = registerBlock("cornflower", new PrimevalPlantBlock(SETTINGS_PLANT()), Weight.VERY_LIGHT, Size.SMALL, PRIMEVAL_BLOCKS);
public static final Block LILY_OF_THE_VALLEY = registerBlock("lily_of_the_valley", new PrimevalPlantBlock(SETTINGS_PLANT()), Weight.VERY_LIGHT, Size.SMALL, PRIMEVAL_BLOCKS);
// Misc
public static final Block REEDS = registerBlock("reeds", new ReedsBlock(SETTINGS_PLANT().ticksRandomly()), Weight.VERY_LIGHT, Size.SMALL, PRIMEVAL_BLOCKS);
public static final Block RIVER_GRASS = registerBlock("river_grass", new PrimevalWaterPlantBlock(SETTINGS_PLANT().offsetType(AbstractBlock.OffsetType.XZ)), Weight.VERY_LIGHT, Size.SMALL, PRIMEVAL_BLOCKS);


// Ore blocks
Expand Down Expand Up @@ -225,16 +230,16 @@ public static void initClient() {
// Render Layers
BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutout(),
GRASSY_DIRT, GRASSY_CLAY,
GRASS, BUSH, SHRUB,
POPPY, DANDELION, OXEYE_DAISY,
GRASS, BUSH, SPIKED_PLANT, LEAFY_PLANT, SHRUB,
POPPY, DANDELION, OXEYE_DAISY, CORNFLOWER, LILY_OF_THE_VALLEY,
MOSS,
/* Crop */
CARROT_CROP, WILD_CARROTS,
WHEAT_CROP, WILD_WHEAT,
CABBAGE_CROP, WILD_CABBAGE,
BEANS_CROP, WILD_BEANS,
POTATO_CROP, WILD_POTATOES,
REEDS,
REEDS, RIVER_GRASS,
/* Tree */
OAK_SAPLING,
OAK_LEAVES,
Expand All @@ -259,7 +264,9 @@ public static void initClient() {
GRASSY_DIRT.asItem(),
GRASSY_CLAY.asItem(),
GRASS.asItem(),
BUSH.asItem());
BUSH.asItem(),
SPIKED_PLANT.asItem(),
LEAFY_PLANT.asItem());

// Block Renderers
BlockEntityRendererRegistry.register(PIT_KILN_BLOCK_ENTITY, PitKilnBlockEntityRenderer::new);
Expand Down Expand Up @@ -289,9 +296,13 @@ private static void registerFlammables() {

FlammableBlockRegistry.getDefaultInstance().add(GRASS, 60, 100);
FlammableBlockRegistry.getDefaultInstance().add(BUSH, 60, 100);
FlammableBlockRegistry.getDefaultInstance().add(SPIKED_PLANT, 60, 100);
FlammableBlockRegistry.getDefaultInstance().add(LEAFY_PLANT, 60, 100);
FlammableBlockRegistry.getDefaultInstance().add(POPPY, 60, 100);
FlammableBlockRegistry.getDefaultInstance().add(DANDELION, 60, 100);
FlammableBlockRegistry.getDefaultInstance().add(OXEYE_DAISY, 60, 100);
FlammableBlockRegistry.getDefaultInstance().add(CORNFLOWER, 60, 100);
FlammableBlockRegistry.getDefaultInstance().add(LILY_OF_THE_VALLEY, 60, 100);

FlammableBlockRegistry.getDefaultInstance().add(STRAW_BLOCK, 10, 40);
FlammableBlockRegistry.getDefaultInstance().add(STRAW_STAIRS, 10, 40);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ public boolean canPathfindThrough(BlockState state, BlockView world, BlockPos po
return type == NavigationType.AIR && !this.collidable ? true : super.canPathfindThrough(state, world, pos, type);
}

public OffsetType getOffsetType() {
return OffsetType.XZ;
}

static {
GROWTH_STATE = IntProperty.of("growth", 0, 4);
GROWING = BooleanProperty.of("active");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,4 @@ public boolean inGrowableArea(World world, BlockPos pos) {
}
return true;
}

public OffsetType getOffsetType() {
return OffsetType.NONE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,4 @@ public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos po
protected boolean canPlantOnTop(BlockState floor, BlockView world, BlockPos pos) {
return floor.isIn(PrimevalBlockTags.HEAVY_SOIL) || floor.isIn(PrimevalBlockTags.MEDIUM_SOIL) || floor.isIn(PrimevalBlockTags.SPECIAL_PLANTABLE);
}

public OffsetType getOffsetType() {
return OffsetType.XZ;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package net.cr24.primeval.block.plant;

import net.cr24.primeval.block.PrimevalBlockTags;
import net.cr24.primeval.block.PrimevalBlocks;
import net.minecraft.block.*;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.tag.FluidTags;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.WorldAccess;
import org.jetbrains.annotations.Nullable;

public class PrimevalWaterPlantBlock extends PlantBlock implements FluidFillable {

protected static final VoxelShape SHAPE = Block.createCuboidShape(2.0, 0.0, 2.0, 14.0, 8.0, 14.0);

public PrimevalWaterPlantBlock(Settings settings) {
super(settings);
}

@Override
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
return SHAPE;
}

@Override
protected boolean canPlantOnTop(BlockState floor, BlockView world, BlockPos pos) {
return floor.isIn(PrimevalBlockTags.MEDIUM_SOIL) || floor.isIn(PrimevalBlockTags.LIGHT_SOIL) || floor.isOf(PrimevalBlocks.STONE);
}

@Nullable
public BlockState getPlacementState(ItemPlacementContext ctx) {
FluidState fluidState = ctx.getWorld().getFluidState(ctx.getBlockPos());
return fluidState.isIn(FluidTags.WATER) && fluidState.getLevel() == 8 ? super.getPlacementState(ctx) : null;
}

public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
BlockState blockState = super.getStateForNeighborUpdate(state, direction, neighborState, world, pos, neighborPos);
if (!blockState.isAir()) {
world.createAndScheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
}

return blockState;
}

public FluidState getFluidState(BlockState state) {
return Fluids.WATER.getStill(false);
}

@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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ private static void create(CallbackInfoReturnable<BlockColors> info) {
((state, world, pos, tintIndex) -> world != null && pos != null ? BiomeColors.getGrassColor(world, pos) : GrassColors.getColor(0.5D, 1.0D)),
PrimevalBlocks.BUSH
);
origin.registerColorProvider(
((state, world, pos, tintIndex) -> world != null && pos != null ? BiomeColors.getGrassColor(world, pos) : GrassColors.getColor(0.5D, 1.0D)),
PrimevalBlocks.SPIKED_PLANT
);
origin.registerColorProvider(
((state, world, pos, tintIndex) -> world != null && pos != null ? BiomeColors.getGrassColor(world, pos) : GrassColors.getColor(0.5D, 1.0D)),
PrimevalBlocks.LEAFY_PLANT
);
origin.registerColorProvider(
((state, world, pos, tintIndex) -> world != null && pos != null ? BiomeColors.getGrassColor(world, pos) : GrassColors.getColor(0.5D, 1.0D)),
PrimevalBlocks.SHRUB
Expand Down
28 changes: 14 additions & 14 deletions src/main/java/net/cr24/primeval/world/PrimevalWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,58 +46,58 @@ public class PrimevalWorld {
buildGeneratorSettings(
UNDERGROUND_FEATURES_NO_TIN,
List.of(PLAINS_OAK_TRUNKED_TREE,
MOSS_RARE,
MOSS_RARE, RIVER_GRASS,
STICK_ITEM_PATCH, FLINT_ITEM_PATCH, ROCK_ITEM_PATCH,
NATIVE_COPPER_ITEM_PATCH, MALACHITE_COPPER_ITEM_PATCH, MIXED_COPPER_ITEM_PATCH, SPHALERITE_ZINC_ITEM_PATCH,
PLAINS_GRASS_PATCH, BUSH_PATCH, SHRUB_PATCH, POPPY_PATCH, DANDELION_PATCH, OXEYE_DAISY_PATCH,
WILD_CARROTS_PATCH, WILD_WHEAT_PATCH
WILD_CARROTS_PATCH, WILD_WHEAT_PATCH, WATER_REED_PATCH
)
)
));
public static final RegistryEntry<Biome> OAK_FOREST = registerBiome(getBiomeKey("inland/oak_forest"), createBiome(
buildGeneratorSettings(
UNDERGROUND_FEATURES_NO_ZINC,
List.of(FOREST_OAK_TRUNKED_TREE,
MOSS_RARE,
MOSS_RARE, RIVER_GRASS,
STICK_ITEM_PATCH, FLINT_ITEM_PATCH, ROCK_ITEM_PATCH,
NATIVE_COPPER_ITEM_PATCH, MALACHITE_COPPER_ITEM_PATCH, MIXED_COPPER_ITEM_PATCH, CASSITERITE_TIN_ITEM_PATCH,
OAK_FOREST_GRASS_PATCH, BUSH_PATCH, POPPY_PATCH,
WILD_BEANS_PATCH, WILD_POTATO_PATCH
OAK_FOREST_GRASS_PATCH, SPIKED_PLANT_PATCH, POPPY_PATCH,
WILD_BEANS_PATCH, WILD_POTATO_PATCH, WATER_REED_PATCH
)
)
));
public static final RegistryEntry<Biome> DENSE_OAK_FOREST = registerBiome(getBiomeKey("inland/dense_oak_forest"), createBiome(
buildGeneratorSettings(
UNDERGROUND_FEATURES_NO_ZINC,
List.of(FOREST_DENSE_OAK_TRUNKED_TREE,
MOSS_RARE,
MOSS_RARE, RIVER_GRASS,
STICK_ITEM_PATCH, FLINT_ITEM_PATCH, ROCK_ITEM_PATCH,
NATIVE_COPPER_ITEM_PATCH, MALACHITE_COPPER_ITEM_PATCH, MIXED_COPPER_ITEM_PATCH, CASSITERITE_TIN_ITEM_PATCH,
SPARSE_GRASS_PATCH, BUSH_PATCH, SHRUB_PATCH, POPPY_PATCH,
WILD_BEANS_PATCH, WILD_POTATO_PATCH
SPARSE_GRASS_PATCH, SPIKED_PLANT_PATCH, SHRUB_PATCH, POPPY_PATCH,
WILD_BEANS_PATCH, WILD_POTATO_PATCH, WATER_REED_PATCH
)
)
));
public static final RegistryEntry<Biome> BIRCH_FOREST = registerBiome(getBiomeKey("inland/birch_forest"), createBiome(
buildGeneratorSettings(
UNDERGROUND_FEATURES_NO_ZINC,
List.of(FOREST_BIRCH_TRUNKED_TREE,
MOSS_RARE,
MOSS_RARE, RIVER_GRASS,
STICK_ITEM_PATCH, FLINT_ITEM_PATCH, ROCK_ITEM_PATCH,
NATIVE_COPPER_ITEM_PATCH, MALACHITE_COPPER_ITEM_PATCH, MIXED_COPPER_ITEM_PATCH, CASSITERITE_TIN_ITEM_PATCH,
PLAINS_GRASS_PATCH, DANDELION_PATCH, OXEYE_DAISY_PATCH,
WILD_CABBAGE_PATCH, REED_PATCH
WILD_CABBAGE_PATCH, REED_PATCH, WATER_REED_PATCH
)
)
));
public static final RegistryEntry<Biome> TAIGA = registerBiome(getBiomeKey("inland/taiga"), createBiome(
buildGeneratorSettings(
UNDERGROUND_FEATURES_ALL,
List.of(FOREST_SPRUCE_TRUNKED_TREE,
MOSS_RARE,
MOSS_RARE, RIVER_GRASS,
STICK_ITEM_PATCH, FLINT_ITEM_PATCH, ROCK_ITEM_PATCH,
NATIVE_COPPER_ITEM_PATCH, MIXED_COPPER_ITEM_PATCH, CASSITERITE_TIN_ITEM_PATCH, SPHALERITE_ZINC_ITEM_PATCH,
SPARSE_GRASS_PATCH, BUSH_PATCH, SHRUB_PATCH, DANDELION_PATCH,
SPARSE_GRASS_PATCH, LEAFY_PLANT_PATCH, SHRUB_PATCH, DANDELION_PATCH, LILY_OF_THE_VALLEY_PATCH,
WILD_CARROTS_PATCH, WILD_BEANS_PATCH
)
)
Expand All @@ -108,7 +108,7 @@ public class PrimevalWorld {
List.of(MOSS_RARE,
FLINT_ITEM_PATCH, ROCK_ITEM_PATCH,
NATIVE_COPPER_ITEM_PATCH, MALACHITE_COPPER_ITEM_PATCH, MIXED_COPPER_ITEM_PATCH, CASSITERITE_TIN_ITEM_PATCH, SPHALERITE_ZINC_ITEM_PATCH,
SPARSE_GRASS_PATCH, OXEYE_DAISY_PATCH,
SPARSE_GRASS_PATCH, LEAFY_PLANT_PATCH, LILY_OF_THE_VALLEY_PATCH,
WILD_WHEAT_PATCH
)
)
Expand All @@ -127,7 +127,7 @@ public class PrimevalWorld {
buildGeneratorSettings(
UNDERGROUND_FEATURES_NO_TIN,
List.of(STICK_ITEM_PATCH, ROCK_ITEM_PATCH,
SPARSE_GRASS_PATCH
SPARSE_GRASS_PATCH, CORNFLOWER_PATCH
)
)
));
Expand Down
Loading

0 comments on commit 52191b7

Please sign in to comment.