mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 05:06:45 +01:00
Blast Mining Tweaks
This commit is contained in:
parent
0a59b79ef9
commit
9f0fe26778
@ -1,3 +1,7 @@
|
||||
Version 2.1.118
|
||||
Fixed another dupe bug
|
||||
Blast Mining no longer reduces debris from explosions due to some issues with the Bukkit API
|
||||
|
||||
Version 2.1.117
|
||||
Fixed a rare http error when polling Mojang for UUIDs
|
||||
Fixed a bug that allowed duping
|
||||
|
@ -7,6 +7,8 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BarStyle;
|
||||
@ -219,6 +221,42 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Materials */
|
||||
public int getXp(PrimarySkillType skill, BlockState blockState)
|
||||
{
|
||||
Material data = blockState.getType();
|
||||
|
||||
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
|
||||
String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(data);
|
||||
if (config.contains(explicitString))
|
||||
return config.getInt(explicitString);
|
||||
String friendlyString = baseString + StringUtils.getFriendlyConfigMaterialString(data);
|
||||
if (config.contains(friendlyString))
|
||||
return config.getInt(friendlyString);
|
||||
String wildcardString = baseString + StringUtils.getWildcardConfigMaterialString(data);
|
||||
if (config.contains(wildcardString))
|
||||
return config.getInt(wildcardString);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Materials */
|
||||
public int getXp(PrimarySkillType skill, Block block)
|
||||
{
|
||||
Material data = block.getType();
|
||||
|
||||
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
|
||||
String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(data);
|
||||
if (config.contains(explicitString))
|
||||
return config.getInt(explicitString);
|
||||
String friendlyString = baseString + StringUtils.getFriendlyConfigMaterialString(data);
|
||||
if (config.contains(friendlyString))
|
||||
return config.getInt(friendlyString);
|
||||
String wildcardString = baseString + StringUtils.getWildcardConfigMaterialString(data);
|
||||
if (config.contains(wildcardString))
|
||||
return config.getInt(wildcardString);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Materials */
|
||||
public int getXp(PrimarySkillType skill, BlockData data)
|
||||
{
|
||||
|
@ -839,8 +839,8 @@ public class EntityListener implements Listener {
|
||||
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
|
||||
|
||||
if (miningManager.canUseBlastMining()) {
|
||||
miningManager.blastMiningDropProcessing(event.getYield(), event.blockList());
|
||||
event.setYield(0);
|
||||
miningManager.blastMiningDropProcessing(event.getYield(), event);
|
||||
// event.setYield(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.skills.mining;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
@ -12,6 +13,8 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.skills.AbilityCooldownTask;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.*;
|
||||
import com.gmail.nossr50.util.blockmeta.HashChunkletManager;
|
||||
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
@ -19,9 +22,11 @@ import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Container;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -126,55 +131,47 @@ public class MiningManager extends SkillManager {
|
||||
* Handler for explosion drops and XP gain.
|
||||
*
|
||||
* @param yield The % of blocks to drop
|
||||
* @param blockList The list of blocks to drop
|
||||
* @param event The {@link EntityExplodeEvent}
|
||||
*/
|
||||
public void blastMiningDropProcessing(float yield, List<Block> blockList) {
|
||||
public void blastMiningDropProcessing(float yield, EntityExplodeEvent event) {
|
||||
//Strip out only stuff that gives mining XP
|
||||
|
||||
List<BlockState> ores = new ArrayList<BlockState>();
|
||||
List<BlockState> debris = new ArrayList<BlockState>();
|
||||
|
||||
List<Block> newYieldList = new ArrayList<>();
|
||||
for (Block targetBlock : event.blockList()) {
|
||||
//Containers usually have 0 XP unless someone edited their config in a very strange way
|
||||
if (ExperienceConfig.getInstance().getXp(PrimarySkillType.MINING, targetBlock) == 0 || targetBlock instanceof Container || mcMMO.getPlaceStore().isTrue(targetBlock)) {
|
||||
newYieldList.add(targetBlock);
|
||||
} else {
|
||||
ores.add(targetBlock.getState());
|
||||
}
|
||||
}
|
||||
|
||||
int xp = 0;
|
||||
|
||||
float oreBonus = (float) (getOreBonus() / 100);
|
||||
//TODO: Pretty sure something is fucked with debrisReduction stuff
|
||||
float debrisReduction = (float) (getDebrisReduction() / 100);
|
||||
// float debrisReduction = (float) (getDebrisReduction() / 100);
|
||||
int dropMultiplier = getDropMultiplier();
|
||||
|
||||
float debrisYield = yield - debrisReduction;
|
||||
|
||||
for (Block block : blockList) {
|
||||
BlockState blockState = block.getState();
|
||||
|
||||
if (BlockUtils.isOre(blockState)) {
|
||||
ores.add(blockState);
|
||||
}
|
||||
//Server bug that allows beacons to be duped when yield is set to 0
|
||||
else if(blockState.getType() != Material.BEACON && blockState.getType() != Material.SHULKER_BOX) {
|
||||
debris.add(blockState);
|
||||
}
|
||||
}
|
||||
// float debrisYield = yield - debrisReduction;
|
||||
|
||||
for (BlockState blockState : ores) {
|
||||
if (Misc.getRandom().nextFloat() < (yield + oreBonus)) {
|
||||
if (!mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||
xp += Mining.getBlockXp(blockState);
|
||||
}
|
||||
if (Misc.getRandom().nextFloat() < (newYieldList.size() + oreBonus)) {
|
||||
xp += Mining.getBlockXp(blockState);
|
||||
|
||||
Misc.dropItem(Misc.getBlockCenter(blockState), new ItemStack(blockState.getType())); // Initial block that would have been dropped
|
||||
|
||||
if (!mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||
for (int i = 1; i < dropMultiplier; i++) {
|
||||
Mining.handleSilkTouchDrops(blockState); // Bonus drops - should drop the block & not the items
|
||||
}
|
||||
for (int i = 1; i < dropMultiplier; i++) {
|
||||
Mining.handleSilkTouchDrops(blockState); // Bonus drops - should drop the block & not the items
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (debrisYield > 0) {
|
||||
for (BlockState blockState : debris) {
|
||||
if (Misc.getRandom().nextFloat() < debrisYield) {
|
||||
Misc.dropItems(Misc.getBlockCenter(blockState), blockState.getBlock().getDrops());
|
||||
}
|
||||
}
|
||||
}
|
||||
//Replace the event blocklist with the newYield list
|
||||
event.blockList().clear();
|
||||
event.blockList().addAll(newYieldList);
|
||||
|
||||
applyXpGain(xp, XPGainReason.PVE);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user