mirror of
https://github.com/darksaid98/SiegeEngines.git
synced 2026-12-01 14:38:55 +00:00
/
This commit is contained in:
1 parent
bbc9ef7d79
commit
aa3a073b89
8 files changed
+48
-12
No files matched your search
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -10,6 +10,7 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Snowball;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@@ -32,7 +33,7 @@ public class ExplosiveProjectile implements CrunchProjectile {
|
||||
public Particle ParticleType = Particle.EXPLOSION_LARGE;
|
||||
public Sound SoundType = Sound.ENTITY_GENERIC_EXPLODE;
|
||||
private boolean PlaySound = true;
|
||||
|
||||
public Boolean AlertOnLanding = false;
|
||||
@Override
|
||||
public void Shoot(Player player, Entity entity, Location loc, Float velocity) {
|
||||
PlaySound = true;
|
||||
@@ -41,23 +42,26 @@ public class ExplosiveProjectile implements CrunchProjectile {
|
||||
if (DelayedFire) {
|
||||
baseDelay += DelayTime;
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(CrunchSiegeCore.plugin, () -> {
|
||||
CreateEntity(entity, loc, velocity);
|
||||
CreateEntity(entity, loc, velocity, player);
|
||||
}, (long) baseDelay);
|
||||
}
|
||||
else {
|
||||
|
||||
CreateEntity(entity,loc, velocity);
|
||||
CreateEntity(entity,loc, velocity, player);
|
||||
}
|
||||
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateEntity(Entity entity, Location loc, Float velocity) {
|
||||
private void CreateEntity(Entity entity, Location loc, Float velocity, Player player) {
|
||||
LivingEntity living = (LivingEntity) entity;
|
||||
World world = entity.getLocation().getWorld();
|
||||
Entity tnt = world.spawnEntity(loc, EntityType.SNOWBALL);
|
||||
Snowball ball = (Snowball) tnt;
|
||||
ball.setShooter(player);
|
||||
ClickHandler.projectiles.put(tnt.getUniqueId(), this);
|
||||
|
||||
if (Inaccuracy != 0f) {
|
||||
tnt.setVelocity(loc.getDirection().multiply(velocity).add(Randomise())
|
||||
.subtract(Randomise()));
|
||||
|
||||
@@ -86,6 +86,11 @@ public class ClickHandler implements Listener {
|
||||
if ((event.getEntity() instanceof Snowball) && projectiles.containsKey(event.getEntity().getUniqueId())) {
|
||||
ExplosiveProjectile proj = projectiles.get(event.getEntity().getUniqueId());
|
||||
Entity snowball = event.getEntity();
|
||||
Snowball ball = (Snowball) snowball;
|
||||
Player player = (Player) ball.getShooter();
|
||||
if (player != null) {
|
||||
player.sendMessage("Distance to impact: " + player.getLocation().distance(ball.getLocation()));
|
||||
}
|
||||
Location loc = snowball.getLocation();
|
||||
World world = event.getEntity().getWorld();
|
||||
// world.createExplosion(loc, proj.Radius, proj.DoFire);
|
||||
|
||||
@@ -305,15 +305,37 @@ public class CrunchSiegeCore extends JavaPlugin {
|
||||
return false;
|
||||
}
|
||||
l.setY(l.getY() + 1);
|
||||
l.setY(l.getY() + equip.PlacementOffsetY);
|
||||
|
||||
l.setDirection(player.getFacing().getDirection());
|
||||
|
||||
Entity entity2 = player.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
|
||||
|
||||
|
||||
//
|
||||
|
||||
ItemStack item = new ItemStack(Material.CARVED_PUMPKIN);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
|
||||
equip.AmmoHolder = new EquipmentMagazine();
|
||||
|
||||
if (equip.HaseBaseStand) {
|
||||
Location l2 = l;
|
||||
l2.setY(l.getY() + equip.BaseStandOffset);
|
||||
Entity entity3 = player.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
|
||||
LivingEntity ent = (LivingEntity) entity3;
|
||||
ArmorStand stand = (ArmorStand) ent;
|
||||
meta.setCustomModelData(equip.BaseStandModelNumber);
|
||||
stand.addEquipmentLock(EquipmentSlot.HEAD, LockType.REMOVING_OR_CHANGING);
|
||||
stand.addEquipmentLock(EquipmentSlot.LEGS, LockType.ADDING_OR_CHANGING);
|
||||
stand.addEquipmentLock(EquipmentSlot.CHEST, LockType.ADDING_OR_CHANGING);
|
||||
stand.addEquipmentLock(EquipmentSlot.FEET, LockType.ADDING_OR_CHANGING);
|
||||
stand.setBasePlate(false);
|
||||
// stand.setSmall(true);
|
||||
item.setItemMeta(meta);
|
||||
stand.setInvisible(equip.AllowInvisibleStand);
|
||||
ent.getEquipment().setHelmet(item);
|
||||
stand.setGravity(false);
|
||||
stand.setMarker(true);
|
||||
}
|
||||
l.setY(l.getY() + equip.PlacementOffsetY);
|
||||
Entity entity2 = player.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
|
||||
meta.setCustomModelData(equip.ReadyModelNumber);
|
||||
meta.setDisplayName("§e" + equip.EquipmentName +" spawn item");
|
||||
List<String> Lore = new ArrayList<String>();
|
||||
@@ -321,6 +343,7 @@ public class CrunchSiegeCore extends JavaPlugin {
|
||||
meta.setLore(Lore);
|
||||
item.setItemMeta(meta);
|
||||
|
||||
// entity3.addPassenger(entity2);
|
||||
|
||||
LivingEntity ent = (LivingEntity) entity2;
|
||||
ArmorStand stand = (ArmorStand) ent;
|
||||
@@ -334,9 +357,9 @@ public class CrunchSiegeCore extends JavaPlugin {
|
||||
stand.setBasePlate(false);
|
||||
ent.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 2000000, 1));
|
||||
// stand.setSmall(true);
|
||||
if (equip.AllowInvisibleStand) {
|
||||
stand.setInvisible(true);
|
||||
}
|
||||
|
||||
stand.setInvisible(equip.AllowInvisibleStand);
|
||||
|
||||
stand.setGravity(false);
|
||||
//stand.setSmall(true);
|
||||
ent.getEquipment().setHelmet(item);
|
||||
|
||||
@@ -42,6 +42,7 @@ public class SiegeEquipment implements Cloneable {
|
||||
public String EquipmentName = "Cannon";
|
||||
public int XOffset = 7;
|
||||
public int YOffset = 0;
|
||||
public int PitchOffset = -90;
|
||||
public int MaxFuel = 5;
|
||||
public double PlacementOffsetY = 0;
|
||||
public float VelocityPerFuel = 0.75f;
|
||||
@@ -60,6 +61,9 @@ public class SiegeEquipment implements Cloneable {
|
||||
public Boolean HasFired = false;
|
||||
public Boolean HasReloaded = false;
|
||||
public Boolean AllowInvisibleStand = true;
|
||||
public Boolean HaseBaseStand = false;
|
||||
public double BaseStandOffset = 0;
|
||||
public int BaseStandModelNumber = 147;
|
||||
public int TaskNumber;
|
||||
|
||||
public int ReadyModelNumber;
|
||||
@@ -129,7 +133,7 @@ public class SiegeEquipment implements Cloneable {
|
||||
else {
|
||||
loc.setY(loc.getY() - this.YOffset);
|
||||
}
|
||||
|
||||
loc.setPitch(loc.getPitch() + this.PitchOffset);
|
||||
return loc;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user