本文整理汇总了Java中org.bukkit.entity.Spider类的典型用法代码示例。如果您正苦于以下问题:Java Spider类的具体用法?Java Spider怎么用?Java Spider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Spider类属于org.bukkit.entity包,在下文中一共展示了Spider类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: on
import org.bukkit.entity.Spider; //导入依赖的package包/类
@EventHandler
public void on(EntityDeathEvent event) {
if (!(event.getEntity() instanceof Spider)) return;
Entity entity = ((CraftEntity) event.getEntity()).getHandle();
// spawn 5 random webs
for (int i = 0; i < 5; i++) {
spawnRandomWeb(entity);
}
// spawn 30 random particle effects
for (int i = 0; i < 30; i++) {
spawnRandomRedstoneParticle(entity);
}
}
示例2: onEntityBendingDeath
import org.bukkit.entity.Spider; //导入依赖的package包/类
@EventHandler
public void onEntityBendingDeath(EntityBendingDeathEvent event) {
Entity v = event.getVictim();
Element e = CoreAbility.getAbility(event.getAbility()).getElement();
int xp;
if(v == null || e == null)
return;
if(v instanceof Player) {
xp = 25 + (int)(Math.random() * ((35 - 25) + 1));
}
else if(v instanceof Zombie || v instanceof Creeper || v instanceof Witch || v instanceof Skeleton || v instanceof Guardian || v instanceof Spider) {
xp = 13 + (int)(Math.random() * ((22 - 13) + 1));
}
else {
xp = 3 + (int)(Math.random() * ((8 - 3) + 1));
}
BendingExp.addExp(event.getAttacker(), e, xp);
}
示例3: effect
import org.bukkit.entity.Spider; //导入依赖的package包/类
@Override
public boolean effect(Event event, Player player) {
// List<String> lore = e.getBow().getItemMeta().getLore();
// if(!lore.contains(placeHolder)) {
// for(int i = descriptionSize; i != 0; i--)
// lore.remove(i);
// e.getProjectile().setMetadata("ce." + this.getOriginalName(), new FixedMetadataValue(main, writeType(lore)));
// player.setMetadata("ce.CanUnleashBeasts", null);
// } else
// e.getProjectile().setMetadata("ce." + this.getOriginalName(), null);
if(event instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
if(e.getDamager() != player)
return false;
Entity ent = e.getEntity();
Location loc = ent.getLocation();
World w = ent.getWorld();
if(ent instanceof Silverfish || ent instanceof EnderDragon || ent instanceof Spider || ent instanceof Slime || ent instanceof Ghast || ent instanceof MagmaCube || ent instanceof CaveSpider || (ent instanceof Wolf && ((Wolf) ent).isAngry()) || ent instanceof PigZombie) {
e.setDamage(e.getDamage()*DamageMultiplication);
w.playEffect(loc, Effect.SMOKE, 50);
w.playEffect(loc, Effect.MOBSPAWNER_FLAMES, 50);
EffectManager.playSound(loc, "BLOCK_PISTON_RETRACT", 1.3f, 3f);
return true;
} else if (ent instanceof Player) {
for(int i = 0; i < MaximumMobs; i++) {
if(rand.nextInt(100) < MobAppearanceChance) {
w.spawnEntity(loc, rand.nextInt(2) == 1 ? EntityType.SPIDER : EntityType.SLIME);
w.playEffect(loc, Effect.MOBSPAWNER_FLAMES, 30);
w.playEffect(loc, Effect.SMOKE, 30);
EffectManager.playSound(loc, "BLOCK_ANVIL_BREAK", 0.3f, 0.1f);
}
}
}
}
return false;
}
示例4: CanarySpider
import org.bukkit.entity.Spider; //导入依赖的package包/类
public CanarySpider(net.canarymod.api.entity.living.monster.Spider entity) {
super(entity);
}
示例5: onEntitySpawn
import org.bukkit.entity.Spider; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntitySpawn(CreatureSpawnEvent event) {
//do nothing for non-natural spawns
if (event.getSpawnReason() != SpawnReason.NATURAL)
return;
if (ConfigData.managedWorld == null || event.getLocation().getWorld() != ConfigData.managedWorld)
return;
//when an animal naturally spawns, grow grass around it
Entity entity = event.getEntity();
if (entity instanceof Animals && ConfigData.regrowGrass)
this.regrow(entity.getLocation().getBlock(), 4);
//when a monster spawns, sometimes spawn animals too
if (entity instanceof Monster && ConfigData.respawnAnimals) {
//only do this if the spawn is in the newest region
if (!Region.getOpenRegion().equals(Region.fromLocation(entity.getLocation())))
return;
//if it's on grass, there's a 1/100 chance it will also spawn a group of animals
Block underBlock = event.getLocation().getBlock().getRelative(BlockFace.DOWN);
if (underBlock.getType() == Material.GRASS && --this.respawnAnimalCounter == 0) {
this.respawnAnimalCounter = 100;
//check the chunk for other animals
Chunk chunk = entity.getLocation().getChunk();
Entity[] entities = chunk.getEntities();
for (int i = 0; i < entities.length; i++) {
if (entity instanceof Animals)
return;
}
EntityType animalType = null;
//decide what to spawn based on the type of monster
if (entity instanceof Creeper)
animalType = EntityType.COW;
else if (entity instanceof Zombie)
animalType = EntityType.CHICKEN;
else if (entity instanceof Spider)
animalType = EntityType.PIG;
else if (entity instanceof Enderman)
animalType = EntityType.SHEEP;
//spawn an animal at the entity's location and regrow some grass
if (animalType != null) {
entity.getWorld().spawnEntity(entity.getLocation(), animalType);
entity.getWorld().spawnEntity(entity.getLocation(), animalType);
this.regrow(entity.getLocation().getBlock(), 4);
}
}
}
}
示例6: teleportCheck
import org.bukkit.entity.Spider; //导入依赖的package包/类
/** Checks that player is not trying to combatlog/is allowed to teleport
* Returns an error message to be displayed if the player is not allowed
* to teleport
* Returns null if the player is allowed to teleport
*/
private static String teleportCheck(Player player) {
Location pLoc = player.getLocation();
World world = player.getWorld();
/* Check if there are any players within 50 blocks */
for (Player p : world.getPlayers()) {
if (!p.equals(player)
&& p.getLocation().distance(pLoc) < 50
&& player.canSee(p)
&& !p.isDead()) {
return ChatColor.RED + "You cannot use this command while within 50 blocks of any other players.";
}
}
/* Check if there are any hostile mobs within 5 blocks */
for (Entity entity : world.getEntitiesByClasses(
Blaze.class,
CaveSpider.class,
Creeper.class,
Enderman.class,
Ghast.class,
MagmaCube.class,
PigZombie.class,
Skeleton.class,
Silverfish.class,
Slime.class,
Spider.class,
Witch.class,
Zombie.class)) {
if (entity.getLocation().distance(pLoc) < 5) {
return ChatColor.RED + "You cannot use this command while within 5 blocks of any hostile mobs.";
}
}
/* Check if the player is falling */
if (player.getVelocity().getY() < -0.079
|| player.getVelocity().getY() > 0.08) {
return ChatColor.RED + "You cannot use this command while falling.";
}
/* Check if the player is burning */
if (player.getFireTicks() > 0
&& !player.hasPotionEffect(
PotionEffectType.FIRE_RESISTANCE)) {
return ChatColor.RED + "You cannot use this command while on fire.";
}
/* Default to allow teleport */
return null;
}
示例7: RemoteSpider
import org.bukkit.entity.Spider; //导入依赖的package包/类
public RemoteSpider(int inID, RemoteSpiderEntity inEntity, EntityManager inManager)
{
super(inID, RemoteEntityType.Spider, inManager);
this.m_entity = inEntity;
}