Permalink
Browse files

Fixed AnimalHarvester sending wool into the abyss.

  • Loading branch information...
me4502 committed Feb 5, 2017
1 parent d445b28 commit 720ba294eddfc82d1d1a78da47a5b3e58f480685
@@ -3,6 +3,7 @@
import java.util.Arrays;
import java.util.Collections;
+import com.sk89q.craftbook.bukkit.CraftBookPlugin;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.block.Block;
@@ -109,9 +110,7 @@ public boolean canHarvest(Entity entity) {
public boolean harvestAnimal(Entity entity) {
if (entity instanceof Cow) {
-
if(doesChestContain(Material.BUCKET)) {
-
removeFromChest(Material.BUCKET);
if(!addToChest(new ItemStack(Material.MILK_BUCKET, 1))) {
addToChest(new ItemStack(Material.BUCKET, 1));
@@ -123,14 +122,14 @@ public boolean harvestAnimal(Entity entity) {
}
if (entity instanceof Sheep) {
-
if(doesChestContain(Material.SHEARS)) {
-
Sheep sh = (Sheep) entity;
if(sh.isSheared())
return false;
- sh.setSheared(true);
- return addToChest(new ItemStack(Material.WOOL, 3, sh.getColor().getWoolData()));
+ if (addToChest(new ItemStack(Material.WOOL, CraftBookPlugin.inst().getRandom().nextInt(2) + 1, sh.getColor().getWoolData()))) {
+ sh.setSheared(true);
+ return true;
+ }
}
}
@@ -148,17 +147,6 @@ public boolean doesChestContain(Material item) {
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) {
if (chest.getType() == Material.CHEST) {

0 comments on commit 720ba29

Please sign in to comment.