Skip to content

Commit 2efe2e4

Browse files
committed
Fix pots freezing if a harvest cycle completes and no drops are collected. #273
1 parent 564791d commit 2efe2e4

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Common/src/main/java/net/darkhax/botanypots/block/BlockEntityBotanyPot.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import net.minecraft.world.level.block.state.BlockState;
3232

3333
import javax.annotation.Nullable;
34+
import java.util.List;
3435
import java.util.Random;
3536

3637
public class BlockEntityBotanyPot extends WorldlyInventoryBlockEntity<BotanyPotContainer> {
@@ -129,15 +130,21 @@ public boolean isValidSeed(ItemStack stack) {
129130

130131
public boolean attemptAutoHarvest() {
131132

132-
boolean didCollect = false;
133-
134133
if (this.getLevel() != null && !this.getLevel().isClientSide && this.getCrop() != null) {
135134

136135
final ContainerInventoryAccess<BotanyPotContainer> inventory = new ContainerInventoryAccess<>(this.getInventory());
137136

138137
this.rng.setSeed(this.rngSeed);
138+
final List<ItemStack> drops = BotanyPotHelper.generateDrop(rng, this.level, this.getBlockPos(), this, this.getCrop());
139+
140+
if (drops.isEmpty()) {
141+
142+
return true;
143+
}
139144

140-
for (ItemStack drop : BotanyPotHelper.generateDrop(rng, this.level, this.getBlockPos(), this, this.getCrop())) {
145+
boolean didCollect = false;
146+
147+
for (ItemStack drop : drops) {
141148

142149
if (!drop.isEmpty()) {
143150

@@ -159,9 +166,11 @@ public boolean attemptAutoHarvest() {
159166
}
160167
}
161168
}
169+
170+
return didCollect;
162171
}
163172

164-
return didCollect;
173+
return false;
165174
}
166175

167176
private void attemptExport() {

0 commit comments

Comments
 (0)