本文整理汇总了Java中org.bukkit.entity.Ghast类的典型用法代码示例。如果您正苦于以下问题:Java Ghast类的具体用法?Java Ghast怎么用?Java Ghast使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Ghast类属于org.bukkit.entity包,在下文中一共展示了Ghast类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCreatureType
import org.bukkit.entity.Ghast; //导入依赖的package包/类
public CreatureType getCreatureType(EntityType entityType) {
if (Monster.class.isAssignableFrom(entityType.getEntityClass())
|| WaterMob.class.isAssignableFrom(entityType.getEntityClass())
|| Slime.class.isAssignableFrom(entityType.getEntityClass())
|| Ghast.class.isAssignableFrom(entityType.getEntityClass())
) {
return CreatureType.MONSTER;
} else if (Animals.class.isAssignableFrom(entityType.getEntityClass())) {
return CreatureType.ANIMAL;
} else if (Villager.class.isAssignableFrom(entityType.getEntityClass())) {
return CreatureType.VILLAGER;
} else if (Golem.class.isAssignableFrom(entityType.getEntityClass())) {
return CreatureType.GOLEM;
}
return CreatureType.UNKNOWN;
}
示例2: checkLimits
import org.bukkit.entity.Ghast; //导入依赖的package包/类
private void checkLimits(Cancellable event, EntityType entityType, Location location) {
if (entityType == null) {
return; // Only happens on "other-plugins", i.e. EchoPet
}
String islandName = WorldGuardHandler.getIslandNameAt(location);
if (islandName == null) {
event.setCancelled(true); // Only allow spawning on active islands...
return;
}
if (entityType.getEntityClass().isAssignableFrom(Ghast.class) && location.getWorld().getEnvironment() != World.Environment.NETHER) {
// Disallow ghasts for now...
event.setCancelled(true);
return;
}
us.talabrek.ultimateskyblock.api.IslandInfo islandInfo = plugin.getIslandInfo(islandName);
if (islandInfo == null) {
// Disallow spawns on inactive islands
event.setCancelled(true);
return;
}
if (!plugin.getLimitLogic().canSpawn(entityType, islandInfo)) {
event.setCancelled(true);
}
}
示例3: onEntityExplodeEvent
import org.bukkit.entity.Ghast; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onEntityExplodeEvent(EntityExplodeEvent event) {
AttackType attackType = AttackType.UNKNOWN;
Entity attacker = event.getEntity();
if (attacker instanceof TNTPrimed) {
attackType = AttackType.TNT;
} else if (attacker instanceof Creeper) {
attackType = AttackType.CREEPER;
} else if (attacker instanceof Fireball) {
if (((Fireball) attacker).getShooter() instanceof Ghast) {
attackType = AttackType.GHAST;
}
}
if (plugin.getChestSettings().allowDestroyBy(attackType)) {
return;
}
for (Iterator<Block> it = event.blockList().iterator(); it.hasNext();) {
Block block = it.next();
if (isProtected(block)) {
it.remove();
}
}
}
示例4: onGhastShoot
import org.bukkit.entity.Ghast; //导入依赖的package包/类
@EventHandler
public void onGhastShoot(ProjectileLaunchEvent event) {
if (event.getEntity() instanceof LargeFireball) {
// ghast fireball
LargeFireball frb = (LargeFireball) event.getEntity();
if (frb.getShooter() instanceof Ghast) {
Ghast g = (Ghast) frb.getShooter();
DroneFighter f = getFighter(g);
if (f == null) {
g.remove();
//System.out.println("f for ghast is null, removing!");
event.setCancelled(true);
} else {
event.setCancelled(true);
//System.out.println("Dud fire!");
}
}
}
}
示例5: onEntityDeath
import org.bukkit.entity.Ghast; //导入依赖的package包/类
@EventHandler
public void onEntityDeath(EntityDeathEvent ev) {
if (ev.getEntity() instanceof Ghast) {
Bukkit.getLogger().info("Modifying drops for Ghast");
List<ItemStack> drops = new ArrayList<ItemStack>(ev.getDrops());
ev.getDrops().clear();
for (ItemStack i : drops) {
if (i.getType() == Material.GHAST_TEAR) {
Bukkit.getLogger().info("Added "+i.getAmount()+" ghast tear(s)");
ev.getDrops().add(new ItemStack(Material.GOLD_INGOT,i.getAmount()));
} else {
Bukkit.getLogger().info("Added "+i.getAmount()+" "+i.getType().toString());
ev.getDrops().add(i);
}
}
}
}
示例6: getFighter
import org.bukkit.entity.Ghast; //导入依赖的package包/类
DroneFighter getFighter(Ghast g) {
for (DroneFighter f : activeFighters) {
if (f.getGhast() == g) {
return f;
}
}
return null;
}
示例7: DroneFighter
import org.bukkit.entity.Ghast; //导入依赖的package包/类
public DroneFighter(Player target){
this.target = target;
Location l = getSafeLocationNearTarget();
if(l == null) return;
myGhast = (Ghast) target.getWorld().spawnEntity(l, EntityType.GHAST);
target.playSound(myGhast.getLocation(), Sound.PORTAL_TRAVEL, 2.0F, 2.0F);
myGhast.getWorld().playEffect(myGhast.getLocation(), Effect.ENDER_SIGNAL, 0);
}
示例8: effect
import org.bukkit.entity.Ghast; //导入依赖的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;
}
示例9: CanaryGhast
import org.bukkit.entity.Ghast; //导入依赖的package包/类
public CanaryGhast(net.canarymod.api.entity.living.monster.Ghast entity) {
super(entity);
}
示例10: getGhast
import org.bukkit.entity.Ghast; //导入依赖的package包/类
public Ghast getGhast(){
return myGhast;
}
示例11: teleportCheck
import org.bukkit.entity.Ghast; //导入依赖的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;
}
示例12: onIgnite
import org.bukkit.entity.Ghast; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onIgnite(BlockIgniteEvent event)
{
BlockState oldState = event.getBlock().getState();
ActionBlock action;
switch (event.getCause())
{
case FIREBALL:
action = this.newAction(IgniteFireball.class, oldState.getWorld());
if (action != null)
{
ProjectileSource shooter = ((Fireball)event.getIgnitingEntity()).getShooter();
if (shooter instanceof Entity)
{
((IgniteFireball)action).setShooter((Entity)shooter);
if (shooter instanceof Ghast)
{
LivingEntity target = BukkitUtils.getTarget((Ghast)shooter);
if (target instanceof Player)
{
((IgniteFireball)action).setPlayer((Player)target);
}
}
else if (shooter instanceof Player)
{
((IgniteFireball)action).setPlayer((Player)shooter);
}
}
}
break;
case LAVA:
action = this.newAction(IgniteLava.class, oldState.getWorld());
if (action != null)
{
((IgniteLava)action).setSource(event.getIgnitingBlock().getLocation());
}
break;
case LIGHTNING:
action = this.newAction(IgniteLightning.class, oldState.getWorld());
break;
case FLINT_AND_STEEL:
action = this.newAction(IgniteLighter.class, oldState.getWorld());
if (action != null && event.getPlayer() != null)
{
((IgniteLighter)action).setPlayer(event.getPlayer());
}
break;
case ENDER_CRYSTAL:
case EXPLOSION:
action = this.newAction(IgniteOther.class, oldState.getWorld());
break;
case SPREAD:
return;
default:
this.module.getLog().warn("Unknown IgniteCause! {}", event.getCause().name());
return;
}
if (action != null)
{
action.setOldBlock(oldState);
action.setNewBlock(FIRE);
action.setLocation(oldState.getLocation());
this.logAction(action);
}
}
示例13: RemoteGhast
import org.bukkit.entity.Ghast; //导入依赖的package包/类
public RemoteGhast(int inID, RemoteGhastEntity inEntity, EntityManager inManager)
{
super(inID, RemoteEntityType.Ghast, inManager);
this.m_entity = inEntity;
}