-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
blooming stem now has unique functionality
- Loading branch information
Showing
12 changed files
with
258 additions
and
51 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
73 changes: 62 additions & 11 deletions
73
src/generated/resources/assets/deeperdarker/blockstates/blooming_stem.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 |
---|---|---|
@@ -1,16 +1,67 @@ | ||
{ | ||
"variants": { | ||
"axis=x": { | ||
"model": "deeperdarker:block/blooming_stem", | ||
"x": 90, | ||
"y": 90 | ||
"multipart": [ | ||
{ | ||
"apply": { | ||
"model": "deeperdarker:block/blooming_stem" | ||
} | ||
}, | ||
"axis=y": { | ||
"model": "deeperdarker:block/blooming_stem" | ||
{ | ||
"apply": { | ||
"model": "deeperdarker:block/blooming_stem_vertical", | ||
"uvlock": true, | ||
"x": 180 | ||
}, | ||
"when": { | ||
"down": "true" | ||
} | ||
}, | ||
"axis=z": { | ||
"model": "deeperdarker:block/blooming_stem", | ||
"x": 90 | ||
{ | ||
"apply": { | ||
"model": "deeperdarker:block/blooming_stem_vertical", | ||
"uvlock": true | ||
}, | ||
"when": { | ||
"up": "true" | ||
} | ||
}, | ||
{ | ||
"apply": { | ||
"model": "deeperdarker:block/blooming_stem_horizontal", | ||
"uvlock": true, | ||
"y": 90 | ||
}, | ||
"when": { | ||
"north": "true" | ||
} | ||
}, | ||
{ | ||
"apply": { | ||
"model": "deeperdarker:block/blooming_stem_horizontal", | ||
"uvlock": true, | ||
"y": 270 | ||
}, | ||
"when": { | ||
"south": "true" | ||
} | ||
}, | ||
{ | ||
"apply": { | ||
"model": "deeperdarker:block/blooming_stem_horizontal", | ||
"uvlock": true | ||
}, | ||
"when": { | ||
"west": "true" | ||
} | ||
}, | ||
{ | ||
"apply": { | ||
"model": "deeperdarker:block/blooming_stem_horizontal", | ||
"uvlock": true, | ||
"y": 180 | ||
}, | ||
"when": { | ||
"east": "true" | ||
} | ||
} | ||
} | ||
] | ||
} |
6 changes: 6 additions & 0 deletions
6
src/generated/resources/assets/deeperdarker/models/block/blooming_stem_horizontal.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": "deeperdarker:block/stem_horizontal", | ||
"textures": { | ||
"stem": "deeperdarker:block/blooming_stem" | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/generated/resources/assets/deeperdarker/models/block/blooming_stem_vertical.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": "deeperdarker:block/stem_vertical", | ||
"textures": { | ||
"stem": "deeperdarker:block/blooming_stem" | ||
} | ||
} |
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
121 changes: 121 additions & 0 deletions
121
src/main/java/com/kyanite/deeperdarker/content/blocks/BloomingStemBlock.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,121 @@ | ||
package com.kyanite.deeperdarker.content.blocks; | ||
|
||
import com.kyanite.deeperdarker.content.DDBlocks; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.util.RandomSource; | ||
import net.minecraft.world.item.context.BlockPlaceContext; | ||
import net.minecraft.world.level.BlockGetter; | ||
import net.minecraft.world.level.LevelAccessor; | ||
import net.minecraft.world.level.LevelReader; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.PipeBlock; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.level.block.state.StateDefinition; | ||
import net.minecraft.world.level.block.state.properties.BlockStateProperties; | ||
import net.minecraft.world.level.block.state.properties.BooleanProperty; | ||
import net.minecraft.world.phys.shapes.BooleanOp; | ||
import net.minecraft.world.phys.shapes.CollisionContext; | ||
import net.minecraft.world.phys.shapes.Shapes; | ||
import net.minecraft.world.phys.shapes.VoxelShape; | ||
|
||
@SuppressWarnings("deprecation, NullableProblems") | ||
public class BloomingStemBlock extends Block { | ||
public static final BooleanProperty UP = BlockStateProperties.UP; | ||
public static final BooleanProperty DOWN = BlockStateProperties.DOWN; | ||
public static final BooleanProperty NORTH = BlockStateProperties.NORTH; | ||
public static final BooleanProperty EAST = BlockStateProperties.EAST; | ||
public static final BooleanProperty SOUTH = BlockStateProperties.SOUTH; | ||
public static final BooleanProperty WEST = BlockStateProperties.WEST; | ||
private static final VoxelShape[] shapes = { | ||
Block.box(5, 5, 5, 11, 11, 11), // CUBE | ||
Block.box(5, 11, 5, 11, 16, 11), // UP | ||
Block.box(5, 0, 5, 11, 5, 11), // DOWN | ||
Block.box(5, 5, 0, 11, 11, 5), // NORTH | ||
Block.box(11, 5, 5, 16, 11, 11), // EAST | ||
Block.box(5, 5, 11, 11, 11, 16), // SOUTH | ||
Block.box(0, 5, 5, 5, 11, 11) // WEST | ||
}; | ||
|
||
public BloomingStemBlock(Properties pProperties) { | ||
super(pProperties); | ||
this.registerDefaultState(this.stateDefinition.any().setValue(UP, false).setValue(DOWN, true).setValue(NORTH, false).setValue(EAST, false).setValue(SOUTH, false).setValue(WEST, false)); | ||
} | ||
|
||
@Override | ||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> pBuilder) { | ||
pBuilder.add(UP, DOWN, NORTH, EAST, SOUTH, WEST); | ||
} | ||
|
||
@Override | ||
public BlockState getStateForPlacement(BlockPlaceContext pContext) { | ||
BlockPos pos = pContext.getClickedPos(); | ||
BlockGetter level = pContext.getLevel(); | ||
|
||
BlockState aboveState = level.getBlockState(pos.above()); | ||
BlockState belowState = level.getBlockState(pos.below()); | ||
BlockState northState = level.getBlockState(pos.north()); | ||
BlockState eastState = level.getBlockState(pos.east()); | ||
BlockState southState = level.getBlockState(pos.south()); | ||
BlockState westState = level.getBlockState(pos.west()); | ||
|
||
if(belowState.is(this) || belowState.is(DDBlocks.BLOOMING_SCULK.get())) return this.defaultBlockState(); | ||
return this.defaultBlockState().setValue(UP, aboveState.is(this)).setValue(DOWN, belowState.is(this) || belowState.is(DDBlocks.BLOOMING_SCULK.get())).setValue(NORTH, northState.is(this)).setValue(EAST, eastState.is(this)).setValue(SOUTH, southState.is(this)).setValue(WEST, westState.is(this)); | ||
} | ||
|
||
@Override | ||
public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) { | ||
VoxelShape shape = shapes[0]; | ||
|
||
if(pState.getValue(UP)) shape = Shapes.join(shape, shapes[1], BooleanOp.OR); | ||
if(pState.getValue(DOWN)) shape = Shapes.join(shape, shapes[2], BooleanOp.OR); | ||
if(pState.getValue(NORTH)) shape = Shapes.join(shape, shapes[3], BooleanOp.OR); | ||
if(pState.getValue(EAST)) shape = Shapes.join(shape, shapes[4], BooleanOp.OR); | ||
if(pState.getValue(SOUTH)) shape = Shapes.join(shape, shapes[5], BooleanOp.OR); | ||
if(pState.getValue(WEST)) shape = Shapes.join(shape, shapes[6], BooleanOp.OR); | ||
|
||
return shape; | ||
} | ||
|
||
@Override | ||
public BlockState updateShape(BlockState pState, Direction pDirection, BlockState pNeighborState, LevelAccessor pLevel, BlockPos pPos, BlockPos pNeighborPos) { | ||
if(!pState.canSurvive(pLevel, pPos)) { | ||
pLevel.scheduleTick(pPos, this, 1); | ||
return super.updateShape(pState, pDirection, pNeighborState, pLevel, pPos, pNeighborPos); | ||
} | ||
|
||
if(pDirection == Direction.DOWN && pNeighborState.is(DDBlocks.BLOOMING_SCULK.get())) return pState.setValue(DOWN, true); | ||
if(pDirection.getAxis().isHorizontal() && !pLevel.getBlockState(pNeighborPos.below()).isAir()) return pState; | ||
return pState.setValue(PipeBlock.PROPERTY_BY_DIRECTION.get(pDirection), pNeighborState.is(this)); | ||
} | ||
|
||
@Override | ||
public void tick(BlockState pState, ServerLevel pLevel, BlockPos pPos, RandomSource pRandom) { | ||
if(!pState.canSurvive(pLevel, pPos)) { | ||
pLevel.destroyBlock(pPos, true); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean canSurvive(BlockState pState, LevelReader pLevel, BlockPos pPos) { | ||
BlockState below = pLevel.getBlockState(pPos.below()); | ||
|
||
if(below.is(this) || below.is(DDBlocks.BLOOMING_SCULK.get())) return true; | ||
|
||
|
||
if(canSurvive(below)) return true; | ||
|
||
for(Direction direction : Direction.Plane.HORIZONTAL) { | ||
BlockPos pos = pPos.relative(direction); | ||
BlockState state = pLevel.getBlockState(pos); | ||
if(state.is(this) && canSurvive(pLevel.getBlockState(pos.below()))) return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
private boolean canSurvive(BlockState state) { | ||
return state.is(this) || state.is(DDBlocks.BLOOMING_SCULK.get()); | ||
} | ||
} |
28 changes: 0 additions & 28 deletions
28
src/main/java/com/kyanite/deeperdarker/content/blocks/flammable/BloomingStemBlock.java
This file was deleted.
Oops, something went wrong.
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
19 changes: 19 additions & 0 deletions
19
src/main/resources/assets/deeperdarker/models/block/stem_horizontal.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,19 @@ | ||
{ | ||
"textures": { | ||
"particle": "#stem" | ||
}, | ||
"elements": [ | ||
{ | ||
"from": [0, 5, 5], | ||
"to": [5, 11, 11], | ||
"faces": { | ||
"north": {"uv": [11, 5, 16, 11], "texture": "#stem"}, | ||
"east": {"uv": [5, 5, 11, 11], "texture": "#stem"}, | ||
"south": {"uv": [0, 5, 5, 11], "texture": "#stem"}, | ||
"west": {"uv": [5, 5, 11, 11], "texture": "#stem"}, | ||
"up": {"uv": [0, 5, 5, 11], "texture": "#stem"}, | ||
"down": {"uv": [0, 5, 5, 11], "texture": "#stem"} | ||
} | ||
} | ||
] | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/resources/assets/deeperdarker/models/block/stem_vertical.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,19 @@ | ||
{ | ||
"textures": { | ||
"particle": "#stem" | ||
}, | ||
"elements": [ | ||
{ | ||
"from": [5, 11, 5], | ||
"to": [11, 16, 11], | ||
"faces": { | ||
"north": {"uv": [5, 0, 11, 5], "texture": "#stem"}, | ||
"east": {"uv": [5, 0, 11, 5], "texture": "#stem"}, | ||
"south": {"uv": [5, 0, 11, 5], "texture": "#stem"}, | ||
"west": {"uv": [5, 0, 11, 5], "texture": "#stem"}, | ||
"up": {"uv": [5, 5, 11, 11], "texture": "#stem"}, | ||
"down": {"uv": [5, 5, 11, 11], "texture": "#stem"} | ||
} | ||
} | ||
] | ||
} |
Binary file modified
BIN
-75 Bytes
(83%)
src/main/resources/assets/deeperdarker/textures/block/blooming_stem.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.