Package org.spout.vanilla.component.entity.living.passive

Examples of org.spout.vanilla.component.entity.living.passive.Sheep


  }

  @Override
  public void onInteract(Entity entity, Entity other, Action action) {
    if (action == Action.RIGHT_CLICK) {
      Sheep sheep = other.get(Sheep.class);
      if (sheep == null) {
        return;
      }

      Slot inv = PlayerUtil.getHeldSlot(entity);
      if (inv != null && inv.get() != null) {
        // get color from holding item
        sheep.setColor(Wool.WoolColor.getById((short) (0xF - inv.get().getData())));
        if (!PlayerUtil.isCostSuppressed(entity)) {
          inv.addAmount(-1);
        }
      }
    }
View Full Code Here


  }

  @Override
  public void onInteract(Entity entity, Entity other, Action action) {
    if (action == Action.RIGHT_CLICK) {
      Sheep sheep = other.get(Sheep.class);

      if (sheep == null) {
        return;
      }

      if (sheep.isSheared()) {
        //TODO: Also return if this is a baby sheep
        return;
      }
      short col = sheep.getColor().getData();
      ItemStack itemStack = new ItemStack(VanillaMaterials.WOOL, col, GenericMath.getRandom().nextInt(3) + 1);

      SheepShearedEvent event = VanillaPlugin.getInstance().getEngine().getEventManager().callEvent(new SheepShearedEvent(other, entity, itemStack));

      if (event.isCancelled()) {
        return;
      }

      sheep.setSheared(true);

      Item.dropNaturally(other.getPhysics().getPosition(), event.getItemStack());
    }
  }
View Full Code Here

TOP

Related Classes of org.spout.vanilla.component.entity.living.passive.Sheep

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.