Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace PlantType system with SpecialPlantable interface and canSustainPlant block method #971

Merged
merged 72 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from 64 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
efc3c13
Have TranslatableContents throw when fed improper arguments in dev
TelepathicGrunt May 4, 2024
eea40f3
Replace PlantType system with SpecialPlantable and canSustainPlant
TelepathicGrunt May 17, 2024
8fae5c3
Patch bamboo stalk block
TelepathicGrunt May 17, 2024
1438b41
patch bamboo sapling and big dripleaf
TelepathicGrunt May 17, 2024
9be4022
patch cocoa and chorus
TelepathicGrunt May 17, 2024
ca67cab
Fix chorus plants and chorus flower
TelepathicGrunt May 17, 2024
8bc7c96
Added gametests
TelepathicGrunt May 17, 2024
8873a9b
Fixed and improved dripleaf gametests
TelepathicGrunt May 17, 2024
6d9c16b
fixed patch import
TelepathicGrunt May 17, 2024
d7e852f
formatting cleanup and one more case to small dripleaf test
TelepathicGrunt May 17, 2024
e166adb
rename interface methods
TelepathicGrunt May 17, 2024
e190d00
Add more javadoc and villagerCanPlantItem hook
TelepathicGrunt May 17, 2024
9c38093
Spotless
TelepathicGrunt May 17, 2024
6ac96f0
Added villager param to villagerCanPlantItem
TelepathicGrunt May 19, 2024
359448b
Extract some patched ternary to if checks
TelepathicGrunt May 19, 2024
343f165
Update TranslatableContents.java.patch
TelepathicGrunt Jun 5, 2024
0c46ead
Revert "Update TranslatableContents.java.patch"
TelepathicGrunt Jun 5, 2024
34fc181
Merge branch '1.20.x' into PlantTypeRefactor
TelepathicGrunt Jun 5, 2024
9f3a6d8
Fix merge conflict properly
TelepathicGrunt Jun 5, 2024
2c3bfdb
Fixed patch errors
TelepathicGrunt Jun 5, 2024
b99b187
spotless
TelepathicGrunt Jun 5, 2024
0d90702
Update patches/net/minecraft/world/level/block/CocoaBlock.java.patch
TelepathicGrunt Jun 6, 2024
a2a4437
Update patches/net/minecraft/world/level/block/ChorusPlantBlock.java.…
TelepathicGrunt Jun 6, 2024
fd7a153
Improve test and chorus block patch
TelepathicGrunt Jun 6, 2024
4c19213
Added getGroundStateForPlantChecks for disguising blocks
TelepathicGrunt Jun 6, 2024
2f98207
Merge branch '1.20.x' into PlantTypeRefactor
TelepathicGrunt Jun 6, 2024
4235871
add the import???
TelepathicGrunt Jun 6, 2024
26a3017
Revert "Added getGroundStateForPlantChecks for disguising blocks"
TelepathicGrunt Jun 6, 2024
9dcd55f
cleanup tristate usage
TelepathicGrunt Jun 6, 2024
2169724
Added villager_farmlands block tag and add itemstack to SpecialPlanta…
TelepathicGrunt Jun 8, 2024
344a93b
Replace PlantType system with SpecialPlantable and canSustainPlant
TelepathicGrunt May 17, 2024
56d8a14
Patch bamboo stalk block
TelepathicGrunt May 17, 2024
66c85b6
patch bamboo sapling and big dripleaf
TelepathicGrunt May 17, 2024
efaea87
patch cocoa and chorus
TelepathicGrunt May 17, 2024
ee5ab00
Fix chorus plants and chorus flower
TelepathicGrunt May 17, 2024
e8c05cc
Added gametests
TelepathicGrunt May 17, 2024
d44ccce
Fixed and improved dripleaf gametests
TelepathicGrunt May 17, 2024
f621f52
fixed patch import
TelepathicGrunt May 17, 2024
3a01de9
formatting cleanup and one more case to small dripleaf test
TelepathicGrunt May 17, 2024
f6e968c
rename interface methods
TelepathicGrunt May 17, 2024
70d5491
Add more javadoc and villagerCanPlantItem hook
TelepathicGrunt May 17, 2024
3413f30
Spotless
TelepathicGrunt May 17, 2024
d217631
Added villager param to villagerCanPlantItem
TelepathicGrunt May 19, 2024
bf323ef
Extract some patched ternary to if checks
TelepathicGrunt May 19, 2024
82fa7d6
Have TranslatableContents throw when fed improper arguments in dev
TelepathicGrunt May 4, 2024
34c1606
Revert "Update TranslatableContents.java.patch"
TelepathicGrunt Jun 5, 2024
0f83547
Fix merge conflict properly
TelepathicGrunt Jun 5, 2024
0b57374
Fixed patch errors
TelepathicGrunt Jun 5, 2024
2b64b05
spotless
TelepathicGrunt Jun 5, 2024
2e8a3e7
Update patches/net/minecraft/world/level/block/CocoaBlock.java.patch
TelepathicGrunt Jun 6, 2024
e913cb5
Update patches/net/minecraft/world/level/block/ChorusPlantBlock.java.…
TelepathicGrunt Jun 6, 2024
5d58c0d
Improve test and chorus block patch
TelepathicGrunt Jun 6, 2024
0c6ca59
Added getGroundStateForPlantChecks for disguising blocks
TelepathicGrunt Jun 6, 2024
75dbb51
add the import???
TelepathicGrunt Jun 6, 2024
f2623bb
Revert "Added getGroundStateForPlantChecks for disguising blocks"
TelepathicGrunt Jun 6, 2024
91463c4
cleanup tristate usage
TelepathicGrunt Jun 6, 2024
5a2c85e
Added villager_farmlands block tag and add itemstack to SpecialPlanta…
TelepathicGrunt Jun 8, 2024
4ebe48c
Fix patches
TelepathicGrunt Jun 13, 2024
35b00c0
Merge branch 'PlantTypeRefactor' of https://github.com/TelepathicGrun…
TelepathicGrunt Jun 13, 2024
76d4198
Merge branch '1.21.x' into PlantTypeRefactor
TelepathicGrunt Jun 13, 2024
3d0f917
Merge branch '1.21.x' into PlantTypeRefactor
TelepathicGrunt Jun 17, 2024
d73a505
Merge branch '1.21.x' into PlantTypeRefactor
TelepathicGrunt Jun 22, 2024
d13ce70
Merge branch '1.21.x' into PlantTypeRefactor
TelepathicGrunt Jun 22, 2024
69cb6af
Add back instanceof famland check
TelepathicGrunt Jun 22, 2024
275e5b5
Merge branch '1.21.x' into PlantTypeRefactor
TelepathicGrunt Jun 23, 2024
40607d3
Fixed merge conflict
TelepathicGrunt Jun 23, 2024
3d59e82
Fix merge issue again
TelepathicGrunt Jun 23, 2024
63380d0
improved chorus patch
TelepathicGrunt Jun 26, 2024
7b89a84
Improved crop patch
TelepathicGrunt Jun 26, 2024
4c51e95
Merge branch '1.21.x' into PlantTypeRefactor
TelepathicGrunt Jun 26, 2024
5e38735
gendata
TelepathicGrunt Jun 26, 2024
0a7b1d1
Merge branch 'PlantTypeRefactor' of https://github.com/TelepathicGrun…
TelepathicGrunt Jun 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,31 @@
return false;
} else if (p_23175_.getVillagerData().getProfession() != VillagerProfession.FARMER) {
return false;
@@ -82,7 +_,7 @@
BlockState blockstate = p_23182_.getBlockState(p_23181_);
Block block = blockstate.getBlock();
Block block1 = p_23182_.getBlockState(p_23181_.below()).getBlock();
- return block instanceof CropBlock && ((CropBlock)block).isMaxAge(blockstate) || blockstate.isAir() && block1 instanceof FarmBlock;
+ return block instanceof CropBlock && ((CropBlock)block).isMaxAge(blockstate) || blockstate.isAir() && (block1 instanceof FarmBlock || block1.builtInRegistryHolder().is(net.neoforged.neoforge.common.Tags.Blocks.VILLAGER_FARMLANDS));
}

protected void start(ServerLevel p_23177_, Villager p_23178_, long p_23179_) {
@@ -109,7 +_,7 @@
p_23196_.destroyBlock(this.aboveFarmlandPos, true, p_23197_);
}

- if (blockstate.isAir() && block1 instanceof FarmBlock && p_23197_.hasFarmSeeds()) {
+ if (blockstate.isAir() && (block1 instanceof FarmBlock || block1.builtInRegistryHolder().is(net.neoforged.neoforge.common.Tags.Blocks.VILLAGER_FARMLANDS)) && p_23197_.hasFarmSeeds()) {
SimpleContainer simplecontainer = p_23197_.getInventory();

for (int i = 0; i < simplecontainer.getContainerSize(); i++) {
@@ -120,6 +_,11 @@
p_23196_.setBlockAndUpdate(this.aboveFarmlandPos, blockstate1);
p_23196_.gameEvent(GameEvent.BLOCK_PLACE, this.aboveFarmlandPos, GameEvent.Context.of(p_23197_, blockstate1));
flag = true;
+ } else if (itemstack.getItem() instanceof net.neoforged.neoforge.common.IPlantable) {
+ if (((net.neoforged.neoforge.common.IPlantable)itemstack.getItem()).getPlantType(p_23196_, aboveFarmlandPos) == net.neoforged.neoforge.common.PlantType.CROP) {
+ p_23196_.setBlock(aboveFarmlandPos, ((net.neoforged.neoforge.common.IPlantable)itemstack.getItem()).getPlant(p_23196_, aboveFarmlandPos), 3);
+ } else if (itemstack.getItem() instanceof net.neoforged.neoforge.common.SpecialPlantable specialPlantable && specialPlantable.villagerCanPlantItem(p_23197_)) {
+ if (specialPlantable.canPlacePlantAtPosition(itemstack, p_23196_, aboveFarmlandPos, net.minecraft.core.Direction.DOWN)) {
+ specialPlantable.spawnPlantAtPosition(itemstack, p_23196_, aboveFarmlandPos, net.minecraft.core.Direction.DOWN);
+ flag = true;
+ }
}
Expand Down
9 changes: 9 additions & 0 deletions patches/net/minecraft/world/entity/npc/Villager.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,12 @@
p_35409_.addFreshEntityWithPassengers(witch);
this.releaseAllPois();
this.discard();
@@ -831,7 +_,7 @@
@Override
public boolean wantsToPickUp(ItemStack p_35543_) {
Item item = p_35543_.getItem();
- return (WANTED_ITEMS.contains(item) || this.getVillagerData().getProfession().requestedItems().contains(item))
+ return (WANTED_ITEMS.contains(item) || this.getVillagerData().getProfession().requestedItems().contains(item) || (p_35543_.getItem() instanceof net.neoforged.neoforge.common.SpecialPlantable specialPlantable && specialPlantable.villagerCanPlantItem(this)))
&& this.getInventory().canAddItem(p_35543_);
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
--- a/net/minecraft/world/level/block/BambooSaplingBlock.java
+++ b/net/minecraft/world/level/block/BambooSaplingBlock.java
@@ -50,6 +_,8 @@

@Override
protected boolean canSurvive(BlockState p_48986_, LevelReader p_48987_, BlockPos p_48988_) {
+ net.neoforged.neoforge.common.util.TriState soilDecision = p_48987_.getBlockState(p_48988_.below()).canSustainPlant(p_48987_, p_48988_.below(), net.minecraft.core.Direction.UP, p_48986_);
+ if (!soilDecision.isDefault()) return soilDecision.isTrue();
return p_48987_.getBlockState(p_48988_.below()).is(BlockTags.BAMBOO_PLANTABLE_ON);
}

@@ -88,7 +_,7 @@

@Override
Expand Down
41 changes: 19 additions & 22 deletions patches/net/minecraft/world/level/block/BambooStalkBlock.java.patch
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
--- a/net/minecraft/world/level/block/BambooStalkBlock.java
+++ b/net/minecraft/world/level/block/BambooStalkBlock.java
@@ -27,7 +_,7 @@
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;

-public class BambooStalkBlock extends Block implements BonemealableBlock {
+public class BambooStalkBlock extends Block implements BonemealableBlock, net.neoforged.neoforge.common.IPlantable {
public static final MapCodec<BambooStalkBlock> CODEC = simpleCodec(BambooStalkBlock::new);
protected static final float SMALL_LEAVES_AABB_OFFSET = 3.0F;
protected static final float LARGE_LEAVES_AABB_OFFSET = 5.0F;
@@ -97,7 +_,8 @@
return null;
} else {
BlockState blockstate = p_261764_.getLevel().getBlockState(p_261764_.getClickedPos().below());
- if (blockstate.is(BlockTags.BAMBOO_PLANTABLE_ON)) {
+ net.neoforged.neoforge.common.util.TriState soilDecision = blockstate.canSustainPlant(p_261764_.getLevel(), p_261764_.getClickedPos().below(), net.minecraft.core.Direction.UP, this.defaultBlockState());
+ if (soilDecision.isDefault() ? blockstate.is(BlockTags.BAMBOO_PLANTABLE_ON) : soilDecision.isTrue()) {
if (blockstate.is(Blocks.BAMBOO_SAPLING)) {
return this.defaultBlockState().setValue(AGE, Integer.valueOf(0));
} else if (blockstate.is(Blocks.BAMBOO)) {
@@ -130,10 +_,11 @@
@Override
protected void randomTick(BlockState p_261931_, ServerLevel p_261751_, BlockPos p_261616_, RandomSource p_261766_) {
Expand All @@ -23,6 +24,15 @@
}
}
}
@@ -141,6 +_,8 @@

@Override
protected boolean canSurvive(BlockState p_261860_, LevelReader p_262154_, BlockPos p_261493_) {
+ net.neoforged.neoforge.common.util.TriState soilDecision = p_262154_.getBlockState(p_261493_.below()).canSustainPlant(p_262154_, p_261493_.below(), Direction.UP, p_261860_);
+ if (!soilDecision.isDefault()) return soilDecision.isTrue();
return p_262154_.getBlockState(p_261493_.below()).is(BlockTags.BAMBOO_PLANTABLE_ON);
}

@@ -193,7 +_,7 @@

@Override
Expand All @@ -32,16 +42,3 @@
}

protected void growBamboo(BlockState p_261855_, Level p_262076_, BlockPos p_262109_, RandomSource p_261633_, int p_261759_) {
@@ -238,5 +_,12 @@
}

return i;
+ }
+
+ @Override
+ public BlockState getPlant(BlockGetter world, BlockPos pos) {
+ BlockState state = world.getBlockState(pos);
+ if (state.getBlock() != this) return defaultBlockState();
+ return state;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/net/minecraft/world/level/block/BigDripleafBlock.java
+++ b/net/minecraft/world/level/block/BigDripleafBlock.java
@@ -146,6 +_,8 @@
protected boolean canSurvive(BlockState p_152289_, LevelReader p_152290_, BlockPos p_152291_) {
BlockPos blockpos = p_152291_.below();
BlockState blockstate = p_152290_.getBlockState(blockpos);
+ net.neoforged.neoforge.common.util.TriState soilDecision = blockstate.canSustainPlant(p_152290_, blockpos, Direction.UP, p_152289_);
+ if (!soilDecision.isDefault()) return soilDecision.isTrue();
return blockstate.is(this) || blockstate.is(Blocks.BIG_DRIPLEAF_STEM) || blockstate.is(BlockTags.BIG_DRIPLEAF_PLACEABLE);
}

43 changes: 1 addition & 42 deletions patches/net/minecraft/world/level/block/Block.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
public boolean dropFromExplosion(Explosion p_49826_) {
return true;
}
@@ -485,6 +_,104 @@
@@ -485,6 +_,63 @@
return this.stateDefinition.getPossibleStates().stream().collect(ImmutableMap.toImmutableMap(Function.identity(), p_152459_));
}

Expand Down Expand Up @@ -181,47 +181,6 @@
+ public void initializeClient(java.util.function.Consumer<net.neoforged.neoforge.client.extensions.common.IClientBlockExtensions> consumer) {
+ }
+
+ @Override
+ public boolean canSustainPlant(BlockState state, BlockGetter world, BlockPos pos, Direction facing, net.neoforged.neoforge.common.IPlantable plantable) {
+ BlockState plant = plantable.getPlant(world, pos.relative(facing));
+ net.neoforged.neoforge.common.PlantType type = plantable.getPlantType(world, pos.relative(facing));
+
+ if (plant.getBlock() == Blocks.CACTUS)
+ return state.is(Blocks.CACTUS) || state.is(BlockTags.SAND);
+
+ if (plant.getBlock() == Blocks.SUGAR_CANE && this == Blocks.SUGAR_CANE)
+ return true;
+
+ if (plantable instanceof BushBlock && ((BushBlock)plantable).mayPlaceOn(state, world, pos))
+ return true;
+
+ if (net.neoforged.neoforge.common.PlantType.DESERT.equals(type)) {
+ return state.is(BlockTags.SAND) || state.is(BlockTags.TERRACOTTA);
+ } else if (net.neoforged.neoforge.common.PlantType.NETHER.equals(type)) {
+ return this == Blocks.SOUL_SAND;
+ } else if (net.neoforged.neoforge.common.PlantType.CROP.equals(type)) {
+ return state.is(Blocks.FARMLAND);
+ } else if (net.neoforged.neoforge.common.PlantType.CAVE.equals(type)) {
+ return state.isFaceSturdy(world, pos, Direction.UP);
+ } else if (net.neoforged.neoforge.common.PlantType.PLAINS.equals(type)) {
+ return state.is(BlockTags.DIRT) || this == Blocks.FARMLAND;
+ } else if (net.neoforged.neoforge.common.PlantType.WATER.equals(type)) {
+ return (state.is(Blocks.WATER) || state.getBlock() instanceof IceBlock) && world.getFluidState(pos.relative(facing)).isEmpty();
+ } else if (net.neoforged.neoforge.common.PlantType.BEACH.equals(type)) {
+ boolean isBeach = state.is(BlockTags.DIRT) || state.is(BlockTags.SAND);
+ boolean hasWater = false;
+ for (Direction face : Direction.Plane.HORIZONTAL) {
+ BlockState adjacentBlockState = world.getBlockState(pos.relative(face));
+ var adjacentFluidState = world.getFluidState(pos.relative(face));
+ hasWater = hasWater || adjacentBlockState.is(Blocks.FROSTED_ICE) || adjacentFluidState.is(net.minecraft.tags.FluidTags.WATER);
+ if (hasWater)
+ break; //No point continuing.
+ }
+ return isBeach && hasWater;
+ }
+ return false;
+ }
+
+ /* ========================================= FORGE END ======================================*/
+
+ /** @deprecated */
Expand Down
31 changes: 6 additions & 25 deletions patches/net/minecraft/world/level/block/BushBlock.java.patch
Original file line number Diff line number Diff line change
@@ -1,33 +1,14 @@
--- a/net/minecraft/world/level/block/BushBlock.java
+++ b/net/minecraft/world/level/block/BushBlock.java
@@ -11,7 +_,7 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.pathfinder.PathComputationType;

-public abstract class BushBlock extends Block {
+public abstract class BushBlock extends Block implements net.neoforged.neoforge.common.IPlantable {
public BushBlock(BlockBehaviour.Properties p_51021_) {
super(p_51021_);
}
@@ -33,6 +_,8 @@
@@ -33,7 +_,10 @@
@Override
protected boolean canSurvive(BlockState p_51028_, LevelReader p_51029_, BlockPos p_51030_) {
BlockPos blockpos = p_51030_.below();
+ if (p_51028_.getBlock() == this) //Forge: This function is called during world gen and placement, before this block is set, so if we are not 'here' then assume it's the pre-check.
+ return p_51029_.getBlockState(blockpos).canSustainPlant(p_51029_, blockpos, Direction.UP, this);
return this.mayPlaceOn(p_51029_.getBlockState(blockpos), p_51029_, blockpos);
- return this.mayPlaceOn(p_51029_.getBlockState(blockpos), p_51029_, blockpos);
+ BlockState belowBlockState = p_51029_.getBlockState(blockpos);
+ net.neoforged.neoforge.common.util.TriState soilDecision = belowBlockState.canSustainPlant(p_51029_, blockpos, Direction.UP, p_51028_);
+ if (!soilDecision.isDefault()) return soilDecision.isTrue();
+ return this.mayPlaceOn(belowBlockState, p_51029_, blockpos);
}

@@ -44,5 +_,12 @@
@Override
protected boolean isPathfindable(BlockState p_51023_, PathComputationType p_51026_) {
return p_51026_ == PathComputationType.AIR && !this.hasCollision ? true : super.isPathfindable(p_51023_, p_51026_);
+ }
+
+ @Override
+ public BlockState getPlant(BlockGetter world, BlockPos pos) {
+ BlockState state = world.getBlockState(pos);
+ if (state.getBlock() != this) return defaultBlockState();
+ return state;
}
}
33 changes: 4 additions & 29 deletions patches/net/minecraft/world/level/block/CactusBlock.java.patch
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
--- a/net/minecraft/world/level/block/CactusBlock.java
+++ b/net/minecraft/world/level/block/CactusBlock.java
@@ -21,7 +_,7 @@
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;

-public class CactusBlock extends Block {
+public class CactusBlock extends Block implements net.neoforged.neoforge.common.IPlantable {
public static final MapCodec<CactusBlock> CODEC = simpleCodec(CactusBlock::new);
public static final IntegerProperty AGE = BlockStateProperties.AGE_15;
public static final int MAX_AGE = 15;
@@ -41,6 +_,7 @@

@Override
Expand All @@ -34,28 +25,12 @@
}
}
}
@@ -99,7 +_,7 @@
@@ -99,6 +_,8 @@
}

BlockState blockstate1 = p_51154_.getBlockState(p_51155_.below());
- return (blockstate1.is(Blocks.CACTUS) || blockstate1.is(BlockTags.SAND)) && !p_51154_.getBlockState(p_51155_.above()).liquid();
+ return blockstate1.canSustainPlant(p_51154_, p_51155_, Direction.UP, this) && !p_51154_.getBlockState(p_51155_.above()).liquid();
+ net.neoforged.neoforge.common.util.TriState soilDecision = blockstate1.canSustainPlant(p_51154_, p_51155_.below(), Direction.UP, p_51153_);
+ if (!soilDecision.isDefault()) return soilDecision.isTrue();
return (blockstate1.is(Blocks.CACTUS) || blockstate1.is(BlockTags.SAND)) && !p_51154_.getBlockState(p_51155_.above()).liquid();
}

@Override
@@ -115,5 +_,15 @@
@Override
protected boolean isPathfindable(BlockState p_51143_, PathComputationType p_51146_) {
return false;
+ }
+
+ @Override
+ public net.neoforged.neoforge.common.PlantType getPlantType(BlockGetter world, BlockPos pos) {
+ return net.neoforged.neoforge.common.PlantType.DESERT;
+ }
+
+ @Override
+ public BlockState getPlant(BlockGetter world, BlockPos pos) {
+ return defaultBlockState();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/ChorusFlowerBlock.java
+++ b/net/minecraft/world/level/block/ChorusFlowerBlock.java
@@ -65,7 +_,7 @@
@@ -65,11 +_,13 @@
BlockPos blockpos = p_220982_.above();
if (p_220981_.isEmptyBlock(blockpos) && blockpos.getY() < p_220981_.getMaxBuildHeight()) {
int i = p_220980_.getValue(AGE);
Expand All @@ -9,6 +9,22 @@
boolean flag = false;
boolean flag1 = false;
BlockState blockstate = p_220981_.getBlockState(p_220982_.below());
- if (blockstate.is(Blocks.END_STONE)) {
+ net.neoforged.neoforge.common.util.TriState soilDecision = blockstate.canSustainPlant(p_220981_, p_220982_.below(), Direction.UP, p_220980_);
+ if (!soilDecision.isDefault()) flag = soilDecision.isTrue();
+ else if (blockstate.is(Blocks.END_STONE)) {
TelepathicGrunt marked this conversation as resolved.
Show resolved Hide resolved
flag = true;
} else if (blockstate.is(this.plant)) {
int j = 1;
@@ -77,6 +_,8 @@
for (int k = 0; k < 4; k++) {
BlockState blockstate1 = p_220981_.getBlockState(p_220982_.below(j + 1));
if (!blockstate1.is(this.plant)) {
+ net.neoforged.neoforge.common.util.TriState soilDecision2 = blockstate1.canSustainPlant(p_220981_, p_220982_.below(j + 1), Direction.UP, p_220980_);
+ if (!soilDecision2.isDefault()) flag1 = soilDecision2.isTrue();
if (blockstate1.is(Blocks.END_STONE)) {
flag1 = true;
}
@@ -123,6 +_,7 @@
} else {
this.placeDeadFlower(p_220981_, p_220982_);
Expand All @@ -17,3 +33,12 @@
}
}
}
@@ -159,6 +_,8 @@
@Override
protected boolean canSurvive(BlockState p_51683_, LevelReader p_51684_, BlockPos p_51685_) {
BlockState blockstate = p_51684_.getBlockState(p_51685_.below());
+ net.neoforged.neoforge.common.util.TriState soilDecision = blockstate.canSustainPlant(p_51684_, p_51685_.below(), Direction.UP, p_51683_);
+ if (!soilDecision.isDefault()) return soilDecision.isTrue();
if (!blockstate.is(this.plant) && !blockstate.is(Blocks.END_STONE)) {
if (!blockstate.isAir()) {
return false;
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
--- a/net/minecraft/world/level/block/ChorusPlantBlock.java
+++ b/net/minecraft/world/level/block/ChorusPlantBlock.java
@@ -49,7 +_,8 @@
BlockState blockstate4 = p_51711_.getBlockState(p_51712_.south());
BlockState blockstate5 = p_51711_.getBlockState(p_51712_.west());
Block block = p_304771_.getBlock();
- return p_304771_.trySetValue(DOWN, Boolean.valueOf(blockstate.is(block) || blockstate.is(Blocks.CHORUS_FLOWER) || blockstate.is(Blocks.END_STONE)))
+ net.neoforged.neoforge.common.util.TriState soilDecision = blockstate.canSustainPlant(p_51711_, p_51712_.below(), Direction.UP, p_304771_);
+ return p_304771_.trySetValue(DOWN, Boolean.valueOf(blockstate.is(block) || blockstate.is(Blocks.CHORUS_FLOWER) || blockstate.is(Blocks.END_STONE) || soilDecision.isTrue()))
.trySetValue(UP, Boolean.valueOf(blockstate1.is(block) || blockstate1.is(Blocks.CHORUS_FLOWER)))
.trySetValue(NORTH, Boolean.valueOf(blockstate2.is(block) || blockstate2.is(Blocks.CHORUS_FLOWER)))
.trySetValue(EAST, Boolean.valueOf(blockstate3.is(block) || blockstate3.is(Blocks.CHORUS_FLOWER)))
@@ -64,6 +_,12 @@
return super.updateShape(p_51728_, p_51729_, p_51730_, p_51731_, p_51732_, p_51733_);
} else {
boolean flag = p_51730_.is(this) || p_51730_.is(Blocks.CHORUS_FLOWER) || p_51729_ == Direction.DOWN && p_51730_.is(Blocks.END_STONE);
+ if (p_51729_ == Direction.DOWN) {
+ net.neoforged.neoforge.common.util.TriState soilDecision = p_51730_.canSustainPlant(p_51731_, p_51733_.relative(p_51729_), p_51729_.getOpposite(), p_51728_);
+ if (!soilDecision.isDefault()) {
+ flag = soilDecision.isTrue();
+ }
+ }
return p_51728_.setValue(PROPERTY_BY_DIRECTION.get(p_51729_), Boolean.valueOf(flag));
}
}
@@ -95,6 +_,8 @@
}
}

+ net.neoforged.neoforge.common.util.TriState soilDecision = blockstate.canSustainPlant(p_51725_, p_51726_.below(), Direction.UP, p_51724_);
+ if (!soilDecision.isDefault()) return soilDecision.isTrue();
return blockstate.is(this) || blockstate.is(Blocks.END_STONE);
}

9 changes: 9 additions & 0 deletions patches/net/minecraft/world/level/block/CocoaBlock.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,12 @@
}
}
}
@@ -75,6 +_,8 @@
@Override
protected boolean canSurvive(BlockState p_51767_, LevelReader p_51768_, BlockPos p_51769_) {
BlockState blockstate = p_51768_.getBlockState(p_51769_.relative(p_51767_.getValue(FACING)));
+ net.neoforged.neoforge.common.util.TriState soilDecision = blockstate.canSustainPlant(p_51768_, p_51769_.relative(p_51767_.getValue(FACING)), p_51767_.getValue(FACING).getOpposite(), p_51767_);
+ if (!soilDecision.isDefault()) return soilDecision.isTrue();
return blockstate.is(BlockTags.JUNGLE_LOGS);
}

Loading
Loading