mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-26 05:08:34 +01:00
projectile generator, part 1
This commit is contained in:
parent
a7b30b310b
commit
3523837e3e
6 changed files with 111 additions and 0 deletions
|
@ -31,6 +31,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("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];
|
||||||
|
|
||||||
@Comment("The amount of blocks that can be between two Aura Field Creators for them to be connectable and work together")
|
@Comment("The amount of blocks that can be between two Aura Field Creators for them to be connectable and work together")
|
||||||
public int fieldCreatorRange = 10;
|
public int fieldCreatorRange = 10;
|
||||||
|
|
||||||
|
@ -124,6 +127,17 @@ public final class ModConfig {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
NaturesAura.LOGGER.warn("Error parsing additionalOres", e);
|
NaturesAura.LOGGER.warn("Error parsing additionalOres", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (String s : general.additionalProjectiles) {
|
||||||
|
String[] split = s.split("->");
|
||||||
|
ResourceLocation name = new ResourceLocation(split[0]);
|
||||||
|
int amount = Integer.parseInt(split[1]);
|
||||||
|
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(name, amount);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
NaturesAura.LOGGER.warn("Error parsing additionalProjectiles", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,6 +124,11 @@ public final class NaturesAuraAPI {
|
||||||
* spawn inside of netherrack blocks in the nether
|
* spawn inside of netherrack blocks in the nether
|
||||||
*/
|
*/
|
||||||
public static final List<WeightedOre> NETHER_ORES = new ArrayList<>();
|
public static final List<WeightedOre> NETHER_ORES = new ArrayList<>();
|
||||||
|
/**
|
||||||
|
* A map of all of the entities' registry names to the amounts of aura they
|
||||||
|
* each generate in the projectile generator
|
||||||
|
*/
|
||||||
|
public static final Map<ResourceLocation, Integer> PROJECTILE_GENERATIONS = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The capability for any item or block that stores Aura in the form of an
|
* The capability for any item or block that stores Aura in the form of an
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
package de.ellpeck.naturesaura.blocks;
|
||||||
|
|
||||||
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityProjectileGenerator;
|
||||||
|
import net.minecraft.block.SoundType;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityList;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.event.entity.ProjectileImpactEvent;
|
||||||
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
|
||||||
|
public class BlockProjectileGenerator extends BlockContainerImpl {
|
||||||
|
public BlockProjectileGenerator() {
|
||||||
|
super(Material.ROCK, "projectile_generator", TileEntityProjectileGenerator.class, "projectile_generator");
|
||||||
|
this.setSoundType(SoundType.STONE);
|
||||||
|
this.setHardness(2.5F);
|
||||||
|
|
||||||
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onProjectileImpact(ProjectileImpactEvent event) {
|
||||||
|
Entity entity = event.getEntity();
|
||||||
|
if (entity.world.isRemote)
|
||||||
|
return;
|
||||||
|
RayTraceResult ray = event.getRayTraceResult();
|
||||||
|
BlockPos pos = ray.getBlockPos();
|
||||||
|
if (pos == null)
|
||||||
|
return;
|
||||||
|
TileEntity tile = entity.world.getTileEntity(pos);
|
||||||
|
if (!(tile instanceof TileEntityProjectileGenerator))
|
||||||
|
return;
|
||||||
|
TileEntityProjectileGenerator generator = (TileEntityProjectileGenerator) tile;
|
||||||
|
if (generator.nextSide != ray.sideHit)
|
||||||
|
return;
|
||||||
|
ResourceLocation name = EntityList.getKey(entity);
|
||||||
|
int amount = NaturesAuraAPI.PROJECTILE_GENERATIONS.get(name);
|
||||||
|
if (amount <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
BlockPos spot = IAuraChunk.getLowestSpot(entity.world, pos, 35, pos);
|
||||||
|
IAuraChunk.getAuraChunk(entity.world, spot).storeAura(spot, amount);
|
||||||
|
|
||||||
|
generator.nextSide = generator.nextSide.rotateY();
|
||||||
|
generator.sendToClients();
|
||||||
|
|
||||||
|
entity.setDead();
|
||||||
|
event.setCanceled(true);
|
||||||
|
}
|
||||||
|
}
|
|
@ -52,4 +52,5 @@ public final class ModBlocks {
|
||||||
public static final Block ENDER_CRATE = new BlockEnderCrate();
|
public static final Block ENDER_CRATE = new BlockEnderCrate();
|
||||||
public static final Block POWDER_PLACER = new BlockPowderPlacer();
|
public static final Block POWDER_PLACER = new BlockPowderPlacer();
|
||||||
public static final Block FIREWORK_GENERATOR = new BlockFireworkGenerator();
|
public static final Block FIREWORK_GENERATOR = new BlockFireworkGenerator();
|
||||||
|
public static final Block PROJECTILE_GENERATOR = new BlockProjectileGenerator();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
|
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.ITickable;
|
||||||
|
|
||||||
|
public class TileEntityProjectileGenerator extends TileEntityImpl {
|
||||||
|
|
||||||
|
public EnumFacing nextSide = EnumFacing.NORTH;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeNBT(NBTTagCompound compound, SaveType type) {
|
||||||
|
super.writeNBT(compound, type);
|
||||||
|
if (type != SaveType.BLOCK) {
|
||||||
|
compound.setInteger("next_side", this.nextSide.getHorizontalIndex());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readNBT(NBTTagCompound compound, SaveType type) {
|
||||||
|
super.readNBT(compound, type);
|
||||||
|
if (type != SaveType.BLOCK) {
|
||||||
|
this.nextSide = EnumFacing.byHorizontalIndex(compound.getInteger("next_side"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -340,6 +340,15 @@ public final class ModRecipes {
|
||||||
|
|
||||||
NaturesAuraAPI.NETHER_ORES.add(new WeightedOre("oreCobalt", 50));
|
NaturesAuraAPI.NETHER_ORES.add(new WeightedOre("oreCobalt", 50));
|
||||||
NaturesAuraAPI.NETHER_ORES.add(new WeightedOre("oreArdite", 50));
|
NaturesAuraAPI.NETHER_ORES.add(new WeightedOre("oreArdite", 50));
|
||||||
|
|
||||||
|
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(new ResourceLocation("egg"), 2500);
|
||||||
|
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(new ResourceLocation("snowball"), 3500);
|
||||||
|
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(new ResourceLocation("small_fireball"), 15000);
|
||||||
|
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(new ResourceLocation("ender_pearl"), 30000);
|
||||||
|
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(new ResourceLocation("xp_bottle"), 75000);
|
||||||
|
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(new ResourceLocation("arrow"), 10000);
|
||||||
|
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(new ResourceLocation("shulker_bullet"), 250000);
|
||||||
|
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(new ResourceLocation("llama_spit"), 80000);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void spawner(String name, String entity, int aura, int time, Ingredient... ings) {
|
private static void spawner(String name, String entity, int aura, int time, Ingredient... ings) {
|
||||||
|
|
Loading…
Reference in a new issue