Skip to content

Commit

Permalink
just need to handle tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JustAHuman-xD committed Apr 23, 2024
1 parent ab7a0e3 commit f2ca408
Show file tree
Hide file tree
Showing 28 changed files with 97 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ private void onTeleport(Player p, Location destination, boolean success, boolean
if (success) {
// Apply Resistance Effect, if enabled
if (resistance) {
p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 600, 20));
p.addPotionEffect(new PotionEffect(PotionEffectType.RESISTANCE, 600, 20));
Slimefun.getLocalization().sendMessage(p, "machines.TELEPORTER.invulnerability");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void run() {
* The {@link Location} of our node
*/
private void spawnParticles(@Nonnull Location l) {
l.getWorld().spawnParticle(Particle.REDSTONE, l.getX() + 0.5, l.getY() + 0.5, l.getZ() + 0.5, 1, 0, 0, 0, 1, particleOptions);
l.getWorld().spawnParticle(Particle.DUST, l.getX() + 0.5, l.getY() + 0.5, l.getZ() + 0.5, 1, 0, 0, 0, 1, particleOptions);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public interface DamageableItem extends ItemAttribute {
*/
default void damageItem(@Nonnull Player p, @Nullable ItemStack item) {
if (isDamageable() && item != null && !item.getType().isAir() && item.getAmount() > 0) {
int unbreakingLevel = item.getEnchantmentLevel(Enchantment.DURABILITY);
int unbreakingLevel = item.getEnchantmentLevel(Enchantment.UNBREAKING);

if (evaluateUnbreakingEnchantment(unbreakingLevel)) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
*/
public enum RadiationSymptom {

SLOW(10, PotionEffectType.SLOW, 3),
SLOW(10, PotionEffectType.SLOWNESS, 3),
WITHER_LOW(25, PotionEffectType.WITHER, 0),
BLINDNESS(50, PotionEffectType.BLINDNESS, 4),
WITHER_HIGH(75, PotionEffectType.WITHER, 3),
IMMINENT_DEATH(100, PotionEffectType.HARM, 49);
IMMINENT_DEATH(100, PotionEffectType.INSTANT_DAMAGE, 49);

private final int minExposure;
private final PotionEffect potionEffect;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ private SlimefunItems() {}
GRANDPAS_WALKING_STICK.addUnsafeEnchantment(Enchantment.KNOCKBACK, 5);

BLADE_OF_VAMPIRES.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, 2);
BLADE_OF_VAMPIRES.addUnsafeEnchantment(Enchantment.DURABILITY, 4);
BLADE_OF_VAMPIRES.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 2);
BLADE_OF_VAMPIRES.addUnsafeEnchantment(Enchantment.UNBREAKING, 4);
BLADE_OF_VAMPIRES.addUnsafeEnchantment(Enchantment.SHARPNESS, 2);
}

/* Bows */
Expand All @@ -212,8 +212,8 @@ private SlimefunItems() {}
public static final SlimefunItemStack CLIMBING_PICK = new SlimefunItemStack("CLIMBING_PICK", Material.IRON_PICKAXE, "&bClimbing Pick", "", "&fAllows you to climb certain surfaces", "&fby right-clicking.", "&fEnchant this pick with Efficiency to", "&fclimb even faster!");

static {
COBALT_PICKAXE.addUnsafeEnchantment(Enchantment.DURABILITY, 10);
COBALT_PICKAXE.addUnsafeEnchantment(Enchantment.DIG_SPEED, 6);
COBALT_PICKAXE.addUnsafeEnchantment(Enchantment.UNBREAKING, 10);
COBALT_PICKAXE.addUnsafeEnchantment(Enchantment.EFFICIENCY, 6);
}

/* Armor */
Expand Down Expand Up @@ -304,57 +304,57 @@ private SlimefunItems() {}
static {
Map<Enchantment, Integer> cactusEnchs = new HashMap<>();
cactusEnchs.put(Enchantment.THORNS, 3);
cactusEnchs.put(Enchantment.DURABILITY, 6);
cactusEnchs.put(Enchantment.UNBREAKING, 6);

CACTUS_HELMET.addUnsafeEnchantments(cactusEnchs);
CACTUS_CHESTPLATE.addUnsafeEnchantments(cactusEnchs);
CACTUS_LEGGINGS.addUnsafeEnchantments(cactusEnchs);
CACTUS_BOOTS.addUnsafeEnchantments(cactusEnchs);

Map<Enchantment, Integer> damascusEnchs = new HashMap<>();
damascusEnchs.put(Enchantment.DURABILITY, 5);
damascusEnchs.put(Enchantment.PROTECTION_ENVIRONMENTAL, 5);
damascusEnchs.put(Enchantment.UNBREAKING, 5);
damascusEnchs.put(Enchantment.PROTECTION, 5);

DAMASCUS_STEEL_HELMET.addUnsafeEnchantments(damascusEnchs);
DAMASCUS_STEEL_CHESTPLATE.addUnsafeEnchantments(damascusEnchs);
DAMASCUS_STEEL_LEGGINGS.addUnsafeEnchantments(damascusEnchs);
DAMASCUS_STEEL_BOOTS.addUnsafeEnchantments(damascusEnchs);

Map<Enchantment, Integer> reinforcedEnchs = new HashMap<>();
reinforcedEnchs.put(Enchantment.DURABILITY, 9);
reinforcedEnchs.put(Enchantment.PROTECTION_ENVIRONMENTAL, 9);
reinforcedEnchs.put(Enchantment.UNBREAKING, 9);
reinforcedEnchs.put(Enchantment.PROTECTION, 9);

REINFORCED_ALLOY_HELMET.addUnsafeEnchantments(reinforcedEnchs);
REINFORCED_ALLOY_CHESTPLATE.addUnsafeEnchantments(reinforcedEnchs);
REINFORCED_ALLOY_LEGGINGS.addUnsafeEnchantments(reinforcedEnchs);
REINFORCED_ALLOY_BOOTS.addUnsafeEnchantments(reinforcedEnchs);

Map<Enchantment, Integer> gildedEnchs = new HashMap<>();
gildedEnchs.put(Enchantment.DURABILITY, 6);
gildedEnchs.put(Enchantment.PROTECTION_ENVIRONMENTAL, 8);
gildedEnchs.put(Enchantment.UNBREAKING, 6);
gildedEnchs.put(Enchantment.PROTECTION, 8);

GILDED_IRON_HELMET.addUnsafeEnchantments(gildedEnchs);
GILDED_IRON_CHESTPLATE.addUnsafeEnchantments(gildedEnchs);
GILDED_IRON_LEGGINGS.addUnsafeEnchantments(gildedEnchs);
GILDED_IRON_BOOTS.addUnsafeEnchantments(gildedEnchs);

GOLDEN_HELMET_12K.addUnsafeEnchantment(Enchantment.DURABILITY, 10);
GOLDEN_CHESTPLATE_12K.addUnsafeEnchantment(Enchantment.DURABILITY, 10);
GOLDEN_LEGGINGS_12K.addUnsafeEnchantment(Enchantment.DURABILITY, 10);
GOLDEN_BOOTS_12K.addUnsafeEnchantment(Enchantment.DURABILITY, 10);
GOLDEN_HELMET_12K.addUnsafeEnchantment(Enchantment.UNBREAKING, 10);
GOLDEN_CHESTPLATE_12K.addUnsafeEnchantment(Enchantment.UNBREAKING, 10);
GOLDEN_LEGGINGS_12K.addUnsafeEnchantment(Enchantment.UNBREAKING, 10);
GOLDEN_BOOTS_12K.addUnsafeEnchantment(Enchantment.UNBREAKING, 10);

Map<Enchantment, Integer> slimeEnchs = new HashMap<>();
slimeEnchs.put(Enchantment.DURABILITY, 4);
slimeEnchs.put(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
slimeEnchs.put(Enchantment.UNBREAKING, 4);
slimeEnchs.put(Enchantment.PROTECTION, 2);

SLIME_HELMET_STEEL.addUnsafeEnchantments(slimeEnchs);
SLIME_CHESTPLATE_STEEL.addUnsafeEnchantments(slimeEnchs);
SLIME_LEGGINGS_STEEL.addUnsafeEnchantments(slimeEnchs);
SLIME_BOOTS_STEEL.addUnsafeEnchantments(slimeEnchs);

Map<Enchantment, Integer> beeEnchs = new HashMap<>();
beeEnchs.put(Enchantment.DURABILITY, 4);
beeEnchs.put(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
beeEnchs.put(Enchantment.UNBREAKING, 4);
beeEnchs.put(Enchantment.PROTECTION, 2);

BEE_HELMET.addUnsafeEnchantments(beeEnchs);
BEE_WINGS.addUnsafeEnchantments(beeEnchs);
Expand Down Expand Up @@ -567,10 +567,10 @@ private SlimefunItems() {}
public static final SlimefunItemStack STAFF_STORM = new SlimefunItemStack("STAFF_ELEMENTAL_STORM", Material.STICK, "&6Elemental Staff &7- &8&oStorm", "", "&7Element: &8&oStorm", "", "&eRight Click&7 to summon a lightning", LoreBuilder.usesLeft(StormStaff.MAX_USES));

static {
STAFF_WIND.addUnsafeEnchantment(Enchantment.LUCK, 1);
STAFF_WIND.addUnsafeEnchantment(Enchantment.LUCK_OF_THE_SEA, 1);
STAFF_FIRE.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, 5);
STAFF_WATER.addUnsafeEnchantment(Enchantment.WATER_WORKER, 1);
STAFF_STORM.addUnsafeEnchantment(Enchantment.DURABILITY, 1);
STAFF_WATER.addUnsafeEnchantment(Enchantment.AQUA_AFFINITY, 1);
STAFF_STORM.addUnsafeEnchantment(Enchantment.UNBREAKING, 1);
}

/* Multiblocks */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ private void breakBlock(BlockMenu menu, Collection<ItemStack> drops, Block block

// "poof" a "new" block was generated
SoundEffect.MINER_ANDROID_BLOCK_GENERATION_SOUND.playAt(block);
block.getWorld().spawnParticle(Particle.SMOKE_NORMAL, block.getX() + 0.5, block.getY() + 1.25, block.getZ() + 0.5, 8, 0.5, 0.5, 0.5, 0.015);
block.getWorld().spawnParticle(Particle.SMOKE, block.getX() + 0.5, block.getY() + 1.25, block.getZ() + 0.5, 8, 0.5, 0.5, 0.5, 0.015);
} else {
block.setType(Material.AIR);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ protected void tick(@Nonnull Block b, @Nonnull Config data) {
if (craft(inv, recipe)) {
// We are done crafting!
Location loc = b.getLocation().add(0.5, 0.8, 0.5);
b.getWorld().spawnParticle(Particle.VILLAGER_HAPPY, loc, 6);
b.getWorld().spawnParticle(Particle.HAPPY_VILLAGER, loc, 6);
removeCharge(b.getLocation(), getEnergyConsumption());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private void generateLiquid(@Nonnull Block block, boolean isWater) {
// Fixes #2877 - If water in the nether is disabled, abort and play an effect.
if (isWater && block.getWorld().getEnvironment() == Environment.NETHER && !allowWaterInNether.getValue()) {
// We will still consume the items but won't generate water in the Nether.
block.getWorld().spawnParticle(Particle.SMOKE_NORMAL, block.getLocation().add(0.5, 0.5, 0.5), 4);
block.getWorld().spawnParticle(Particle.SMOKE, block.getLocation().add(0.5, 0.5, 0.5), 4);
SoundEffect.CRUCIBLE_GENERATE_LIQUID_SOUND.playAt(block);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ private EntityInteractHandler getEntityInteractionHandler() {
return (e, item, offhand) -> {
// Fixes #2217 - Prevent them from being used to shear entities
switch (e.getRightClicked().getType()) {
case MUSHROOM_COW:
case MOOSHROOM:
case SHEEP:
case SNOWMAN:
case SNOW_GOLEM:
Slimefun.getLocalization().sendMessage(e.getPlayer(), "messages.multi-tool.not-shears");
e.setCancelled(true);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.potion.PotionType;

import io.github.bakedlibs.dough.inventory.InvUtils;
Expand All @@ -36,14 +33,16 @@ public class AutoBrewer extends AContainer implements NotHopperable {

private static final Map<Material, PotionType> potionRecipes = new EnumMap<>(Material.class);
private static final Map<PotionType, PotionType> fermentations = new EnumMap<>(PotionType.class);
private static final Map<PotionType, PotionType> extendedPotions = new EnumMap<>(PotionType.class);
private static final Map<PotionType, PotionType> upgradedPotions = new EnumMap<>(PotionType.class);

static {
potionRecipes.put(Material.SUGAR, PotionType.SPEED);
potionRecipes.put(Material.RABBIT_FOOT, PotionType.JUMP);
potionRecipes.put(Material.SUGAR, PotionType.SWIFTNESS);
potionRecipes.put(Material.RABBIT_FOOT, PotionType.LEAPING);
potionRecipes.put(Material.BLAZE_POWDER, PotionType.STRENGTH);
potionRecipes.put(Material.GLISTERING_MELON_SLICE, PotionType.INSTANT_HEAL);
potionRecipes.put(Material.GLISTERING_MELON_SLICE, PotionType.HEALING);
potionRecipes.put(Material.SPIDER_EYE, PotionType.POISON);
potionRecipes.put(Material.GHAST_TEAR, PotionType.REGEN);
potionRecipes.put(Material.GHAST_TEAR, PotionType.REGENERATION);
potionRecipes.put(Material.MAGMA_CREAM, PotionType.FIRE_RESISTANCE);
potionRecipes.put(Material.PUFFERFISH, PotionType.WATER_BREATHING);
potionRecipes.put(Material.GOLDEN_CARROT, PotionType.NIGHT_VISION);
Expand All @@ -54,6 +53,28 @@ public class AutoBrewer extends AContainer implements NotHopperable {
fermentations.put(PotionType.HEALING, PotionType.HARMING);
fermentations.put(PotionType.POISON, PotionType.HARMING);
fermentations.put(PotionType.NIGHT_VISION, PotionType.INVISIBILITY);

extendedPotions.put(PotionType.NIGHT_VISION, PotionType.LONG_NIGHT_VISION);
extendedPotions.put(PotionType.INVISIBILITY, PotionType.LONG_INVISIBILITY);
extendedPotions.put(PotionType.LEAPING, PotionType.LONG_LEAPING);
extendedPotions.put(PotionType.FIRE_RESISTANCE, PotionType.LONG_FIRE_RESISTANCE);
extendedPotions.put(PotionType.SWIFTNESS, PotionType.LONG_SWIFTNESS);
extendedPotions.put(PotionType.SLOWNESS, PotionType.LONG_SLOWNESS);
extendedPotions.put(PotionType.WATER_BREATHING, PotionType.LONG_WATER_BREATHING);
extendedPotions.put(PotionType.POISON, PotionType.LONG_POISON);
extendedPotions.put(PotionType.REGENERATION, PotionType.LONG_REGENERATION);
extendedPotions.put(PotionType.STRENGTH, PotionType.LONG_STRENGTH);
extendedPotions.put(PotionType.WEAKNESS, PotionType.LONG_WEAKNESS);
extendedPotions.put(PotionType.TURTLE_MASTER, PotionType.LONG_TURTLE_MASTER);
extendedPotions.put(PotionType.SLOW_FALLING, PotionType.LONG_SLOW_FALLING);

upgradedPotions.put(PotionType.LEAPING, PotionType.STRONG_LEAPING);
upgradedPotions.put(PotionType.SWIFTNESS, PotionType.STRONG_SWIFTNESS);
upgradedPotions.put(PotionType.SLOWNESS, PotionType.STRONG_SLOWNESS);
upgradedPotions.put(PotionType.POISON, PotionType.STRONG_POISON);
upgradedPotions.put(PotionType.REGENERATION, PotionType.STRONG_REGENERATION);
upgradedPotions.put(PotionType.STRENGTH, PotionType.STRONG_STRENGTH);
upgradedPotions.put(PotionType.TURTLE_MASTER, PotionType.STRONG_TURTLE_MASTER);
}

@ParametersAreNonnullByDefault
Expand Down Expand Up @@ -105,9 +126,7 @@ public AutoBrewer(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipe

@ParametersAreNonnullByDefault
private @Nullable ItemStack brew(Material input, Material potionType, PotionMeta potion) {
PotionType data = potion.getBasePotionType();

PotionType type = data.getType();
PotionType type = potion.getBasePotionType();
if (type == PotionType.WATER) {
if (input == Material.FERMENTED_SPIDER_EYE) {
potion.setBasePotionType(PotionType.WEAKNESS);
Expand All @@ -127,19 +146,19 @@ public AutoBrewer(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipe
potion.setBasePotionType(fermented);
return new ItemStack(potionType);
}
} else if (input == Material.REDSTONE && type.isExtendable() && !data) {
} else if (input == Material.REDSTONE && extendedPotions.containsKey(type)) {
// Fixes #3390 - Potions can only be either extended or upgraded. Not both.
potion.setBasePotionData(new PotionData(type, true, false));
potion.setBasePotionType(extendedPotions.get(type));
return new ItemStack(potionType);
} else if (input == Material.GLOWSTONE_DUST && type.isUpgradeable() && !data.isExtended()) {
} else if (input == Material.GLOWSTONE_DUST && upgradedPotions.containsKey(type)) {
// Fixes #3390 - Potions can only be either extended or upgraded. Not both.
potion.setBasePotionData(new PotionData(type, false, true));
potion.setBasePotionType(upgradedPotions.get(type));
return new ItemStack(potionType);
} else if (type == PotionType.AWKWARD) {
PotionType potionRecipe = potionRecipes.get(input);

if (potionRecipe != null) {
potion.setBasePotionData(new PotionData(potionRecipe, false, false));
potion.setBasePotionType(potionRecipe);
return new ItemStack(potionType);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionType;

/**
Expand Down Expand Up @@ -218,7 +217,7 @@ private Block findNextFluid(@Nonnull Block fluid) {
case BUBBLE_COLUMN:
ItemStack waterBottle = new ItemStack(Material.POTION);
PotionMeta meta = (PotionMeta) waterBottle.getItemMeta();
meta.setBasePotionData(new PotionData(PotionType.WATER));
meta.setBasePotionType(PotionType.WATER);
waterBottle.setItemMeta(meta);
return waterBottle;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected void tick(Block b) {
ageable.setAge(0);
}

n.getWorld().spawnParticle(Particle.VILLAGER_HAPPY, ((LivingEntity) n).getEyeLocation(), 8, 0.2F, 0.2F, 0.2F);
n.getWorld().spawnParticle(Particle.HAPPY_VILLAGER, ((LivingEntity) n).getEyeLocation(), 8, 0.2F, 0.2F, 0.2F);
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private boolean grow(Block machine, BlockMenu inv, Block crop) {
ageable.setAge(ageable.getAge() + 1);
crop.setBlockData(ageable);

crop.getWorld().spawnParticle(Particle.VILLAGER_HAPPY, crop.getLocation().add(0.5D, 0.5D, 0.5D), 4, 0.1F, 0.1F, 0.1F);
crop.getWorld().spawnParticle(Particle.HAPPY_VILLAGER, crop.getLocation().add(0.5D, 0.5D, 0.5D), 4, 0.1F, 0.1F, 0.1F);
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private boolean applyBoneMeal(Block machine, Block sapling, BlockMenu inv) {
sapling.applyBoneMeal(BlockFace.UP);

inv.consumeItem(slot);
sapling.getWorld().spawnParticle(Particle.VILLAGER_HAPPY, sapling.getLocation().add(0.5D, 0.5D, 0.5D), 4, 0.1F, 0.1F, 0.1F);
sapling.getWorld().spawnParticle(Particle.HAPPY_VILLAGER, sapling.getLocation().add(0.5D, 0.5D, 0.5D), 4, 0.1F, 0.1F, 0.1F);
return true;
}
}
Expand All @@ -111,7 +111,7 @@ private boolean updateSaplingData(Block machine, Block block, BlockMenu inv, Sap
block.setBlockData(sapling, false);

inv.consumeItem(slot);
block.getWorld().spawnParticle(Particle.VILLAGER_HAPPY, block.getLocation().add(0.5D, 0.5D, 0.5D), 4, 0.1F, 0.1F, 0.1F);
block.getWorld().spawnParticle(Particle.HAPPY_VILLAGER, block.getLocation().add(0.5D, 0.5D, 0.5D), 4, 0.1F, 0.1F, 0.1F);
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private void addRandomEnchantment(@Nonnull Player p, @Nonnull Item rune) {
// Being sure entities are still valid and not picked up or whatsoever.
if (rune.isValid() && item.isValid() && itemStack.getAmount() == 1) {

l.getWorld().spawnParticle(Particle.CRIT_MAGIC, l, 1);
l.getWorld().spawnParticle(Particle.ENCHANTED_HIT, l, 1);
SoundEffect.ENCHANTMENT_RUNE_ADD_ENCHANT_SOUND.playAt(l, SoundCategory.PLAYERS);

item.remove();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public VillagerRune(ItemGroup itemGroup, SlimefunItemStack item, RecipeType reci

SoundEffect.VILLAGER_RUNE_TRANSFORM_SOUND.playAt(villager.getLocation(), SoundCategory.NEUTRAL);
villager.getWorld().spawnParticle(Particle.CRIMSON_SPORE, villager.getLocation(), 10, 0, offset / 2, 0, 0);
villager.getWorld().spawnParticle(Particle.ENCHANTMENT_TABLE, villager.getLocation(), 5, 0.04, 1, 0.04);
villager.getWorld().spawnParticle(Particle.ENCHANT, villager.getLocation(), 5, 0.04, 1, 0.04);
}
};
}
Expand Down
Loading

0 comments on commit f2ca408

Please sign in to comment.