-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Issues with Changing Modes on GCYM Multiblocks
- Loading branch information
1 parent
e86bb33
commit 42a6735
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
src/main/java/com/nomiceu/nomilabs/mixin/gregtech/MultiMapMultiblockControllerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.nomiceu.nomilabs.mixin.gregtech; | ||
|
||
import net.minecraft.util.ResourceLocation; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import gregtech.api.capability.impl.MultiblockRecipeLogic; | ||
import gregtech.api.metatileentity.multiblock.MultiMapMultiblockController; | ||
import gregtech.api.metatileentity.multiblock.RecipeMapMultiblockController; | ||
import gregtech.api.recipes.RecipeMap; | ||
|
||
/** | ||
* Fixes Recipes not being Rechecked when Mode Changed in GUI. | ||
* <p> | ||
* Allows Changing Modes with Screwdriver when Machine Active. | ||
*/ | ||
@Mixin(value = MultiMapMultiblockController.class, remap = false) | ||
public abstract class MultiMapMultiblockControllerMixin extends RecipeMapMultiblockController { | ||
|
||
/** | ||
* Mandatory Ignored Constructor | ||
*/ | ||
public MultiMapMultiblockControllerMixin(ResourceLocation metaTileEntityId, RecipeMap<?> recipeMap) { | ||
super(metaTileEntityId, recipeMap); | ||
} | ||
|
||
@Redirect(method = "onScrewdriverClick", | ||
at = @At(value = "INVOKE", target = "Lgregtech/api/capability/impl/MultiblockRecipeLogic;isActive()Z"), | ||
require = 1) | ||
private boolean allowModeChangeWhenActive(MultiblockRecipeLogic instance) { | ||
return false; | ||
} | ||
|
||
/** | ||
* Cancel original recipe recheck in on screwdriver click, prevent double recheck | ||
*/ | ||
@Redirect(method = "onScrewdriverClick", | ||
at = @At(value = "INVOKE", | ||
target = "Lgregtech/api/capability/impl/MultiblockRecipeLogic;forceRecipeRecheck()V"), | ||
require = 1) | ||
private void cancelOriginalRecheck(MultiblockRecipeLogic instance) {} | ||
|
||
@Inject(method = "setRecipeMapIndex", at = @At("RETURN")) | ||
private void forceRecheck(int index, CallbackInfo ci) { | ||
if (!getWorld().isRemote) recipeMapWorkable.forceRecipeRecheck(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters