Skip to content

Commit

Permalink
Implement Forestry ExtraTrees windfall tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Mar 11, 2023
1 parent 297d522 commit 942476f
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 1 deletion.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ repositories {

dependencies {
deobfCompile "curse.maven:baubles-227083:2518667"
deobfCompile "curse.maven:binnies-mods-223525:2916129"
deobfCompile "curse.maven:biomes-o-plenty-220318:2842510"
deobfCompile "curse.maven:botania-225643:3330934"
deobfCompile "curse.maven:chameleon-230497:2450900"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class UniversalTweaks
public static final String MODID = "universaltweaks";
public static final String NAME = "Universal Tweaks";
public static final String VERSION = "1.12.2-1.4.2";
public static final String DEPENDENCIES = "required-after:mixinbooter;after:biomesoplenty;after:botania;after:customspawner;after:epicsiegemod;after:forestry;after:storagedrawers;after:tconstruct;after:thaumcraft";
public static final String DEPENDENCIES = "required-after:mixinbooter;after:biomesoplenty;after:botania;after:customspawner;after:epicsiegemod;after:extratrees;after:forestry;after:storagedrawers;after:tconstruct;after:thaumcraft";
public static final Logger LOGGER = LogManager.getLogger(NAME);

@Mod.EventHandler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,10 @@ public static class ForestryCategory
@Config.Name("Disable Bee Damage Armor Bypass")
@Config.Comment("Disables damage caused by bees bypassing player armor")
public boolean utFOBeeDamageArmorBypassToggle = true;

@Config.Name("Extra Trees: Gather Windfall")
@Config.Comment("Allows Forestry farms to pick up ExtraTrees fruit")
public boolean utFOGatherWindfallToggle = true;
}

public static class MoCreaturesCategory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public List<String> getMixinConfigs()
"mixins.mods.customspawner.json",
"mixins.mods.epicsiegemod.json",
"mixins.mods.forestry.json",
"mixins.mods.forestry.extratrees.json",
"mixins.mods.storagedrawers.client.json",
"mixins.mods.storagedrawers.server.json",
"mixins.mods.thaumcraft.json",
Expand Down Expand Up @@ -51,6 +52,8 @@ public boolean shouldMixinConfigQueue(String mixinConfig)
return Loader.isModLoaded("epicsiegemod");
case "mixins.mods.forestry.json":
return Loader.isModLoaded("forestry");
case "mixins.mods.forestry.extratrees.json":
return Loader.isModLoaded("extratrees");
case "mixins.mods.storagedrawers.server.json":
return Loader.isModLoaded("storagedrawers");
case "mixins.mods.thaumcraft.json":
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package mod.acgaming.universaltweaks.mods.forestry.extratrees.mixin;

import net.minecraft.item.ItemStack;

import binnie.extratrees.items.ItemETFood;
import forestry.api.farming.IFarmProperties;
import forestry.farming.logic.FarmLogicArboreal;
import forestry.farming.logic.FarmLogicHomogeneous;
import mod.acgaming.universaltweaks.config.UTConfig;
import org.spongepowered.asm.mixin.Mixin;

@Mixin(value = FarmLogicArboreal.class, remap = false)
public abstract class UTFarmLogicArborealMixin extends FarmLogicHomogeneous
{
public UTFarmLogicArborealMixin(IFarmProperties properties, boolean isManual)
{
super(properties, isManual);
}

@Override
public boolean isAcceptedWindfall(ItemStack stack)
{
return UTConfig.MOD_INTEGRATION.FORESTRY.utFOGatherWindfallToggle && stack.getItem() instanceof ItemETFood;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package mod.acgaming.universaltweaks.mods.forestry.extratrees.mixin;

import net.minecraft.item.ItemStack;

import binnie.extratrees.items.ItemETFood;
import forestry.api.farming.IFarmProperties;
import forestry.farming.logic.FarmLogic;
import forestry.farming.logic.FarmLogicOrchard;
import mod.acgaming.universaltweaks.config.UTConfig;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(value = FarmLogicOrchard.class, remap = false)
public abstract class UTFarmLogicOrchardMixin extends FarmLogic
{
public UTFarmLogicOrchardMixin(IFarmProperties properties, boolean isManual)
{
super(properties, isManual);
}

@Inject(method = "isAcceptedWindfall", at = @At("RETURN"), cancellable = true)
public void utExtraTreesWindfall(ItemStack stack, CallbackInfoReturnable<Boolean> cir)
{
if (UTConfig.MOD_INTEGRATION.FORESTRY.utFOGatherWindfallToggle && stack.getItem() instanceof ItemETFood) cir.setReturnValue(true);
}
}
7 changes: 7 additions & 0 deletions src/main/resources/mixins.mods.forestry.extratrees.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"package": "mod.acgaming.universaltweaks.mods.forestry.extratrees.mixin",
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": ["UTFarmLogicArborealMixin", "UTFarmLogicOrchardMixin"]
}

2 comments on commit 942476f

@ACGaming
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xJon
Copy link

@xJon xJon commented on 942476f Mar 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much

Please sign in to comment.