Secondary gem moved to eventHandler. Closes #1365
This commit is contained in:
parent
376f02df26
commit
6c7f9078ec
3 changed files with 94 additions and 80 deletions
|
@ -31,7 +31,6 @@ import net.minecraft.block.state.BlockStateContainer;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.init.Items;
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
|
@ -48,7 +47,6 @@ import reborncore.common.registration.RebornRegistry;
|
||||||
import reborncore.common.registration.impl.ConfigRegistry;
|
import reborncore.common.registration.impl.ConfigRegistry;
|
||||||
import reborncore.common.util.ArrayUtils;
|
import reborncore.common.util.ArrayUtils;
|
||||||
import reborncore.common.util.OreDrop;
|
import reborncore.common.util.OreDrop;
|
||||||
import reborncore.common.util.OreDropSet;
|
|
||||||
import reborncore.common.util.StringUtils;
|
import reborncore.common.util.StringUtils;
|
||||||
import techreborn.client.TechRebornCreativeTabMisc;
|
import techreborn.client.TechRebornCreativeTabMisc;
|
||||||
import techreborn.events.TRRecipeHandler;
|
import techreborn.events.TRRecipeHandler;
|
||||||
|
@ -58,7 +56,6 @@ import techreborn.items.ItemGems;
|
||||||
import techreborn.lib.ModInfo;
|
import techreborn.lib.ModInfo;
|
||||||
import techreborn.world.config.IOreNameProvider;
|
import techreborn.world.config.IOreNameProvider;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
@ -71,8 +68,30 @@ public class BlockOre extends Block implements IOreNameProvider {
|
||||||
"lead", "silver" };
|
"lead", "silver" };
|
||||||
private static final List<String> oreNamesList = Lists.newArrayList(ArrayUtils.arrayToLowercase(ores));
|
private static final List<String> oreNamesList = Lists.newArrayList(ArrayUtils.arrayToLowercase(ores));
|
||||||
public static final PropertyString VARIANTS = new PropertyString("type", oreNamesList);
|
public static final PropertyString VARIANTS = new PropertyString("type", oreNamesList);
|
||||||
@ConfigRegistry(category = "blocks", key = "secondaryDropChance", comment = "Secondary Gem drop chance")
|
@ConfigRegistry(config = "misc", category = "blocks", key = "rubyMinQuatity", comment = "Minimum quantity of Ruby gems per Ruby ore")
|
||||||
public static double secondaryDropChance = 0.5;
|
public static int rubyMinQuatity = 1;
|
||||||
|
@ConfigRegistry(config = "misc", category = "blocks", key = "rubyMaxQuantity", comment = "Maximum quantity of Ruby gems per Ruby ore")
|
||||||
|
public static int rubyMaxQuantity = 2;
|
||||||
|
@ConfigRegistry(config = "misc", category = "blocks", key = "sapphireMinQuantity", comment = "Minimum quantity of Sapphire gems per Sapphire ore")
|
||||||
|
public static int sapphireMinQuantity = 1;
|
||||||
|
@ConfigRegistry(config = "misc", category = "blocks", key = "sapphireMaxQuantity", comment = "Maximum quantity of Sapphire gems per Sapphire ore")
|
||||||
|
public static int sapphireMaxQuantity = 2;
|
||||||
|
@ConfigRegistry(config = "misc", category = "blocks", key = "pyriteMinQuatity", comment = "Minimum quantity of Pyrite dust per Pyrite ore")
|
||||||
|
public static int pyriteMinQuatity = 1;
|
||||||
|
@ConfigRegistry(config = "misc", category = "blocks", key = "pyriteMaxQuantity", comment = "Maximum quantity of Pyrite dust per Pyrite ore")
|
||||||
|
public static int pyriteMaxQuantity = 2;
|
||||||
|
@ConfigRegistry(config = "misc", category = "blocks", key = "sodaliteMinQuatity", comment = "Minimum quantity of Sodalite dust per Sodalite ore")
|
||||||
|
public static int sodaliteMinQuatity = 1;
|
||||||
|
@ConfigRegistry(config = "misc", category = "blocks", key = "sodaliteMaxQuantity", comment = "Maximum quantity of Sodalite dust per Sodalite ore")
|
||||||
|
public static int sodaliteMaxQuantity = 2;
|
||||||
|
@ConfigRegistry(config = "misc", category = "blocks", key = "cinnabarMinQuatity", comment = "Minimum quantity of Cinnabar dust per Cinnabar ore")
|
||||||
|
public static int cinnabarMinQuatity = 1;
|
||||||
|
@ConfigRegistry(config = "misc", category = "blocks", key = "cinnabarMaxQuantity", comment = "Maximum quantity of Cinnabar dust per Cinnabar ore")
|
||||||
|
public static int cinnabarMaxQuantity = 2;
|
||||||
|
@ConfigRegistry(config = "misc", category = "blocks", key = "sphaleriteMinQuatity", comment = "Minimum quantity of Sphalerite dust per Sphalerite ore")
|
||||||
|
public static int sphaleriteMinQuatity = 1;
|
||||||
|
@ConfigRegistry(config = "misc", category = "blocks", key = "sphaleriteMaxQuantity", comment = "Maximum quantity of Sphalerite dust per Sphalerite ore")
|
||||||
|
public static int sphaleriteMaxQuantity = 2;
|
||||||
|
|
||||||
public BlockOre() {
|
public BlockOre() {
|
||||||
super(Material.ROCK);
|
super(Material.ROCK);
|
||||||
|
@ -114,67 +133,41 @@ public class BlockOre extends Block implements IOreNameProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||||
public ArrayList<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
|
||||||
String variant = state.getValue(VARIANTS);
|
String variant = state.getValue(VARIANTS);
|
||||||
int meta = getMetaFromState(state);
|
int meta = getMetaFromState(state);
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
// Ruby
|
|
||||||
|
// Secondary drop, like peridot from sapphire ore added via event handler.
|
||||||
if (variant.equalsIgnoreCase("Ruby")) {
|
if (variant.equalsIgnoreCase("Ruby")) {
|
||||||
OreDrop ruby = new OreDrop(ItemGems.getGemByName("ruby"),
|
OreDrop ruby = new OreDrop(ItemGems.getGemByName("ruby", rubyMinQuatity), rubyMaxQuantity);
|
||||||
secondaryDropChance);
|
drops.add(ruby.getDrops(fortune, random));
|
||||||
OreDrop redGarnet = new OreDrop(ItemGems.getGemByName("red_garnet"), 0.02);
|
}
|
||||||
OreDropSet set = new OreDropSet(ruby, redGarnet);
|
else if (variant.equalsIgnoreCase("Sapphire")) {
|
||||||
return set.drop(fortune, random);
|
OreDrop sapphire = new OreDrop(ItemGems.getGemByName("sapphire", sapphireMinQuantity), sapphireMaxQuantity);
|
||||||
|
drops.add(sapphire.getDrops(fortune, random));
|
||||||
|
}
|
||||||
|
else if (variant.equalsIgnoreCase("Pyrite")) {
|
||||||
|
OreDrop pyriteDust = new OreDrop(ItemDusts.getDustByName("pyrite", pyriteMinQuatity), pyriteMaxQuantity);
|
||||||
|
drops.add(pyriteDust.getDrops(fortune, random));
|
||||||
|
}
|
||||||
|
else if (variant.equalsIgnoreCase("Sodalite")) {
|
||||||
|
OreDrop sodalite = new OreDrop(ItemDusts.getDustByName("sodalite", sodaliteMinQuatity), sodaliteMaxQuantity);
|
||||||
|
drops.add(sodalite.getDrops(fortune, random));
|
||||||
|
}
|
||||||
|
else if (variant.equalsIgnoreCase("Cinnabar")) {
|
||||||
|
OreDrop cinnabar = new OreDrop(ItemDusts.getDustByName("cinnabar", cinnabarMinQuatity), cinnabarMaxQuantity);
|
||||||
|
drops.add(cinnabar.getDrops(fortune, random));
|
||||||
|
}
|
||||||
|
else if (variant.equalsIgnoreCase("Sphalerite")) {
|
||||||
|
OreDrop sphalerite = new OreDrop(ItemDusts.getDustByName("sphalerite", sphaleriteMinQuatity), sphaleriteMaxQuantity);
|
||||||
|
drops.add(sphalerite.getDrops(fortune, random));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
drops.add(new ItemStack(Item.getItemFromBlock(this), 1, meta));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sapphire
|
return;
|
||||||
if (variant.equalsIgnoreCase("Sapphire")) {
|
|
||||||
OreDrop sapphire = new OreDrop(ItemGems.getGemByName("sapphire"),
|
|
||||||
secondaryDropChance);
|
|
||||||
OreDrop peridot = new OreDrop(ItemGems.getGemByName("peridot"), 0.03);
|
|
||||||
OreDropSet set = new OreDropSet(sapphire, peridot);
|
|
||||||
return set.drop(fortune, random);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pyrite
|
|
||||||
if (variant.equalsIgnoreCase("Pyrite")) {
|
|
||||||
OreDrop pyriteDust = new OreDrop(ItemDusts.getDustByName("pyrite"),
|
|
||||||
secondaryDropChance);
|
|
||||||
OreDropSet set = new OreDropSet(pyriteDust);
|
|
||||||
return set.drop(fortune, random);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sodalite
|
|
||||||
if (variant.equalsIgnoreCase("Sodalite")) {
|
|
||||||
OreDrop sodalite = new OreDrop(ItemDusts.getDustByName("sodalite", 6),
|
|
||||||
secondaryDropChance);
|
|
||||||
OreDrop aluminum = new OreDrop(ItemDusts.getDustByName("aluminum"), 0.50);
|
|
||||||
OreDropSet set = new OreDropSet(sodalite, aluminum);
|
|
||||||
return set.drop(fortune, random);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cinnabar
|
|
||||||
if (variant.equalsIgnoreCase("Cinnabar")) {
|
|
||||||
OreDrop cinnabar = new OreDrop(ItemDusts.getDustByName("cinnabar"),
|
|
||||||
secondaryDropChance);
|
|
||||||
OreDrop redstone = new OreDrop(new ItemStack(Items.REDSTONE), 0.25);
|
|
||||||
OreDropSet set = new OreDropSet(cinnabar, redstone);
|
|
||||||
return set.drop(fortune, random);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sphalerite 1, 1/8 yellow garnet
|
|
||||||
if (variant.equalsIgnoreCase("Sphalerite")) {
|
|
||||||
OreDrop sphalerite = new OreDrop(ItemDusts.getDustByName("sphalerite"),
|
|
||||||
secondaryDropChance);
|
|
||||||
OreDrop yellowGarnet = new OreDrop(ItemGems.getGemByName("yellowGarnet"), 0.125);
|
|
||||||
OreDropSet set = new OreDropSet(sphalerite, yellowGarnet);
|
|
||||||
return set.drop(fortune, random);
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList<ItemStack> block = new ArrayList<>();
|
|
||||||
block.add(new ItemStack(Item.getItemFromBlock(this), 1, meta));
|
|
||||||
return block;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -191,28 +184,10 @@ public class BlockOre extends Block implements IOreNameProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos,
|
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
|
||||||
EntityPlayer player) {
|
|
||||||
return new ItemStack(this, 1, getMetaFromState(state));
|
return new ItemStack(this, 1, getMetaFromState(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public int damageDropped(IBlockState state)
|
|
||||||
// {
|
|
||||||
// int meta = getMetaFromState(state);
|
|
||||||
// if (meta == 2)
|
|
||||||
// {
|
|
||||||
// return 0;
|
|
||||||
// } else if (meta == 3)
|
|
||||||
// {
|
|
||||||
// return 1;
|
|
||||||
// } else if (meta == 5)
|
|
||||||
// {
|
|
||||||
// return 60;
|
|
||||||
// }
|
|
||||||
// return meta;
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int damageDropped(IBlockState state) {
|
public int damageDropped(IBlockState state) {
|
||||||
return getMetaFromState(state);
|
return getMetaFromState(state);
|
||||||
|
|
|
@ -24,7 +24,12 @@
|
||||||
|
|
||||||
package techreborn.events;
|
package techreborn.events;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.init.Items;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.EnumHand;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
@ -33,7 +38,9 @@ import net.minecraftforge.event.world.BlockEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import reborncore.common.registration.RebornRegistry;
|
import reborncore.common.registration.RebornRegistry;
|
||||||
import reborncore.common.registration.impl.ConfigRegistry;
|
import reborncore.common.registration.impl.ConfigRegistry;
|
||||||
|
import reborncore.common.util.OreDrop;
|
||||||
import techreborn.init.ModItems;
|
import techreborn.init.ModItems;
|
||||||
|
import techreborn.items.ItemDusts;
|
||||||
import techreborn.items.ItemGems;
|
import techreborn.items.ItemGems;
|
||||||
import techreborn.lib.ModInfo;
|
import techreborn.lib.ModInfo;
|
||||||
import techreborn.utils.OreDictUtils;
|
import techreborn.utils.OreDictUtils;
|
||||||
|
@ -41,13 +48,45 @@ import techreborn.utils.OreDictUtils;
|
||||||
@RebornRegistry(modID = ModInfo.MOD_ID)
|
@RebornRegistry(modID = ModInfo.MOD_ID)
|
||||||
public class BlockBreakHandler {
|
public class BlockBreakHandler {
|
||||||
|
|
||||||
@ConfigRegistry(config = "misc", category = "general", key = "RubyRedGarnetDrops", comment = "Give red garnet drops to any harvested oreRuby")
|
@ConfigRegistry(config = "compat", category = "general", key = "secondaryGemDrops", comment = "Drop red and yellow garnets and peridot from any harvested oreRuby, oreSapphire, oreSphalerite. False will also disable drop from TechReborn ores.")
|
||||||
public static boolean rubyGarnetDrops = true;
|
public static boolean secondaryGemDrops = true;
|
||||||
|
@ConfigRegistry(config = "misc", category = "blocks", key = "redGarnetDropChance", comment = "Chance to get Red Garnet from Ruby Ore")
|
||||||
|
public static double redGarnetDropChance = 0.125;
|
||||||
|
@ConfigRegistry(config = "misc", category = "blocks", key = "peridotDropChance", comment = "Chance to get Peridot from Sapphire Ore")
|
||||||
|
public static double peridotDropChance = 0.125;
|
||||||
|
@ConfigRegistry(config = "misc", category = "blocks", key = "aluminiumDropChance", comment = "Chance to get Aluminium dust from Sodalite Ore")
|
||||||
|
public static double aluminiumDropChance = 0.50;
|
||||||
|
@ConfigRegistry(config = "misc", category = "blocks", key = "redstoneDropChance", comment = "Chance to get Redstone from Cinnabar Ore")
|
||||||
|
public static double redstoneDropChance = 0.25;
|
||||||
|
@ConfigRegistry(config = "misc", category = "blocks", key = "yellowGarnetDropChance", comment = "Chance to get Yellow Garnet gem from Sphalerite Ore")
|
||||||
|
public static double yellowGarnetDropChance = 0.125;
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onBlockHarvest(BlockEvent.HarvestDropsEvent event) {
|
public void onBlockHarvest(BlockEvent.HarvestDropsEvent event) {
|
||||||
if (!event.isSilkTouching() && rubyGarnetDrops && OreDictUtils.isOre(event.getState(), "oreRuby")) {
|
if (secondaryGemDrops && !event.isSilkTouching()) {
|
||||||
event.getDrops().add(ItemGems.getGemByName("red_garnet").copy());
|
IBlockState state = event.getState();
|
||||||
|
List<ItemStack> drops = event.getDrops();
|
||||||
|
Random random = new Random();
|
||||||
|
if (OreDictUtils.isOre(state, "oreRuby")) {
|
||||||
|
OreDrop redGarnet = new OreDrop(ItemGems.getGemByName("red_garnet"), redGarnetDropChance, 1);
|
||||||
|
drops.add(redGarnet.getDrops(event.getFortuneLevel(), random));
|
||||||
|
}
|
||||||
|
else if (OreDictUtils.isOre(state, "oreSapphire")) {
|
||||||
|
OreDrop peridot = new OreDrop(ItemGems.getGemByName("peridot"), peridotDropChance, 1);
|
||||||
|
drops.add(peridot.getDrops(event.getFortuneLevel(), random));
|
||||||
|
}
|
||||||
|
else if (OreDictUtils.isOre(state, "oreSodalite")) {
|
||||||
|
OreDrop aluminium = new OreDrop(ItemDusts.getDustByName("aluminium"), aluminiumDropChance, 1);
|
||||||
|
drops.add(aluminium.getDrops(event.getFortuneLevel(), random));
|
||||||
|
}
|
||||||
|
else if (OreDictUtils.isOre(state, "oreCinnabar")) {
|
||||||
|
OreDrop redstone = new OreDrop(new ItemStack(Items.REDSTONE), redstoneDropChance, 1);
|
||||||
|
drops.add(redstone.getDrops(event.getFortuneLevel(), random));
|
||||||
|
}
|
||||||
|
else if (OreDictUtils.isOre(state, "oreSphalerite")) {
|
||||||
|
OreDrop yellowGarnet = new OreDrop(ItemGems.getGemByName("yellowGarnet"), yellowGarnetDropChance, 1);
|
||||||
|
drops.add(yellowGarnet.getDrops(event.getFortuneLevel(), random));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ public class OreDictUtils {
|
||||||
public static boolean isOre(
|
public static boolean isOre(
|
||||||
@Nonnull
|
@Nonnull
|
||||||
ItemStack stack, String oreName) {
|
ItemStack stack, String oreName) {
|
||||||
if (!stack.isEmpty() && !stack.isEmpty() && oreName != null) {
|
if (!stack.isEmpty() && oreName != null) {
|
||||||
int id = OreDictionary.getOreID(oreName);
|
int id = OreDictionary.getOreID(oreName);
|
||||||
int[] ids = OreDictionary.getOreIDs(stack);
|
int[] ids = OreDictionary.getOreIDs(stack);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue