TF-ProjectKorra/src/com/projectkorra/projectkorra/ability/ElementalAbility.java
Vahagn Tovmasian 3c1d6b7b85
Blue Fire Update & Firebending Refactor (#1062)
## Additions
* Adds Blue Fire SubElement.
    > *Adds related damage, cooldown, and range modifiers for configuration
* Adds Sticks, Sponges, and Chorus Fruit to cookable HeatControl items.
* Adds Smoker, BlastFurnace, and extinguished Campfires to blocks which FireBlast can light.
* Adds new TempBlock constructor which takes in a `long revertTime` parameter
* Adds new blocks to block lists in configuration
  >* Adds new nether plants to plantBlocks list
  >* Adds new earth blocks to earthBlocks list

## Fixes
* Fixes AvatarState buffs overriding day related buffs for firebending.
* Fixes Blaze not going up hills, going through walls (mostly), jumping gaps.
* Fixes Furnaces and related blocks not smelting after being activated by FireBlast

## Removals
* Removes BlazeArc dependencies for Fire Abilities which ignite the ground.
* Removes smoke particles from Fire bending to increase visibility and better emulate the show.

## Misc. Changes
* Changes API versioning to 1.16.1
* Fire from Firebending no longer reverts all at once.
* Changes Combustion animation to be more beam-like rather than a rehash of FireBlast.
* Changes Add, Remove, Display command to properly display space for Blue Fire.
* Changes `ElementalAbility#isFire()` to check for SOUL_FIRE_FLAME.
* Changes isIgnitable to check whether fire can be placed at that location rather than solely based on flammability.
* Changes firebending abilities to use `FireAbility#playFirebendingParticles()` & `FireAbility#createTempFire()` where applicable.
* Changes `FireAbility#playFirebendingParticles()` to play blue fire particles when player has the BlueFire subelement.
2020-07-11 22:05:45 -07:00

234 lines
7.4 KiB
Java

package com.projectkorra.projectkorra.ability;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Waterlogged;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType;
import com.projectkorra.projectkorra.GeneralMethods;
/**
* ElementalAbility is used to hold methods that should be accessible by every
* Air, Water, Earth, Fire, Chi, or AvatarAbility. This class is mainly used to
* keep CoreAbility from becoming too cluttered.
*/
public abstract class ElementalAbility extends CoreAbility {
private static final PotionEffectType[] POSITIVE_EFFECTS = { PotionEffectType.ABSORPTION, PotionEffectType.DAMAGE_RESISTANCE, PotionEffectType.FAST_DIGGING, PotionEffectType.FIRE_RESISTANCE, PotionEffectType.HEAL, PotionEffectType.HEALTH_BOOST, PotionEffectType.INCREASE_DAMAGE, PotionEffectType.JUMP, PotionEffectType.NIGHT_VISION, PotionEffectType.REGENERATION, PotionEffectType.SATURATION, PotionEffectType.SPEED, PotionEffectType.WATER_BREATHING };
private static final PotionEffectType[] NEUTRAL_EFFECTS = { PotionEffectType.INVISIBILITY };
private static final PotionEffectType[] NEGATIVE_EFFECTS = { PotionEffectType.POISON, PotionEffectType.BLINDNESS, PotionEffectType.CONFUSION, PotionEffectType.HARM, PotionEffectType.HUNGER, PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING, PotionEffectType.WEAKNESS, PotionEffectType.WITHER };
private static final Set<Material> TRANSPARENT = new HashSet<>();
static {
TRANSPARENT.clear();
for (final Material mat : Material.values()) {
if (GeneralMethods.isTransparent(mat)) {
TRANSPARENT.add(mat);
}
}
}
public ElementalAbility(final Player player) {
super(player);
}
public boolean isTransparent(final Block block) {
return isTransparent(this.player, this.getName(), block);
}
public List<String> getEarthbendableBlocks() {
return getConfig().getStringList("Properties.Earth.EarthBlocks");
}
public static Material[] getTransparentMaterials() {
return TRANSPARENT.toArray(new Material[TRANSPARENT.size()]);
}
public static HashSet<Material> getTransparentMaterialSet() {
return new HashSet<>(TRANSPARENT);
}
public static boolean isAir(final Material material) {
return material == Material.AIR || material == Material.CAVE_AIR || material == Material.VOID_AIR;
}
public static boolean isDay(final World world) {
final long time = world.getTime();
if (world.getEnvironment() == Environment.NETHER || world.getEnvironment() == Environment.THE_END) {
return true;
}
if (time >= 23500 || time <= 12500) {
return true;
}
return false;
}
public static boolean isEarth(final Block block) {
return block != null ? isEarth(block.getType()) : false;
}
public static boolean isEarth(final Material material) {
return getConfig().getStringList("Properties.Earth.EarthBlocks").contains(material.toString());
}
public static boolean isFire(final Block block) {
return block != null ? isFire(block.getType()) : false;
}
public static boolean isFire(final Material material) {
return material == Material.SOUL_FIRE || material == Material.FIRE;
}
public static boolean isFullMoon(final World world) {
final double days = Math.ceil(world.getFullTime() / 24000) + 1;
final double phase = days % 8;
return phase == 0;
}
public static boolean isIce(final Block block) {
return block != null ? isIce(block.getType()) : false;
}
public static boolean isIce(final Material material) {
return getConfig().getStringList("Properties.Water.IceBlocks").contains(material.toString());
}
public static boolean isLava(final Block block) {
return block != null ? isLava(block.getType()) : false;
}
public static boolean isLava(final Material material) {
return material == Material.LAVA;
}
public static boolean isSnow(final Block block) {
return block != null ? isSnow(block.getType()) : false;
}
public static boolean isSnow(final Material material) {
return getConfig().getStringList("Properties.Water.SnowBlocks").contains(material.toString());
}
public static boolean isMeltable(final Block block) {
if (isIce(block) || isSnow(block)) {
return true;
}
return false;
}
public static boolean isMetal(final Block block) {
return block != null ? isMetal(block.getType()) : false;
}
public static boolean isMetal(final Material material) {
return getConfig().getStringList("Properties.Earth.MetalBlocks").contains(material.toString());
}
public static boolean isMetalBlock(final Block block) {
if (block.getType() == Material.GOLD_BLOCK || block.getType() == Material.IRON_BLOCK || block.getType() == Material.IRON_ORE || block.getType() == Material.GOLD_ORE || block.getType() == Material.QUARTZ_BLOCK || block.getType() == Material.NETHER_QUARTZ_ORE) {
return true;
}
return false;
}
public static boolean isNegativeEffect(final PotionEffectType effect) {
for (final PotionEffectType effect2 : NEGATIVE_EFFECTS) {
if (effect2.equals(effect)) {
return true;
}
}
return false;
}
public static boolean isNeutralEffect(final PotionEffectType effect) {
for (final PotionEffectType effect2 : NEUTRAL_EFFECTS) {
if (effect2.equals(effect)) {
return true;
}
}
return false;
}
public static boolean isNight(final World world) {
if (world.getEnvironment() == Environment.NETHER || world.getEnvironment() == Environment.THE_END) {
return false;
}
final long time = world.getTime();
if (time >= 12950 && time <= 23050) {
return true;
}
return false;
}
public static boolean isPlant(final Block block) {
return block != null ? isPlant(block.getType()) : false;
}
public static boolean isPlant(final Material material) {
return getConfig().getStringList("Properties.Water.PlantBlocks").contains(material.toString());
}
public static boolean isPositiveEffect(final PotionEffectType effect) {
for (final PotionEffectType effect2 : POSITIVE_EFFECTS) {
if (effect2.equals(effect)) {
return true;
}
}
return false;
}
public static boolean isSand(final Block block) {
return block != null ? isSand(block.getType()) : false;
}
public static boolean isSand(final Material material) {
return getConfig().getStringList("Properties.Earth.SandBlocks").contains(material.toString());
}
public static boolean isTransparent(final Player player, final Block block) {
return isTransparent(player, null, block);
}
public static boolean isTransparent(final Player player, final String abilityName, final Block block) {
return Arrays.asList(getTransparentMaterials()).contains(block.getType()) && !GeneralMethods.isRegionProtectedFromBuild(player, abilityName, block.getLocation());
}
public static boolean isWater(final Block block) {
if (block == null) {
return false;
} else if (isWater(block.getType())) {
return true;
} else {
return isWater(block.getBlockData());
}
}
public static boolean isWater(final BlockData data) {
return (data instanceof Waterlogged) ? ((Waterlogged) data).isWaterlogged() : isWater(data.getMaterial());
}
public static boolean isWater(final Material material) {
return material == Material.WATER || material == Material.SEAGRASS || material == Material.TALL_SEAGRASS || material == Material.KELP_PLANT || material == Material.KELP || material == Material.BUBBLE_COLUMN;
}
}