mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 13:46:46 +01:00
Pass location & type as params, rather than calling inside the function.
This commit is contained in:
parent
57ff84cd4d
commit
159ec3f04d
@ -7,6 +7,7 @@ import java.util.List;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -57,15 +58,17 @@ public class BlastMining {
|
|||||||
|
|
||||||
while (oresIterator.hasNext()) {
|
while (oresIterator.hasNext()) {
|
||||||
Block temp = oresIterator.next();
|
Block temp = oresIterator.next();
|
||||||
|
Location tempLocation = temp.getLocation();
|
||||||
|
Material tempType = temp.getType();
|
||||||
|
|
||||||
if (random.nextFloat() < (yield + oreBonus)) {
|
if (random.nextFloat() < (yield + oreBonus)) {
|
||||||
blocksDropped.add(temp);
|
blocksDropped.add(temp);
|
||||||
Mining.miningDrops(temp);
|
Mining.miningDrops(temp, tempLocation, tempType);
|
||||||
|
|
||||||
if (!mcMMO.placeStore.isTrue(temp)) {
|
if (!mcMMO.placeStore.isTrue(temp)) {
|
||||||
for (int i = 1 ; i < extraDrops ; i++) {
|
for (int i = 1 ; i < extraDrops ; i++) {
|
||||||
blocksDropped.add(temp);
|
blocksDropped.add(temp);
|
||||||
Mining.miningDrops(temp);
|
Mining.miningDrops(temp, tempLocation, tempType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,9 +79,11 @@ public class BlastMining {
|
|||||||
|
|
||||||
while (debrisIterator.hasNext()) {
|
while (debrisIterator.hasNext()) {
|
||||||
Block temp = debrisIterator.next();
|
Block temp = debrisIterator.next();
|
||||||
|
Location tempLocation = temp.getLocation();
|
||||||
|
Material tempType = temp.getType();
|
||||||
|
|
||||||
if (random.nextFloat() < (yield - debrisReduction))
|
if (random.nextFloat() < (yield - debrisReduction))
|
||||||
Mining.miningDrops(temp);
|
Mining.miningDrops(temp, tempLocation, tempType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,10 +201,10 @@ public class Mining {
|
|||||||
* Handle double drops when using Silk Touch.
|
* Handle double drops when using Silk Touch.
|
||||||
*
|
*
|
||||||
* @param block The block to process drops for
|
* @param block The block to process drops for
|
||||||
|
* @param location The location of the block
|
||||||
|
* @param type The material type of the block
|
||||||
*/
|
*/
|
||||||
protected static void silkTouchDrops(Block block) {
|
protected static void silkTouchDrops(Block block, Location location, Material type) {
|
||||||
Location location = block.getLocation();
|
|
||||||
Material type = block.getType();
|
|
||||||
ItemStack item = new ItemStack(type);
|
ItemStack item = new ItemStack(type);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -215,7 +215,7 @@ public class Mining {
|
|||||||
case NETHERRACK:
|
case NETHERRACK:
|
||||||
case OBSIDIAN:
|
case OBSIDIAN:
|
||||||
case SANDSTONE:
|
case SANDSTONE:
|
||||||
miningDrops(block);
|
miningDrops(block, location, type);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COAL_ORE:
|
case COAL_ORE:
|
||||||
@ -276,10 +276,10 @@ public class Mining {
|
|||||||
* Drop items from Mining & Blast Mining skills.
|
* Drop items from Mining & Blast Mining skills.
|
||||||
*
|
*
|
||||||
* @param block The block to process drops for
|
* @param block The block to process drops for
|
||||||
|
* @param location The location of the block
|
||||||
|
* @param type The material type of the block
|
||||||
*/
|
*/
|
||||||
protected static void miningDrops(Block block) {
|
protected static void miningDrops(Block block, Location location, Material type) {
|
||||||
Location location = block.getLocation();
|
|
||||||
Material type = block.getType();
|
|
||||||
ItemStack item = new ItemStack(type);
|
ItemStack item = new ItemStack(type);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -1,19 +1,27 @@
|
|||||||
package com.gmail.nossr50.skills.mining;
|
package com.gmail.nossr50.skills.mining;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
|
||||||
public class MiningDropsBlockHandler {
|
public class MiningBlockEventHandler {
|
||||||
private MiningManager manager;
|
private MiningManager manager;
|
||||||
|
|
||||||
private Block block;
|
private Block block;
|
||||||
|
private Location blockLocation;
|
||||||
|
private Material blockType;
|
||||||
|
|
||||||
protected int skillModifier;
|
protected int skillModifier;
|
||||||
|
|
||||||
protected MiningDropsBlockHandler(MiningManager manager, Block block) {
|
protected MiningBlockEventHandler(MiningManager manager, Block block) {
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
|
|
||||||
this.block = block;
|
this.block = block;
|
||||||
|
this.blockLocation = block.getLocation();
|
||||||
|
this.blockType = block.getType();
|
||||||
|
|
||||||
calculateSkillModifier();
|
calculateSkillModifier();
|
||||||
}
|
}
|
||||||
@ -30,10 +38,10 @@ public class MiningDropsBlockHandler {
|
|||||||
*/
|
*/
|
||||||
protected void processDrops() {
|
protected void processDrops() {
|
||||||
if (manager.getPlayer().getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
|
if (manager.getPlayer().getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
|
||||||
Mining.silkTouchDrops(block);
|
Mining.silkTouchDrops(block, blockLocation, blockType);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Mining.miningDrops(block);
|
Mining.miningDrops(block, blockLocation, blockType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -38,17 +38,17 @@ public class MiningManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MiningDropsBlockHandler blockHandler = new MiningDropsBlockHandler(this, block);
|
MiningBlockEventHandler eventHandler = new MiningBlockEventHandler(this, block);
|
||||||
|
|
||||||
int randomChance = 100;
|
int randomChance = 100;
|
||||||
if (Permissions.luckyMining(player)) {
|
if (Permissions.luckyMining(player)) {
|
||||||
randomChance = (int) (randomChance * 0.75);
|
randomChance = (int) (randomChance * 0.75);
|
||||||
}
|
}
|
||||||
|
|
||||||
float chance = (float) (((double) Mining.DOUBLE_DROPS_MAX_CHANCE / Mining.DOUBLE_DROPS_MAX_BONUS_LEVEL) * blockHandler.skillModifier);
|
float chance = (float) (((double) Mining.DOUBLE_DROPS_MAX_CHANCE / Mining.DOUBLE_DROPS_MAX_BONUS_LEVEL) * eventHandler.skillModifier);
|
||||||
|
|
||||||
if (chance > Mining.getRandom().nextInt(randomChance)) {
|
if (chance > Mining.getRandom().nextInt(randomChance)) {
|
||||||
blockHandler.processDrops();
|
eventHandler.processDrops();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user