mirror of
https://github.com/darksaid98/SiegeEngines.git
synced 2026-12-03 06:28:55 +00:00
feat: splash potion projectile
This commit is contained in:
commit
604bf94cfd
5 files changed
+57
-18
No files matched your search
@@ -7,9 +7,7 @@
|
|||||||
<groupId>com.github.alathra</groupId>
|
<groupId>com.github.alathra</groupId>
|
||||||
<artifactId>SiegeEngines</artifactId>
|
<artifactId>SiegeEngines</artifactId>
|
||||||
<version>0.8.3</version>
|
<version>0.8.3</version>
|
||||||
|
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>SiegeEngines</name>
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import com.github.alathra.siegeengines.SiegeEnginesUtil;
|
|||||||
import com.github.alathra.siegeengines.projectile.EntityProjectile;
|
import com.github.alathra.siegeengines.projectile.EntityProjectile;
|
||||||
import com.github.alathra.siegeengines.projectile.ExplosiveProjectile;
|
import com.github.alathra.siegeengines.projectile.ExplosiveProjectile;
|
||||||
import com.github.alathra.siegeengines.projectile.FireworkProjectile;
|
import com.github.alathra.siegeengines.projectile.FireworkProjectile;
|
||||||
|
import com.github.alathra.siegeengines.projectile.PotionProjectile;
|
||||||
import com.github.alathra.siegeengines.projectile.ProjectileType;
|
import com.github.alathra.siegeengines.projectile.ProjectileType;
|
||||||
import com.github.alathra.siegeengines.projectile.SiegeEngineProjectile;
|
import com.github.alathra.siegeengines.projectile.SiegeEngineProjectile;
|
||||||
|
|
||||||
@@ -307,6 +308,22 @@ public class Config {
|
|||||||
.getDouble("Projectiles." + projectileName + ".VelocityFactor");
|
.getDouble("Projectiles." + projectileName + ".VelocityFactor");
|
||||||
projectileMap.put(projectileName, fireworkProjectile);
|
projectileMap.put(projectileName, fireworkProjectile);
|
||||||
break;
|
break;
|
||||||
|
case POTION:
|
||||||
|
PotionProjectile potionProjectile = new PotionProjectile(new ItemStack(
|
||||||
|
Material.getMaterial(config.getString("Projectiles." + projectileName + ".AmmoItem"))));
|
||||||
|
potionProjectile.inaccuracy = (float) config
|
||||||
|
.getDouble("Projectiles." + projectileName + ".Inaccuracy");
|
||||||
|
potionProjectile.entityCount = config.getInt("Projectiles." + projectileName + ".EntityCount");
|
||||||
|
potionProjectile.delayTime = config.getInt("Projectiles." + projectileName + ".EntityCount");
|
||||||
|
if (potionProjectile.delayTime <= 0) {
|
||||||
|
potionProjectile.delayedFire = false;
|
||||||
|
} else {
|
||||||
|
potionProjectile.delayedFire = true;
|
||||||
|
}
|
||||||
|
potionProjectile.velocityFactor = (float) config
|
||||||
|
.getDouble("Projectiles." + projectileName + ".VelocityFactor");
|
||||||
|
projectileMap.put(projectileName, potionProjectile);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import com.github.alathra.siegeengines.SiegeEnginesUtil;
|
|||||||
import com.github.alathra.siegeengines.SiegeEngine;
|
import com.github.alathra.siegeengines.SiegeEngine;
|
||||||
import com.github.alathra.siegeengines.projectile.ExplosiveProjectile;
|
import com.github.alathra.siegeengines.projectile.ExplosiveProjectile;
|
||||||
import com.github.alathra.siegeengines.projectile.FireworkProjectile;
|
import com.github.alathra.siegeengines.projectile.FireworkProjectile;
|
||||||
|
import com.github.alathra.siegeengines.projectile.PotionProjectile;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -49,6 +50,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
|||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.PotionMeta;
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
import org.bukkit.util.EulerAngle;
|
import org.bukkit.util.EulerAngle;
|
||||||
|
|
||||||
@@ -298,7 +300,8 @@ public class ClickHandler implements Listener {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
inventoryItem = inventoryItem.clone();
|
inventoryItem = inventoryItem.clone();
|
||||||
if (!(stack.isSimilar(inventoryItem)) && (stack.getType() != Material.FIREWORK_ROCKET))
|
if (!(stack.isSimilar(inventoryItem)) && (stack.getType() != Material.FIREWORK_ROCKET)
|
||||||
|
&& (stack.getType() != Material.SPLASH_POTION))
|
||||||
continue;
|
continue;
|
||||||
inventoryItem.setAmount(1);
|
inventoryItem.setAmount(1);
|
||||||
if (stack.getType() != Material.FIREWORK_ROCKET && stack.isSimilar(inventoryItem)
|
if (stack.getType() != Material.FIREWORK_ROCKET && stack.isSimilar(inventoryItem)
|
||||||
@@ -317,6 +320,15 @@ public class ClickHandler implements Listener {
|
|||||||
siegeEngine.getProjectiles().put(inventoryItem, proj);
|
siegeEngine.getProjectiles().put(inventoryItem, proj);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (stack.getType() == Material.SPLASH_POTION && inventoryItem.getType() == stack.getType()
|
||||||
|
&& siegeEngine.getAmmoHolder().getLoadedProjectile() == 0) {
|
||||||
|
siegeEngine.getAmmoHolder().setLoadedProjectile(1);
|
||||||
|
siegeEngine.getAmmoHolder().setMaterialName(inventoryItem);
|
||||||
|
state.getInventory().removeItem(inventoryItem);
|
||||||
|
PotionProjectile proj = new PotionProjectile(inventoryItem);
|
||||||
|
siegeEngine.getProjectiles().put(inventoryItem, proj);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -20,12 +20,13 @@ import org.bukkit.util.Vector;
|
|||||||
|
|
||||||
public class PotionProjectile extends SiegeEngineProjectile {
|
public class PotionProjectile extends SiegeEngineProjectile {
|
||||||
|
|
||||||
public int EntityCount = 3;
|
public int entityCount = 3;
|
||||||
public Boolean DelayedFire = false;
|
public Boolean delayedFire = false;
|
||||||
public int DelayTime = 6;
|
public int delayTime = 6;
|
||||||
public float Inaccuracy = 0.1f;
|
public float inaccuracy = 0.1f;
|
||||||
public Particle ParticleType = Particle.EXPLOSION_LARGE;
|
public Particle particleType = Particle.EXPLOSION_LARGE;
|
||||||
public Sound SoundType = Sound.ENTITY_GENERIC_EXPLODE;
|
public Sound soundType = Sound.ENTITY_GENERIC_EXPLODE;
|
||||||
|
public float velocityFactor = 1.0f;
|
||||||
|
|
||||||
public PotionProjectile(ItemStack ammunitionItem) {
|
public PotionProjectile(ItemStack ammunitionItem) {
|
||||||
super(ProjectileType.POTION, ammunitionItem);
|
super(ProjectileType.POTION, ammunitionItem);
|
||||||
@@ -35,9 +36,9 @@ public class PotionProjectile extends SiegeEngineProjectile {
|
|||||||
public void Shoot(Entity player, Entity entity, Location loc, Float velocity) {
|
public void Shoot(Entity player, Entity entity, Location loc, Float velocity) {
|
||||||
//TODO Auto-generated method stub
|
//TODO Auto-generated method stub
|
||||||
int baseDelay = 0;
|
int baseDelay = 0;
|
||||||
for (int i = 0; i < EntityCount; i++) {
|
for (int i = 0; i < entityCount; i++) {
|
||||||
if (DelayedFire) {
|
if (delayedFire) {
|
||||||
baseDelay += DelayTime;
|
baseDelay += delayTime;
|
||||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SiegeEngines.getInstance(), () -> {
|
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SiegeEngines.getInstance(), () -> {
|
||||||
|
|
||||||
CreateEntity(entity, loc, velocity);
|
CreateEntity(entity, loc, velocity);
|
||||||
@@ -52,25 +53,27 @@ public class PotionProjectile extends SiegeEngineProjectile {
|
|||||||
World world = entity.getLocation().getWorld();
|
World world = entity.getLocation().getWorld();
|
||||||
|
|
||||||
Entity arrow = world.spawnEntity(loc, EntityType.SPLASH_POTION);
|
Entity arrow = world.spawnEntity(loc, EntityType.SPLASH_POTION);
|
||||||
if (Inaccuracy != 0f) {
|
if (inaccuracy != 0f) {
|
||||||
arrow.setVelocity(loc.getDirection().multiply(velocity).add(Randomise()).subtract(Randomise()));
|
arrow.setVelocity(loc.getDirection().multiply(velocity).add(Randomise()).subtract(Randomise()));
|
||||||
} else {
|
} else {
|
||||||
arrow.setVelocity(loc.getDirection().multiply(velocity));
|
arrow.setVelocity(loc.getDirection().multiply(velocity));
|
||||||
}
|
}
|
||||||
arrow.setMetadata("isPotionProj", SiegeEnginesUtil.addMetaDataValue("true"));
|
arrow.setMetadata("isPotionProj", SiegeEnginesUtil.addMetaDataValue("true"));
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new org.bukkit.event.entity.ProjectileLaunchEvent(arrow));
|
Bukkit.getServer().getPluginManager().callEvent(new org.bukkit.event.entity.ProjectileLaunchEvent(arrow));
|
||||||
ItemStack itemStack = new ItemStack(Material.SPLASH_POTION);
|
ItemStack itemStack = this.getAmmuinitionItem();
|
||||||
PotionMeta potionMeta = (PotionMeta) itemStack.getItemMeta();
|
PotionMeta potionMeta = (PotionMeta) itemStack.getItemMeta();
|
||||||
potionMeta.addCustomEffect(new PotionEffect(PotionEffectType.HARM, 100, 3, true), true);
|
System.out.println(potionMeta.toString());
|
||||||
|
System.out.println(itemStack.toString());
|
||||||
|
potionMeta.getBasePotionData();
|
||||||
itemStack.setItemMeta(potionMeta);
|
itemStack.setItemMeta(potionMeta);
|
||||||
ThrownPotion potion = (ThrownPotion) arrow;
|
ThrownPotion potion = (ThrownPotion) arrow;
|
||||||
potion.setItem(itemStack);
|
potion.setItem(itemStack);
|
||||||
world.playSound(loc, this.SoundType, 20, 2);
|
world.playSound(loc, this.soundType, 20, 2);
|
||||||
world.spawnParticle(this.ParticleType, loc.getX(), loc.getY(), loc.getZ(), 0);
|
world.spawnParticle(this.particleType, loc.getX(), loc.getY(), loc.getZ(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector Randomise() {
|
private Vector Randomise() {
|
||||||
return new Vector(SiegeEngines.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1), SiegeEngines.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1), SiegeEngines.random.nextFloat() * (Inaccuracy - (Inaccuracy * -1)) + (Inaccuracy * -1));
|
return new Vector(SiegeEngines.random.nextFloat() * (inaccuracy - (inaccuracy * -1)) + (inaccuracy * -1), SiegeEngines.random.nextFloat() * (inaccuracy - (inaccuracy * -1)) + (inaccuracy * -1), SiegeEngines.random.nextFloat() * (inaccuracy - (inaccuracy * -1)) + (inaccuracy * -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProjectileType getProjectileType() {
|
public ProjectileType getProjectileType() {
|
||||||
|
|||||||
@@ -114,6 +114,14 @@ Projectiles:
|
|||||||
EntityCount: 1
|
EntityCount: 1
|
||||||
VelocityFactor: 0.5
|
VelocityFactor: 0.5
|
||||||
Delay: 5
|
Delay: 5
|
||||||
|
SplashPotionProjectile:
|
||||||
|
ProjectileType: POTION
|
||||||
|
Inaccuracy: 0.0125
|
||||||
|
EntityCount: 1
|
||||||
|
VelocityFactor: 0.5
|
||||||
|
ArrowDamageFactor: 1.0
|
||||||
|
AmmoItem: SPLASH_POTION
|
||||||
|
FireSound: ITEM_CROSSBOW_SHOOT
|
||||||
|
|
||||||
SiegeEngines:
|
SiegeEngines:
|
||||||
Trebuchet:
|
Trebuchet:
|
||||||
@@ -142,6 +150,7 @@ SiegeEngines:
|
|||||||
- ScatterShot
|
- ScatterShot
|
||||||
- DragonsBreath
|
- DragonsBreath
|
||||||
- FireworkShot
|
- FireworkShot
|
||||||
|
- SplashPotionProjectile
|
||||||
ItemName: "&e&lBallista"
|
ItemName: "&e&lBallista"
|
||||||
Lore:
|
Lore:
|
||||||
- "&ePlace as a block to spawn a Ballista"
|
- "&ePlace as a block to spawn a Ballista"
|
||||||
|
|||||||
Reference in new issue
Block a user