Allow the Scythe to harvest crops in an AOE (#159)

This commit is contained in:
Yannick Marcotte-Gourde authored and GitHub committed 2025-04-02 12:07:47 -05:00
1 parent eb0ac72963
commit d370627703
11 files changed
+219 -1

No files matched your search

@@ -0,0 +1,22 @@
package tconstruct.plugins.ic2;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import ic2.api.crops.ICropTile;
import tconstruct.api.harvesting.CropHarvestHandler;
public class Ic2CropHarvestHandler implements CropHarvestHandler {
@Override
public boolean couldHarvest(World world, int x, int y, int z) {
return world.getTileEntity(x, y, z) instanceof ICropTile;
}
@Override
public boolean tryHarvest(ItemStack stack, EntityPlayer player, World world, int x, int y, int z) {
return world.getTileEntity(x, y, z) instanceof ICropTile crop && crop.getCrop().canBeHarvested(crop)
&& crop.harvest(true);
}
}
@@ -11,6 +11,7 @@ import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder;
import mantle.pulsar.pulse.Handler;
import mantle.pulsar.pulse.Pulse;
import tconstruct.TConstruct;
import tconstruct.api.harvesting.CropHarvestHandlers;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.crafting.LiquidCasting;
@@ -28,6 +29,8 @@ public class TinkerIC2 {
public void init(FMLInitializationEvent event) {
TConstruct.logger.info("IC2 detected. Preparing for shenanigans.");
CropHarvestHandlers.registerCropHarvestHandler(new Ic2CropHarvestHandler());
Fluid fluidUUM = FluidRegistry.getFluid(IC2_UUM_FLUIDNAME);
if (fluidUUM == null) return;
@@ -0,0 +1,32 @@
package tconstruct.plugins.natura;
import net.minecraft.block.Block;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import mods.natura.blocks.crops.CropBlock;
import tconstruct.api.harvesting.CropHarvestHandler;
public class NaturaCropHarvestHandler implements CropHarvestHandler {
@Override
public boolean couldHarvest(World world, int x, int y, int z) {
return world.getBlock(x, y, z) instanceof CropBlock;
}
@Override
public boolean tryHarvest(ItemStack stack, EntityPlayer player, World world, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
if (block instanceof CropBlock crop) {
int meta = world.getBlockMetadata(x, y, z);
if (meta == crop.getMaxGrowth(meta)) {
crop.dropBlockAsItem(world, x, y, z, meta, EnchantmentHelper.getFortuneModifier(player));
world.setBlockMetadataWithNotify(x, y, z, crop.getStartGrowth(meta), 2);
return true;
}
}
return false;
}
}
@@ -0,0 +1,22 @@
package tconstruct.plugins.natura;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import mantle.pulsar.pulse.Handler;
import mantle.pulsar.pulse.Pulse;
import tconstruct.TConstruct;
import tconstruct.api.harvesting.CropHarvestHandlers;
@GameRegistry.ObjectHolder(TConstruct.modID)
@Pulse(
id = "Tinkers Natura Compatibility",
description = "Tinkers Construct compatibility for Natura",
modsRequired = "Natura",
forced = true)
public class TinkerNatura {
@Handler
public void init(FMLInitializationEvent event) {
CropHarvestHandlers.registerCropHarvestHandler(new NaturaCropHarvestHandler());
}
}