Skip to content

Commit

Permalink
fix GT bug that spawns a water source when breaking ice with a saw/ch… (
Browse files Browse the repository at this point in the history
#103)

* fix GT bug that spawns a water source when breaking ice with a saw/chainsaw

* added config option and moved target to GT5U

* typo
  • Loading branch information
Alexdoru authored Sep 9, 2022
1 parent 817ae42 commit da7b1ab
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
dependencies {
compile("com.github.GTNewHorizons:NotEnoughItems:2.3.1-GTNH:dev")
compile("com.github.GTNewHorizons:GT5-Unofficial:5.09.41.18:dev")
compileOnly("com.github.GTNewHorizons:ForestryMC:4.4.14:dev")
compileOnly("com.github.GTNewHorizons:EnderIO:2.3.1.43:dev")
compile("com.github.GTNewHorizons:StructureLib:1.0.15:dev")
compile("com.github.GTNewHorizons:GTNHLib:0.0.3:dev")
compile("net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class LoadingConfig {
public boolean fixHugeChatKick;
public boolean logHugeChat;
public boolean fixThaumcraftUnprotectedGetBlock;
public boolean fixGTSawSpawningWaterWithIceBLock;
public boolean fixUrlDetection;
public boolean fixVanillaUnprotectedGetBlock;
public boolean fixWorldGetBlock;
Expand Down Expand Up @@ -140,6 +141,12 @@ public LoadingConfig(File file) {
true,
"Various Thaumcraft unchecked getBlock() patches")
.getBoolean();
fixGTSawSpawningWaterWithIceBLock = config.get(
"fixes",
"fixGTSawSpawningWaterWithIceBLock",
true,
"Fixes GT bug that spawns a water source after breaking an ice block with a GT Saw")
.getBoolean();
fixHungerOverhaul = config.get("fixes", "fixHungerOverhaul", true, "Fix hunger overhaul low stat effects")
.getBoolean();
removeUpdateChecks = config.get("fixes", "removeUpdateChecks", true, "Remove old/stale/outdated update checks.")
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ public enum Mixins {
"gregtech.textures.MixinGT_GeneratedMaterial_Renderer",
() -> Hodgepodge.config.speedupAnimations,
TargetedMod.GT5U),
FIX_SAW_ICE_BREAK(
"minecraft.MixinBlockIce", () -> Hodgepodge.config.fixGTSawSpawningWaterWithIceBLock, TargetedMod.GT5U),

// COFH
COFH_CORE_UPDATE_CHECK(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.mitchej123.hodgepodge.mixins.minecraft;

import gregtech.api.items.GT_MetaGenerated_Tool;
import gregtech.common.tools.GT_Tool_Saw;
import net.minecraft.block.Block;
import net.minecraft.block.BlockIce;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(BlockIce.class)
public class MixinBlockIce {

/**
* Fixes the gregtech bug where breaking an ice block with a saw or chainsaw drops the block and spawns a water source
*/
@Redirect(
method = "harvestBlock",
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlock(IIILnet/minecraft/block/Block;)Z"))
public boolean hodgepodge$fixWaterSpawnWithGTSaw(
World instance,
int x,
int y,
int z,
Block block,
World p_149636_1_,
EntityPlayer p_149636_2_,
int p_149636_3_,
int p_149636_4_,
int p_149636_5_,
int p_149636_6_) {
final ItemStack itemStack = p_149636_2_.getCurrentEquippedItem();
if (itemStack == null
|| !(itemStack.getItem() instanceof GT_MetaGenerated_Tool)
|| !(((GT_MetaGenerated_Tool) itemStack.getItem()).getToolStats(itemStack) instanceof GT_Tool_Saw)) {
return instance.setBlock(x, y, z, block);
}
return false;
}
}

0 comments on commit da7b1ab

Please sign in to comment.