Skip to content

Commit

Permalink
fix(gc/slimelings): change favourite food list
Browse files Browse the repository at this point in the history
Wooden hoes are unobtainable, so slimeling's must have their diet
modified - these slimelings now eat Prismarine Shards

fixes DarkPacks/SevTech-Ages#2066
  • Loading branch information
sam-kirby committed Feb 28, 2024
1 parent 3d12fe5 commit 68548af
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version_base = 1.11.1
version_base = 1.12.0

# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public class SevPatchesLoadingPlugin implements IFMLLoadingPlugin {

public static String IS_EMPTY;

public static String WOODEN_HOE;
public static String PRISMARINE_SHARD;

public SevPatchesLoadingPlugin() {
LOGGER.info("setting up mixin environment");
MixinBootstrap.init();
Expand Down Expand Up @@ -115,6 +118,9 @@ public void injectData(Map<String, Object> data) {
SevPatchesLoadingPlugin.MATERIAL_WOOD = dev ? "WOOD" : "field_151575_d";

SevPatchesLoadingPlugin.IS_EMPTY = dev ? "isEmpty" : "func_191420_l";

SevPatchesLoadingPlugin.WOODEN_HOE = dev ? "WOODEN_HOE" : "field_151017_I";
SevPatchesLoadingPlugin.PRISMARINE_SHARD = dev ? "PRISMARINE_SHARD" : "field_179562_cC";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public byte[] transform(String name, String transformedName, byte[] basicClass)
return new PatchPrimalDrying(basicClass).apply();
case "micdoodle8.mods.galacticraft.core.tile.TileEntityInventory":
return new PatchGalacticraftInventories(basicClass).apply();
case "micdoodle8.mods.galacticraft.planets.mars.entities.EntitySlimeling":
return new PatchGalacticraftSlimeling(basicClass).apply();
default:
return basicClass;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package tv.darkosto.sevpatches.core.patches;

import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.MethodNode;
import tv.darkosto.sevpatches.core.SevPatchesLoadingPlugin;
import tv.darkosto.sevpatches.core.utils.AsmUtils;

import java.util.Optional;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

public class PatchGalacticraftSlimeling extends Patch {
public PatchGalacticraftSlimeling(byte[] inputClass) {
super(inputClass);
}

@Override
protected boolean patch() {
MethodNode favFoodSetter = AsmUtils.findMethod(this.classNode, "setRandomFavFood");

if (favFoodSetter == null)
return false;

Iterable<AbstractInsnNode> insnsIter = () -> favFoodSetter.instructions.iterator();
Stream<AbstractInsnNode> insns = StreamSupport.stream(insnsIter.spliterator(), false);

Optional<FieldInsnNode> fieldInsn = insns
.filter(insn -> insn instanceof FieldInsnNode)
.map(insn -> (FieldInsnNode) insn)
.filter(fieldInsnNode -> fieldInsnNode.desc.equals("Lnet/minecraft/item/Item;") && fieldInsnNode.name.equals(SevPatchesLoadingPlugin.WOODEN_HOE))
.findAny();

fieldInsn.ifPresent(insn -> insn.name = SevPatchesLoadingPlugin.PRISMARINE_SHARD);

return fieldInsn.isPresent();
}
}
2 changes: 1 addition & 1 deletion src/main/resources/mcmod.info
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"modid": "sevpatches",
"name": "SevPatches",
"description": "Consolidated patches for mods that are EOL used in SevTech: Ages",
"version": "1.9",
"version": "1.12.0",
"mcversion": "1.12.2",
"url": "https://www.curseforge.com/minecraft/mc-mods/sevpatches",
"updateUrl": "",
Expand Down

0 comments on commit 68548af

Please sign in to comment.