Fixed worldgenned plants popping off when blockupdated.

This commit is contained in:
Flanks255 2024-11-28 17:08:33 -06:00
parent 7a95edfcaa
commit 38d6404b62
8 changed files with 37 additions and 11 deletions

View file

@ -1,4 +1,4 @@
// 1.21.1 2024-10-22T22:13:28.2925645 Registries
// 1.21.1 2024-11-28T16:44:16.4483104 Registries
74628b34b75e1a2fa2ac1f6282b7d9d4e155c254 data/actuallyadditions/banner_pattern/book.json
899dfa1e0d0b15ffc090605543ec144bbfcacc4c data/actuallyadditions/banner_pattern/drill.json
7d9a33a9a151ad83de36e9af8822d08c86137adc data/actuallyadditions/banner_pattern/leaf_blo.json
@ -8,9 +8,9 @@
360756e7cd20afc4c6b2ad58b2fd4f37358f2ee6 data/actuallyadditions/neoforge/biome_modifier/add_canola.json
0f06d7aad676a45a4ca187552ac8c4bbd6f1b1b7 data/actuallyadditions/neoforge/biome_modifier/add_coffee.json
1401a66bbf2e1daaa459381103ffba9d02be352d data/actuallyadditions/neoforge/biome_modifier/add_flax.json
dceca4be717b43a4dfc945f62f5c09622604d7f4 data/actuallyadditions/worldgen/configured_feature/canola_patch.json
d56ed72dde226d9ac5eb07fa701f7a3902f1dcf2 data/actuallyadditions/worldgen/configured_feature/coffee_patch.json
9a42d5943e40d102c5e9efee988527da3622d88d data/actuallyadditions/worldgen/configured_feature/flax_patch.json
a9f260aa69d01d64a6332df904d1164e14990663 data/actuallyadditions/worldgen/configured_feature/canola_patch.json
5dbbd50693c6463bf8b45997e3163fb5beb99b0a data/actuallyadditions/worldgen/configured_feature/coffee_patch.json
7e6f0a47b395a141247d1fdfce0de2d9ef6abf36 data/actuallyadditions/worldgen/configured_feature/flax_patch.json
80765c24aa747df53139d14a9ac3293b4b3eab16 data/actuallyadditions/worldgen/configured_feature/ore_black_quartz.json
0401f9a4edd53ed76536a2c050364a6a442185bd data/actuallyadditions/worldgen/placed_feature/canola_patch.json
d7358c6519319ed3950dcdc34102504c53ccaf22 data/actuallyadditions/worldgen/placed_feature/coffee_patch.json

View file

@ -1 +1,2 @@
// 1.21.1 2024-10-22T20:41:07.9123026 Update structure files in /structure/
// 1.21.1 2024-11-28T16:44:16.4503165 Update structure files in /structure/
be1261b16ca6da9123934a123abb191d64ed46b8 data/actuallyadditions/structure/andrew_period_house.nbt

View file

@ -10,7 +10,8 @@
"state": {
"Name": "actuallyadditions:canola",
"Properties": {
"age": "7"
"age": "7",
"persistent": "true"
}
}
}

View file

@ -10,7 +10,8 @@
"state": {
"Name": "actuallyadditions:coffee",
"Properties": {
"age": "7"
"age": "7",
"persistent": "true"
}
}
}

View file

@ -10,7 +10,8 @@
"state": {
"Name": "actuallyadditions:flax",
"Properties": {
"age": "7"
"age": "7",
"persistent": "true"
}
}
}

View file

@ -6,28 +6,50 @@ import net.minecraft.tags.BlockTags;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.CropBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import javax.annotation.Nonnull;
import java.util.function.Supplier;
public class AACrops extends CropBlock {
Supplier<? extends Item> itemSupplier;
public static final BooleanProperty PERSISTENT = BooleanProperty.create("persistent");
public AACrops(Properties properties, Supplier<? extends Item> seedSupplier) {
super(properties);
this.itemSupplier = seedSupplier;
this.registerDefaultState(this.stateDefinition.any().setValue(AGE, 0).setValue(PERSISTENT, false));
}
@Nonnull
@Override
protected ItemLike getBaseSeedId() {
return this.itemSupplier.get();
}
@Override
protected boolean mayPlaceOn(BlockState state, BlockGetter level, BlockPos pos) {
protected boolean mayPlaceOn(@Nonnull BlockState state, @Nonnull BlockGetter level, @Nonnull BlockPos pos) {
if (level instanceof WorldGenRegion) {
return state.is(BlockTags.DIRT);
}
return super.mayPlaceOn(state, level, pos);
}
@Override
protected boolean canSurvive(@Nonnull BlockState state, @Nonnull LevelReader level, @Nonnull BlockPos pos) {
if (!(level instanceof WorldGenRegion) && state.getValue(PERSISTENT) && !level.getBlockState(pos.below()).isAir())
return true;
return super.canSurvive(state, level, pos);
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(AGE, PERSISTENT);
}
}

View file

@ -41,7 +41,7 @@ public class ActuallyConfiguredFeatures {
}
private static RandomPatchConfiguration plantPatch(Block crop, int tries) {
BlockStateProvider stateProvider = BlockStateProvider.simple(crop.defaultBlockState().setValue(AACrops.AGE, AACrops.MAX_AGE));
BlockStateProvider stateProvider = BlockStateProvider.simple(crop.defaultBlockState().setValue(AACrops.AGE, AACrops.MAX_AGE).setValue(AACrops.PERSISTENT, true));
return FeatureUtils.simpleRandomPatchConfiguration(
tries, PlacementUtils.onlyWhenEmpty(Feature.SIMPLE_BLOCK, new SimpleBlockConfiguration(stateProvider))
);

View file

@ -115,7 +115,7 @@ public class ItemWingsOfTheBats extends ItemBase {
public void livingUpdateEvent(PlayerTickEvent.Post event) {
if (event.getEntity() instanceof Player player) {
if (false &&!player.isCreative() && !player.isSpectator()) { //TODO disabled for now.
if (false &&!player.isCreative() && !player.isSpectator()) { //TODO disabled for now.
PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player);
if (!player.level().isClientSide) {