Skip to content

Commit 29693eb

Browse files
authored
Mystical Agriculture compatibility with farmer (#64)
1 parent fd383c8 commit 29693eb

File tree

5 files changed

+85
-2
lines changed

5 files changed

+85
-2
lines changed

build.gradle

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ repositories {
7171
includeGroup "top.theillusivec4.curios"
7272
}
7373
}
74+
maven {
75+
name = "Blakebr0"
76+
url = "https://maven.blakesmods.com/releases"
77+
content {
78+
// Cucumber
79+
includeGroup "com.blakebr0.cucumber"
80+
// Mystical Agriculture
81+
includeGroup "com.blakebr0.mysticalagriculture"
82+
}
83+
}
7484
}
7585

7686
dependencies {
@@ -112,6 +122,14 @@ dependencies {
112122
} else {
113123
compileOnly "top.theillusivec4.curios:curios-neoforge:${curios_version}"
114124
}
125+
126+
if (project.runtime_include_mystical_agriculture.toBoolean()) {
127+
localImplementation "com.blakebr0.cucumber:Cucumber:${cucumber_version}"
128+
localImplementation "com.blakebr0.mysticalagriculture:MysticalAgriculture:${mystical_agriculture_version}"
129+
} else {
130+
compileOnly "com.blakebr0.cucumber:Cucumber:${cucumber_version}"
131+
compileOnly "com.blakebr0.mysticalagriculture:MysticalAgriculture:${mystical_agriculture_version}"
132+
}
115133
}
116134

117135
tasks.named('jar') {
@@ -348,7 +366,8 @@ tasks.withType(ProcessResources).configureEach {
348366
mi_tweaks_version_range : mi_tweaks_version_range,
349367
emi_version_range : emi_version_range,
350368
accessories_version_range : accessories_version_range,
351-
curios_version_range : curios_version_range
369+
curios_version_range : curios_version_range,
370+
mystical_agriculture_version_range : mystical_agriculture_version_range
352371
]
353372
inputs.properties replaceProperties
354373

gradle.properties

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ runtime_include_emi=true
33
runtime_include_mi_tweaks=true
44
runtime_include_accessories=false
55
runtime_include_curios=false
6+
runtime_include_mystical_agriculture=false
67

78
# Gradle Configuration
89
artifact_name=extended-industrialization
@@ -47,4 +48,7 @@ mixinextras_version=0.3.5
4748
accessories_version=1.0.0-beta.34+1.21
4849
accessories_version_range=[1.0.0-beta.34-, 1.1.0-)
4950
curios_version=9.0.10+1.21
50-
curios_version_range=[9,)
51+
curios_version_range=[9,)
52+
cucumber_version=1.21.1-8.0.8
53+
mystical_agriculture_version=1.21.1-8.0.9
54+
mystical_agriculture_version_range=[8.0.0,)

src/main/java/net/swedz/extended_industrialization/machines/component/farmer/FarmerComponent.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import net.swedz.extended_industrialization.machines.component.farmer.harvesting.HarvestableBehaviorHolder;
2323
import net.swedz.extended_industrialization.machines.component.farmer.harvesting.HarvestingContext;
2424
import net.swedz.extended_industrialization.machines.component.farmer.harvesting.harvestable.CropBlockHarvestable;
25+
import net.swedz.extended_industrialization.machines.component.farmer.harvesting.harvestable.MysticalAgricultureHarvestable;
2526
import net.swedz.extended_industrialization.machines.component.farmer.harvesting.harvestable.NetherWartHarvestable;
2627
import net.swedz.extended_industrialization.machines.component.farmer.harvesting.harvestable.SimpleTallCropHarvestable;
2728
import net.swedz.extended_industrialization.machines.component.farmer.harvesting.harvestable.TreeHarvestable;
@@ -34,6 +35,7 @@
3435
import net.swedz.extended_industrialization.machines.component.farmer.task.FarmerTask;
3536
import net.swedz.extended_industrialization.machines.component.farmer.task.FarmerTaskType;
3637
import net.swedz.tesseract.neoforge.behavior.BehaviorRegistry;
38+
import net.swedz.tesseract.neoforge.compat.ModLoadedHelper;
3739
import net.swedz.tesseract.neoforge.compat.mi.helper.MachineInventoryHelper;
3840
import net.swedz.tesseract.neoforge.event.FarmlandLoseMoistureEvent;
3941

@@ -62,6 +64,11 @@ public static void registerHarvestable(Supplier<HarvestableBehavior> creator)
6264
registerPlantable(StandardFarmerPlantable::new);
6365
registerPlantable(SpecialFarmerPlantable::new);
6466

67+
if(ModLoadedHelper.isLoaded("mysticalagriculture"))
68+
{
69+
registerHarvestable(MysticalAgricultureHarvestable::new);
70+
}
71+
6572
registerHarvestable(CropBlockHarvestable::new);
6673
registerHarvestable(NetherWartHarvestable::new);
6774
registerHarvestable(SimpleTallCropHarvestable::new);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package net.swedz.extended_industrialization.machines.component.farmer.harvesting.harvestable;
2+
3+
import com.blakebr0.mysticalagriculture.block.MysticalCropBlock;
4+
import com.google.common.collect.Lists;
5+
import net.minecraft.core.BlockPos;
6+
import net.minecraft.server.level.ServerLevel;
7+
import net.minecraft.world.item.ItemStack;
8+
import net.minecraft.world.level.storage.loot.LootParams;
9+
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
10+
import net.minecraft.world.phys.Vec3;
11+
import net.swedz.extended_industrialization.machines.component.farmer.harvesting.HarvestableBehavior;
12+
import net.swedz.extended_industrialization.machines.component.farmer.harvesting.HarvestingContext;
13+
14+
import java.util.List;
15+
16+
public final class MysticalAgricultureHarvestable implements HarvestableBehavior
17+
{
18+
@Override
19+
public boolean matches(HarvestingContext context)
20+
{
21+
return context.state().getBlock() instanceof MysticalCropBlock;
22+
}
23+
24+
@Override
25+
public boolean isFullyGrown(HarvestingContext context)
26+
{
27+
MysticalCropBlock mysticalCropBlock = (MysticalCropBlock) context.state().getBlock();
28+
return mysticalCropBlock.isMaxAge(context.state());
29+
}
30+
31+
@Override
32+
public List<BlockPos> getBlocks(HarvestingContext context)
33+
{
34+
return Lists.newArrayList(context.pos());
35+
}
36+
37+
@Override
38+
public List<ItemStack> getDrops(HarvestingContext context)
39+
{
40+
MysticalCropBlock cropBlock = (MysticalCropBlock) context.state().getBlock();
41+
LootParams.Builder builder = new LootParams.Builder((ServerLevel) context.level())
42+
.withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(context.pos()))
43+
.withParameter(LootContextParams.TOOL, ItemStack.EMPTY);
44+
return cropBlock.getDrops(context.state(), builder);
45+
}
46+
}

src/main/resources/META-INF/neoforge.mods.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,11 @@ modId = "curios"
6565
type = "optional"
6666
versionRange = "${curios_version_range}"
6767
ordering = "AFTER"
68+
side = "BOTH"
69+
70+
[[dependencies.${ mod_id }]]
71+
modId = "mysticalagriculture"
72+
type = "optional"
73+
versionRange = "${mystical_agriculture_version_range}"
74+
ordering = "AFTER"
6875
side = "BOTH"

0 commit comments

Comments
 (0)