Skip to content

Commit

Permalink
Improve several simulated block break actions of mods (#478)
Browse files Browse the repository at this point in the history
Co-authored-by: glowredman <[email protected]>
  • Loading branch information
Pilzinsel64 and glowredman authored Jan 21, 2025
1 parent 0d73124 commit af57067
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main/java/com/mitchej123/hodgepodge/config/TweaksConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ public class TweaksConfig {
@Config.DefaultBoolean(false)
public static boolean removeBOPQuicksandGeneration;

// Cofh

@Config.Comment("Improve CoFH's breakBlock method")
@Config.DefaultBoolean(true)
public static boolean improveCofhBreakBlock;

// Extra Utilities

@Config.Comment("Disables the spawn of zombie aid when zombie is killed by Extra Utilities Spikes, since it can spawn them too far.")
Expand Down Expand Up @@ -249,6 +255,16 @@ public class TweaksConfig {
@Config.DefaultInt(255)
public static int atropineHighID;

// Minefactory Reloaded

@Config.Comment("Improves MineFactory Reloaded smasher block to support other mods manipulating its drops")
@Config.DefaultBoolean(true)
public static boolean improveMfrBlockSmasher;

@Config.Comment("Improves MineFactory Reloaded breaker block to support other mods manipulating its drops")
@Config.DefaultBoolean(true)
public static boolean improveMfrBlockBreaker;

// NotEnoughItems

@Config.Comment("Fix vanilla potion effects rendering above the NEI tooltips in the inventory")
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java
Original file line number Diff line number Diff line change
Expand Up @@ -685,12 +685,21 @@ public enum Mixins {
FIX_ORE_DICT_CME(new Builder("Fix race condition in CoFH oredict").addMixinClasses("cofhcore.MixinFMLEventHandler")
.setPhase(Phase.EARLY).setSide(Side.CLIENT).addTargetedMod(TargetedMod.COFH_CORE)
.setApplyIf(() -> FixesConfig.fixCofhOreDictCME)),
COFH_IMPROVE_BREAKBLOCK(new Builder("Improve CoFH breakBlock method to support mods")
.addMixinClasses("cofhcore.MixinBlockHelper").setPhase(Phase.EARLY).setSide(Side.CLIENT)
.addTargetedMod(TargetedMod.COFH_CORE).setApplyIf(() -> TweaksConfig.improveCofhBreakBlock)),

// Minefactory Reloaded
DISARM_SACRED_TREE(new Builder("Prevents Sacred Rubber Tree Generation")
.addMixinClasses("minefactoryreloaded.MixinBlockRubberSapling").setPhase(Phase.LATE).setSide(Side.BOTH)
.addTargetedMod(TargetedMod.MINEFACTORY_RELOADED)
.setApplyIf(() -> FixesConfig.disableMassiveSacredTreeGeneration)),
MFR_IMPROVE_BLOCKSMASHER(new Builder("Improve MFR block smasher")
.addMixinClasses("minefactoryreloaded.MixinTileEntityBlockSmasher").setPhase(Phase.LATE).setSide(Side.BOTH)
.addTargetedMod(TargetedMod.MINEFACTORY_RELOADED).setApplyIf(() -> TweaksConfig.improveMfrBlockSmasher)),
MFR_IMPROVE_BLOCKBREAKER(new Builder("Improve MFR block breaker")
.addMixinClasses("minefactoryreloaded.MixinTileEntityBlockBreaker").setPhase(Phase.LATE).setSide(Side.BOTH)
.addTargetedMod(TargetedMod.MINEFACTORY_RELOADED).setApplyIf(() -> TweaksConfig.improveMfrBlockBreaker)),

// Immersive engineering
JAVA12_IMMERSIVE_ENGINERRING(new Builder("Immersive Engineering Java-12 safe potion array resizing")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.mitchej123.hodgepodge.mixins.early.cofhcore;

import java.util.ArrayList;

import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.event.ForgeEventFactory;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.sugar.Local;

import cofh.lib.util.helpers.BlockHelper;

@Mixin(BlockHelper.class)
public class MixinBlockHelper {

@ModifyExpressionValue(
at = @At(
target = "Lnet/minecraft/block/Block;getDrops(Lnet/minecraft/world/World;IIIII)Ljava/util/ArrayList;",
value = "INVOKE"),
method = "breakBlock(Lnet/minecraft/world/World;Lnet/minecraft/entity/player/EntityPlayer;IIILnet/minecraft/block/Block;IZZ)Ljava/util/List;",
remap = false)
private static ArrayList<ItemStack> hodgepodge$fireBlockHarvesting(ArrayList<ItemStack> drops, World world,
EntityPlayer player, int x, int y, int z, Block block, int fortune, boolean var7, boolean silkTouch,
@Local(ordinal = 6) int meta) {
ForgeEventFactory.fireBlockHarvesting(drops, world, block, x, y, z, meta, fortune, 1.0f, silkTouch, player);
return drops;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.mitchej123.hodgepodge.mixins.late.minefactoryreloaded;

import java.util.ArrayList;

import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.event.ForgeEventFactory;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.sugar.Local;

import powercrystals.minefactoryreloaded.tile.machine.TileEntityBlockBreaker;

@Mixin(TileEntityBlockBreaker.class)
public class MixinTileEntityBlockBreaker {

@ModifyExpressionValue(
at = @At(
target = "Lnet/minecraft/block/Block;getDrops(Lnet/minecraft/world/World;IIIII)Ljava/util/ArrayList;",
value = "INVOKE"),
method = "activateMachine",
remap = false)
private ArrayList<ItemStack> hodgepodge$fireBlockHarvesting(ArrayList<ItemStack> drops,
@Local(ordinal = 0) World world, @Local(ordinal = 0) Block block, @Local(ordinal = 0) int x,
@Local(ordinal = 1) int y, @Local(ordinal = 2) int z, @Local(ordinal = 3) int meta) {
ForgeEventFactory.fireBlockHarvesting(drops, world, block, x, y, z, meta, 0, 1.0f, false, null);
return drops;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.mitchej123.hodgepodge.mixins.late.minefactoryreloaded;

import java.util.ArrayList;

import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.ForgeEventFactory;

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

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.sugar.Local;

import powercrystals.minefactoryreloaded.tile.machine.TileEntityBlockSmasher;
import powercrystals.minefactoryreloaded.world.SmashingWorld;

@Mixin(TileEntityBlockSmasher.class)
public class MixinTileEntityBlockSmasher {

@Shadow(remap = false)
private int _fortune = 0;

@Shadow(remap = false)
private SmashingWorld _smashingWorld;

@ModifyExpressionValue(
at = @At(
target = "powercrystals/minefactoryreloaded/world/SmashingWorld.smashBlock(Lnet/minecraft/item/ItemStack;Lnet/minecraft/block/Block;II)Ljava/util/ArrayList;",
value = "INVOKE"),
method = "getOutput",
remap = false)
private ArrayList<ItemStack> hodgepodge$fireBlockHarvesting(ArrayList<ItemStack> drops, ItemStack lastInputStack,
@Local(ordinal = 0) Block block, @Local(ordinal = 0) ItemBlock lastInputItem) {
ForgeEventFactory.fireBlockHarvesting(
drops,
this._smashingWorld,
block,
0,
1,
0,
lastInputItem.getMetadata(lastInputStack.getItemDamage()),
this._fortune,
1.0f,
false,
null);
return drops;
}
}

0 comments on commit af57067

Please sign in to comment.