mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-26 05:08:34 +01:00
Compare commits
3 commits
945f71ae30
...
4c29b7a380
Author | SHA1 | Date | |
---|---|---|---|
4c29b7a380 | |||
335c01702b | |||
55ad057dda |
4 changed files with 26 additions and 17 deletions
|
@ -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.4'
|
version = '37.5'
|
||||||
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'
|
||||||
|
|
||||||
|
|
|
@ -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.getParameter(LootContextParams.BLOCK_ENTITY);
|
var tile = builder.getOptionalParameter(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())
|
||||||
|
|
|
@ -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.getParameter(LootContextParams.BLOCK_ENTITY);
|
var tile = builder.getOptionalParameter(LootContextParams.BLOCK_ENTITY);
|
||||||
if (tile instanceof BlockEntityEndFlower && ((BlockEntityEndFlower) tile).isDrainMode)
|
if (tile instanceof BlockEntityEndFlower f && f.isDrainMode)
|
||||||
return NonNullList.create();
|
return NonNullList.create();
|
||||||
return super.getDrops(state, builder);
|
return super.getDrops(state, builder);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,12 @@ 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;
|
||||||
|
@ -34,21 +37,13 @@ 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))
|
if (!(tile instanceof BlockEntityOakGenerator oak))
|
||||||
return false;
|
return false;
|
||||||
|
var replacement = BlockOakGenerator.getReplacement(event.getFeature());
|
||||||
var rand = event.getRandomSource();
|
if (replacement != null) {
|
||||||
if (rand.nextInt(10) == 0)
|
oak.scheduledBigTrees.add(pos);
|
||||||
((BlockEntityOakGenerator) tile).scheduledBigTrees.add(pos);
|
event.setFeature(replacement);
|
||||||
|
|
||||||
long seed;
|
|
||||||
do {
|
|
||||||
seed = rand.nextLong();
|
|
||||||
rand.setSeed(seed);
|
|
||||||
}
|
}
|
||||||
while (rand.nextInt(10) == 0);
|
|
||||||
rand.setSeed(seed);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -73,4 +68,18 @@ 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue