diff --git a/src/main/java/de/ellpeck/naturesaura/ModConfig.java b/src/main/java/de/ellpeck/naturesaura/ModConfig.java index cbf48e0b..76a71ef1 100644 --- a/src/main/java/de/ellpeck/naturesaura/ModConfig.java +++ b/src/main/java/de/ellpeck/naturesaura/ModConfig.java @@ -4,6 +4,7 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.type.BasicAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.recipes.WeightedOre; +import de.ellpeck.naturesaura.chunk.effect.OreSpawnEffect; import net.minecraft.util.ResourceLocation; import net.minecraft.world.DimensionType; import net.minecraftforge.common.config.Config; @@ -31,6 +32,9 @@ public final class ModConfig { @Comment("Additional blocks that are recognized as generatable ores for the passive ore generation effect. Each entry needs to be formatted as oredictEntry:oreWeight:dimension where a higher weight makes the ore more likely to spawn with 5000 being the weight of coal, the default ore with the highest weight, and dimension being any of overworld and nether") public String[] additionalOres = new String[0]; + @Comment("Blocks that are exempt from being recognized as generatable ores for the passive ore generation effect. Each entry needs to be formatted as modid:block[prop1=value1,...] where block state properties are optional") + public String[] oreExceptions = new String[0]; + @Comment("Additional projectile types that are allowed to be consumed by the projectile generator. Each entry needs to be formatted as entity_registry_name->aura_amount") public String[] additionalProjectiles = new String[0]; @@ -130,6 +134,13 @@ public final class ModConfig { NaturesAura.LOGGER.warn("Error parsing additionalOres", e); } + try { + for (String s : general.oreExceptions) + OreSpawnEffect.SPAWN_EXCEPTIONS.add(Helper.getStateFromString(s)); + } catch (Exception e) { + NaturesAura.LOGGER.warn("Error parsing oreExceptions", e); + } + try { for (String s : general.additionalProjectiles) { String[] split = s.split("->"); diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java index 00adefad..c712a880 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java @@ -12,21 +12,25 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.Tuple; -import net.minecraft.util.WeightedRandom; +import net.minecraft.util.*; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; +import net.minecraft.world.WorldServer; import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.common.util.FakePlayer; +import net.minecraftforge.common.util.FakePlayerFactory; import net.minecraftforge.oredict.OreDictionary; +import java.util.HashSet; import java.util.List; +import java.util.Set; public class OreSpawnEffect implements IDrainSpotEffect { + public static final Set SPAWN_EXCEPTIONS = new HashSet<>(); public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "ore_spawn"); private int amount; @@ -109,7 +113,11 @@ public class OreSpawnEffect implements IDrainSpotEffect { if (toPlace == Blocks.AIR) continue; - IBlockState stateToPlace = toPlace.getDefaultState(); + FakePlayer player = FakePlayerFactory.getMinecraft((WorldServer) world); + IBlockState stateToPlace = toPlace.getStateForPlacement(world, pos, EnumFacing.UP, 0, 0, 0, stack.getMetadata(), player, EnumHand.MAIN_HAND); + if (SPAWN_EXCEPTIONS.contains(stateToPlace)) + continue; + world.setBlockState(orePos, stateToPlace); world.playEvent(2001, orePos, Block.getStateId(stateToPlace));