-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0cffe76
commit 2e183c5
Showing
6 changed files
with
77 additions
and
4 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
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
30 changes: 30 additions & 0 deletions
30
src/main/java/io/github/sakurawald/module/mixin/color/anvil/AnvilScreenHandlerMixin.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,30 @@ | ||
package io.github.sakurawald.module.mixin.color.anvil; | ||
|
||
import io.github.sakurawald.util.MessageUtil; | ||
import net.minecraft.entity.player.PlayerInventory; | ||
import net.minecraft.screen.AnvilScreenHandler; | ||
import net.minecraft.screen.ForgingScreenHandler; | ||
import net.minecraft.screen.ScreenHandlerContext; | ||
import net.minecraft.screen.ScreenHandlerType; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.ModifyArg; | ||
|
||
@Mixin(AnvilScreenHandler.class) | ||
public abstract class AnvilScreenHandlerMixin { | ||
|
||
@Shadow | ||
private String newItemName; | ||
|
||
@ModifyArg(method = "updateResult", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;set(Lnet/minecraft/component/ComponentType;Ljava/lang/Object;)Ljava/lang/Object;", ordinal = 0)) | ||
public Object updateResult(Object text) { | ||
return MessageUtil.ofText(newItemName); | ||
} | ||
|
||
@ModifyArg(method = "setNewItemName", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;set(Lnet/minecraft/component/ComponentType;Ljava/lang/Object;)Ljava/lang/Object;", ordinal = 0)) | ||
public Object newItemName(Object text) { | ||
return MessageUtil.ofText(newItemName); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/io/github/sakurawald/module/mixin/color/sign/SignBlockEntityMixin.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,31 @@ | ||
package io.github.sakurawald.module.mixin.color.sign; | ||
|
||
import io.github.sakurawald.util.MessageUtil; | ||
import lombok.extern.slf4j.Slf4j; | ||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; | ||
import net.minecraft.block.entity.SignBlockEntity; | ||
import net.minecraft.block.entity.SignText; | ||
import net.minecraft.text.Text; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.ModifyVariable; | ||
|
||
import java.util.Arrays; | ||
|
||
@Mixin(SignBlockEntity.class) | ||
@Slf4j | ||
public class SignBlockEntityMixin { | ||
|
||
@ModifyVariable(method = "setText", at = @At("HEAD"), argsOnly = true) | ||
SignText method(SignText signText) { | ||
Text[] messages = signText.getMessages(false); | ||
Text[] newMessages = new Text[messages.length]; | ||
for (int i = 0; i < messages.length; i++) { | ||
String string = PlainTextComponentSerializer.plainText().serialize(messages[i].asComponent()); | ||
Text formated = MessageUtil.ofText(string); | ||
newMessages[i] = formated; | ||
} | ||
|
||
return new SignText(newMessages, newMessages, signText.getColor(), signText.isGlowing()); | ||
} | ||
} |
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