diff --git a/dependencies.gradle b/dependencies.gradle index 06d5a97a..71bb6446 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -16,6 +16,7 @@ dependencies { compileOnly("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev") compileOnly("com.github.GTNewHorizons:Mobs-Info:0.5.2-GTNH:dev") compileOnlyApi("net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev") + compileOnlyApi("com.github.GTNewHorizons:Natura:2.7.6:dev") // devOnlyNonPublishable("net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev") diff --git a/src/main/java/tconstruct/TConstruct.java b/src/main/java/tconstruct/TConstruct.java index d45a6933..788b0f26 100644 --- a/src/main/java/tconstruct/TConstruct.java +++ b/src/main/java/tconstruct/TConstruct.java @@ -61,6 +61,7 @@ import tconstruct.plugins.imc.TinkerBuildCraft; import tconstruct.plugins.imc.TinkerMystcraft; import tconstruct.plugins.imc.TinkerRfTools; import tconstruct.plugins.mfr.TinkerMFR; +import tconstruct.plugins.natura.TinkerNatura; import tconstruct.plugins.te4.TinkerTE4; import tconstruct.plugins.te4.TinkersThermalFoundation; import tconstruct.plugins.ubc.TinkerUBC; @@ -174,6 +175,7 @@ public class TConstruct { pulsar.registerPulse(new TinkerUBC()); pulsar.registerPulse(new TinkerGears()); pulsar.registerPulse(new TinkerRfTools()); + pulsar.registerPulse(new TinkerNatura()); TConstructRegistry.materialTab = new TConstructCreativeTab("TConstructMaterials"); TConstructRegistry.toolTab = new TConstructCreativeTab("TConstructTools"); diff --git a/src/main/java/tconstruct/plugins/natura/NaturaCropHarvestHandler.java b/src/main/java/tconstruct/plugins/natura/NaturaCropHarvestHandler.java new file mode 100644 index 00000000..8b784777 --- /dev/null +++ b/src/main/java/tconstruct/plugins/natura/NaturaCropHarvestHandler.java @@ -0,0 +1,31 @@ +package tconstruct.plugins.natura; + +import net.minecraft.block.Block; +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, 0); + world.setBlockMetadataWithNotify(x, y, z, crop.getStartGrowth(meta), 2); + return true; + } + } + return false; + } +} diff --git a/src/main/java/tconstruct/plugins/natura/TinkerNatura.java b/src/main/java/tconstruct/plugins/natura/TinkerNatura.java new file mode 100644 index 00000000..8dca4817 --- /dev/null +++ b/src/main/java/tconstruct/plugins/natura/TinkerNatura.java @@ -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()); + } +}