mirror of
https://github.com/darksaid98/SiegeEngines.git
synced 2026-12-03 14:38:53 +00:00
block facing placement
This commit is contained in:
1 parent
3bea96a5fa
commit
72d3cdad85
8 files changed
+63
-5
No files matched your search
@@ -5,5 +5,6 @@
|
|||||||
<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/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/LibsDisguises-10.0.37-Free.jar"/>
|
||||||
<classpathentry kind="lib" path="E:/4 1.19.4 test/plugins/ProtocolLib (15).jar"/>
|
<classpathentry kind="lib" path="E:/4 1.19.4 test/plugins/ProtocolLib (15).jar"/>
|
||||||
|
<classpathentry kind="lib" path="E:/4 1.19.4 test/plugins/Towny-0.99.5.0.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -21,6 +21,9 @@ import siegeCore.CrunchSiegeCore;
|
|||||||
public class ExplosiveProjectile implements CrunchProjectile {
|
public class ExplosiveProjectile implements CrunchProjectile {
|
||||||
|
|
||||||
public String ProjectileType = "Explosive";
|
public String ProjectileType = "Explosive";
|
||||||
|
public Boolean PlaceBlocks = false;
|
||||||
|
public Material BlockToPlace = Material.COBWEB;
|
||||||
|
public int BlocksToPlaceAmount = 3;
|
||||||
public int ExplodePower = 2;
|
public int ExplodePower = 2;
|
||||||
public float Inaccuracy = 0.3f;
|
public float Inaccuracy = 0.3f;
|
||||||
public int ProjectilesCount = 1;
|
public int ProjectilesCount = 1;
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import org.bukkit.event.block.SignChangeEvent;
|
|||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
@@ -48,6 +49,10 @@ import org.bukkit.potion.PotionEffect;
|
|||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.bukkit.util.EulerAngle;
|
import org.bukkit.util.EulerAngle;
|
||||||
|
|
||||||
|
import com.palmergames.bukkit.towny.TownyAPI;
|
||||||
|
import com.palmergames.bukkit.towny.event.actions.TownyDestroyEvent;
|
||||||
|
import com.palmergames.bukkit.towny.object.TownBlock;
|
||||||
|
|
||||||
import CrunchProjectiles.ExplosiveProjectile;
|
import CrunchProjectiles.ExplosiveProjectile;
|
||||||
|
|
||||||
public class ClickHandler implements Listener {
|
public class ClickHandler implements Listener {
|
||||||
@@ -65,14 +70,56 @@ public class ClickHandler implements Listener {
|
|||||||
World world = event.getEntity().getWorld();
|
World world = event.getEntity().getWorld();
|
||||||
// world.createExplosion(loc, proj.Radius, proj.DoFire);
|
// world.createExplosion(loc, proj.Radius, proj.DoFire);
|
||||||
Entity tnt = event.getEntity().getWorld().spawnEntity(loc, EntityType.PRIMED_TNT);
|
Entity tnt = event.getEntity().getWorld().spawnEntity(loc, EntityType.PRIMED_TNT);
|
||||||
|
|
||||||
|
projectiles.remove(event.getEntity().getUniqueId());
|
||||||
|
|
||||||
|
if (proj.PlaceBlocks) {
|
||||||
|
TNTPrimed tntEnt = (TNTPrimed) tnt;
|
||||||
|
tntEnt.setYield(1);
|
||||||
|
tntEnt.setFuseTicks(0);
|
||||||
|
if (CrunchSiegeCore.towny != null) {
|
||||||
|
TownBlock block = TownyAPI.getInstance().getTownBlock(loc);
|
||||||
|
if (block != null) {
|
||||||
|
if (block.hasTown()) {
|
||||||
|
if (!block.getTownBlockOwner().getPermissions().explosion) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<Block> Blocks = sphere(loc, proj.ExplodePower);
|
||||||
|
for (int i = 0; i < proj.BlocksToPlaceAmount; i++) {
|
||||||
|
Block replace = getRandomElement(Blocks);
|
||||||
|
replace.setType(Material.COBWEB);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
TNTPrimed tntEnt = (TNTPrimed) tnt;
|
TNTPrimed tntEnt = (TNTPrimed) tnt;
|
||||||
tntEnt.setYield(proj.ExplodePower);
|
tntEnt.setYield(proj.ExplodePower);
|
||||||
tntEnt.setFuseTicks(0);
|
tntEnt.setFuseTicks(0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
projectiles.remove(event.getEntity().getUniqueId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Block> sphere(final Location center, final int radius) {
|
||||||
|
ArrayList<Block> sphere = new ArrayList<Block>();
|
||||||
|
for (int Y = -radius; Y < radius; Y++)
|
||||||
|
for (int X = -radius; X < radius; X++)
|
||||||
|
for (int Z = -radius; Z < radius; Z++)
|
||||||
|
if (Math.sqrt((X * X) + (Y * Y) + (Z * Z)) <= radius) {
|
||||||
|
final Block block = center.getWorld().getBlockAt(X + center.getBlockX(), Y + center.getBlockY(), Z + center.getBlockZ());
|
||||||
|
if (block.getType() == Material.AIR) {
|
||||||
|
sphere.add(block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sphere;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Block getRandomElement(List<Block> list)
|
||||||
|
{
|
||||||
|
Random rand = new Random();
|
||||||
|
return list.get(rand.nextInt(list.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
|
|||||||
@@ -50,6 +50,9 @@ import org.bukkit.potion.PotionEffect;
|
|||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
|
||||||
|
import com.palmergames.bukkit.towny.Towny;
|
||||||
|
|
||||||
import CrunchProjectiles.EntityProjectile;
|
import CrunchProjectiles.EntityProjectile;
|
||||||
import CrunchProjectiles.CrunchProjectile;
|
import CrunchProjectiles.CrunchProjectile;
|
||||||
import CrunchProjectiles.ExplosiveProjectile;
|
import CrunchProjectiles.ExplosiveProjectile;
|
||||||
@@ -61,6 +64,7 @@ public class CrunchSiegeCore extends JavaPlugin {
|
|||||||
public static Random random = new Random();
|
public static Random random = new Random();
|
||||||
private static String Path;
|
private static String Path;
|
||||||
|
|
||||||
|
public static Towny towny;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
@@ -101,6 +105,7 @@ public class CrunchSiegeCore extends JavaPlugin {
|
|||||||
DefinedEquipment.clear();
|
DefinedEquipment.clear();
|
||||||
}
|
}
|
||||||
LoadConfigs();
|
LoadConfigs();
|
||||||
|
towny = (Towny) Bukkit.getServer().getPluginManager().getPlugin("Towny");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LoadConfigs() {
|
public static void LoadConfigs() {
|
||||||
@@ -299,7 +304,8 @@ public class CrunchSiegeCore extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
l.setY(l.getY() + 1);
|
l.setY(l.getY() + 1);
|
||||||
l.setY(l.getY() + equip.PlacementOffsetY);
|
l.setY(l.getY() + equip.PlacementOffsetY);
|
||||||
l.setDirection(player.getLocation().getDirection());
|
l.setDirection(player.getFacing().getDirection());
|
||||||
|
|
||||||
Entity entity2 = player.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
|
Entity entity2 = player.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
|
||||||
|
|
||||||
ItemStack item = new ItemStack(Material.CARVED_PUMPKIN);
|
ItemStack item = new ItemStack(Material.CARVED_PUMPKIN);
|
||||||
@@ -317,6 +323,7 @@ public class CrunchSiegeCore extends JavaPlugin {
|
|||||||
LivingEntity ent = (LivingEntity) entity2;
|
LivingEntity ent = (LivingEntity) entity2;
|
||||||
ArmorStand stand = (ArmorStand) ent;
|
ArmorStand stand = (ArmorStand) ent;
|
||||||
equip.Entity = entity2;
|
equip.Entity = entity2;
|
||||||
|
|
||||||
equip.EntityId = entity2.getUniqueId();
|
equip.EntityId = entity2.getUniqueId();
|
||||||
stand.addEquipmentLock(EquipmentSlot.HEAD, LockType.REMOVING_OR_CHANGING);
|
stand.addEquipmentLock(EquipmentSlot.HEAD, LockType.REMOVING_OR_CHANGING);
|
||||||
stand.addEquipmentLock(EquipmentSlot.LEGS, LockType.ADDING_OR_CHANGING);
|
stand.addEquipmentLock(EquipmentSlot.LEGS, LockType.ADDING_OR_CHANGING);
|
||||||
|
|||||||
Reference in new issue
Block a user