-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
307 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
src/main/java/net/cr24/primeval/block/plant/ReedsBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
7
src/main/resources/assets/primeval/blockstates/sandstone.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"variants": { | ||
"": { | ||
"model": "primeval:block/sandstone" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/main/resources/assets/primeval/models/block/reeds_air.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"parent": "minecraft:block/cross", | ||
"textures": { | ||
"cross": "primeval:block/reeds_2" | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/resources/assets/primeval/models/block/reeds_air_cap.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"parent": "minecraft:block/cross", | ||
"textures": { | ||
"cross": "primeval:block/reeds_5" | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/resources/assets/primeval/models/block/reeds_base.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"parent": "minecraft:block/cross", | ||
"textures": { | ||
"cross": "primeval:block/reeds_1" | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/resources/assets/primeval/models/block/reeds_base_cap.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"parent": "minecraft:block/cross", | ||
"textures": { | ||
"cross": "primeval:block/reeds_4" | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/resources/assets/primeval/models/block/reeds_water.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"parent": "minecraft:block/cross", | ||
"textures": { | ||
"cross": "primeval:block/reeds_0" | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/resources/assets/primeval/models/block/reeds_water_cap.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"parent": "minecraft:block/cross", | ||
"textures": { | ||
"cross": "primeval:block/reeds_3" | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/resources/assets/primeval/models/block/sandstone.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"parent": "minecraft:block/cube_all", | ||
"textures": { | ||
"all": "primeval:block/sandstone" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
3
src/main/resources/assets/primeval/models/item/sandstone.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"parent": "primeval:block/sandstone" | ||
} |
Binary file removed
BIN
-420 Bytes
src/main/resources/assets/primeval/textures/block/log_pile_side.png
Binary file not shown.
Binary file removed
BIN
-661 Bytes
src/main/resources/assets/primeval/textures/block/log_pile_top.png
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
20
src/main/resources/data/primeval/loot_tables/blocks/reeds.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
20
src/main/resources/data/primeval/loot_tables/blocks/sandstone.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
] | ||
} | ||
] | ||
} |
Oops, something went wrong.