mirror of
https://github.com/YouHaveTrouble/Enchantio.git
synced 2026-05-11 21:56:55 +00:00
skip check for seeds in creative
This commit is contained in:
@@ -38,31 +38,34 @@ public class ReplantingListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
PlayerInventory inventory = player.getInventory();
|
PlayerInventory inventory = player.getInventory();
|
||||||
|
|
||||||
boolean removed = false;
|
// If the player is in creative mode, skip the inventory check
|
||||||
|
boolean shouldReplant = player.getGameMode().equals(GameMode.CREATIVE);
|
||||||
|
|
||||||
|
if (!shouldReplant) {
|
||||||
// try to remove seed from the player's inventory
|
// try to remove seed from the player's inventory
|
||||||
for (ItemStack item : inventory.getContents()) {
|
for (ItemStack item : inventory.getContents()) {
|
||||||
if (item == null) continue;
|
if (item == null) continue;
|
||||||
if (item.getType() == placementMaterial) {
|
if (item.getType() == placementMaterial) {
|
||||||
item.setAmount(item.getAmount() - 1);
|
item.setAmount(item.getAmount() - 1);
|
||||||
removed = true;
|
shouldReplant = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!removed) {
|
if (!shouldReplant) {
|
||||||
// Try to remove the seed from the items dropped by the block
|
// Try to remove the seed from the items dropped by the block
|
||||||
for (Item item : event.getItems()) {
|
for (Item item : event.getItems()) {
|
||||||
ItemStack itemStack = item.getItemStack();
|
ItemStack itemStack = item.getItemStack();
|
||||||
if (itemStack.getType().equals(placementMaterial)) {
|
if (itemStack.getType().equals(placementMaterial)) {
|
||||||
itemStack.setAmount(itemStack.getAmount() - 1);
|
itemStack.setAmount(itemStack.getAmount() - 1);
|
||||||
removed = true;
|
shouldReplant = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!removed) return;
|
if (!shouldReplant) return;
|
||||||
|
|
||||||
// Replant the crop
|
// Replant the crop
|
||||||
event.getBlock().setType(block.getType());
|
event.getBlock().setType(block.getType());
|
||||||
|
|||||||
Reference in New Issue
Block a user