-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support to craft item directly from recipe book
- Loading branch information
1 parent
b7fd171
commit f29bfce
Showing
5 changed files
with
153 additions
and
66 deletions.
There are no files selected for viewing
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
35 changes: 35 additions & 0 deletions
35
src/main/java/com/mrcrayfish/controllable/mixin/client/RecipeBookPageAccessor.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,35 @@ | ||
package com.mrcrayfish.controllable.mixin.client; | ||
|
||
import net.minecraft.client.gui.recipebook.RecipeBookPage; | ||
import net.minecraft.client.gui.recipebook.RecipeWidget; | ||
import net.minecraft.client.gui.widget.ToggleWidget; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
import org.spongepowered.asm.mixin.gen.Invoker; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Author: MrCrayfish | ||
*/ | ||
@Mixin(RecipeBookPage.class) | ||
public interface RecipeBookPageAccessor | ||
{ | ||
@Accessor("buttons") | ||
List<RecipeWidget> getButtons(); | ||
|
||
@Accessor("forwardButton") | ||
ToggleWidget getForwardButton(); | ||
|
||
@Accessor("backButton") | ||
ToggleWidget getBackButton(); | ||
|
||
@Accessor("currentPage") | ||
int getCurrentPage(); | ||
|
||
@Accessor("currentPage") | ||
void setCurrentPage(int page); | ||
|
||
@Invoker("updateButtonsForPage") | ||
void invokeUpdateButtonsForPage(); | ||
} |
39 changes: 17 additions & 22 deletions
39
src/main/java/com/mrcrayfish/controllable/mixin/client/RecipeBookPageMixin.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 |
---|---|---|
@@ -1,35 +1,30 @@ | ||
package com.mrcrayfish.controllable.mixin.client; | ||
|
||
import com.mrcrayfish.controllable.Controllable; | ||
import net.minecraft.client.gui.recipebook.RecipeBookPage; | ||
import net.minecraft.client.gui.recipebook.RecipeWidget; | ||
import net.minecraft.client.gui.widget.ToggleWidget; | ||
import net.minecraft.util.text.ITextComponent; | ||
import net.minecraft.util.text.TextFormatting; | ||
import net.minecraft.util.text.TranslationTextComponent; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
import org.spongepowered.asm.mixin.gen.Invoker; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.ModifyArgs; | ||
import org.spongepowered.asm.mixin.injection.invoke.arg.Args; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Author: MrCrayfish | ||
*/ | ||
@Mixin(RecipeBookPage.class) | ||
public interface RecipeBookPageMixin | ||
public class RecipeBookPageMixin | ||
{ | ||
@Accessor("buttons") | ||
List<RecipeWidget> getButtons(); | ||
|
||
@Accessor("forwardButton") | ||
ToggleWidget getForwardButton(); | ||
|
||
@Accessor("backButton") | ||
ToggleWidget getBackButton(); | ||
|
||
@Accessor("currentPage") | ||
int getCurrentPage(); | ||
|
||
@Accessor("currentPage") | ||
void setCurrentPage(int page); | ||
|
||
@Invoker("updateButtonsForPage") | ||
void invokeUpdateButtonsForPage(); | ||
@ModifyArgs(method = "func_238926_a_", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;func_243308_b(Lcom/mojang/blaze3d/matrix/MatrixStack;Ljava/util/List;II)V")) | ||
private void modifyRenderToolTip(Args args) | ||
{ | ||
if(Controllable.getInput().isControllerInUse()) | ||
{ | ||
List<ITextComponent> components = args.get(1); | ||
components.add(new TranslationTextComponent("controllable.tooltip.craft").mergeStyle(TextFormatting.BOLD).mergeStyle(TextFormatting.BLUE)); | ||
} | ||
} | ||
} |
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
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