-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Radiant Hands to the End Wilds
- Loading branch information
Showing
37 changed files
with
472 additions
and
12 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
4 changes: 4 additions & 0 deletions
4
...src/generated/resources/data/biomesoplenty/worldgen/configured_feature/radiant_hands.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,4 @@ | ||
{ | ||
"type": "biomesoplenty:radiant_hands", | ||
"config": {} | ||
} |
19 changes: 19 additions & 0 deletions
19
common/src/generated/resources/data/biomesoplenty/worldgen/placed_feature/radiant_hands.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 @@ | ||
{ | ||
"feature": "biomesoplenty:radiant_hands", | ||
"placement": [ | ||
{ | ||
"type": "minecraft:rarity_filter", | ||
"chance": 2 | ||
}, | ||
{ | ||
"type": "minecraft:in_square" | ||
}, | ||
{ | ||
"type": "minecraft:heightmap", | ||
"heightmap": "MOTION_BLOCKING" | ||
}, | ||
{ | ||
"type": "minecraft:biome" | ||
} | ||
] | ||
} |
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
124 changes: 124 additions & 0 deletions
124
common/src/main/java/biomesoplenty/block/RadiantHandsBlock.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,124 @@ | ||
/******************************************************************************* | ||
* Copyright 2022, the Glitchfiend Team. | ||
* All rights reserved. | ||
******************************************************************************/ | ||
package biomesoplenty.block; | ||
|
||
import biomesoplenty.api.block.BOPBlocks; | ||
import com.mojang.serialization.MapCodec; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.tags.BlockTags; | ||
import net.minecraft.util.RandomSource; | ||
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.Blocks; | ||
import net.minecraft.world.level.block.GrowingPlantHeadBlock; | ||
import net.minecraft.world.level.block.NetherVines; | ||
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.VoxelShape; | ||
|
||
import java.util.function.ToIntFunction; | ||
|
||
public class RadiantHandsBlock extends GrowingPlantHeadBlock | ||
{ | ||
public static final MapCodec<RadiantHandsBlock> CODEC = simpleCodec(RadiantHandsBlock::new); | ||
public static final BooleanProperty LIT = BlockStateProperties.LIT; | ||
public static final VoxelShape SHAPE = Block.box(1.0D, 0.0D, 1.0D, 15.0D, 16.0D, 15.0D); | ||
public static final int MAX_AGE = 8; | ||
private final double growPerTickProbability; | ||
|
||
public RadiantHandsBlock(Properties p_i241195_1_) | ||
{ | ||
super(p_i241195_1_, Direction.UP, SHAPE, false, 0.01D); | ||
this.growPerTickProbability = 0.01D; | ||
this.registerDefaultState(this.stateDefinition.any().setValue(AGE, 0).setValue(LIT, false)); | ||
} | ||
|
||
@Override | ||
public MapCodec<RadiantHandsBlock> codec() | ||
{ | ||
return CODEC; | ||
} | ||
|
||
@Override | ||
public BlockState getStateForPlacement(LevelAccessor p_53949_) | ||
{ | ||
return this.defaultBlockState().setValue(AGE, Integer.valueOf(p_53949_.getRandom().nextInt(MAX_AGE))).setValue(LIT, p_53949_.getRandom().nextInt(7) == 0); | ||
} | ||
|
||
@Override | ||
public boolean isRandomlyTicking(BlockState p_53961_) { | ||
return p_53961_.getValue(AGE) < MAX_AGE; | ||
} | ||
|
||
@Override | ||
public BlockState getMaxAgeState(BlockState p_187439_) { | ||
return p_187439_.setValue(AGE, Integer.valueOf(MAX_AGE)); | ||
} | ||
|
||
@Override | ||
public boolean isMaxAge(BlockState p_187441_) { | ||
return p_187441_.getValue(AGE) == MAX_AGE; | ||
} | ||
|
||
@Override | ||
protected int getBlocksToGrowWhenBonemealed(RandomSource p_230332_1_) { | ||
return NetherVines.getBlocksToGrowWhenBonemealed(p_230332_1_); | ||
} | ||
|
||
@Override | ||
public void performBonemeal(ServerLevel p_221337_, RandomSource p_221338_, BlockPos p_221339_, BlockState p_221340_) { | ||
BlockPos blockpos = p_221339_.relative(this.growthDirection); | ||
int i = Math.min(p_221340_.getValue(AGE) + 1, MAX_AGE); | ||
int j = this.getBlocksToGrowWhenBonemealed(p_221338_); | ||
|
||
for(int k = 0; k < j && this.canGrowInto(p_221337_.getBlockState(blockpos)); ++k) { | ||
p_221337_.setBlockAndUpdate(blockpos, p_221340_.setValue(AGE, Integer.valueOf(i))); | ||
blockpos = blockpos.relative(this.growthDirection); | ||
i = Math.min(i + 1, MAX_AGE); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
protected boolean canGrowInto(BlockState p_230334_1_) { | ||
return NetherVines.isValidGrowthState(p_230334_1_); | ||
} | ||
|
||
@Override | ||
protected Block getBodyBlock() { | ||
return BOPBlocks.RADIANT_HANDS_PLANT; | ||
} | ||
|
||
@Override | ||
public boolean canSurvive(BlockState p_196260_1_, LevelReader p_196260_2_, BlockPos p_196260_3_) | ||
{ | ||
BlockPos blockpos = p_196260_3_.relative(this.growthDirection.getOpposite()); | ||
BlockState blockstate = p_196260_2_.getBlockState(blockpos); | ||
Block block = blockstate.getBlock(); | ||
if (!this.canAttachTo(blockstate)) | ||
{ | ||
return false; | ||
} | ||
else | ||
{ | ||
return block == this.getHeadBlock() || block == this.getBodyBlock() || block == Blocks.END_STONE || block == BOPBlocks.ALGAL_END_STONE; | ||
} | ||
} | ||
|
||
public static ToIntFunction<BlockState> lightLevel(int level) | ||
{ | ||
return (state) -> { return state.getValue(LIT) ? level : 0; }; | ||
} | ||
|
||
@Override | ||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> p_56651_) { | ||
p_56651_.add(AGE, LIT); | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
common/src/main/java/biomesoplenty/block/RadiantHandsPlantBlock.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,75 @@ | ||
/******************************************************************************* | ||
* Copyright 2022, the Glitchfiend Team. | ||
* All rights reserved. | ||
******************************************************************************/ | ||
package biomesoplenty.block; | ||
|
||
import biomesoplenty.api.block.BOPBlocks; | ||
import com.mojang.serialization.MapCodec; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.tags.BlockTags; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.LevelReader; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.Blocks; | ||
import net.minecraft.world.level.block.GrowingPlantBodyBlock; | ||
import net.minecraft.world.level.block.GrowingPlantHeadBlock; | ||
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.VoxelShape; | ||
|
||
import java.util.function.ToIntFunction; | ||
|
||
public class RadiantHandsPlantBlock extends GrowingPlantBodyBlock | ||
{ | ||
public static final MapCodec<RadiantHandsPlantBlock> CODEC = simpleCodec(RadiantHandsPlantBlock::new); | ||
public static final BooleanProperty LIT = BlockStateProperties.LIT; | ||
public static final VoxelShape SHAPE = Block.box(1.0D, 0.0D, 1.0D, 15.0D, 16.0D, 15.0D); | ||
|
||
public RadiantHandsPlantBlock(Properties p_i241195_1_) | ||
{ | ||
super(p_i241195_1_, Direction.UP, SHAPE, false); | ||
this.registerDefaultState(this.stateDefinition.any().setValue(LIT, false)); | ||
} | ||
|
||
@Override | ||
public MapCodec<RadiantHandsPlantBlock> codec() | ||
{ | ||
return CODEC; | ||
} | ||
|
||
@Override | ||
protected GrowingPlantHeadBlock getHeadBlock() { | ||
return (GrowingPlantHeadBlock) BOPBlocks.RADIANT_HANDS; | ||
} | ||
|
||
@Override | ||
public boolean canSurvive(BlockState p_196260_1_, LevelReader p_196260_2_, BlockPos p_196260_3_) | ||
{ | ||
BlockPos blockpos = p_196260_3_.relative(this.growthDirection.getOpposite()); | ||
BlockState blockstate = p_196260_2_.getBlockState(blockpos); | ||
Block block = blockstate.getBlock(); | ||
if (!this.canAttachTo(blockstate)) | ||
{ | ||
return false; | ||
} | ||
else | ||
{ | ||
return block == this.getHeadBlock() || block == this.getBodyBlock() || block == Blocks.END_STONE || block == BOPBlocks.ALGAL_END_STONE; | ||
} | ||
} | ||
|
||
public static ToIntFunction<BlockState> lightLevel(int level) | ||
{ | ||
return (state) -> { return state.getValue(LIT) ? level : 0; }; | ||
} | ||
|
||
@Override | ||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> p_56651_) { | ||
p_56651_.add(LIT); | ||
} | ||
} |
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
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
Oops, something went wrong.