From a515839c5c299b4da5de4477fb312cdeb77b562b Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Mon, 31 Oct 2016 19:20:29 +0100 Subject: [PATCH] move the ore lists to the API --- .../api/ActuallyAdditionsAPI.java | 25 +++++ .../api/recipe/WeightedOre.java | 23 +++++ .../mod/items/lens/LensMining.java | 95 ++++++++----------- 3 files changed, 89 insertions(+), 54 deletions(-) create mode 100644 src/main/java/de/ellpeck/actuallyadditions/api/recipe/WeightedOre.java diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java index 4ad66c652..47cff1381 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java @@ -17,6 +17,7 @@ import de.ellpeck.actuallyadditions.api.laser.ILaserRelayConnectionHandler; import de.ellpeck.actuallyadditions.api.lens.Lens; import de.ellpeck.actuallyadditions.api.lens.LensConversion; import de.ellpeck.actuallyadditions.api.recipe.*; +import de.ellpeck.actuallyadditions.mod.items.lens.LensMining; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -43,6 +44,8 @@ public final class ActuallyAdditionsAPI{ public static final Map OIL_GENERATOR_RECIPES = new HashMap(); public static final List BOOKLET_ENTRIES = new ArrayList(); public static final List BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA = new ArrayList(); + public static final List STONE_ORES = new ArrayList(); + public static final List NETHERRACK_ORES = new ArrayList(); /** * Use this to handle things that aren't based in the API itself @@ -142,6 +145,28 @@ public final class ActuallyAdditionsAPI{ public static void addCrusherRecipe(String input, ItemStack outputOne){ } + /** + * Adds an ore with a specific weight to the list of ores that the lens of the miner will generate inside of stone. + * Higher weight means higher occurence. + * + * @param oreName The ore's name + * @param weight The ore's weight + */ + public static void addMiningLensStoneOre(String oreName, int weight){ + STONE_ORES.add(new WeightedOre(oreName, weight)); + } + + /** + * Adds an ore with a specific weight to the list of ores that the lens of the miner will generate inside of netherrack. + * Higher weight means higher occurence. + * + * @param oreName The ore's name + * @param weight The ore's weight + */ + public static void addMiningLensNetherOre(String oreName, int weight){ + NETHERRACK_ORES.add(new WeightedOre(oreName, weight)); + } + /** * Adds a Recipe to the Crusher Recipe Registry * diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/WeightedOre.java b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/WeightedOre.java new file mode 100644 index 000000000..35e02f78e --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/WeightedOre.java @@ -0,0 +1,23 @@ +/* + * This file ("WeightedOre.java") is part of the Actually Additions mod for Minecraft. + * It is created and owned by Ellpeck and distributed + * under the Actually Additions License to be found at + * http://ellpeck.de/actaddlicense + * View the source code at https://github.com/Ellpeck/ActuallyAdditions + * + * © 2015-2016 Ellpeck + */ + +package de.ellpeck.actuallyadditions.api.recipe; + +import net.minecraft.util.WeightedRandom; + +public class WeightedOre extends WeightedRandom.Item{ + + public final String name; + + public WeightedOre(String name, int weight){ + super(weight); + this.name = name; + } +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensMining.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensMining.java index 0e7004b71..85bc35eb2 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensMining.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensMining.java @@ -10,8 +10,10 @@ package de.ellpeck.actuallyadditions.mod.items.lens; +import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; import de.ellpeck.actuallyadditions.api.lens.Lens; +import de.ellpeck.actuallyadditions.api.recipe.WeightedOre; import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; import net.minecraft.block.Block; import net.minecraft.block.BlockNetherrack; @@ -23,59 +25,53 @@ import net.minecraft.util.WeightedRandom; import net.minecraft.util.math.BlockPos; import net.minecraftforge.oredict.OreDictionary; -import java.util.ArrayList; import java.util.List; public class LensMining extends Lens{ public static final int ENERGY_USE = 60000; - private static final List STONE_ORES = new ArrayList(); - private static final List NETHERRACK_ORES = new ArrayList(); static{ - add(STONE_ORES, "oreCoal", 5000); - add(NETHERRACK_ORES, "oreNetherCoal", 5000); - add(STONE_ORES, "oreIron", 3000); - add(NETHERRACK_ORES, "oreNetherIron", 3000); - add(STONE_ORES, "oreGold", 500); - add(NETHERRACK_ORES, "oreNetherGold", 500); - add(STONE_ORES, "oreDiamond", 50); - add(NETHERRACK_ORES, "oreNetherDiamond", 50); - add(STONE_ORES, "oreLapis", 250); - add(NETHERRACK_ORES, "oreNetherLapis", 250); - add(STONE_ORES, "oreRedstone", 200); - add(NETHERRACK_ORES, "oreNetherRedstone", 200); - add(STONE_ORES, "oreEmerald", 30); - add(NETHERRACK_ORES, "oreQuartz", 30); + ActuallyAdditionsAPI.addMiningLensStoneOre("oreCoal", 5000); + ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherCoal", 5000); + ActuallyAdditionsAPI.addMiningLensStoneOre("oreIron", 3000); + ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherIron", 3000); + ActuallyAdditionsAPI.addMiningLensStoneOre("oreGold", 500); + ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherGold", 500); + ActuallyAdditionsAPI.addMiningLensStoneOre("oreDiamond", 50); + ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherDiamond", 50); + ActuallyAdditionsAPI.addMiningLensStoneOre("oreLapis", 250); + ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherLapis", 250); + ActuallyAdditionsAPI.addMiningLensStoneOre("oreRedstone", 200); + ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherRedstone", 200); + ActuallyAdditionsAPI.addMiningLensStoneOre("oreEmerald", 30); + ActuallyAdditionsAPI.addMiningLensNetherOre("oreQuartz", 30); - add(STONE_ORES, "oreCopper", 2000); - add(NETHERRACK_ORES, "oreNetherCopper", 2000); - add(STONE_ORES, "oreTin", 1800); - add(NETHERRACK_ORES, "oreNetherTin", 1800); - add(STONE_ORES, "oreLead", 1500); - add(NETHERRACK_ORES, "oreNetherLead", 1500); - add(STONE_ORES, "oreSilver", 1000); - add(NETHERRACK_ORES, "oreNetherSilver", 1000); - add(STONE_ORES, "oreNickel", 100); - add(NETHERRACK_ORES, "oreNetherNickel", 100); - add(STONE_ORES, "orePlatinum", 20); - add(NETHERRACK_ORES, "oreNetherPlatinum", 20); - add(STONE_ORES, "oreAluminum", 1600); - add(STONE_ORES, "oreOsmium", 1500); - add(STONE_ORES, "oreZinc", 1000); - add(STONE_ORES, "oreYellorite", 1200); - add(STONE_ORES, "oreUranium", 400); - add(STONE_ORES, "oreCertusQuartz", 800); - add(STONE_ORES, "oreApatite", 700); - add(STONE_ORES, "oreQuartzBlack", 3000); + ActuallyAdditionsAPI.addMiningLensStoneOre("oreCopper", 2000); + ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherCopper", 2000); + ActuallyAdditionsAPI.addMiningLensStoneOre("oreTin", 1800); + ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherTin", 1800); + ActuallyAdditionsAPI.addMiningLensStoneOre("oreLead", 1500); + ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherLead", 1500); + ActuallyAdditionsAPI.addMiningLensStoneOre("oreSilver", 1000); + ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherSilver", 1000); + ActuallyAdditionsAPI.addMiningLensStoneOre("oreNickel", 100); + ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherNickel", 100); + ActuallyAdditionsAPI.addMiningLensStoneOre("orePlatinum", 20); + ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherPlatinum", 20); + ActuallyAdditionsAPI.addMiningLensStoneOre("oreAluminum", 1200); + ActuallyAdditionsAPI.addMiningLensStoneOre("oreAluminium", 1200); + ActuallyAdditionsAPI.addMiningLensStoneOre("oreOsmium", 1500); + ActuallyAdditionsAPI.addMiningLensStoneOre("oreZinc", 1000); + ActuallyAdditionsAPI.addMiningLensStoneOre("oreYellorite", 1200); + ActuallyAdditionsAPI.addMiningLensStoneOre("oreUranium", 400); + ActuallyAdditionsAPI.addMiningLensStoneOre("oreCertusQuartz", 800); + ActuallyAdditionsAPI.addMiningLensStoneOre("oreApatite", 700); + ActuallyAdditionsAPI.addMiningLensStoneOre("oreQuartzBlack", 3000); - add(NETHERRACK_ORES, "oreCobalt", 50); - add(NETHERRACK_ORES, "oreArdite", 50); - } - - private static void add(List list, String name, int weight){ - list.add(new WeightedOre(name, weight)); + ActuallyAdditionsAPI.addMiningLensNetherOre("oreCobalt", 50); + ActuallyAdditionsAPI.addMiningLensNetherOre("oreArdite", 50); } @Override @@ -87,10 +83,10 @@ public class LensMining extends Lens{ List ores = null; Block hitBlock = hitState.getBlock(); if(hitBlock instanceof BlockStone){ - ores = STONE_ORES; + ores = ActuallyAdditionsAPI.STONE_ORES; } else if(hitBlock instanceof BlockNetherrack){ - ores = NETHERRACK_ORES; + ores = ActuallyAdditionsAPI.NETHERRACK_ORES; adaptedUse += 10000; } @@ -150,13 +146,4 @@ public class LensMining extends Lens{ return 10; } - private static class WeightedOre extends WeightedRandom.Item{ - - public final String name; - - public WeightedOre(String name, int weight){ - super(weight); - this.name = name; - } - } }