@EventHandler(priority = EventPriority.HIGHEST) public void onHit(EntityDamageEvent event) { if(event.isCancelled()) return; Entity hitTarget = event.getEntity(); if(hitTarget != null && hitTarget instanceof ArmorStand && hitTarget.getCustomName() == "Chair") // Chair entity is immune to damage. event.setCancelled(true); else if(hitTarget != null && hitTarget instanceof Player && hitTarget.getVehicle() != null) { // Let players stand up if receiving damage. Entity vehicle = hitTarget.getVehicle(); if(vehicle != null && vehicle instanceof ArmorStand && vehicle.getCustomName() == "Chair") vehicle.remove(); } }
private void run__A(int id){ HashMap<Integer, ArmorStand> car = cars.get(id); double radius = carsR.get(id); int total = car.size()-1; ArmorStand A1 = car.get(1); for(int i = 1; i < total+1; i++) { ArmorStand A2 = car.get(i+1); { double angle = ((A1.getLocation().getYaw()+(360.0/total*i))*Math.PI / 180); double x = radius*Math.cos(angle); double z = radius*Math.sin(angle); String command = String.format("minecraft:tp @e[name=%s] %s %s %s %s %s", A2.getUniqueId().toString(), A1.getLocation().getX() + x, A1.getLocation().getY(), A1.getLocation().getZ() + z, A1.getLocation().getYaw(), A1.getLocation().getPitch()); Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command); } } }
@EventHandler public void ArmorStandGreef(PlayerArmorStandManipulateEvent e){ if(e.getRightClicked() instanceof ArmorStand){ ArmorStand clickedA = (ArmorStand) e.getRightClicked(); if(clickedA.getPassenger() == null){ ArrayList<Location> all_main_seats = new ArrayList<Location>(); for(attractie att : Main.r.Attracties.values()){ for(ArmorStand a : att.getMainSeats()) { all_main_seats.add(a.getLocation()); } } if(all_main_seats.contains(clickedA.getLocation())){ e.setCancelled(true); } } } }
@Override protected void onCommand(CommandSender sender, String[] args) { boolean load = ArmorStands.getPoses().containsKey(args[0]); sender.sendMessage(ChatColor.GREEN + "Please right-click the ArmorStand you'd like to " + (load ? "load" : "save") + "."); Callbacks.selectEntity((Player) sender, e -> { if (!(e instanceof ArmorStand)) { sender.sendMessage(ChatColor.RED + "That is not an ArmorStand."); return; } if (load) { ArmorStands.assumePose((ArmorStand) e, args[0]); } else { ArmorStands.getPoses().put(args[0], new ArmorStands.ArmorPose((ArmorStand) e)); } sender.sendMessage(ChatColor.GREEN + "Pose " + (load ? "load" : "sav") + "ed."); }); }
@EventHandler public void onPlayerInteractEntity(PlayerInteractEntityEvent e) { PAUser u = PAServer.getUser(e.getPlayer()); Entity en = e.getRightClicked(); e.setCancelled(true); System.out.println("Entidad encontrada"); if (en instanceof ArmorStand) { ArmorStand ar = (ArmorStand) en; e.setCancelled(true); System.out.println(ar.getItemInHand().getType()); switch (ar.getItemInHand().getType()) { case IRON_AXE: u.sendToServer("toa"); break; case BOW: break; } } }
@EventHandler public void EntityClick(PlayerInteractAtEntityEvent e) { Player p = e.getPlayer(); if(e.getRightClicked() instanceof ArmorStand){ ArmorStand clickedA = (ArmorStand) e.getRightClicked(); if(clickedA.getPassenger() == null){ for(attractie att : Main.r.Attracties.values()){ if(att.getSeats().contains(clickedA)){ if(att.allowSit == true){ e.setCancelled(true); p.teleport(clickedA); clickedA.setPassenger(p); att.addPassagier(p, clickedA); } return; } } } } }
@Override public void run() { for (final Player player : PetBlockListener.this.manager.timeBlocked.keySet().toArray(new Player[PetBlockListener.this.manager.timeBlocked.size()])) { PetBlockListener.this.manager.timeBlocked.put(player, PetBlockListener.this.manager.timeBlocked.get(player) - 1); if (PetBlockListener.this.manager.timeBlocked.get(player) <= 0) { PetBlockListener.this.manager.timeBlocked.remove(player); PetBlockListener.this.providePet(player, (petMeta, petBlock) -> PetBlockListener.this.setPetBlock(player, petMeta)); } } for (final World world : Bukkit.getWorlds()) { for (final Entity entity : world.getEntities()) { if (entity instanceof ArmorStand && PetBlockListener.this.isDeadPet(entity)) { entity.remove(); } else if (!PetBlockListener.this.isPet(entity) && entity.getCustomName() != null && entity.getCustomName().equals("PetBlockIdentifier")) { entity.remove(); } } } }
@EventHandler public void EntityClick(PlayerInteractAtEntityEvent e) { Player p = e.getPlayer(); if(e.getRightClicked() instanceof ArmorStand){ ArmorStand clickedA = (ArmorStand) e.getRightClicked(); if(clickedA.getPassenger() == null){ for(Rollercoaster att : Main.r.Attracties.values()){ if(att.getSeats().contains(clickedA)){ if(att.allowSit != false){ e.setCancelled(true); p.teleport(clickedA); clickedA.setPassenger(p); att.addPassagier(p, clickedA); } return; } } } } }
public static ArmorStand getArmorStand(Block hopper) { Location l = new Location(hopper.getWorld(), (double)hopper.getX() + 0.5D, (double)hopper.getY() + 1.2D, (double)hopper.getZ() + 0.5D); Entity aentity[]; int j = (aentity = l.getChunk().getEntities()).length; for(int i = 0; i < j; i++) { Entity n = aentity[i]; if((n instanceof ArmorStand) && n.getCustomName() == null && l.distanceSquared(n.getLocation()) < 0.40000000000000002D) return (ArmorStand)n; } ArmorStand hologram = ArmorStandFactory.createHidden(l); hologram.setCustomNameVisible(false); hologram.setCustomName(null); return hologram; }
public static ArmorStand getArmorStand(Block hopper) { Location l = new Location(hopper.getWorld(), (double)hopper.getX() + 0.5D, hopper.getY(), (double)hopper.getZ() + 0.5D); Entity aentity[]; int j = (aentity = l.getChunk().getEntities()).length; for(int i = 0; i < j; i++) { Entity n = aentity[i]; if((n instanceof ArmorStand) && n.getCustomName() == null && l.distanceSquared(n.getLocation()) < 0.40000000000000002D) return (ArmorStand)n; } ArmorStand hologram = ArmorStandFactory.createHidden(l); hologram.setCustomNameVisible(false); hologram.setCustomName(null); return hologram; }
public static void update(final Block b, final String name) { Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() { private final Block val$b; private final String val$name; public void run() { ArmorStand hologram = EnergyHologram.getArmorStand(b); hologram.setCustomName(ChatColor.translateAlternateColorCodes('&', name)); } { b = block; name = s; super(); } } ); }
public static void remove(final Block b) { Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() { private final Block val$b; public void run() { ArmorStand hologram = EnergyHologram.getArmorStand(b); hologram.remove(); } { b = block; super(); } } ); }
public static ArmorStand getArmorStand(Block hopper, boolean createIfNoneFound) { Location l = new Location(hopper.getWorld(), hopper.getX() + 0.5, hopper.getY() + offset, hopper.getZ() + 0.5); for (Entity n: l.getChunk().getEntities()) { if (n instanceof ArmorStand) { if (n.getCustomName() == null && l.distanceSquared(n.getLocation()) < 0.4D) return (ArmorStand) n; } } if (!createIfNoneFound) { return null; } ArmorStand hologram = ArmorStandFactory.createHidden(l); hologram.setCustomNameVisible(false); hologram.setCustomName(null); return hologram; }
/** * Force an ArmorStand to assume a pose. * @param stand * @param pose */ public static void assumePose(ArmorStand stand, ArmorPose pose) { if (!stand.isInvulnerable()) { stand.setInvulnerable(true); stand.setBasePlate(false); stand.setArms(true); MetadataManager.setMetadata(stand, "noModify", true); } assert pose != null; // Set Pose stand.setHeadPose(pose.getHead()); stand.setBodyPose(pose.getBody()); stand.setLeftArmPose(pose.getLeftArm()); stand.setRightArmPose(pose.getRightArm()); stand.setLeftLegPose(pose.getLeftLeg()); stand.setRightLegPose(pose.getRightLeg()); // Give gear. Map<EquipmentSlot, ItemStack> map = pose.getGear().toEnumMap(EquipmentSlot.class); for (EquipmentSlot slot : map.keySet()) Utils.setItem(stand, slot, map.get(slot)); }
private List<ArmorStand> checkChair(ArmorStand drop) { List<ArmorStand> drops = new ArrayList<ArmorStand>(); // Check for already existing chair items. for(Entity e : drop.getNearbyEntities(0.5, 0.5, 0.5)) { if(e != null && e instanceof ArmorStand && e.getCustomName() == "Chair") { if(e.getPassengers().isEmpty()) e.remove(); else drops.add(drop); } } if(!drops.isEmpty()) return drops; return null; }
public DeveloperRoomParkour(Hub hub, Location spawn, Location end, Location fail, Pair<Location, Location> portals, Location minusFloor, String resourcePack) { super(hub, "Salle de test n°42", "de la", "la", spawn, end, fail, 0, 0, new ArrayList<>(), 5, 9); this.expected = new ArrayList<>(); this.minusFloor = minusFloor; this.resourcePack = resourcePack; this.portalArmorStand = spawn.getWorld().spawn(portals.getKey(), ArmorStand.class); this.portalArmorStand.setGravity(false); this.portalArmorStand.setVisible(false); this.portalTask = ProximityUtils.onNearbyOf(hub, this.portalArmorStand, 2.0D, 2.0D, 2.0D, Player.class, (player) -> player.teleport(portals.getValue().clone().subtract(0.0D, 1.0D, 0.0D))); hub.getServer().getPluginManager().registerEvents(this, hub); }
public static ArmorStand makeFloatingText(String name, Location loc, double xzOffset, double yMin, double yMax, double durationSec) { loc.add(-xzOffset / 2 + (Math.random() * (xzOffset)), (Math.random() * (yMax - yMin)) + yMin, -xzOffset / 2 + (Math.random() * (xzOffset))); final ArmorStand as = (ArmorStand) REntities.createLivingEntity(CustomArmorStand.class, loc); as.setVisible(false); as.setSmall(true); as.setMarker(true); as.setGravity(false); as.setArms(false); as.setBasePlate(false); as.setCanPickupItems(false); as.setCustomName(name); as.setCustomNameVisible(true); as.setRemoveWhenFarAway(false); RScheduler.schedule(SakiCore.plugin, new Runnable() { public void run() { if (as != null && as.isValid()) as.remove(); } }, RTicks.seconds(durationSec)); return as; }
@EventHandler public void onPlayerQuit(PlayerQuitEvent event) { Entity vehicle = event.getPlayer().getVehicle(); // Let players stand up when leaving the server. if(vehicle != null && vehicle instanceof ArmorStand && vehicle.getCustomName() == "Chair") vehicle.remove(); }
private Position getNewLinePosition() { if (spawnedEntities.isEmpty()) { return position; } else { // get the last entry ArmorStand last = spawnedEntities.get(spawnedEntities.size() - 1); return Position.of(last.getLocation()).subtract(0.0d, 0.25d, 0.0d); } }
public ArrayList<ArmorStand> getSeats(){ ArrayList<ArmorStand> result = new ArrayList<ArmorStand>(); for(HashMap<Integer, ArmorStand> car : cars.values()){ result.add(car.get(2)); result.add(car.get(3)); } return result; }
@Override protected void doTick() { if (this.isSpecial) { this.counter = PetBlockHelper.doTick(this.counter, this, location -> { CustomGroundArmorstand.this.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); final PacketPlayOutEntityTeleport animation = new PacketPlayOutEntityTeleport(CustomGroundArmorstand.this); for (final Player player : ((ArmorStand)this.getArmorStand()).getWorld().getPlayers()) { ((CraftPlayer) player).getHandle().playerConnection.sendPacket(animation); } }); } super.doTick(); }
public void spawn(Location location) { final PetBlockSpawnEvent event = new PetBlockSpawnEvent(this); Bukkit.getPluginManager().callEvent(event); if (!event.isCanceled()) { NMSRegistry.accessWorldGuardSpawn(location); this.rabbit.spawn(location); final net.minecraft.server.v1_8_R1.World mcWorld = ((org.bukkit.craftbukkit.v1_8_R1.CraftWorld) location.getWorld()).getHandle(); this.setPosition(location.getX(), location.getY(), location.getZ()); mcWorld.addEntity(this, SpawnReason.CUSTOM); final net.minecraft.server.v1_8_R1.NBTTagCompound compound = new net.minecraft.server.v1_8_R1.NBTTagCompound(); compound.setBoolean("invulnerable", true); compound.setBoolean("Invisible", true); compound.setBoolean("PersistenceRequired", true); compound.setBoolean("ShowArms", true); compound.setBoolean("NoBasePlate", true); this.a(compound); ((ArmorStand)this.getArmorStand()).setBodyPose(new EulerAngle(0, 0, 2878)); ((ArmorStand)this.getArmorStand()).setLeftArmPose(new EulerAngle(2878, 0, 0)); ((ArmorStand)this.getArmorStand()).setMetadata("keep", this.getKeepField()); NMSRegistry.rollbackWorldGuardSpawn(location); ((ArmorStand)this.getArmorStand()).setCustomNameVisible(true); ((ArmorStand)this.getArmorStand()).setCustomName(this.petMeta.getPetDisplayName()); ((ArmorStand)this.getArmorStand()).setRemoveWhenFarAway(false); ((LivingEntity) this.rabbit.getEntity()).setRemoveWhenFarAway(false); this.health = ConfigPet.getInstance().getCombat_health(); if (this.petMeta == null) return; PetBlockHelper.setItemConsideringAge(this); } }
/** * Initializes the armorstand * * @param player player * @param location location * @param id id * @param data data * @param watchers watchers */ public DisplayArmorstand(Player player, Location location, int id, byte data, Set<Player> watchers) { super(); this.watchers = watchers; this.player = player; this.armorStand = new EntityArmorStand(((CraftWorld) player.getWorld()).getHandle()); final NBTTagCompound compound = new NBTTagCompound(); compound.setBoolean("invulnerable", true); compound.setBoolean("Invisible", true); compound.setBoolean("PersistenceRequired", true); compound.setBoolean("NoBasePlate", true); this.armorStand.a(compound); this.armorStand.setLocation(location.getX(), location.getY(), location.getZ(), 0, 0); this.storedId = id; this.storedData = data; ItemStackBuilder stackBuilder = new ItemStackBuilder(Material.getMaterial(id), 1, data); this.getCraftEntity().setHelmet(stackBuilder.build()); this.getCraftEntity().setBodyPose(new EulerAngle(3.15, 0, 0)); this.getCraftEntity().setLeftLegPose(new EulerAngle(3.15, 0, 0)); this.getCraftEntity().setRightLegPose(new EulerAngle(3.15, 0, 0)); this.getCraftEntity().setGlowing(true); if (((ArmorStand) this.armorStand.getBukkitEntity()).getHelmet().getType() == Material.AIR) { stackBuilder = new ItemStackBuilder(Material.SKULL_ITEM, 1, (short) 3); if (id == Material.WATER.getId() || id == Material.STATIONARY_WATER.getId()) { stackBuilder.setSkin(NMSRegistry.WATER_HEAD); } else if (id == Material.LAVA.getId() || id == Material.STATIONARY_LAVA.getId()) { stackBuilder.setSkin(NMSRegistry.LAVA_HEAD); } else { stackBuilder.setSkin(NMSRegistry.NOT_FOUND); } ((ArmorStand) this.armorStand.getBukkitEntity()).setHelmet(stackBuilder.build()); } }
/** * Spawns the armorstand */ @Override public void spawn() { final PacketPlayOutSpawnEntityLiving packetSpawn = new PacketPlayOutSpawnEntityLiving(this.armorStand); final PacketPlayOutEntityEquipment packetHead = new PacketPlayOutEntityEquipment(this.armorStand.getId(), EnumItemSlot.HEAD, CraftItemStack.asNMSCopy(((ArmorStand) this.armorStand.getBukkitEntity()).getHelmet())); this.sendPacket(packetSpawn); this.sendPacket(packetHead); }
@Override public void damage(double amount) { if (amount < -1.0) { this.hitflor = true; } else { this.health = PetBlockHelper.setDamage(this, this.health, amount, location -> { final PacketPlayOutAnimation animation = new PacketPlayOutAnimation(CustomGroundArmorstand.this, 1); for (final Player player : ((ArmorStand) this.getArmorStand()).getWorld().getPlayers()) { ((CraftPlayer) player).getHandle().playerConnection.sendPacket(animation); } }); } }
/** * Initializes the armorstand * * @param player player * @param location location * @param id id * @param data data * @param watchers watchers */ public DisplayArmorstand(Player player, Location location, int id, byte data, Set<Player> watchers) { super(); this.watchers = watchers; this.player = player; this.armorStand = new EntityArmorStand(((CraftWorld) player.getWorld()).getHandle()); final NBTTagCompound compound = new NBTTagCompound(); compound.setBoolean("invulnerable", true); compound.setBoolean("Invisible", true); compound.setBoolean("PersistenceRequired", true); compound.setBoolean("NoBasePlate", true); this.armorStand.a(compound); this.armorStand.setLocation(location.getX(), location.getY(), location.getZ(), 0, 0); this.storedId = id; this.storedData = data; ItemStackBuilder stackBuilder = new ItemStackBuilder(Material.getMaterial(id), 1, data); this.getCraftEntity().setHelmet(stackBuilder.build()); this.getCraftEntity().setBodyPose(new EulerAngle(3.15, 0, 0)); this.getCraftEntity().setLeftLegPose(new EulerAngle(3.15, 0, 0)); this.getCraftEntity().setRightLegPose(new EulerAngle(3.15, 0, 0)); if (((ArmorStand) this.armorStand.getBukkitEntity()).getHelmet().getType() == Material.AIR) { stackBuilder = new ItemStackBuilder(Material.SKULL_ITEM, 1, (short) 3); if (id == Material.WATER.getId() || id == Material.STATIONARY_WATER.getId()) { stackBuilder.setSkin(NMSRegistry.WATER_HEAD); } else if (id == Material.LAVA.getId() || id == Material.STATIONARY_LAVA.getId()) { stackBuilder.setSkin(NMSRegistry.LAVA_HEAD); } else { stackBuilder.setSkin(NMSRegistry.NOT_FOUND); } ((ArmorStand) this.armorStand.getBukkitEntity()).setHelmet(stackBuilder.build()); } }
public void spawn(Location location) { final PetBlockSpawnEvent event = new PetBlockSpawnEvent(this); Bukkit.getPluginManager().callEvent(event); if (!event.isCanceled()) { NMSRegistry.accessWorldGuardSpawn(location); this.rabbit.spawn(location); final net.minecraft.server.v1_8_R3.World mcWorld = ((org.bukkit.craftbukkit.v1_8_R3.CraftWorld) location.getWorld()).getHandle(); this.setPosition(location.getX(), location.getY(), location.getZ()); mcWorld.addEntity(this, SpawnReason.CUSTOM); final net.minecraft.server.v1_8_R3.NBTTagCompound compound = new net.minecraft.server.v1_8_R3.NBTTagCompound(); compound.setBoolean("invulnerable", true); compound.setBoolean("Invisible", true); compound.setBoolean("PersistenceRequired", true); compound.setBoolean("ShowArms", true); compound.setBoolean("NoBasePlate", true); this.a(compound); ((ArmorStand)this.getArmorStand()).setBodyPose(new EulerAngle(0, 0, 2878)); ((ArmorStand)this.getArmorStand()).setLeftArmPose(new EulerAngle(2878, 0, 0)); ((ArmorStand)this.getArmorStand()).setMetadata("keep", this.getKeepField()); NMSRegistry.rollbackWorldGuardSpawn(location); ((ArmorStand)this.getArmorStand()).setCustomNameVisible(true); ((ArmorStand)this.getArmorStand()).setCustomName(this.petMeta.getPetDisplayName()); ((ArmorStand)this.getArmorStand()).setRemoveWhenFarAway(false); ((LivingEntity) this.getEngineEntity()).setRemoveWhenFarAway(false); this.health = ConfigPet.getInstance().getCombat_health(); if (this.petMeta == null) return; PetBlockHelper.setItemConsideringAge(this); } }
public void spawn(Location location) { final PetBlockSpawnEvent event = new PetBlockSpawnEvent(this); Bukkit.getPluginManager().callEvent(event); if (!event.isCanceled()) { NMSRegistry.accessWorldGuardSpawn(location); this.rabbit.spawn(location); final net.minecraft.server.v1_8_R2.World mcWorld = ((org.bukkit.craftbukkit.v1_8_R2.CraftWorld) location.getWorld()).getHandle(); this.setPosition(location.getX(), location.getY(), location.getZ()); mcWorld.addEntity(this, SpawnReason.CUSTOM); final net.minecraft.server.v1_8_R2.NBTTagCompound compound = new net.minecraft.server.v1_8_R2.NBTTagCompound(); compound.setBoolean("invulnerable", true); compound.setBoolean("Invisible", true); compound.setBoolean("PersistenceRequired", true); compound.setBoolean("ShowArms", true); compound.setBoolean("NoBasePlate", true); this.a(compound); ((ArmorStand)this.getArmorStand()).setBodyPose(new EulerAngle(0, 0, 2878)); ((ArmorStand)this.getArmorStand()).setLeftArmPose(new EulerAngle(2878, 0, 0)); ((ArmorStand)this.getArmorStand()).setMetadata("keep", this.getKeepField()); NMSRegistry.rollbackWorldGuardSpawn(location); ((ArmorStand)this.getArmorStand()).setCustomNameVisible(true); ((ArmorStand)this.getArmorStand()).setCustomName(this.petMeta.getPetDisplayName()); ((ArmorStand)this.getArmorStand()).setRemoveWhenFarAway(false); ((LivingEntity) this.getEngineEntity()).setRemoveWhenFarAway(false); this.health = ConfigPet.getInstance().getCombat_health(); if (this.petMeta == null) return; PetBlockHelper.setItemConsideringAge(this); } }
/** * Sets the pose of * * @param angle angle */ @Override public void setHeadPose(EulerAngle angle) { ((ArmorStand) this.armorStand.getBukkitEntity()).setHeadPose(angle); final PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(this.armorStand.getId(), this.armorStand.getDataWatcher(), true); this.sendPacket(packet); }
@EventHandler(priority = EventPriority.HIGHEST) public void entityRightClickEvent(final PlayerInteractAtEntityEvent event) { if (this.manager.carryingPet.contains(event.getPlayer())) { NMSRegistry.setItemInHand19(event.getPlayer(), null, true); if (this.manager.getPetBlockController().getByPlayer(event.getPlayer()) != null) this.manager.getPetBlockController().removeByPlayer(event.getPlayer()); event.setCancelled(true); } else if (this.isPet(event.getRightClicked())) { final PetBlock petBlock = this.getPet(event.getRightClicked()); if (petBlock != null && petBlock.getPlayer().equals(event.getPlayer())) { if (ConfigPet.getInstance().isFeedingEnabled() && NMSRegistry.getItemInHand19(event.getPlayer(), false) != null && NMSRegistry.getItemInHand19(event.getPlayer(), false).getType() == Material.CARROT_ITEM) { petBlock.getEffectPipeline().playParticleEffect(event.getRightClicked().getLocation(), ConfigPet.getInstance().getFeedingClickParticleEffect()); petBlock.getEffectPipeline().playSound(event.getRightClicked().getLocation(), ConfigPet.getInstance().getFeedingClickSound()); if (NMSRegistry.getItemInHand19(event.getPlayer(), false).getAmount() == 1) event.getPlayer().getInventory().setItem(event.getPlayer().getInventory().getHeldItemSlot(), new ItemStack(Material.AIR)); else NMSRegistry.getItemInHand19(event.getPlayer(), false).setAmount(NMSRegistry.getItemInHand19(event.getPlayer(), false).getAmount() - 1); if (!this.jumped.contains(petBlock)) { this.plugin.getServer().getScheduler().runTaskLater(this.plugin, () -> PetBlockListener.this.jumped.remove(PetBlockListener.this.getPet(event.getRightClicked())), 20L); this.jumped.add(this.getPet(event.getRightClicked())); petBlock.jump(); } } else if (ConfigPet.getInstance().isFollow_carry() && (event.getPlayer().getInventory() == null || NMSRegistry.getItemInHand19(event.getPlayer(), true).getType() == Material.AIR)) { NMSRegistry.setItemInHand19(event.getPlayer(), ((ArmorStand) petBlock.getArmorStand()).getHelmet().clone(), true); this.manager.getPetBlockController().remove(petBlock); this.manager.carryingPet.add(event.getPlayer()); } } event.setCancelled(true); } }
public AbstractAmo(int range, int damages, Vector direction, GamePlayer owner, WeaponType type) { RANGE = range; DAMAGES = damages; COLOR = owner.getTeamColor(); OWNER = owner; armorStand = (ArmorStand) owner.getPlayer().getWorld().spawnEntity(owner.getPlayer().getEyeLocation(), EntityType.ARMOR_STAND); armorStand.setVisible(false); int r = 20; if(type == WeaponType.SHOOTER) r = 4; if(type == WeaponType.SNIPER) r = 2; double rng = (double) RANGE / r; if(rng > 5) rng = 5; armorStand.setVelocity(direction.multiply(rng)); lastLocation = armorStand.getLocation(); onFire(owner.getPlayer().getLocation()); task = Bukkit.getScheduler().runTaskTimer(Absorption.get(), new Runnable() { @Override public void run() { check(); play(armorStand.getLocation()); } }, 2, 1); }
@EventHandler public void onEntityDamage(EntityDamageEvent e) { if(e.getEntity() instanceof ArmorStand || e.getEntity() instanceof Item) e.setCancelled(true); if(e.getEntity() instanceof Player) { e.setCancelled(true); if(e.getCause() == DamageCause.FALL) { GamePlayer player = Absorption.getPlayer((Player) e.getEntity()); if(player == null) return; player.damage((int) e.getDamage()); } } }
@EventHandler public void onArmorSpawn(CreatureSpawnEvent evt) { if (evt.getEntityType() != EntityType.ARMOR_STAND || placing == null) return; ArmorStand as = (ArmorStand) evt.getEntity(); as.setArms(placing.isArms()); as.setSmall(placing.isSmall()); placing = null; }
public static void enableArmorSlots(ArmorStand armorStand, boolean enabled) { CraftArmorStand craftArmorStand = (CraftArmorStand) armorStand; NBTTagCompound nbt = new NBTTagCompound(); craftArmorStand.getHandle().b(nbt); nbt.setInt("DisabledSlots", enabled ? 0 : 0x1f1f00); craftArmorStand.getHandle().a(nbt); }