类org.bukkit.entity.Painting源码实例Demo

下面列出了怎么用org.bukkit.entity.Painting的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: PGM   文件: RegionMatchModule.java
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;
  }
}
 
源代码2 项目: ProjectAres   文件: EventRuleMatchModule.java
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;
    }
}
 
源代码3 项目: Carbon   文件: ItemHanging.java
public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) {
	if (l == 0) {
		return false;
	}
	if (l == 1) {
		return false;
	}
	int i1 = Direction.e[l];
	EntityHanging entityhanging = a(world, i, j, k, i1);
	if (!entityhuman.a(i, j, k, l, itemstack)) {
		return false;
	}
	if ((entityhanging != null) && (entityhanging.survives())) {
		if (!world.isStatic) {
			Player who = entityhuman == null ? null : (Player) entityhuman.getBukkitEntity();
			Block blockClicked = world.getWorld().getBlockAt(i, j, k);
			BlockFace blockFace = CraftBlock.notchToBlockFace(l);

			HangingPlaceEvent event = new HangingPlaceEvent((Hanging) entityhanging.getBukkitEntity(), who, blockClicked, blockFace);
			world.getServer().getPluginManager().callEvent(event);

			PaintingPlaceEvent paintingEvent = null;
			if ((entityhanging instanceof EntityPainting)) {
				paintingEvent = new PaintingPlaceEvent((Painting) entityhanging.getBukkitEntity(), who, blockClicked, blockFace);
				paintingEvent.setCancelled(event.isCancelled());
				world.getServer().getPluginManager().callEvent(paintingEvent);
			}
			if ((event.isCancelled()) || ((paintingEvent != null) && (paintingEvent.isCancelled()))) {
				return false;
			}
			world.addEntity(entityhanging);
		}
		itemstack.count -= 1;
	}
	return true;
}
 
源代码4 项目: civcraft   文件: BlockListener.java
@EventHandler(priority = EventPriority.HIGHEST)
public void OnPlayerInteractEntityEvent(PlayerInteractEntityEvent event) {

	if (event.getRightClicked().getType().equals(EntityType.HORSE)) {
		if (!HorseModifier.isCivCraftHorse((LivingEntity)event.getRightClicked())) {
			CivMessage.sendError(event.getPlayer(), "Invalid horse! You can only get horses from stable structures.");
			event.setCancelled(true);
			event.getRightClicked().remove();
			return;
		}
	}

	ItemStack inHand = event.getPlayer().getItemInHand();
		if (inHand != null) {

			boolean denyBreeding = false;
			switch (event.getRightClicked().getType()) {
			case COW:
			case SHEEP:
			case MUSHROOM_COW:
				if (inHand.getType().equals(Material.WHEAT)) {
					denyBreeding = true;
				}
				break;
			case PIG:
				if (inHand.getType().equals(Material.CARROT_ITEM)) {
					denyBreeding = true;
				}
				break;
			case HORSE:
				if (inHand.getType().equals(Material.GOLDEN_APPLE) ||
						inHand.getType().equals(Material.GOLDEN_CARROT)) {
					CivMessage.sendError(event.getPlayer(), "You cannot breed horses, buy them from the stable.");
					event.setCancelled(true);
					return;
				}
				break;
			case CHICKEN:
				if (inHand.getType().equals(Material.SEEDS) ||
					inHand.getType().equals(Material.MELON_SEEDS) ||
					inHand.getType().equals(Material.PUMPKIN_SEEDS)) {
					denyBreeding = true;
				}
				break;
			default:
				break;
			}

			if (denyBreeding) {
				ChunkCoord coord = new ChunkCoord(event.getPlayer().getLocation());
				Pasture pasture = Pasture.pastureChunks.get(coord);

				if (pasture == null) {
					CivMessage.sendError(event.getPlayer(), "You cannot breed mobs in the wild, take them to a pasture.");
					event.setCancelled(true);
				} else {
						int loveTicks;
						NBTTagCompound tag = new NBTTagCompound();
						((CraftEntity)event.getRightClicked()).getHandle().c(tag);
						loveTicks = tag.getInt("InLove");

						if (loveTicks == 0) {	
							if(!pasture.processMobBreed(event.getPlayer(), event.getRightClicked().getType())) {
								event.setCancelled(true);
							}
						} else {
							event.setCancelled(true);
						}
				}

				return;			
			}
		}
	if (!(event.getRightClicked() instanceof ItemFrame) && !(event.getRightClicked() instanceof Painting)) {
		return;
	}

	coord.setFromLocation(event.getPlayer().getLocation());
	TownChunk tc = CivGlobal.getTownChunk(coord);
	if (tc == null) {
		return;
	}

	Resident resident = CivGlobal.getResident(event.getPlayer().getName());
	if (resident == null) {
		return;
	}

	if(!tc.perms.hasPermission(PlotPermissions.Type.INTERACT, resident)) {
		event.setCancelled(true);
		CivMessage.sendErrorNoRepeat(event.getPlayer(), "You do not have permission to interact with this painting/itemframe.");
	}

}
 
public WrapperPlayServerSpawnEntityPainting(Painting painting) {
    super(fromPainting(painting), TYPE);
}
 
private static PacketContainer fromPainting(Painting painting) {
    if (entityConstructor == null)
    	entityConstructor = ProtocolLibrary.getProtocolManager().createPacketConstructor(TYPE, (Entity) painting);
    return entityConstructor.createPacket((Entity) painting);
}
 
 类所在包
 类方法
 同包方法