org.bukkit.entity.Painting Java Examples
The following examples show how to use
org.bukkit.entity.Painting.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RegionMatchModule.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
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; } }
Example #2
Source File: EventRuleMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
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; } }
Example #3
Source File: ItemHanging.java From Carbon with GNU Lesser General Public License v3.0 | 5 votes |
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; }
Example #4
Source File: BlockListener.java From civcraft with GNU General Public License v2.0 | 4 votes |
@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."); } }
Example #5
Source File: WrapperPlayServerSpawnEntityPainting.java From PacketWrapper with GNU Lesser General Public License v3.0 | 4 votes |
public WrapperPlayServerSpawnEntityPainting(Painting painting) { super(fromPainting(painting), TYPE); }
Example #6
Source File: WrapperPlayServerSpawnEntityPainting.java From PacketWrapper with GNU Lesser General Public License v3.0 | 4 votes |
private static PacketContainer fromPainting(Painting painting) { if (entityConstructor == null) entityConstructor = ProtocolLibrary.getProtocolManager().createPacketConstructor(TYPE, (Entity) painting); return entityConstructor.createPacket((Entity) painting); }