Compare commits

...

3 commits

Author SHA1 Message Date
Ell
4c29b7a380 37.5 2023-01-28 10:58:09 +01:00
Ell
335c01702b fixed a crash with pneumaticcraft drones
closes #273
2023-01-28 10:50:13 +01:00
Ell
55ad057dda fixed the canopy diminisher not working
Closes #287
2023-01-28 10:48:11 +01:00
4 changed files with 26 additions and 17 deletions

View file

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

View file

@ -114,7 +114,7 @@ public class BlockContainerImpl extends BaseEntityBlock implements IModItem {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder 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) {
for (var stack : drops) {
if (stack.getItem() != this.asItem())

View file

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

View file

@ -8,9 +8,12 @@ import de.ellpeck.naturesaura.blocks.tiles.BlockEntityOakGenerator;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
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.block.SaplingBlock;
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.phys.AABB;
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)
&& level.getBlockState(pos).getBlock() instanceof SaplingBlock) {
Helper.getBlockEntitiesInArea(level, pos, 10, tile -> {
if (!(tile instanceof BlockEntityOakGenerator))
if (!(tile instanceof BlockEntityOakGenerator oak))
return false;
var rand = event.getRandomSource();
if (rand.nextInt(10) == 0)
((BlockEntityOakGenerator) tile).scheduledBigTrees.add(pos);
long seed;
do {
seed = rand.nextLong();
rand.setSeed(seed);
var replacement = BlockOakGenerator.getReplacement(event.getFeature());
if (replacement != null) {
oak.scheduledBigTrees.add(pos);
event.setFeature(replacement);
}
while (rand.nextInt(10) == 0);
rand.setSeed(seed);
return true;
});
}
@ -73,4 +68,18 @@ public class BlockOakGenerator extends BlockContainerImpl implements IVisualizab
generator.modLoc("block/" + this.getBaseName() + "_bottom"),
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;
}
}
}