mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-27 03:04:44 +02:00
Fixed errors with block-based skill experience (#3506)
* Updated configs * [WIP] Replacing MaterialData with Blockdata * Fixed most block based experience gain * Fixed most block based experience gain & updated wooden_tools * Removed debug prints
This commit is contained in:

committed by
t00thpick1

parent
210b418e44
commit
ee324c77a9
@ -20,14 +20,14 @@ public class Excavation {
|
||||
* @return the list of treasures that could be found
|
||||
*/
|
||||
protected static List<ExcavationTreasure> getTreasures(BlockState blockState) {
|
||||
String friendly = StringUtils.getFriendlyConfigMaterialDataString(blockState.getData());
|
||||
String friendly = StringUtils.getFriendlyConfigBlockDataString(blockState.getBlockData());
|
||||
if (TreasureConfig.getInstance().excavationMap.containsKey(friendly))
|
||||
return TreasureConfig.getInstance().excavationMap.get(friendly);
|
||||
return new ArrayList<ExcavationTreasure>();
|
||||
}
|
||||
|
||||
protected static int getBlockXP(BlockState blockState) {
|
||||
int xp = ExperienceConfig.getInstance().getXp(SkillType.EXCAVATION, blockState.getData());
|
||||
int xp = ExperienceConfig.getInstance().getXp(SkillType.EXCAVATION, blockState.getBlockData());
|
||||
|
||||
if (xp == 0 && mcMMO.getModManager().isCustomExcavationBlock(blockState)) {
|
||||
xp = mcMMO.getModManager().getBlock(blockState).getXpGain();
|
||||
|
@ -279,7 +279,7 @@ public class FishingManager extends SkillManager {
|
||||
*/
|
||||
public void handleFishing(Item fishingCatch) {
|
||||
this.fishingCatch = fishingCatch;
|
||||
int fishXp = ExperienceConfig.getInstance().getXp(SkillType.FISHING, fishingCatch.getItemStack().getData());
|
||||
int fishXp = ExperienceConfig.getInstance().getXp(SkillType.FISHING, fishingCatch.getItemStack().getType().createBlockData());
|
||||
int treasureXp = 0;
|
||||
Player player = getPlayer();
|
||||
FishingTreasure treasure = null;
|
||||
|
@ -112,18 +112,22 @@ public class HerbalismManager extends SkillManager {
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*/
|
||||
public void herbalismBlockCheck(BlockState blockState) {
|
||||
System.out.print(">>1");
|
||||
Player player = getPlayer();
|
||||
Material material = blockState.getType();
|
||||
boolean oneBlockPlant = !(material == Material.CACTUS || material == Material.CHORUS_PLANT || material == Material.SUGAR_CANE);
|
||||
|
||||
// Prevents placing and immediately breaking blocks for exp
|
||||
if (oneBlockPlant && mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||
System.out.print(">>1.5");
|
||||
return;
|
||||
}
|
||||
System.out.print(">>2");
|
||||
|
||||
if (!canBlockCheck()) {
|
||||
return;
|
||||
}
|
||||
System.out.print(">>3");
|
||||
|
||||
Collection<ItemStack> drops = null;
|
||||
int amount = 1;
|
||||
@ -131,6 +135,7 @@ public class HerbalismManager extends SkillManager {
|
||||
boolean greenTerra = mcMMOPlayer.getAbilityMode(skill.getAbility());
|
||||
|
||||
if (mcMMO.getModManager().isCustomHerbalismBlock(blockState)) {
|
||||
System.out.print(">>4");
|
||||
CustomBlock customBlock = mcMMO.getModManager().getBlock(blockState);
|
||||
xp = customBlock.getXpGain();
|
||||
|
||||
@ -139,28 +144,34 @@ public class HerbalismManager extends SkillManager {
|
||||
}
|
||||
}
|
||||
else {
|
||||
System.out.print(">>5");
|
||||
if(material == Material.CHORUS_FLOWER && blockState.getRawData() != 5) {
|
||||
return;
|
||||
}
|
||||
xp = ExperienceConfig.getInstance().getXp(skill, blockState.getData());
|
||||
xp = ExperienceConfig.getInstance().getXp(skill, blockState.getBlockData());
|
||||
|
||||
if (Config.getInstance().getDoubleDropsEnabled(skill, material) && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.HERBALISM_DOUBLE_DROPS)) {
|
||||
drops = blockState.getBlock().getDrops();
|
||||
System.out.print(">>6");
|
||||
}
|
||||
|
||||
if (!oneBlockPlant) {
|
||||
System.out.print(">>7");
|
||||
amount = Herbalism.calculateMultiBlockPlantDrops(blockState);
|
||||
xp *= amount;
|
||||
}
|
||||
|
||||
if (Permissions.greenThumbPlant(player, material)) {
|
||||
System.out.print(">>8");
|
||||
processGreenThumbPlants(blockState, greenTerra);
|
||||
}
|
||||
}
|
||||
System.out.print(">>9");
|
||||
|
||||
applyXpGain(xp, XPGainReason.PVE);
|
||||
|
||||
if (drops == null) {
|
||||
System.out.print(">>10");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -199,7 +210,7 @@ public class HerbalismManager extends SkillManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
String friendly = StringUtils.getFriendlyConfigMaterialDataString(blockState.getData());
|
||||
String friendly = StringUtils.getFriendlyConfigBlockDataString(blockState.getBlockData());
|
||||
if (!TreasureConfig.getInstance().hylianMap.containsKey(friendly))
|
||||
return false;
|
||||
List<HylianTreasure> treasures = TreasureConfig.getInstance().hylianMap.get(friendly);
|
||||
@ -320,11 +331,11 @@ public class HerbalismManager extends SkillManager {
|
||||
|
||||
switch (blockState.getType()) {
|
||||
|
||||
case POTATO:
|
||||
case CARROT:
|
||||
case POTATOES:
|
||||
case CARROTS:
|
||||
case BEETROOTS:
|
||||
case WHEAT:
|
||||
Crops crops = (Crops) blockState.getData();
|
||||
Crops crops = (Crops) blockState.getBlockData();
|
||||
|
||||
if (greenTerra) {
|
||||
crops.setState(CropState.MEDIUM);
|
||||
@ -349,7 +360,7 @@ public class HerbalismManager extends SkillManager {
|
||||
return true;
|
||||
|
||||
case NETHER_WART_BLOCK:
|
||||
NetherWarts warts = (NetherWarts) blockState.getData();
|
||||
NetherWarts warts = (NetherWarts) blockState.getBlockData();
|
||||
|
||||
if (greenTerra || greenThumbStage > 2) {
|
||||
warts.setState(NetherWartsState.STAGE_TWO);
|
||||
@ -364,7 +375,7 @@ public class HerbalismManager extends SkillManager {
|
||||
return true;
|
||||
|
||||
case COCOA:
|
||||
CocoaPlant plant = (CocoaPlant) blockState.getData();
|
||||
CocoaPlant plant = (CocoaPlant) blockState.getBlockData();
|
||||
|
||||
if (greenTerra || getGreenThumbStage() > 1) {
|
||||
plant.setSize(CocoaPlantSize.MEDIUM);
|
||||
|
@ -6,6 +6,7 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class Mining {
|
||||
|
||||
@ -15,7 +16,7 @@ public class Mining {
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*/
|
||||
public static int getBlockXp(BlockState blockState) {
|
||||
int xp = ExperienceConfig.getInstance().getXp(SkillType.MINING, blockState.getData());
|
||||
int xp = ExperienceConfig.getInstance().getXp(SkillType.MINING, blockState.getBlockData());
|
||||
|
||||
if (xp == 0 && mcMMO.getModManager().isCustomMiningBlock(blockState)) {
|
||||
xp = mcMMO.getModManager().getBlock(blockState).getXpGain();
|
||||
@ -86,12 +87,12 @@ public class Mining {
|
||||
case REDSTONE_ORE:
|
||||
case STONE:
|
||||
case PRISMARINE:
|
||||
Misc.dropItem(Misc.getBlockCenter(blockState), blockState.getData().toItemStack(1));
|
||||
Misc.dropItem(Misc.getBlockCenter(blockState), new ItemStack(blockState.getType()));
|
||||
return;
|
||||
|
||||
default:
|
||||
if (mcMMO.getModManager().isCustomMiningBlock(blockState)) {
|
||||
Misc.dropItem(Misc.getBlockCenter(blockState), blockState.getData().toItemStack(1));
|
||||
Misc.dropItem(Misc.getBlockCenter(blockState), new ItemStack(blockState.getType()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
@ -146,7 +147,7 @@ public class MiningManager extends SkillManager {
|
||||
xp += Mining.getBlockXp(blockState);
|
||||
}
|
||||
|
||||
Misc.dropItem(Misc.getBlockCenter(blockState), blockState.getData().toItemStack(1)); // Initial block that would have been dropped
|
||||
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++) {
|
||||
|
@ -22,7 +22,7 @@ import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@ -89,7 +89,7 @@ public class RepairManager extends SkillManager {
|
||||
|
||||
Material repairMaterial = repairable.getRepairMaterial();
|
||||
byte repairMaterialMetadata = repairable.getRepairMaterialMetadata();
|
||||
ItemStack toRemove = new MaterialData(repairMaterial, repairMaterialMetadata).toItemStack(1);
|
||||
ItemStack toRemove = new ItemStack(repairMaterial);
|
||||
|
||||
short startDurability = item.getDurability();
|
||||
|
||||
|
@ -20,7 +20,7 @@ import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@ -108,9 +108,7 @@ public class SalvageManager extends SkillManager {
|
||||
enchantBook = arcaneSalvageCheck(enchants);
|
||||
}
|
||||
|
||||
byte salvageMaterialMetadata = (salvageable.getSalvageMaterialMetadata() != (byte) -1) ? salvageable.getSalvageMaterialMetadata() : 0;
|
||||
|
||||
ItemStack salvageResults = new MaterialData(salvageable.getSalvageMaterial(), salvageMaterialMetadata).toItemStack(salvageableAmount);
|
||||
ItemStack salvageResults = new ItemStack(salvageable.getSalvageMaterial(), salvageableAmount);
|
||||
|
||||
//Call event
|
||||
if (EventUtils.callSalvageCheckEvent(player, item, salvageResults, enchantBook).isCancelled()) {
|
||||
|
@ -2,7 +2,7 @@ package com.gmail.nossr50.skills.smelting;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
@ -47,7 +47,7 @@ public class Smelting {
|
||||
public static double fluxMiningChance = AdvancedConfig.getInstance().getFluxMiningChance();
|
||||
|
||||
protected static int getResourceXp(ItemStack smelting) {
|
||||
MaterialData data = smelting.getData();
|
||||
BlockData data = smelting.getType().createBlockData();
|
||||
|
||||
return mcMMO.getModManager().isCustomOre(data) ? mcMMO.getModManager().getBlock(data).getSmeltingXpGain() : ExperienceConfig.getInstance().getXp(SkillType.SMELTING, data);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public class UnarmedManager extends SkillManager {
|
||||
public UnarmedManager(McMMOPlayer mcMMOPlayer) {
|
||||
@ -59,7 +59,7 @@ public class UnarmedManager extends SkillManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
MaterialData data = blockState.getData();
|
||||
BlockData data = blockState.getBlockData();
|
||||
|
||||
switch (blockState.getType()) {
|
||||
case STONE_BRICKS:
|
||||
|
@ -44,7 +44,7 @@ public final class Woodcutting {
|
||||
return mcMMO.getModManager().getBlock(blockState).getXpGain();
|
||||
}
|
||||
|
||||
return ExperienceConfig.getInstance().getXp(SkillType.WOODCUTTING, blockState.getData());
|
||||
return ExperienceConfig.getInstance().getXp(SkillType.WOODCUTTING, blockState.getBlockData());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,6 +45,7 @@ public class WoodcuttingManager extends SkillManager {
|
||||
* @param blockState Block being broken
|
||||
*/
|
||||
public void woodcuttingBlockCheck(BlockState blockState) {
|
||||
System.out.print(">>HEYO");
|
||||
int xp = Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.DEFAULT);
|
||||
|
||||
switch (blockState.getType()) {
|
||||
|
Reference in New Issue
Block a user