Skip to content

Commit

Permalink
fix: modify some internals to support Farmers Delight tomato rope log…
Browse files Browse the repository at this point in the history
…ging

Closes #75, #77
  • Loading branch information
Jamalam360 committed Nov 4, 2024
1 parent 92a7141 commit 5a58d41
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 4 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
- (fix) do not attempt to send the Hello packet when the client does not have RCH installed.
- This means that RCH is now properly client-optional again, as intended.
- (fix) modify some internals to support Farmers Delight tomato rope logging.
- Closes #75, #77
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import io.github.jamalam360.jamlib.JamLib;
import io.github.jamalam360.jamlib.JamLibPlatform;
import io.github.jamalam360.jamlib.config.ConfigManager;
import io.github.jamalam360.rightclickharvest.mixin.CropBlockAccessor;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
Expand Down Expand Up @@ -260,7 +261,12 @@ private static BlockState getReplantState(BlockState state) {
if (state.getBlock() instanceof CocoaBlock) {
return state.setValue(CocoaBlock.AGE, 0);
} else if (state.getBlock() instanceof CropBlock cropBlock) {
return cropBlock.getStateForAge(0);
// This is used instead of getStateForAge(i) because of an issue with Farmers Delight
// tomatoes - they have a 'ropelogged' property. Since getStateForAge returns the
// default block state with the age set, the ropelogged property is reset to false
// when calling it. This method requires a mixin accessor, but I don't think there are
// any potential issues with it other than that.
return state.setValue(((CropBlockAccessor) cropBlock).invokeGetAgeProperty(), 0);
} else if (state.getBlock() instanceof NetherWartBlock) {
return state.setValue(NetherWartBlock.AGE, 0);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.github.jamalam360.rightclickharvest.mixin;

import net.minecraft.world.level.block.CropBlock;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;

@Mixin(CropBlock.class)
public interface CropBlockAccessor {
@Invoker
IntegerProperty invokeGetAgeProperty();
}
16 changes: 16 additions & 0 deletions common/src/main/resources/rightclickharvest.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"required": true,
"minVersion": "0.8",
"package": "io.github.jamalam360.rightclickharvest.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
"CropBlockAccessor"
],
"client": [
],
"server": [
],
"injectors": {
"defaultRequire": 1
}
}
1 change: 1 addition & 0 deletions datagen/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
]
},
"mixins": [
"rightclickharvest.mixins.json"
],
"depends": {
}
Expand Down
1 change: 1 addition & 0 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
]
},
"mixins": [
"rightclickharvest.mixins.json"
],
"depends": {
"fabric": ">=${fabric_api_version}",
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
org.gradle.parallel=true
version=4.4.2+1.21.3
version=4.4.3+1.21.3
minecraft_version=1.21.3
additional_minecraft_versions=1.21.2
minimum_minecraft_version=1.21.2
Expand Down
3 changes: 3 additions & 0 deletions neoforge/src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ type = "required"
versionRange = "[${jamlib_version},)"
ordering = "AFTER"
side = "BOTH"

[[mixins]]
config = "rightclickharvest.mixins.json"

0 comments on commit 5a58d41

Please sign in to comment.