Skip to content

Commit

Permalink
reeds and sandstone
Browse files Browse the repository at this point in the history
  • Loading branch information
MBatt1 committed Aug 12, 2023
1 parent 8f1883b commit bc30085
Show file tree
Hide file tree
Showing 34 changed files with 307 additions and 29 deletions.
13 changes: 4 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@ repositories {
// REI
maven { url "https://maven.shedaniel.me" }
// Incubus
maven {
name = "JitPack"
url = 'https://jitpack.io/'
metadataSources {
artifact() //Look directly for artifact
}
}
maven { url 'https://jitpack.io' }
// Mod Menu + Trinkets
maven {
name = "TerraformersMC"
Expand All @@ -27,7 +21,7 @@ repositories {
// Cardinal Components
maven {
name = 'Ladysnake Mods'
url = 'https://ladysnake.jfrog.io/artifactory/mods'
url = 'https://maven.ladysnake.org/releases'
}

maven {
Expand All @@ -40,7 +34,8 @@ repositories {
}

dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
implementation 'org.jetbrains:annotations:24.0.0'
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
org.gradle.jvmargs=-Xmx2G

# Fabric Properties
# check these on https://fabricmc.net/develop/
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/net/cr24/primeval/block/PrimevalBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public class PrimevalBlocks {
public static final Block GRAVEL = registerBlock("gravel", new SemiSupportedBlock(SETTINGS_SAND(), 0.1f), Weight.NORMAL, Size.MEDIUM, PRIMEVAL_BLOCKS);
public static final Block COBBLESTONE = registerBlock("cobblestone", new SemiSupportedBlock(SETTINGS_STONE().strength(5.0f, 6.0f), 0.1f), Weight.HEAVY, Size.MEDIUM, PRIMEVAL_BLOCKS);
public static final Block STONE = registerBlock("stone", new CascadingBlock(SETTINGS_STONE(), 0.35f, COBBLESTONE), Weight.HEAVY, Size.MEDIUM, PRIMEVAL_BLOCKS);
public static final Block SANDSTONE = registerBlock("sandstone", new CascadingBlock(SETTINGS_STONE(), 0.3f), Weight.HEAVY, Size.MEDIUM, PRIMEVAL_BLOCKS);
public static final Block DIRT_FARMLAND = registerBlockWithoutItem("farmland_dirt", new PrimevalFarmlandBlock(SETTINGS_SOIL().ticksRandomly(), 0.2f, DIRT, new Block[]{DIRT, GRASSY_DIRT}));
public static final Block CLAY_FARMLAND = registerBlockWithoutItem("farmland_clay", new PrimevalFarmlandBlock(SETTINGS_SOIL().ticksRandomly(), 0.3f, CLAY_BLOCK, new Block[]{CLAY_BLOCK}));

Expand Down Expand Up @@ -97,6 +98,8 @@ public class PrimevalBlocks {
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);
// Misc
public static final Block REEDS = registerBlock("reeds", new ReedsBlock(SETTINGS_PLANT().ticksRandomly()), Weight.VERY_LIGHT, Size.SMALL, PRIMEVAL_BLOCKS);


// Ore blocks
Expand Down Expand Up @@ -229,6 +232,7 @@ public static void initClient() {
CABBAGE_CROP, WILD_CABBAGE,
BEANS_CROP, WILD_BEANS,
POTATO_CROP, WILD_POTATOES,
REEDS,
/* Tree */
OAK_SAPLING,
OAK_LEAVES,
Expand Down
103 changes: 103 additions & 0 deletions src/main/java/net/cr24/primeval/block/plant/ReedsBlock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
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.block.piston.PistonBehavior;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.IntProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;

public class ReedsBlock extends Block implements Waterloggable {
public static final BooleanProperty WATERLOGGED;
public static final IntProperty AGE;
public static final BooleanProperty CAP;

public ReedsBlock(Settings settings) {
super(settings);
this.setDefaultState(this.getDefaultState().with(WATERLOGGED, false));
this.setDefaultState(this.getDefaultState().with(AGE, 0));
this.setDefaultState(this.getDefaultState().with(CAP, true));
}

public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
BlockState upBlock = world.getBlockState(pos.up());
if (upBlock.isAir() || upBlock.isOf(Blocks.WATER)) {
world.setBlockState(pos.up(), getStateFor(world, pos.up()));
}
}

public boolean hasRandomTicks(BlockState state) {
return state.get(AGE) < 4;
}

public BlockState getPlacementState(ItemPlacementContext ctx) {
World world = ctx.getWorld();
BlockPos pos = ctx.getBlockPos();

return getStateFor(world, pos);
}

private BlockState getStateFor(WorldAccess world, BlockPos pos) {
FluidState fluidState = world.getFluidState(pos);
BlockState downBlock = world.getBlockState(pos.down());
BlockState upBlock = world.getBlockState(pos.up());
boolean capState = !upBlock.isOf(PrimevalBlocks.REEDS);
if (fluidState.getFluid() == Fluids.WATER) {
return this.getDefaultState().with(WATERLOGGED, true).with(CAP, capState);
} else {
if (downBlock.isOf(PrimevalBlocks.REEDS)) { // planting on another reed
int downAge = downBlock.get(AGE);
return this.getDefaultState().with(AGE, Math.min(downAge+1, 4)).with(CAP, capState);
} else { // planted on soil
return this.getDefaultState().with(AGE, 1).with(CAP, capState);
}
}
}

public FluidState getFluidState(BlockState state) {
return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state);
}

public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
BlockState down = world.getBlockState(pos.down());
return down.isIn(PrimevalBlockTags.HEAVY_SOIL) || down.isIn(PrimevalBlockTags.MEDIUM_SOIL) || down.isOf(PrimevalBlocks.REEDS);
}

public PistonBehavior getPistonBehavior(BlockState state) {
return PistonBehavior.DESTROY;
}

public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
if (state.get(WATERLOGGED)) {
world.createAndScheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
}
if (canPlaceAt(state, world, pos)) {
return getStateFor(world, pos);
} else {
return Blocks.AIR.getDefaultState();
}
}

protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
super.appendProperties(builder);
builder.add(WATERLOGGED, AGE, CAP);
}

static {
WATERLOGGED = Properties.WATERLOGGED;
AGE = IntProperty.of("age", 0, 4);
CAP = BooleanProperty.of("cap");
}
}
2 changes: 1 addition & 1 deletion src/main/java/net/cr24/primeval/world/PrimevalWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public class PrimevalWorld {
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
WILD_CABBAGE_PATCH, REED_PATCH
)
)
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ private static <C extends FeatureConfig, F extends Feature<C>> F registerFeature
private static final RegistryEntry<ConfiguredFeature<RandomPatchFeatureConfig, ?>> CONFIGURED_SHRUB_PATCH = register("patch_shrub", Feature.RANDOM_PATCH, Configs.SHRUB_PATCH);
public static final RegistryEntry<PlacedFeature> SHRUB_PATCH = register("patch_shrub", CONFIGURED_SHRUB_PATCH, RarityFilterPlacementModifier.of(6), SquarePlacementModifier.of(), HeightmapPlacementModifier.of(Heightmap.Type.WORLD_SURFACE_WG), BiomePlacementModifier.of());

private static final RegistryEntry<ConfiguredFeature<RandomPatchFeatureConfig, ?>> CONFIGURED_REED_PATCH = register("patch_reed", Feature.RANDOM_PATCH, Configs.REED_PATCH);
public static final RegistryEntry<PlacedFeature> REED_PATCH = register("patch_reed", CONFIGURED_REED_PATCH, RarityFilterPlacementModifier.of(27), SquarePlacementModifier.of(), HeightmapPlacementModifier.of(Heightmap.Type.OCEAN_FLOOR_WG), BiomePlacementModifier.of());

private static final RegistryEntry<ConfiguredFeature<RandomPatchFeatureConfig, ?>> CONFIGURED_POPPY_PATCH = register("patch_poppy", Feature.RANDOM_PATCH, Configs.POPPY_PATCH);
public static final RegistryEntry<PlacedFeature> POPPY_PATCH = register("patch_poppy", CONFIGURED_POPPY_PATCH, RarityFilterPlacementModifier.of(8), SquarePlacementModifier.of(), HeightmapPlacementModifier.of(Heightmap.Type.WORLD_SURFACE_WG), BiomePlacementModifier.of());

Expand Down Expand Up @@ -295,6 +298,12 @@ protected static class Configs {
3,
blockProviderFeature(SimpleBlockStateProvider.of(PrimevalBlocks.SHRUB.getDefaultState()))
);
public static final RandomPatchFeatureConfig REED_PATCH = new RandomPatchFeatureConfig(
20,
6,
3,
blockProviderFeature(SimpleBlockStateProvider.of(PrimevalBlocks.REEDS.getDefaultState()))
);
public static final RandomPatchFeatureConfig POPPY_PATCH = new RandomPatchFeatureConfig(
6,
7,
Expand Down
6 changes: 2 additions & 4 deletions src/main/resources/asset_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,11 @@ def create_ore_set(ore_type):
generate_standard_item("raw_"+ore_type+"_large")

#create_ore_set("lazurite")
generate_standard_item("fired_clay_jug_filled")
#generate_standard_item("fired_clay_jug_filled")
#generate_stairs_block("stone_paver_stairs", "stone_paver")
#generate_slab_block("stone_paver_slab", "stone_paver", "stone_paver")

#generate_standard_block("wicker")
#generate_stairs_block("crude_bricks_stairs", "crude_bricks")
#generate_slab_block("crude_bricks_slab", "crude_bricks", "crude_bricks")
generate_standard_block("sandstone")
#create_ore_set("zinc_sphalerite")

#generate_handheld_item("copper_hoe")
Expand Down
34 changes: 34 additions & 0 deletions src/main/resources/assets/primeval/blockstates/reeds.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"variants": {
"age=0,cap=false": {
"model": "primeval:block/reeds_water"
},
"age=1,cap=false": {
"model": "primeval:block/reeds_base"
},
"age=2,cap=false": {
"model": "primeval:block/reeds_air"
},
"age=3,cap=false": {
"model": "primeval:block/reeds_air"
},
"age=4,cap=false": {
"model": "primeval:block/reeds_air"
},
"age=0,cap=true": {
"model": "primeval:block/reeds_water_cap"
},
"age=1,cap=true": {
"model": "primeval:block/reeds_base_cap"
},
"age=2,cap=true": {
"model": "primeval:block/reeds_base_cap"
},
"age=3,cap=true": {
"model": "primeval:block/reeds_base_cap"
},
"age=4,cap=true": {
"model": "primeval:block/reeds_air_cap"
}
}
}
7 changes: 7 additions & 0 deletions src/main/resources/assets/primeval/blockstates/sandstone.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "primeval:block/sandstone"
}
}
}
2 changes: 2 additions & 0 deletions src/main/resources/assets/primeval/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"block.primeval.gravel": "Gravel",
"block.primeval.cobblestone": "Cobblestone",
"block.primeval.stone": "Stone",
"block.primeval.sandstone": "Sandstone",

"block.primeval.oak_sapling": "Oak Sapling",
"block.primeval.oak_log": "Oak Log",
Expand All @@ -27,6 +28,7 @@
"block.primeval.dandelion": "Dandelion",
"block.primeval.oxeye_daisy": "Oxeye Daisy",
"block.primeval.moss": "Moss",
"block.primeval.reeds": "Reeds",

"block.primeval.copper_malachite_ore_small": "Small Malachite Copper Ore",
"block.primeval.copper_malachite_ore_medium": "Medium Malachite Copper Ore",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cross",
"textures": {
"cross": "primeval:block/reeds_2"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cross",
"textures": {
"cross": "primeval:block/reeds_5"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cross",
"textures": {
"cross": "primeval:block/reeds_1"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cross",
"textures": {
"cross": "primeval:block/reeds_4"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cross",
"textures": {
"cross": "primeval:block/reeds_0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cross",
"textures": {
"cross": "primeval:block/reeds_3"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "primeval:block/sandstone"
}
}
6 changes: 6 additions & 0 deletions src/main/resources/assets/primeval/models/item/reeds.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "primeval:item/reeds"
}
}
3 changes: 3 additions & 0 deletions src/main/resources/assets/primeval/models/item/sandstone.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "primeval:block/sandstone"
}
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions src/main/resources/data/primeval/loot_tables/blocks/reeds.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"name": "primeval:reeds"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}
20 changes: 20 additions & 0 deletions src/main/resources/data/primeval/loot_tables/blocks/sandstone.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"name": "primeval:sandstone"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}
Loading

0 comments on commit bc30085

Please sign in to comment.