Skip to content

Commit

Permalink
Fixed AnimalHarvester sending wool into the abyss.
Browse files Browse the repository at this point in the history
  • Loading branch information
me4502 committed Feb 5, 2017
1 parent d445b28 commit 720ba29
Showing 1 changed file with 5 additions and 17 deletions.
Expand Up @@ -3,6 +3,7 @@
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;


import com.sk89q.craftbook.bukkit.CraftBookPlugin;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.block.Block; import org.bukkit.block.Block;
Expand Down Expand Up @@ -109,9 +110,7 @@ public boolean canHarvest(Entity entity) {
public boolean harvestAnimal(Entity entity) { public boolean harvestAnimal(Entity entity) {


if (entity instanceof Cow) { if (entity instanceof Cow) {

if(doesChestContain(Material.BUCKET)) { if(doesChestContain(Material.BUCKET)) {

removeFromChest(Material.BUCKET); removeFromChest(Material.BUCKET);
if(!addToChest(new ItemStack(Material.MILK_BUCKET, 1))) { if(!addToChest(new ItemStack(Material.MILK_BUCKET, 1))) {
addToChest(new ItemStack(Material.BUCKET, 1)); addToChest(new ItemStack(Material.BUCKET, 1));
Expand All @@ -123,14 +122,14 @@ public boolean harvestAnimal(Entity entity) {
} }


if (entity instanceof Sheep) { if (entity instanceof Sheep) {

if(doesChestContain(Material.SHEARS)) { if(doesChestContain(Material.SHEARS)) {

Sheep sh = (Sheep) entity; Sheep sh = (Sheep) entity;
if(sh.isSheared()) if(sh.isSheared())
return false; return false;
sh.setSheared(true); if (addToChest(new ItemStack(Material.WOOL, CraftBookPlugin.inst().getRandom().nextInt(2) + 1, sh.getColor().getWoolData()))) {
return addToChest(new ItemStack(Material.WOOL, 3, sh.getColor().getWoolData())); sh.setSheared(true);
return true;
}
} }
} }


Expand All @@ -148,17 +147,6 @@ public boolean doesChestContain(Material item) {
return false; return false;
} }


public boolean addToChest(Material item) {

if (chest.getType() == Material.CHEST) {

Chest c = (Chest) chest.getState();
return c.getInventory().addItem(new ItemStack(item, 1)).isEmpty();
}

return false;
}

public boolean addToChest(ItemStack item) { public boolean addToChest(ItemStack item) {


if (chest.getType() == Material.CHEST) { if (chest.getType() == Material.CHEST) {
Expand Down

0 comments on commit 720ba29

Please sign in to comment.