本文整理汇总了Java中org.bukkit.entity.Hanging类的典型用法代码示例。如果您正苦于以下问题:Java Hanging类的具体用法?Java Hanging怎么用?Java Hanging使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Hanging类属于org.bukkit.entity包,在下文中一共展示了Hanging类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: move
import org.bukkit.entity.Hanging; //导入依赖的package包/类
public void move(double d0, double d1, double d2) {
if (!this.world.isStatic && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) {
if (this.dead) return; // CraftBukkit
// CraftBukkit start - fire break events
// TODO - Does this need its own cause? Seems to only be triggered by pistons
HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.PHYSICS);
this.world.getServer().getPluginManager().callEvent(event);
if (this.dead || event.isCancelled()) {
return;
}
// CraftBukkit end
this.die();
this.b((Entity) null);
}
}
示例2: onEntityDamage
import org.bukkit.entity.Hanging; //导入依赖的package包/类
@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
if(event.getEntity() != null) {
Lot lot = this.module.getLotManager().getLot(event.getEntity().getLocation());
Town town = this.module.getLotManager().getTown(event.getEntity().getLocation());
if(event.getEntity() instanceof Player && (lot != null || town != null)) {
event.setCancelled(true);
} else if(lot != null && event instanceof EntityDamageByEntityEvent && (event.getEntity() instanceof Hanging || event.getEntity() instanceof ArmorStand)) {
EntityDamageByEntityEvent entityEvent = (EntityDamageByEntityEvent) event;
if(entityEvent.getDamager() instanceof Player && !entityEvent.getDamager().getName().equals(lot.getOwner()) && !entityEvent.getDamager().hasPermission(LotPermissions.BUILD_ANYWHERE)) {
sendMessage(entityEvent.getDamager(), "lots.cannot-do");
event.setCancelled(true);
}
}
}
}
示例3: getTargetEntities
import org.bukkit.entity.Hanging; //导入依赖的package包/类
@Override
public Collection<Entity> getTargetEntities()
{
if (cloneTarget == null || mage == null) return null;
if (mode == BrushMode.CLONE || mode == BrushMode.REPLICATE || mode == BrushMode.SCHEMATIC)
{
List<Entity> targetData = new ArrayList<Entity>();
World targetWorld = cloneTarget.getWorld();
List<Entity> targetEntities = targetWorld.getEntities();
for (Entity entity : targetEntities) {
// Schematics currently only deal with Hanging entities
if (mode == BrushMode.SCHEMATIC && !(entity instanceof Hanging)) continue;
// Note that we ignore players and NPCs
if (!(entity instanceof Player) && !mage.getController().isNPC(entity)) {
targetData.add(entity);
}
}
return targetData;
}
return null;
}
示例4: moveEntity
import org.bukkit.entity.Hanging; //导入依赖的package包/类
public void moveEntity(double p_70091_1_, double p_70091_3_, double p_70091_5_)
{
if (!this.worldObj.isRemote && !this.isDead && p_70091_1_ * p_70091_1_ + p_70091_3_ * p_70091_3_ + p_70091_5_ * p_70091_5_ > 0.0D)
{
if (this.isDead)
{
return; // CraftBukkit
}
// CraftBukkit start
// TODO - Does this need its own cause? Seems to only be triggered by pistons
HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.PHYSICS);
this.worldObj.getServer().getPluginManager().callEvent(event);
if (this.isDead || event.isCancelled())
{
return;
}
// CraftBukkit end
this.setDead();
this.onBroken((Entity)null);
}
}
示例5: onHangingPlace
import org.bukkit.entity.Hanging; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onHangingPlace(HangingPlaceEvent event)
{
Hanging hanging = event.getEntity();
HangingPlace action;
if (hanging instanceof Painting)
{
action = this.newAction(PaintingPlace.class, hanging.getWorld());
if (action != null)
{
((PaintingPlace)action).art = ((Painting)hanging).getArt();
}
}
else
{
action = this.newAction(HangingPlace.class, hanging.getWorld());
}
if (action != null)
{
action.setLocation(hanging.getLocation());
action.setHanging(hanging);
action.setPlayer(event.getPlayer());
this.logAction(action);
}
}
示例6: move
import org.bukkit.entity.Hanging; //导入依赖的package包/类
public void move(double d0, double d1, double d2) {
if (!this.world.isClientSide && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) {
if (this.dead) return; // CraftBukkit
// CraftBukkit start - fire break events
// TODO - Does this need its own cause? Seems to only be triggered by pistons
HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.PHYSICS);
this.world.getServer().getPluginManager().callEvent(event);
if (this.dead || event.isCancelled()) {
return;
}
// CraftBukkit end
this.die();
this.a((Entity) null);
}
}
示例7: checkItemFrameItemRemove
import org.bukkit.entity.Hanging; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void checkItemFrameItemRemove(EntityDamageByEntityEvent event) {
// This event is fired when popping an item out of an item frame, without breaking the frame itself
if(event.getEntity() instanceof ItemFrame && ((ItemFrame) event.getEntity()).getItem() != null) {
this.handleHangingBreak(event, (Hanging) event.getEntity(), event.getDamager());
}
}
示例8: handleHangingBreak
import org.bukkit.entity.Hanging; //导入依赖的package包/类
private void handleHangingBreak(Event event, Hanging hanging, Entity breaker) {
BlockState blockState = getHangingBlockState(hanging);
if(blockState == null) return;
IEventQuery query = makeBlockQuery(event, breaker, blockState);
for(EventRule rule : this.ruleContext.get(EventRuleScope.BLOCK_BREAK)) {
if(rule.region().contains(blockState)) {
if(processQuery(rule, query)) {
sendCancelMessage(rule, query);
if(this.useRegionPriority) break;
}
}
}
}
示例9: getHangingType
import org.bukkit.entity.Hanging; //导入依赖的package包/类
private static Material getHangingType(Hanging hanging) {
if(hanging instanceof Painting) {
return Material.PAINTING;
} else if(hanging instanceof ItemFrame) {
return Material.ITEM_FRAME;
} else if(hanging instanceof LeashHitch) {
return Material.LEASH;
} else {
return null;
}
}
示例10: serializeState
import org.bukkit.entity.Hanging; //导入依赖的package包/类
public static String serializeState(Entity entity) {
YamlConfiguration yaml = new YamlConfiguration();
if (Support.ARMOR_STAND && entity instanceof ArmorStand) {
EulerAngleSerializer eas = EulerAngleSerializer.getInstance();
ArmorStand stand = (ArmorStand) entity;
yaml.set(PITCH, stand.getLocation().getPitch());
yaml.set(YAW, stand.getLocation().getYaw());
yaml.set(ARMOR_STAND_HELMET, stand.getHelmet());
yaml.set(ARMOR_STAND_CHESTPLATE, stand.getChestplate());
yaml.set(ARMOR_STAND_LEGGINGS, stand.getLeggings());
yaml.set(ARMOR_STAND_BOOTS, stand.getBoots());
yaml.set(ARMOR_STAND_HAND, stand.getItemInHand());
yaml.set(ARMOR_STAND_POSE_HEAD, eas.serialize(stand.getHeadPose()));
yaml.set(ARMOR_STAND_POSE_BODY, eas.serialize(stand.getBodyPose()));
yaml.set(ARMOR_STAND_POSE_ARM_LEFT, eas.serialize(stand.getLeftArmPose()));
yaml.set(ARMOR_STAND_POSE_ARM_RIGHT, eas.serialize(stand.getRightArmPose()));
yaml.set(ARMOR_STAND_POSE_LEG_LEFT, eas.serialize(stand.getLeftLegPose()));
yaml.set(ARMOR_STAND_POSE_LEG_RIGHT, eas.serialize(stand.getRightLegPose()));
yaml.set(ARMOR_STAND_ARMS, stand.hasArms());
yaml.set(ARMOR_STAND_BASE_PLATE, stand.hasBasePlate());
yaml.set(ARMOR_STAND_GRAVITY, stand.hasGravity());
yaml.set(ARMOR_STAND_SMALL, stand.isSmall());
yaml.set(ARMOR_STAND_VISIBLE, stand.isVisible());
} else if (entity instanceof Hanging) {
yaml.set(HANGING_FACING, ((Hanging) entity).getFacing().name());
if (entity instanceof ItemFrame) {
yaml.set(ITEM_FRAME_ITEM, ((ItemFrame) entity).getItem());
yaml.set(ITEM_FRAME_ROTATION, ((ItemFrame) entity).getRotation().name());
} else if (entity instanceof Painting) {
yaml.set(PAINTING_ART, ((Painting) entity).getArt().name());
}
}
return yaml.saveToString();
}
示例11: onHangingBreak
import org.bukkit.entity.Hanging; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onHangingBreak(HangingBreakEvent event) {
Hanging hanging = event.getEntity();
if (event.getCause().equals(RemoveCause.OBSTRUCTION)) {
hanging.getLocation().getBlock().breakNaturally();
event.setCancelled(true);
} else if (event.getCause().equals(RemoveCause.EXPLOSION)) {
event.setCancelled(true);
}
}
示例12: clearMobs
import org.bukkit.entity.Hanging; //导入依赖的package包/类
private void clearMobs(World world) {
for (Entity entity : world.getEntities()) {
if (!(entity instanceof Hanging) && !(entity instanceof Player)) {
entity.remove();
}
}
}
示例13: onEntityDamage
import org.bukkit.entity.Hanging; //导入依赖的package包/类
/**
* On entity damage.
*
* @param event the event
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityDamage(EntityDamageEvent event) {
if (conf.isOverrideExplosions()
&& event.getEntity() instanceof Hanging
&& (event.getCause() == DamageCause.BLOCK_EXPLOSION || event.getCause() == DamageCause.ENTITY_EXPLOSION
|| event.getCause() == DamageCause.PROJECTILE)) {
// Check for ItemFrame
Factoid.getThisPlugin().iLog().write("Cancel HangingBreak : " + event.getEntity() + ", Cause: " + event.getCause());
event.setCancelled(true);
}
}
示例14: logAttachedBlocks
import org.bukkit.entity.Hanging; //导入依赖的package包/类
public static void logAttachedBlocks(LogListener ll, EventManager em, Block block, ActionBlock action)
{
if (!block.getType().isSolid() && !(block.getType() == SUGAR_CANE_BLOCK))
{
return; // cannot have attached
}
for (Block aBlock : BlockUtil.getAttachedBlocks(block))
{
em.fireEvent(new BlockPreBreakEvent(aBlock.getLocation(), action));
}
for (Block dBlock : BlockUtil.getDetachableBlocksOnTop(block))
{
if (isNotUpperDoorHalf(dBlock)) // ignore upper door halfs
{
em.fireEvent(new BlockPreBreakEvent(dBlock.getLocation(), action));
}
}
if (ll.isActive(HangingBreak.class, block.getWorld()))
{
Location location = block.getLocation();
Location entityLocation = block.getLocation();
for (Entity entity : block.getChunk().getEntities())
{
if (entity instanceof Hanging && location.distanceSquared(entity.getLocation(entityLocation)) < 4)
{
em.fireEvent(new HangingPreBreakEvent(entityLocation, action));
}
}
}
}
示例15: onLightningStrike
import org.bukkit.entity.Hanging; //导入依赖的package包/类
public void onLightningStrike(EntityLightning entitylightning) {
// CraftBukkit start
final org.bukkit.entity.Entity thisBukkitEntity = this.getBukkitEntity();
final org.bukkit.entity.Entity stormBukkitEntity = entitylightning.getBukkitEntity();
final PluginManager pluginManager = Bukkit.getPluginManager();
if (thisBukkitEntity instanceof Hanging) {
HangingBreakByEntityEvent hangingEvent = new HangingBreakByEntityEvent((Hanging) thisBukkitEntity, stormBukkitEntity);
pluginManager.callEvent(hangingEvent);
if (hangingEvent.isCancelled()) {
return;
}
}
if (this.fireProof) {
return;
}
CraftEventFactory.entityDamage = entitylightning;
if (!this.damageEntity(DamageSource.LIGHTNING, 5.0F)) {
CraftEventFactory.entityDamage = null;
return;
}
// CraftBukkit end
++this.fireTicks;
if (this.fireTicks == 0) {
// CraftBukkit start - Call a combust event when lightning strikes
EntityCombustByEntityEvent entityCombustEvent = new EntityCombustByEntityEvent(stormBukkitEntity, thisBukkitEntity, 8);
pluginManager.callEvent(entityCombustEvent);
if (!entityCombustEvent.isCancelled()) {
this.setOnFire(entityCombustEvent.getDuration());
}
// CraftBukkit end
}
}