|
| 1 | +/* |
| 2 | + * Copyright (c) 2014-2025 Wurst-Imperium and contributors. |
| 3 | + * |
| 4 | + * This source code is subject to the terms of the GNU General Public |
| 5 | + * License, version 3. If a copy of the GPL was not distributed with this |
| 6 | + * file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt |
| 7 | + */ |
| 8 | +package net.wurstclient.hacks.autofarm.plants; |
| 9 | + |
| 10 | +import net.minecraft.block.BlockState; |
| 11 | +import net.minecraft.block.CaveVines; |
| 12 | +import net.minecraft.item.Item; |
| 13 | +import net.minecraft.item.Items; |
| 14 | +import net.minecraft.util.math.BlockPos; |
| 15 | +import net.minecraft.util.math.Direction; |
| 16 | +import net.wurstclient.WurstClient; |
| 17 | +import net.wurstclient.hacks.autofarm.AutoFarmPlantType; |
| 18 | +import net.wurstclient.settings.CheckboxSetting; |
| 19 | +import net.wurstclient.util.BlockUtils; |
| 20 | + |
| 21 | +public final class GlowBerryPlantType extends AutoFarmPlantType |
| 22 | +{ |
| 23 | + @Override |
| 24 | + public final boolean isReplantingSpot(BlockPos pos, BlockState state) |
| 25 | + { |
| 26 | + return state.getBlock() instanceof CaveVines && hasPlantingSurface(pos); |
| 27 | + } |
| 28 | + |
| 29 | + @Override |
| 30 | + public final boolean hasPlantingSurface(BlockPos pos) |
| 31 | + { |
| 32 | + BlockState ceiling = BlockUtils.getState(pos.up()); |
| 33 | + return !(ceiling.getBlock() instanceof CaveVines) && ceiling |
| 34 | + .isSideSolidFullSquare(WurstClient.MC.world, pos, Direction.DOWN); |
| 35 | + } |
| 36 | + |
| 37 | + @Override |
| 38 | + public Item getSeedItem() |
| 39 | + { |
| 40 | + return Items.GLOW_BERRIES; |
| 41 | + } |
| 42 | + |
| 43 | + @Override |
| 44 | + public boolean shouldHarvestByInteracting(BlockPos pos, BlockState state) |
| 45 | + { |
| 46 | + // Right-click-harvest the top-most part so we don't have to replant it. |
| 47 | + return state.getBlock() instanceof CaveVines |
| 48 | + && CaveVines.hasBerries(state) && isReplantingSpot(pos, state); |
| 49 | + } |
| 50 | + |
| 51 | + @Override |
| 52 | + public boolean shouldHarvestByMining(BlockPos pos, BlockState state) |
| 53 | + { |
| 54 | + // Left-click-harvest any other part so it can grow more berries. |
| 55 | + return state.getBlock() instanceof CaveVines |
| 56 | + && !isReplantingSpot(pos, state); |
| 57 | + } |
| 58 | + |
| 59 | + @Override |
| 60 | + protected CheckboxSetting createHarvestSetting() |
| 61 | + { |
| 62 | + return new CheckboxSetting("Harvest glow berries", true); |
| 63 | + } |
| 64 | + |
| 65 | + @Override |
| 66 | + protected CheckboxSetting createReplantSetting() |
| 67 | + { |
| 68 | + return new CheckboxSetting("Replant glow berries", true); |
| 69 | + } |
| 70 | +} |
0 commit comments