multiple ammo effects

This commit is contained in:
TheCrunchy committed 2023-07-02 20:30:20 +01:00
1 parent cb4b66a266
commit e3a656d159
7 files changed
+87 -22

No files matched your search

+2
View File
@@ -3,5 +3,7 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="E:/4 1.19.4 test/spigot-api-1.19.4-R0.1-SNAPSHOT-shaded.jar"/>
<classpathentry kind="lib" path="E:/4 1.19.4 test/plugins/LibsDisguises-10.0.37-Free.jar"/>
<classpathentry kind="lib" path="E:/4 1.19.4 test/plugins/ProtocolLib (15).jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Binary file not shown.
Binary file not shown.
Binary file not shown.
+9 -6
View File
@@ -165,6 +165,7 @@ public class ClickHandler implements Listener {
}
else {
equip = CrunchSiegeCore.CreateClone(living.getEquipment().getHelmet().getItemMeta().getCustomModelData());
equip.AmmoHolder = new EquipmentMagazine();
equip.Entity = entity;
equip.EntityId = entity.getUniqueId();
@@ -277,16 +278,18 @@ public class ClickHandler implements Listener {
}
if(sign.getLine(0).equalsIgnoreCase( "[Cannon]")){
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
CrunchSiegeCore.TrackedStands.remove(player.getUniqueId());
player.sendMessage("Releasing the cannons!");
return;
}
if(event.getAction() == Action.RIGHT_CLICK_BLOCK){
if (player.isSneaking()) {
SaveCannons(player, event.getClickedBlock());
return;
}
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
CrunchSiegeCore.TrackedStands.remove(player.getUniqueId());
player.sendMessage("Releasing the cannons!");
return;
}
NamespacedKey key = new NamespacedKey(CrunchSiegeCore.plugin, "cannons");
TileState state = (TileState) sign.getBlock().getState();
CrunchSiegeCore.TrackedStands.remove(player.getUniqueId());
@@ -343,7 +346,7 @@ public class ClickHandler implements Listener {
return;
}
if (equipment.Projectiles.containsKey(itemInHand.getType()) && !equipment.isLoaded()){
if (equipment.Projectiles.containsKey(itemInHand.getType()) && equipment.AmmoHolder.LoadedProjectile == 0){
equipment.AmmoHolder.LoadedProjectile = 1;
equipment.AmmoHolder.MaterialName = (Material) itemInHand.getType();
player.sendMessage("Adding projectile to cannon");
+5 -1
View File
@@ -115,7 +115,11 @@ public class CrunchSiegeCore extends JavaPlugin {
public static void AddDefined() {
SiegeEquipment equip = new SiegeEquipment();
equip.Projectiles.put(Material.COBBLESTONE, new SiegeProjectile(2, false));
equip.Projectiles.put(Material.COBBLESTONE, new SiegeProjectile(1, false));
equip.Projectiles.put(Material.TNT, new SiegeProjectile(1, false));
equip.Projectiles.put(Material.COPPER_BLOCK, new SiegeProjectile(4, false));
equip.Projectiles.put(Material.GRAVEL, new SiegeProjectile(1, false));
equip.Projectiles.put(Material.FIREWORK_STAR, new SiegeProjectile(1, false));
ItemStack item = new ItemStack(Material.CARVED_PUMPKIN);
equip.ReadyModelNumber = 122;
equip.ModelNumberToFireAt = 135;
+71 -15
View File
@@ -11,13 +11,19 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Firework;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.disguisetypes.MiscDisguise;
public class SiegeEquipment implements Cloneable {
@Override
@@ -51,7 +57,7 @@ public class SiegeEquipment implements Cloneable {
public Location location;
public int ModelNumberToFireAt;
public Boolean CycleThroughModelsBeforeFiring = false;
public Boolean RotateSideways = false;
public Boolean RotateSideways = true;
public Boolean RotateUpDown = true;
public Boolean HasFired = false;
@@ -176,11 +182,7 @@ public class SiegeEquipment implements Cloneable {
// player.sendMessage("" + modelData);
CrunchSiegeCore.UpdateEntityIdModel(this.Entity, modelData, this.WorldName);
if (modelData == this.ModelNumberToFireAt) {
Entity tnt = Bukkit.getServer().getWorld(this.WorldName).spawnEntity(loc, EntityType.SNOWBALL);
ClickHandler.projectiles.put(tnt.getUniqueId(), Projectiles.get(LoadedProjectile));
tnt.setVelocity(loc.getDirection().multiply(loadedFuel * this.VelocityPerFuel));
Bukkit.getServer().getWorld(this.WorldName).playSound(this.location, Sound.ENTITY_BAT_DEATH, 20, 2);
Shoot(loc, loadedFuel, LoadedProjectile);
}
this.NextModelNumber += 1;
@@ -198,23 +200,77 @@ public class SiegeEquipment implements Cloneable {
Location loc = living.getEyeLocation();
Vector direction = Entity.getLocation().getDirection().multiply(XOffset);
Random random = new Random();
float randomVar = random.nextFloat() * (6 - -6) + -6;
loc.add(direction);
loc.setYaw(loc.getYaw() + randomVar);
this.NextModelNumber = 0;
this.location = loc;
// player.sendMessage("Cannot fire for another " + CrunchSiegeCore.convertTime(this.NextShotTime - System.currentTimeMillis()));
Entity tnt = Bukkit.getServer().getWorld(this.WorldName).spawnEntity(loc, EntityType.SNOWBALL);
ClickHandler.projectiles.put(tnt.getUniqueId(), Projectiles.get(LoadedProjectile));
tnt.setVelocity(loc.getDirection().multiply(loadedFuel * this.VelocityPerFuel));
Bukkit.getServer().getWorld(this.WorldName).playSound(this.location, Sound.ENTITY_GENERIC_EXPLODE, 20, 2);
Bukkit.getServer().getWorld(this.WorldName).spawnParticle(Particle.EXPLOSION_LARGE, loc.getX(), loc.getY(), loc.getZ(), 0);
Shoot(loc, loadedFuel, LoadedProjectile);
}, (long) delay);
}
}
public static Random random = new Random();
public void Shoot(Location loc, float loadedFuel, Material LoadedProjectile) {
switch (LoadedProjectile) {
case COBBLESTONE:
case COPPER_BLOCK:
{
float randomVar = random.nextFloat() * (6 - -6) + -6;
loc.setYaw(loc.getYaw() + randomVar);
Entity tnt = Bukkit.getServer().getWorld(this.WorldName).spawnEntity(loc, EntityType.SNOWBALL);
ClickHandler.projectiles.put(tnt.getUniqueId(), Projectiles.get(LoadedProjectile));
tnt.setVelocity(loc.getDirection().multiply(loadedFuel * this.VelocityPerFuel));
Bukkit.getServer().getWorld(this.WorldName).playSound(this.location, Sound.ENTITY_GENERIC_EXPLODE, 20, 2);
Bukkit.getServer().getWorld(this.WorldName).spawnParticle(Particle.EXPLOSION_LARGE, loc.getX(), loc.getY(), loc.getZ(), 0);
}
break;
case GRAVEL:
{
for (int i = 0; i < 20; i++) {
Entity arrow = Bukkit.getServer().getWorld(this.WorldName).spawnEntity(loc, EntityType.ARROW);
arrow.setVelocity(loc.getDirection().multiply(loadedFuel * this.VelocityPerFuel / 2).add(new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble())
.subtract(new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble()))));
Arrow arr = (Arrow) arrow;
arr.setDamage(3 * loadedFuel);
MiscDisguise miscDisguise = new MiscDisguise(DisguiseType.DROPPED_ITEM, Material.IRON_NUGGET);
DisguiseAPI.disguiseEntity(arrow, miscDisguise);
Bukkit.getServer().getWorld(this.WorldName).playSound(this.location, Sound.ITEM_CROSSBOW_SHOOT, 20, 2);
}
}
break;
case TNT:
{
for (int i = 0; i < 5; i++) {
//float randomVar = random.nextFloat() * (15 - -15) + -15;
Entity tnt = Bukkit.getServer().getWorld(this.WorldName).spawnEntity(loc, EntityType.SNOWBALL);
ClickHandler.projectiles.put(tnt.getUniqueId(), Projectiles.get(LoadedProjectile));
tnt.setVelocity(loc.getDirection().multiply(loadedFuel * this.VelocityPerFuel).add(new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble())
.subtract(new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble()))));
Bukkit.getServer().getWorld(this.WorldName).playSound(this.location, Sound.ENTITY_GENERIC_EXPLODE, 20, 2);
Bukkit.getServer().getWorld(this.WorldName).spawnParticle(Particle.EXPLOSION_LARGE, loc.getX(), loc.getY(), loc.getZ(), 0);
}
}
break;
case FIREWORK_STAR:
{
for (int i = 0; i < 4; i++) {
Entity arrow = Bukkit.getServer().getWorld(this.WorldName).spawnEntity(loc, EntityType.SMALL_FIREBALL);
arrow.setVelocity(loc.getDirection().multiply(loadedFuel * this.VelocityPerFuel).add(new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble())
.subtract(new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble()))));
Bukkit.getServer().getWorld(this.WorldName).playSound(this.location, Sound.ITEM_CROSSBOW_SHOOT, 20, 2);
}
}
break;
}
}
}