Compare commits

..

No commits in common. "4c29b7a3808c71110e5ca5fe2b7baa538ab53fc1" and "945f71ae3029b99c11ac85bc927fdcaeb33e0c42" have entirely different histories.

4 changed files with 17 additions and 26 deletions

View file

@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse' apply plugin: 'eclipse'
apply plugin: 'maven-publish' apply plugin: 'maven-publish'
version = '37.5' version = '37.4'
group = 'de.ellpeck.naturesaura' // http://maven.apache.org/guides/mini/guide-naming-conventions.html group = 'de.ellpeck.naturesaura' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'NaturesAura' archivesBaseName = 'NaturesAura'

View file

@ -114,7 +114,7 @@ public class BlockContainerImpl extends BaseEntityBlock implements IModItem {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
var drops = super.getDrops(state, builder); var drops = super.getDrops(state, builder);
var tile = builder.getOptionalParameter(LootContextParams.BLOCK_ENTITY); var tile = builder.getParameter(LootContextParams.BLOCK_ENTITY);
if (tile instanceof BlockEntityImpl) { if (tile instanceof BlockEntityImpl) {
for (var stack : drops) { for (var stack : drops) {
if (stack.getItem() != this.asItem()) if (stack.getItem() != this.asItem())

View file

@ -105,8 +105,8 @@ public class BlockEndFlower extends BushBlock implements IModItem, ICustomBlockS
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
var tile = builder.getOptionalParameter(LootContextParams.BLOCK_ENTITY); var tile = builder.getParameter(LootContextParams.BLOCK_ENTITY);
if (tile instanceof BlockEntityEndFlower f && f.isDrainMode) if (tile instanceof BlockEntityEndFlower && ((BlockEntityEndFlower) tile).isDrainMode)
return NonNullList.create(); return NonNullList.create();
return super.getDrops(state, builder); return super.getDrops(state, builder);
} }

View file

@ -8,12 +8,9 @@ import de.ellpeck.naturesaura.blocks.tiles.BlockEntityOakGenerator;
import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder;
import net.minecraft.data.worldgen.features.TreeFeatures;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.SaplingBlock; import net.minecraft.world.level.block.SaplingBlock;
import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
@ -37,13 +34,21 @@ public class BlockOakGenerator extends BlockContainerImpl implements IVisualizab
if (level instanceof Level && !level.isClientSide() && IAuraType.forLevel((Level) level).isSimilar(NaturesAuraAPI.TYPE_OVERWORLD) if (level instanceof Level && !level.isClientSide() && IAuraType.forLevel((Level) level).isSimilar(NaturesAuraAPI.TYPE_OVERWORLD)
&& level.getBlockState(pos).getBlock() instanceof SaplingBlock) { && level.getBlockState(pos).getBlock() instanceof SaplingBlock) {
Helper.getBlockEntitiesInArea(level, pos, 10, tile -> { Helper.getBlockEntitiesInArea(level, pos, 10, tile -> {
if (!(tile instanceof BlockEntityOakGenerator oak)) if (!(tile instanceof BlockEntityOakGenerator))
return false; return false;
var replacement = BlockOakGenerator.getReplacement(event.getFeature());
if (replacement != null) { var rand = event.getRandomSource();
oak.scheduledBigTrees.add(pos); if (rand.nextInt(10) == 0)
event.setFeature(replacement); ((BlockEntityOakGenerator) tile).scheduledBigTrees.add(pos);
long seed;
do {
seed = rand.nextLong();
rand.setSeed(seed);
} }
while (rand.nextInt(10) == 0);
rand.setSeed(seed);
return true; return true;
}); });
} }
@ -68,18 +73,4 @@ public class BlockOakGenerator extends BlockContainerImpl implements IVisualizab
generator.modLoc("block/" + this.getBaseName() + "_bottom"), generator.modLoc("block/" + this.getBaseName() + "_bottom"),
generator.modLoc("block/" + this.getBaseName() + "_top"))); generator.modLoc("block/" + this.getBaseName() + "_top")));
} }
private static Holder<? extends ConfiguredFeature<?, ?>> getReplacement(Holder<? extends ConfiguredFeature<?, ?>> feature) {
if (feature == TreeFeatures.FANCY_OAK || feature == TreeFeatures.FANCY_OAK_BEES) {
return TreeFeatures.OAK;
} else if (feature == TreeFeatures.FANCY_OAK_BEES_002) {
return TreeFeatures.OAK_BEES_002;
} else if (feature == TreeFeatures.FANCY_OAK_BEES_0002) {
return TreeFeatures.OAK_BEES_0002;
} else if (feature == TreeFeatures.FANCY_OAK_BEES_005) {
return TreeFeatures.OAK_BEES_005;
} else {
return null;
}
}
} }