1.16 support part 5

This commit is contained in:
nossr50
2020-03-03 17:14:57 -08:00
parent 89a990f0cb
commit 3a81d94b32
8 changed files with 173 additions and 16 deletions

View File

@ -75,6 +75,8 @@ public class SalvageConfig extends ConfigLoader {
}
else if (ItemUtils.isDiamondArmor(salvageItem) || ItemUtils.isDiamondTool(salvageItem)) {
salvageMaterialType = MaterialType.DIAMOND;
} else if (ItemUtils.isNetherriteTool(salvageItem) || ItemUtils.isNetherriteArmor(salvageItem)) {
salvageMaterialType = MaterialType.NETHERRACK;
}
}
else {

View File

@ -10,6 +10,7 @@ public enum MaterialType {
IRON,
GOLD,
DIAMOND,
NETHERRACK,
OTHER;
public Material getDefaultMaterial() {
@ -35,6 +36,12 @@ public enum MaterialType {
case DIAMOND:
return Material.DIAMOND;
case NETHERRACK:
if(Material.getMaterial("netherrite_scrap") != null)
return Material.getMaterial("netherrite_scrap");
else
return Material.GOLD_INGOT;
case OTHER:
default:
return null;

View File

@ -17,6 +17,7 @@ import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import org.apache.commons.lang.math.RandomUtils;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
@ -131,6 +132,30 @@ public class MiningManager extends SkillManager {
* @param yield The % of blocks to drop
* @param event The {@link EntityExplodeEvent}
*/
//TODO: Rewrite this garbage
//TODO: Rewrite this garbage
//TODO: Rewrite this garbage
//TODO: Rewrite this garbage
//TODO: Rewrite this garbage
//TODO: Rewrite this garbage
//TODO: Rewrite this garbage
//TODO: Rewrite this garbage
//TODO: Rewrite this garbage
//TODO: Rewrite this garbage
//TODO: Rewrite this garbage
//TODO: Rewrite this garbage
//TODO: Rewrite this garbage
//TODO: Rewrite this garbage
//TODO: Rewrite this garbage
//TODO: Rewrite this garbage
//TODO: Rewrite this garbage
//TODO: Rewrite this garbage
//TODO: Rewrite this garbage
//TODO: Rewrite this garbage
//TODO: Rewrite this garbage
//TODO: Rewrite this garbage
//TODO: Rewrite this garbage
//TODO: Rewrite this garbage
public void blastMiningDropProcessing(float yield, EntityExplodeEvent event) {
//Strip out only stuff that gives mining XP
@ -148,7 +173,7 @@ public class MiningManager extends SkillManager {
int xp = 0;
float oreBonus = (float) (getOreBonus() / 100);
// float oreBonus = (float) (getOreBonus() / 100);
//TODO: Pretty sure something is fucked with debrisReduction stuff
// float debrisReduction = (float) (getDebrisReduction() / 100);
int dropMultiplier = getDropMultiplier();
@ -156,13 +181,14 @@ public class MiningManager extends SkillManager {
// float debrisYield = yield - debrisReduction;
for (BlockState blockState : ores) {
if (Misc.getRandom().nextFloat() < (notOres.size() + oreBonus)) {
if (RandomUtils.nextInt(ores.size()) >= (ores.size() / 2)) {
xp += Mining.getBlockXp(blockState);
Misc.dropItem(Misc.getBlockCenter(blockState), new ItemStack(blockState.getType())); // Initial block that would have been dropped
for (int i = 1; i < dropMultiplier; i++) {
Mining.handleSilkTouchDrops(blockState); // Bonus drops - should drop the block & not the items
if(RandomUtils.nextInt(100) >= 75)
Mining.handleSilkTouchDrops(blockState); // Bonus drops - should drop the block & not the items
}
}
}
@ -234,7 +260,21 @@ public class MiningManager extends SkillManager {
* @return the Blast Mining tier
*/
public int getDropMultiplier() {
return getDropMultiplier(getBlastMiningTier());
switch(getBlastMiningTier()) {
case 8:
case 7:
return 3;
case 6:
case 5:
case 4:
case 3:
return 2;
case 2:
case 1:
return 1;
default:
return 0;
}
}
/**

View File

@ -144,6 +144,29 @@ public final class Misc {
return location.getWorld().dropItem(location, itemStack);
}
/**
* Drop an item at a given location.
*
* @param location The location to drop the item at
* @param itemStack The item to drop
* @return Dropped Item entity or null if invalid or cancelled
*/
public static Item dropItem(Location location, ItemStack itemStack, int count) {
if (itemStack.getType() == Material.AIR) {
return null;
}
// We can't get the item until we spawn it and we want to make it cancellable, so we have a custom event.
McMMOItemSpawnEvent event = new McMMOItemSpawnEvent(location, itemStack);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return null;
}
return location.getWorld().dropItem(location, itemStack);
}
/**
* Drop items at a given location.
*

View File

@ -298,6 +298,11 @@ public class SkillUtils {
public static int getRepairAndSalvageQuantities(Material itemMaterial, Material recipeMaterial) {
int quantity = 0;
if(mcMMO.getMaterialMapStore().isNetherriteTool(itemMaterial) || mcMMO.getMaterialMapStore().isNetherriteArmor(itemMaterial)) {
//One netherrite bar requires 4 netherrite scraps
return 4;
}
for(Iterator<? extends Recipe> recipeIterator = Bukkit.getServer().recipeIterator(); recipeIterator.hasNext();) {
Recipe bukkitRecipe = recipeIterator.next();