mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 15:16:45 +01:00
Improve our drop handling.
This commit is contained in:
parent
6eaec5ffab
commit
0c83bf2a80
@ -7,7 +7,6 @@ import java.util.Set;
|
|||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.material.MaterialData;
|
import org.bukkit.material.MaterialData;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.ConfigLoader;
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
@ -92,27 +91,6 @@ public class CustomBlockConfig extends ConfigLoader {
|
|||||||
|
|
||||||
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain");
|
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain");
|
||||||
|
|
||||||
boolean shouldDropItem = config.getBoolean(skillType + "." + blockName + ".Drop_Item");
|
|
||||||
Material dropMaterial = Material.matchMaterial(config.getString(skillType + "." + blockName + ".Drop_Item_Name"));
|
|
||||||
|
|
||||||
if (shouldDropItem && dropMaterial == null) {
|
|
||||||
plugin.getLogger().warning("Incomplete item drop information. This block will drop itself. - " + blockInfo[0]);
|
|
||||||
shouldDropItem = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack itemDrop;
|
|
||||||
|
|
||||||
if (shouldDropItem) {
|
|
||||||
byte dropData = (byte) config.getInt(skillType + "." + blockName + ".Drop_Item_Data_Value");
|
|
||||||
itemDrop = (new MaterialData(dropMaterial, dropData)).toItemStack(1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
itemDrop = blockMaterialData.toItemStack(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int minimumDropAmount = config.getInt(skillType + "." + blockName + ".Min_Drop_Item_Amount", 1);
|
|
||||||
int maxiumDropAmount = config.getInt(skillType + "." + blockName + ".Max_Drop_Item_Amount", 1);
|
|
||||||
|
|
||||||
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
|
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
|
||||||
customOres.add(blockMaterialData);
|
customOres.add(blockMaterialData);
|
||||||
}
|
}
|
||||||
@ -126,7 +104,7 @@ public class CustomBlockConfig extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
customBlockMap.put(blockMaterialData, new CustomBlock(minimumDropAmount, maxiumDropAmount, itemDrop, xp));
|
customBlockMap.put(blockMaterialData, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,33 +1,19 @@
|
|||||||
package com.gmail.nossr50.datatypes.mods;
|
package com.gmail.nossr50.datatypes.mods;
|
||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
public class CustomBlock {
|
public class CustomBlock {
|
||||||
private int xpGain;
|
private int xpGain;
|
||||||
private ItemStack itemDrop;
|
private boolean canDoubleDrop;
|
||||||
private int minimumDropAmount;
|
|
||||||
private int maximumDropAmount;
|
|
||||||
|
|
||||||
public CustomBlock(int minimumDropAmount, int maximumDropAmount, ItemStack itemDrop, int xpGain) {
|
public CustomBlock(int xpGain, boolean canDoubleDrop) {
|
||||||
this.xpGain = xpGain;
|
this.xpGain = xpGain;
|
||||||
this.itemDrop = itemDrop;
|
this.canDoubleDrop = canDoubleDrop;
|
||||||
this.minimumDropAmount = minimumDropAmount;
|
|
||||||
this.maximumDropAmount = maximumDropAmount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getXpGain() {
|
public int getXpGain() {
|
||||||
return xpGain;
|
return xpGain;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItemDrop() {
|
public boolean isDoubleDropEnabled() {
|
||||||
return itemDrop;
|
return canDoubleDrop;
|
||||||
}
|
|
||||||
|
|
||||||
public int getMinimumDropAmount() {
|
|
||||||
return minimumDropAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMaximumDropAmount() {
|
|
||||||
return maximumDropAmount;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||||
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||||
|
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
@ -135,10 +136,10 @@ public class HerbalismManager extends SkillManager {
|
|||||||
boolean greenTerra = mcMMOPlayer.getAbilityMode(skill.getAbility());
|
boolean greenTerra = mcMMOPlayer.getAbilityMode(skill.getAbility());
|
||||||
|
|
||||||
if (ModUtils.isCustomHerbalismBlock(blockState)) {
|
if (ModUtils.isCustomHerbalismBlock(blockState)) {
|
||||||
xp = ModUtils.getCustomBlock(blockState).getXpGain();
|
CustomBlock customBlock = ModUtils.getCustomBlock(blockState);
|
||||||
|
xp = customBlock.getXpGain();
|
||||||
|
|
||||||
// XXX: Add double drop check to blocks.yml
|
if (Permissions.doubleDrops(player, skill) && customBlock.isDoubleDropEnabled()) {
|
||||||
if (Permissions.doubleDrops(player, skill)) {
|
|
||||||
drops = blockState.getBlock().getDrops();
|
drops = blockState.getBlock().getDrops();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.skills.mining;
|
package com.gmail.nossr50.skills.mining;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -8,7 +7,6 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.ModUtils;
|
import com.gmail.nossr50.util.ModUtils;
|
||||||
@ -88,10 +86,7 @@ public class Mining {
|
|||||||
* @param blockState The {@link BlockState} to check ability activation for
|
* @param blockState The {@link BlockState} to check ability activation for
|
||||||
*/
|
*/
|
||||||
protected static void handleMiningDrops(BlockState blockState) {
|
protected static void handleMiningDrops(BlockState blockState) {
|
||||||
Material blockType = blockState.getType();
|
switch (blockState.getType()) {
|
||||||
Location location = blockState.getLocation();
|
|
||||||
|
|
||||||
switch (blockType) {
|
|
||||||
case COAL_ORE:
|
case COAL_ORE:
|
||||||
case DIAMOND_ORE:
|
case DIAMOND_ORE:
|
||||||
case EMERALD_ORE:
|
case EMERALD_ORE:
|
||||||
@ -104,36 +99,21 @@ public class Mining {
|
|||||||
case MOSSY_COBBLESTONE:
|
case MOSSY_COBBLESTONE:
|
||||||
case NETHERRACK:
|
case NETHERRACK:
|
||||||
case OBSIDIAN:
|
case OBSIDIAN:
|
||||||
|
case REDSTONE_ORE:
|
||||||
case SANDSTONE:
|
case SANDSTONE:
|
||||||
case QUARTZ_ORE:
|
case QUARTZ_ORE:
|
||||||
for (ItemStack drop : blockState.getBlock().getDrops()) {
|
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
||||||
Misc.dropItem(location, drop);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case GLOWING_REDSTONE_ORE:
|
case GLOWING_REDSTONE_ORE:
|
||||||
case REDSTONE_ORE:
|
|
||||||
if (Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, Material.REDSTONE_ORE)) {
|
if (Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, Material.REDSTONE_ORE)) {
|
||||||
for (ItemStack drop : blockState.getBlock().getDrops()) {
|
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
||||||
Misc.dropItem(location, drop);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (ModUtils.isCustomMiningBlock(blockState)) {
|
if (ModUtils.isCustomMiningBlock(blockState)) {
|
||||||
CustomBlock customBlock = ModUtils.getCustomBlock(blockState);
|
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
||||||
int minimumDropAmount = customBlock.getMinimumDropAmount();
|
|
||||||
int maximumDropAmount = customBlock.getMaximumDropAmount();
|
|
||||||
|
|
||||||
ItemStack dropItem = customBlock.getItemDrop();
|
|
||||||
|
|
||||||
if (minimumDropAmount != maximumDropAmount) {
|
|
||||||
Misc.dropItems(location, dropItem, minimumDropAmount);
|
|
||||||
Misc.randomDropItems(location, dropItem, maximumDropAmount - minimumDropAmount);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Misc.dropItems(location, dropItem, minimumDropAmount);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import com.gmail.nossr50.skills.SkillManager;
|
|||||||
import com.gmail.nossr50.skills.mining.BlastMining.Tier;
|
import com.gmail.nossr50.skills.mining.BlastMining.Tier;
|
||||||
import com.gmail.nossr50.util.BlockUtils;
|
import com.gmail.nossr50.util.BlockUtils;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
import com.gmail.nossr50.util.ModUtils;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
@ -69,7 +70,7 @@ public class MiningManager extends SkillManager {
|
|||||||
SkillUtils.handleDurabilityChange(getPlayer().getItemInHand(), Config.getInstance().getAbilityToolDamage());
|
SkillUtils.handleDurabilityChange(getPlayer().getItemInHand(), Config.getInstance().getAbilityToolDamage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (material != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(skill, material)) {
|
if ((ModUtils.isCustomMiningBlock(blockState) && !ModUtils.getCustomBlock(blockState).isDoubleDropEnabled()) || material != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(skill, material)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.skills.smelting;
|
package com.gmail.nossr50.skills.smelting;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -28,6 +27,10 @@ public class SmeltingManager extends SkillManager {
|
|||||||
return getSkillLevel() >= Smelting.fluxMiningUnlockLevel && BlockUtils.affectedByFluxMining(blockState) && Permissions.fluxMining(getPlayer()) && !mcMMO.getPlaceStore().isTrue(blockState);
|
return getSkillLevel() >= Smelting.fluxMiningUnlockLevel && BlockUtils.affectedByFluxMining(blockState) && Permissions.fluxMining(getPlayer()) && !mcMMO.getPlaceStore().isTrue(blockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDoubleDropSuccessful() {
|
||||||
|
return Permissions.doubleDrops(getPlayer(), skill) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process the Flux Mining ability.
|
* Process the Flux Mining ability.
|
||||||
*
|
*
|
||||||
@ -57,13 +60,7 @@ public class SmeltingManager extends SkillManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Location location = blockState.getLocation();
|
Misc.dropItems(blockState.getLocation(), item, isDoubleDropSuccessful() ? 2 : 1);
|
||||||
|
|
||||||
Misc.dropItem(location, item);
|
|
||||||
|
|
||||||
if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) {
|
|
||||||
Misc.dropItem(location, item);
|
|
||||||
}
|
|
||||||
|
|
||||||
blockState.setType(Material.AIR);
|
blockState.setType(Material.AIR);
|
||||||
player.sendMessage(LocaleLoader.getString("Smelting.FluxMining.Success"));
|
player.sendMessage(LocaleLoader.getString("Smelting.FluxMining.Success"));
|
||||||
|
@ -3,7 +3,6 @@ package com.gmail.nossr50.skills.woodcutting;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
@ -14,7 +13,6 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
|
||||||
import com.gmail.nossr50.util.BlockUtils;
|
import com.gmail.nossr50.util.BlockUtils;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.ModUtils;
|
import com.gmail.nossr50.util.ModUtils;
|
||||||
@ -87,46 +85,32 @@ public final class Woodcutting {
|
|||||||
* @param blockState Block being broken
|
* @param blockState Block being broken
|
||||||
*/
|
*/
|
||||||
protected static void checkForDoubleDrop(BlockState blockState) {
|
protected static void checkForDoubleDrop(BlockState blockState) {
|
||||||
if (ModUtils.isCustomLogBlock(blockState)) {
|
if (ModUtils.isCustomLogBlock(blockState) && ModUtils.getCustomBlock(blockState).isDoubleDropEnabled()) {
|
||||||
CustomBlock customBlock = ModUtils.getCustomBlock(blockState);
|
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
||||||
int minimumDropAmount = customBlock.getMinimumDropAmount();
|
|
||||||
int maximumDropAmount = customBlock.getMaximumDropAmount();
|
|
||||||
Location location = blockState.getLocation();
|
|
||||||
ItemStack item = customBlock.getItemDrop();
|
|
||||||
|
|
||||||
Misc.dropItems(location, item, minimumDropAmount);
|
|
||||||
|
|
||||||
if (minimumDropAmount != maximumDropAmount) {
|
|
||||||
Misc.randomDropItems(location, item, maximumDropAmount - minimumDropAmount);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Location location = blockState.getLocation();
|
switch (((Tree) blockState.getData()).getSpecies()) {
|
||||||
Tree tree = (Tree) blockState.getData();
|
|
||||||
ItemStack item = tree.toItemStack(1);
|
|
||||||
|
|
||||||
switch (tree.getSpecies()) {
|
|
||||||
case GENERIC:
|
case GENERIC:
|
||||||
if (Config.getInstance().getOakDoubleDropsEnabled()) {
|
if (Config.getInstance().getOakDoubleDropsEnabled()) {
|
||||||
Misc.dropItem(location, item);
|
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case REDWOOD:
|
case REDWOOD:
|
||||||
if (Config.getInstance().getSpruceDoubleDropsEnabled()) {
|
if (Config.getInstance().getSpruceDoubleDropsEnabled()) {
|
||||||
Misc.dropItem(location, item);
|
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case BIRCH:
|
case BIRCH:
|
||||||
if (Config.getInstance().getBirchDoubleDropsEnabled()) {
|
if (Config.getInstance().getBirchDoubleDropsEnabled()) {
|
||||||
Misc.dropItem(location, item);
|
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case JUNGLE:
|
case JUNGLE:
|
||||||
if (Config.getInstance().getJungleDoubleDropsEnabled()) {
|
if (Config.getInstance().getJungleDoubleDropsEnabled()) {
|
||||||
Misc.dropItem(location, item);
|
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@ package com.gmail.nossr50.skills.woodcutting;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -127,7 +127,9 @@ public class WoodcuttingManager extends SkillManager {
|
|||||||
int xp = 0;
|
int xp = 0;
|
||||||
|
|
||||||
for (BlockState blockState : treeFellerBlocks) {
|
for (BlockState blockState : treeFellerBlocks) {
|
||||||
if (!SkillUtils.blockBreakSimulate(blockState.getBlock(), player, true)) {
|
Block block = blockState.getBlock();
|
||||||
|
|
||||||
|
if (!SkillUtils.blockBreakSimulate(block, player, true)) {
|
||||||
break; // TODO: Shouldn't we use continue instead?
|
break; // TODO: Shouldn't we use continue instead?
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,10 +137,7 @@ public class WoodcuttingManager extends SkillManager {
|
|||||||
|
|
||||||
if (material == Material.HUGE_MUSHROOM_1 || material == Material.HUGE_MUSHROOM_2) {
|
if (material == Material.HUGE_MUSHROOM_1 || material == Material.HUGE_MUSHROOM_2) {
|
||||||
xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER);
|
xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER);
|
||||||
|
Misc.dropItems(blockState.getLocation(), block.getDrops());
|
||||||
for (ItemStack drop : blockState.getBlock().getDrops()) {
|
|
||||||
Misc.dropItem(blockState.getLocation(), drop);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (ModUtils.isCustomLogBlock(blockState)) {
|
else if (ModUtils.isCustomLogBlock(blockState)) {
|
||||||
if (canGetDoubleDrops()) {
|
if (canGetDoubleDrops()) {
|
||||||
@ -147,19 +146,11 @@ public class WoodcuttingManager extends SkillManager {
|
|||||||
|
|
||||||
CustomBlock customBlock = ModUtils.getCustomBlock(blockState);
|
CustomBlock customBlock = ModUtils.getCustomBlock(blockState);
|
||||||
xp = customBlock.getXpGain();
|
xp = customBlock.getXpGain();
|
||||||
int minimumDropAmount = customBlock.getMinimumDropAmount();
|
|
||||||
int maximumDropAmount = customBlock.getMaximumDropAmount();
|
|
||||||
Location location = blockState.getLocation();
|
|
||||||
ItemStack item = customBlock.getItemDrop();;
|
|
||||||
|
|
||||||
Misc.dropItems(location, item, minimumDropAmount);
|
Misc.dropItems(blockState.getLocation(), block.getDrops());
|
||||||
|
|
||||||
if (minimumDropAmount < maximumDropAmount) {
|
|
||||||
Misc.randomDropItems(location, item, maximumDropAmount - minimumDropAmount);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (ModUtils.isCustomLeafBlock(blockState)) {
|
else if (ModUtils.isCustomLeafBlock(blockState)) {
|
||||||
Misc.randomDropItem(blockState.getLocation(), ModUtils.getCustomBlock(blockState).getItemDrop(), 10);
|
Misc.randomDropItems(blockState.getLocation(), block.getDrops(), 10.0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Tree tree = (Tree) blockState.getData();
|
Tree tree = (Tree) blockState.getData();
|
||||||
@ -171,11 +162,11 @@ public class WoodcuttingManager extends SkillManager {
|
|||||||
Woodcutting.checkForDoubleDrop(blockState);
|
Woodcutting.checkForDoubleDrop(blockState);
|
||||||
}
|
}
|
||||||
xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER);
|
xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER);
|
||||||
Misc.dropItem(blockState.getLocation(), tree.toItemStack(1));
|
Misc.dropItems(blockState.getLocation(), block.getDrops());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LEAVES:
|
case LEAVES:
|
||||||
Misc.randomDropItem(blockState.getLocation(), new ItemStack(Material.SAPLING, 1, tree.getSpecies().getData()), 10);
|
Misc.randomDropItems(blockState.getLocation(), block.getDrops(), 10.0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -138,7 +138,7 @@ public final class Misc {
|
|||||||
* @param is The item to drop
|
* @param is The item to drop
|
||||||
* @param chance The percentage chance for the item to drop
|
* @param chance The percentage chance for the item to drop
|
||||||
*/
|
*/
|
||||||
public static void randomDropItem(Location location, ItemStack is, int chance) {
|
public static void randomDropItem(Location location, ItemStack is, double chance) {
|
||||||
if (random.nextInt(100) < chance) {
|
if (random.nextInt(100) < chance) {
|
||||||
dropItem(location, is);
|
dropItem(location, is);
|
||||||
}
|
}
|
||||||
@ -160,6 +160,12 @@ public final class Misc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void randomDropItems(Location location, Collection<ItemStack> drops, double chance) {
|
||||||
|
for (ItemStack item : drops) {
|
||||||
|
randomDropItem(location, item, chance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Drop an item at a given location.
|
* Drop an item at a given location.
|
||||||
*
|
*
|
||||||
|
@ -4,18 +4,10 @@
|
|||||||
Excavation:
|
Excavation:
|
||||||
Block_1|0:
|
Block_1|0:
|
||||||
XP_Gain: 99
|
XP_Gain: 99
|
||||||
Drop_Item: false
|
Double_Drops_Enabled: true
|
||||||
Drop_Item_Name: BLOCK_DROP
|
|
||||||
Drop_Item_Data_Value: 0
|
|
||||||
Min_Drop_Item_Amount: 1
|
|
||||||
Max_Drop_Item_Amount: 1
|
|
||||||
Block_2|0:
|
Block_2|0:
|
||||||
XP_Gain: 99
|
XP_Gain: 99
|
||||||
Drop_Item: false
|
Double_Drops_Enabled: true
|
||||||
Drop_Item_Name: BLOCK_DROP
|
|
||||||
Drop_Item_Data_Value: 0
|
|
||||||
Min_Drop_Item_Amount: 1
|
|
||||||
Max_Drop_Item_Amount: 1
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Settings for Custom Herbalism Blocks
|
# Settings for Custom Herbalism Blocks
|
||||||
@ -23,18 +15,10 @@ Excavation:
|
|||||||
Herbalism:
|
Herbalism:
|
||||||
Block_1|0:
|
Block_1|0:
|
||||||
XP_Gain: 99
|
XP_Gain: 99
|
||||||
Drop_Item: false
|
Double_Drops_Enabled: true
|
||||||
Drop_Item_Name: BLOCK_DROP
|
|
||||||
Drop_Item_Data_Value: 0
|
|
||||||
Min_Drop_Item_Amount: 1
|
|
||||||
Max_Drop_Item_Amount: 1
|
|
||||||
Block_2|0:
|
Block_2|0:
|
||||||
XP_Gain: 99
|
XP_Gain: 99
|
||||||
Drop_Item: false
|
Double_Drops_Enabled: true
|
||||||
Drop_Item_Name: BLOCK_DROP
|
|
||||||
Drop_Item_Data_Value: 0
|
|
||||||
Min_Drop_Item_Amount: 1
|
|
||||||
Max_Drop_Item_Amount: 1
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Settings for Custom Mining Blocks
|
# Settings for Custom Mining Blocks
|
||||||
@ -42,20 +26,12 @@ Herbalism:
|
|||||||
Mining:
|
Mining:
|
||||||
Block_1|0:
|
Block_1|0:
|
||||||
XP_Gain: 99
|
XP_Gain: 99
|
||||||
|
Double_Drops_Enabled: true
|
||||||
Is_Ore: true
|
Is_Ore: true
|
||||||
Drop_Item: false
|
|
||||||
Drop_Item_Name: BLOCK_DROP
|
|
||||||
Drop_Item_Data_Value: 0
|
|
||||||
Min_Drop_Item_Amount: 1
|
|
||||||
Max_Drop_Item_Amount: 1
|
|
||||||
Block_2|0:
|
Block_2|0:
|
||||||
XP_Gain: 99
|
XP_Gain: 99
|
||||||
|
Double_Drops_Enabled: true
|
||||||
Is_Ore: true
|
Is_Ore: true
|
||||||
Drop_Item: false
|
|
||||||
Drop_Item_Name: BLOCK_DROP
|
|
||||||
Drop_Item_Data_Value: 0
|
|
||||||
Min_Drop_Item_Amount: 1
|
|
||||||
Max_Drop_Item_Amount: 1
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Settings for Custom Woodcutting Blocks
|
# Settings for Custom Woodcutting Blocks
|
||||||
@ -63,20 +39,12 @@ Mining:
|
|||||||
Woodcutting:
|
Woodcutting:
|
||||||
Block_1|0:
|
Block_1|0:
|
||||||
XP_Gain: 99
|
XP_Gain: 99
|
||||||
|
Double_Drops_Enabled: true
|
||||||
Is_Log: true
|
Is_Log: true
|
||||||
Drop_Item: false
|
|
||||||
Drop_Item_Name: BLOCK_DROP
|
|
||||||
Drop_Item_Data_Value: 0
|
|
||||||
Min_Drop_Item_Amount: 1
|
|
||||||
Max_Drop_Item_Amount: 1
|
|
||||||
Block_2|0:
|
Block_2|0:
|
||||||
XP_Gain: 99
|
XP_Gain: 99
|
||||||
|
Double_Drops_Enabled: true
|
||||||
Is_Log: true
|
Is_Log: true
|
||||||
Drop_Item: false
|
|
||||||
Drop_Item_Name: BLOCK_DROP
|
|
||||||
Drop_Item_Data_Value: 0
|
|
||||||
Min_Drop_Item_Amount: 1
|
|
||||||
Max_Drop_Item_Amount: 1
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Settings for Custom Ability Blocks
|
# Settings for Custom Ability Blocks
|
||||||
|
Loading…
Reference in New Issue
Block a user