Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
842b424
allow all valid books to be inserted via automation
felixfour Jul 28, 2026
eade58b
rename for better grouping
felixfour Jul 28, 2026
eaca3fd
make insertion work correctly
felixfour Jul 28, 2026
3ac61f2
cursed system
felixfour Jul 28, 2026
3aab1ae
imports
felixfour Jul 28, 2026
5ba43f1
add ench plate automation mixin
felixfour Jul 28, 2026
259bc35
add ench plate automation to config
felixfour Jul 28, 2026
e704046
add EIO and Automagy loader checks
felixfour Jul 28, 2026
105c93a
d'oh
felixfour Jul 28, 2026
039b791
add real loader checks
felixfour Jul 28, 2026
d7bc1d8
Merge branch 'master' into master
felixfour Jul 28, 2026
7ff817f
fix punctuation
felixfour Jul 28, 2026
3be1f88
e
felixfour Jul 28, 2026
23180aa
wrong variable name
felixfour Jul 28, 2026
e157e20
right that too
felixfour Jul 28, 2026
3ced137
fix types
felixfour Jul 28, 2026
347d470
make shadows public
felixfour Jul 28, 2026
dff50cf
remap = false
felixfour Jul 28, 2026
7d02ac1
forgot hte other one
felixfour Jul 28, 2026
88d8aa7
forgot to make it abstract
felixfour Jul 28, 2026
0867966
thought it auto inits to null in java
felixfour Jul 28, 2026
1a628c6
spotless
felixfour Jul 28, 2026
3727403
spotless is no fun
felixfour Jul 28, 2026
3cca8be
spacing
felixfour Jul 28, 2026
1fd5c7d
spacing
felixfour Jul 28, 2026
80289dd
unused
felixfour Jul 28, 2026
b07f7df
ah the o was lowercase
felixfour Jul 28, 2026
382d4f9
prevent exp int overflow
felixfour Aug 21, 2026
8d44252
Merge branch 'master' into master
felixfour Aug 21, 2026
f224f56
Merge branch 'master' into master
felixfour Sep 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/main/java/com/mitchej123/hodgepodge/Compat.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public class Compat {
private static boolean isSupernovaPresent;
private static boolean isCubicChunksPresent;

private static boolean isEnderIoPresent;
private static boolean isAutomagyPresent;

static void init(Side side) {
isClient = side == Side.CLIENT;

Expand Down Expand Up @@ -81,6 +84,10 @@ static void init(Side side) {
isSupernovaPresent = Loader.isModLoaded("supernova");

isCubicChunksPresent = Loader.isModLoaded("cubicchunks");

isEnderIoPresent = Loader.isModLoaded("EnderIO");

isAutomagyPresent = Loader.isModLoaded("Automagy");
}

/**
Expand Down Expand Up @@ -197,4 +204,18 @@ public static boolean isSupernovaPresent() {
public static boolean isCubicChunksPresent() {
return isCubicChunksPresent;
}

/**
* Cannot be used before pre-init phase.
*/
public static boolean isEnderIoPresent() {
return isEnderIoPresent;
}

/**
* Cannot be used before pre-init phase.
*/
public static boolean isAutomagyPresent() {
return isAutomagyPresent;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,12 @@ public class TweaksConfig {
@Config.DefaultBoolean(true)
public static boolean thirstyTankContainer;

// Bibliocraft

@Config.Comment("Automate automation of Enchanted Plates at the Typesetting Table (requires EnderIO or Automagy for XP containers)")
@Config.DefaultBoolean(true)
public static boolean automateBibliocraftEnchantedPlates;

// Biomes O' Plenty

@Config.Comment("Allow 5 Fir Sapling planted together ('+' shape) to grow to a big fir tree")
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java
Original file line number Diff line number Diff line change
Expand Up @@ -2066,6 +2066,13 @@ public enum Mixins implements IMixins {
.addServerMixins("morpheus.MixinMorpheusWakePlayers")
.setApplyIf(() -> FixesConfig.fixMorpheusWaking)
.addRequiredMod(TargetedMod.MORPHEUS)
.setPhase(Phase.LATE)),

// Bibliocraft
BIBLIOCRAFT_AUTOMATION_ENCHANTED_PLATE(new MixinBuilder("Bibliocraft enchanted plate automation")
.addCommonMixins("bibliocraft.MixinBibliocraftAutomationTypesettingTile")
.setApplyIf(() -> TweaksConfig.automateBibliocraftEnchantedPlates)
.addRequiredMod(TargetedMod.BIBLIOCRAFT)
.setPhase(Phase.LATE));

// spotless:on
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
package com.mitchej123.hodgepodge.mixins.late.bibliocraft;

import static com.mitchej123.hodgepodge.Compat.isAutomagyPresent;
import static com.mitchej123.hodgepodge.Compat.isEnderIoPresent;

import java.util.ArrayList;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemEditableBook;
import net.minecraft.item.ItemEnchantedBook;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;

import com.gtnewhorizon.gtnhlib.geometry.CubeIterator;
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;

import crazypants.enderio.machine.obelisk.xp.TileExperienceObelisk;
import crazypants.enderio.xp.ExperienceContainer;
import jds.bibliocraft.items.ItemAtlas;
import jds.bibliocraft.items.ItemBigBook;
import jds.bibliocraft.items.ItemPlate;
import jds.bibliocraft.items.ItemRecipeBook;
import jds.bibliocraft.items.ItemStockroomCatalog;
import jds.bibliocraft.tileentities.TileEntityTypeMachine;
import tuhljin.automagy.tiles.TileEntityJarXP;

@Mixin(TileEntityTypeMachine.class)
public abstract class MixinBibliocraftAutomationTypesettingTile extends TileEntity {

@WrapMethod(method = "isItemValidForSlot")
private boolean hodgepodge$allowAllValidInputTypes(int slot, ItemStack itemstack, Operation<Boolean> original) {
NBTTagCompound nbt;
Item stackItem = itemstack.getItem();
if (slot == 0) return stackItem instanceof ItemPlate || stackItem instanceof ItemEditableBook
|| stackItem instanceof ItemEnchantedBook
|| stackItem instanceof ItemStockroomCatalog
|| ((stackItem instanceof ItemBigBook || stackItem instanceof ItemRecipeBook)
&& (nbt = itemstack.getTagCompound()) != null
&& nbt.getBoolean("signed"))
|| stackItem instanceof ItemAtlas && itemstack.getTagCompound() != null;
return original.call(slot, itemstack);
}

@Shadow(remap = false)
public abstract boolean addBookorPlate(ItemStack playerstack, World world);

@WrapMethod(method = "setInventorySlotContents")
private void hodgepodge$useAddBookorPlate(int slot, ItemStack itemstack, Operation<Void> original) {
if (slot == 0 && itemstack != null) addBookorPlate(itemstack, this.worldObj);
else original.call(slot, itemstack);
}

@Shadow(remap = false)
public abstract boolean enchantPlate(EntityPlayer player);

@WrapMethod(method = "setPlate", remap = false)
private void hodgepodge$enchIfCanEnch(Operation<Void> op) {
if (enchantPlate(null)) return;
op.call();
}

@WrapOperation(
method = "enchantPlate",
at = @At(
value = "FIELD",
opcode = Opcodes.GETFIELD,
target = "Lnet/minecraft/entity/player/EntityPlayer;experienceLevel:I"),
remap = false)
private int hdogepodge$cursedXpDrainImpl(EntityPlayer instance, Operation<Integer> original, @Local int levelcost) {
if (instance != null) return instance.experienceLevel;
levelcost = levelcost > 22222 ? 22222 : levelcost < 0 ? 0 : levelcost; // avoid >maxint exp
int xpCost = levelcost < 16 ? 17 * levelcost
: levelcost < 30 ? (((3 * levelcost - 59) * levelcost) >> 1) + 360
: (((7 * levelcost - 303) * levelcost) >> 1) + 2220;
CubeIterator iter = new CubeIterator(8);
ArrayList<ExperienceContainer> obeliskstodrain = null;
int xp;
if (isEnderIoPresent()) {
if (!worldObj.isRemote) obeliskstodrain = new ArrayList<>();
while (iter.hasNext()) {
iter.next();
if (this.worldObj.getTileEntity(
iter.n + this.xCoord,
iter.l + this.yCoord,
iter.m + this.zCoord) instanceof TileExperienceObelisk obelisk) {
ExperienceContainer cont = obelisk.getContainer();
xp = cont.getExperienceTotal();
int r11d = xpCost - xp;
if (r11d < 0) {
if (obeliskstodrain != null) {
obeliskstodrain.forEach(c -> c.drain(null, Integer.MAX_VALUE, true));
cont.drain(null, Integer.MAX_VALUE, true);
if (r11d != 0) cont.addExperience(-r11d);
}
return Integer.MAX_VALUE;
}
if (obeliskstodrain != null) obeliskstodrain.add(cont);
xpCost = r11d;
}
}
}
if (isAutomagyPresent()) {
ArrayList<TileEntityJarXP> jarstodrain = worldObj.isRemote ? null : new ArrayList<>();
iter.n = 0;
iter.l = 0;
iter.m = 0;
while (iter.hasNext()) {
iter.next();
if (this.worldObj.getTileEntity(
iter.n + this.xCoord,
iter.l + this.yCoord,
iter.m + this.zCoord) instanceof TileEntityJarXP jar) {
xp = jar.getXP();
xpCost -= xp;
if (xpCost < 0) {
if (jarstodrain != null) {
if (obeliskstodrain != null)
obeliskstodrain.forEach(c -> c.drain(null, Integer.MAX_VALUE, true));
jarstodrain.forEach(j -> j.setXP(0));
jar.setXP(-xpCost);
}
return Integer.MAX_VALUE;
}
}
}
}

return Integer.MIN_VALUE;

}

@WrapOperation(
method = "enchantPlate",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/entity/player/EntityPlayer;addExperienceLevel(Lnet/minecraft/entity/player/EntityPlayer;I)V"),
remap = false)
private void hodgepodge$avoidDrainIfNull(EntityPlayer instance, int lvl, Operation<Void> op) {
if (instance != null) return;
op.call(lvl);
}

}
Loading