diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java index 1f5b46ba7..4ad66c652 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java @@ -80,6 +80,7 @@ public final class ActuallyAdditionsAPI{ public static Lens lensColor; public static Lens lensDisruption; public static Lens lensDisenchanting; + public static Lens lensMining; /** * Adds a Recipe to the Crusher Recipe Registry diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/creative/CreativeTab.java b/src/main/java/de/ellpeck/actuallyadditions/mod/creative/CreativeTab.java index 867951254..65e9b3dad 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/creative/CreativeTab.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/creative/CreativeTab.java @@ -156,6 +156,8 @@ public class CreativeTab extends CreativeTabs{ this.add(InitItems.itemColorLens); this.add(InitItems.itemExplosionLens); this.add(InitItems.itemDamageLens); + this.add(InitItems.itemDisenchantingLens); + this.add(InitItems.itemMiningLens); this.add(InitItems.itemLaserWrench); this.add(InitItems.itemCrateKeeper); this.add(InitItems.itemChestToCrateUpgrade); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/InitItems.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/InitItems.java index 21e56fedf..942c635d3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/InitItems.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/InitItems.java @@ -145,6 +145,7 @@ public final class InitItems{ public static Item itemExplosionLens; public static Item itemDamageLens; public static Item itemDisenchantingLens; + public static Item itemMiningLens; public static Item itemPickaxeCrystalRed; public static Item itemAxeCrystalRed; @@ -236,6 +237,7 @@ public final class InitItems{ itemExplosionLens = new ItemLens("itemExplosionLens", ActuallyAdditionsAPI.lensDetonation); itemDamageLens = new ItemLens("itemDamageLens", ActuallyAdditionsAPI.lensDeath); itemDisenchantingLens = new ItemLens("itemDisenchantingLens", ActuallyAdditionsAPI.lensDisenchanting); + itemMiningLens = new ItemLens("itemMiningLens", ActuallyAdditionsAPI.lensMining); itemCrystal = new ItemCrystal("itemCrystal", false); itemCrystalEmpowered = new ItemCrystal("itemCrystalEmpowered", true); itemLaserWrench = new ItemLaserWrench("itemLaserWrench"); 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 new file mode 100644 index 000000000..11096917d --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensMining.java @@ -0,0 +1,162 @@ +/* + * This file ("LensMining.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.mod.items.lens; + +import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; +import de.ellpeck.actuallyadditions.api.lens.Lens; +import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; +import net.minecraft.block.Block; +import net.minecraft.block.BlockNetherrack; +import net.minecraft.block.BlockStone; +import net.minecraft.block.state.IBlockState; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +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 = 30000; + + 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); + + 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); + + add(NETHERRACK_ORES, "oreCobalt", 50); + add(NETHERRACK_ORES, "oreArdite", 50); + } + + @Override + public boolean invoke(IBlockState hitState, BlockPos hitPos, IAtomicReconstructor tile){ + if(!tile.getWorldObject().isAirBlock(hitPos)){ + if(tile.getEnergy() >= ENERGY_USE){ + int adaptedUse = ENERGY_USE; + + List ores = null; + Block hitBlock = hitState.getBlock(); + if(hitBlock instanceof BlockStone){ + ores = STONE_ORES; + } + else if(hitBlock instanceof BlockNetherrack){ + ores = NETHERRACK_ORES; + adaptedUse += 10000; + } + + if(ores != null){ + int totalWeight = WeightedRandom.getTotalWeight(ores); + ItemStack stack = null; + + boolean found = false; + while(!found){ + WeightedOre ore = WeightedRandom.getRandomItem(tile.getWorldObject().rand, ores, totalWeight); + if(ore != null){ + List stacks = OreDictionary.getOres(ore.name, false); + if(stacks != null && !stacks.isEmpty()){ + for(ItemStack aStack : stacks){ + if(aStack != null && aStack.getItem() instanceof ItemBlock){ + adaptedUse += (totalWeight-ore.itemWeight)%10000; + + stack = aStack; + found = true; + break; + } + } + } + } + } + + if(tile.getEnergy() >= adaptedUse){ + Block block = Block.getBlockFromItem(stack.getItem()); + if(block != null){ + IBlockState state = block.getStateFromMeta(stack.getItemDamage()); + tile.getWorldObject().setBlockState(hitPos, state, 2); + + if(!ConfigBoolValues.LESS_BLOCK_BREAKING_EFFECTS.isEnabled()){ + tile.getWorldObject().playEvent(2001, hitPos, Block.getStateId(state)); + } + + tile.extractEnergy(adaptedUse); + } + } + } + } + + return true; + } + else{ + return false; + } + } + + @Override + public float[] getColor(){ + return new float[]{76F/255F, 76F/255F, 76F/255F}; + } + + @Override + public int getDistance(){ + return 10; + } + + private static void add(List list, String name, int weight){ + list.add(new WeightedOre(name, weight)); + } + + private static 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/Lenses.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/Lenses.java index 1dd121a9c..ac1da4679 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/Lenses.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/Lenses.java @@ -22,5 +22,6 @@ public final class Lenses{ ActuallyAdditionsAPI.lensColor = new LensColor(); ActuallyAdditionsAPI.lensDisruption = new LensDisruption(); ActuallyAdditionsAPI.lensDisenchanting = new LensDisenchanting(); + ActuallyAdditionsAPI.lensMining = new LensMining(); } } diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index 6e137f0da..0dc2a81a7 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -507,6 +507,7 @@ item.actuallyadditions.itemBag.name=Traveler's Sack item.actuallyadditions.itemVoidBag.name=Void Sack item.actuallyadditions.itemMiscCrystallizedCanolaSeed.name=Crystallized Canola Seed item.actuallyadditions.itemMiscEmpoweredCanolaSeed.name=Empowered Canola Seed +item.actuallyadditions.itemMiningLens.name=Lens of the Miner #Tooltips tooltip.actuallyadditions.onSuffix.desc=On diff --git a/src/main/resources/assets/actuallyadditions/models/item/itemMiningLens.json b/src/main/resources/assets/actuallyadditions/models/item/itemMiningLens.json new file mode 100644 index 000000000..5c57eedf9 --- /dev/null +++ b/src/main/resources/assets/actuallyadditions/models/item/itemMiningLens.json @@ -0,0 +1,6 @@ +{ + "parent": "actuallyadditions:item/standardItem", + "textures": { + "layer0": "actuallyadditions:items/itemMiningLens" + } +} diff --git a/src/main/resources/assets/actuallyadditions/textures/items/itemMiningLens.png b/src/main/resources/assets/actuallyadditions/textures/items/itemMiningLens.png new file mode 100644 index 000000000..148f41e2d Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/items/itemMiningLens.png differ