mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 11:53:29 +01:00
added a config to blacklist ores and fix metadata being misrecognized
Closes #47
This commit is contained in:
parent
f13a5a7b3d
commit
7f2f65aa88
2 changed files with 23 additions and 4 deletions
|
@ -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.BasicAuraType;
|
||||||
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||||
import de.ellpeck.naturesaura.api.recipes.WeightedOre;
|
import de.ellpeck.naturesaura.api.recipes.WeightedOre;
|
||||||
|
import de.ellpeck.naturesaura.chunk.effect.OreSpawnEffect;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.world.DimensionType;
|
import net.minecraft.world.DimensionType;
|
||||||
import net.minecraftforge.common.config.Config;
|
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")
|
@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];
|
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")
|
@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];
|
public String[] additionalProjectiles = new String[0];
|
||||||
|
|
||||||
|
@ -130,6 +134,13 @@ public final class ModConfig {
|
||||||
NaturesAura.LOGGER.warn("Error parsing additionalOres", e);
|
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 {
|
try {
|
||||||
for (String s : general.additionalProjectiles) {
|
for (String s : general.additionalProjectiles) {
|
||||||
String[] split = s.split("->");
|
String[] split = s.split("->");
|
||||||
|
|
|
@ -12,21 +12,25 @@ import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.*;
|
||||||
import net.minecraft.util.Tuple;
|
|
||||||
import net.minecraft.util.WeightedRandom;
|
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.WorldServer;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
import net.minecraftforge.common.util.FakePlayer;
|
||||||
|
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class OreSpawnEffect implements IDrainSpotEffect {
|
public class OreSpawnEffect implements IDrainSpotEffect {
|
||||||
|
|
||||||
|
public static final Set<IBlockState> SPAWN_EXCEPTIONS = new HashSet<>();
|
||||||
public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "ore_spawn");
|
public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "ore_spawn");
|
||||||
|
|
||||||
private int amount;
|
private int amount;
|
||||||
|
@ -109,7 +113,11 @@ public class OreSpawnEffect implements IDrainSpotEffect {
|
||||||
if (toPlace == Blocks.AIR)
|
if (toPlace == Blocks.AIR)
|
||||||
continue;
|
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.setBlockState(orePos, stateToPlace);
|
||||||
world.playEvent(2001, orePos, Block.getStateId(stateToPlace));
|
world.playEvent(2001, orePos, Block.getStateId(stateToPlace));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue