-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
f3a86c5
commit 1d45d1a
Showing
5 changed files
with
83 additions
and
1 deletion.
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
23 changes: 23 additions & 0 deletions
23
src/main/java/de/florianmichael/viafabricplus/injection/access/ITextFieldWidget.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,23 @@ | ||
/* | ||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus | ||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package de.florianmichael.viafabricplus.injection.access; | ||
|
||
public interface ITextFieldWidget { | ||
|
||
void viaFabricPlus$unlockForbiddenCharacters(); | ||
} |
54 changes: 54 additions & 0 deletions
54
src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/MixinTextFieldWidget.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,54 @@ | ||
/* | ||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus | ||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package de.florianmichael.viafabricplus.injection.mixin.base; | ||
|
||
import de.florianmichael.viafabricplus.injection.access.ITextFieldWidget; | ||
import net.minecraft.SharedConstants; | ||
import net.minecraft.client.gui.widget.TextFieldWidget; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(TextFieldWidget.class) | ||
public class MixinTextFieldWidget implements ITextFieldWidget { | ||
|
||
@Unique | ||
private boolean viaFabricPlus$forbiddenCharactersUnlocked = false; | ||
|
||
@Redirect(method = "charTyped", at = @At(value = "INVOKE", target = "Lnet/minecraft/SharedConstants;isValidChar(C)Z")) | ||
public boolean allowForbiddenCharacters(char c) { | ||
if (this.viaFabricPlus$forbiddenCharactersUnlocked) { | ||
return true; | ||
} | ||
return SharedConstants.isValidChar(c); | ||
} | ||
|
||
@Redirect(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/SharedConstants;stripInvalidChars(Ljava/lang/String;)Ljava/lang/String;")) | ||
public String allowForbiddenCharacters(String string) { | ||
if (this.viaFabricPlus$forbiddenCharactersUnlocked) { | ||
return string; | ||
} | ||
return SharedConstants.stripInvalidChars(string); | ||
} | ||
|
||
@Override | ||
public void viaFabricPlus$unlockForbiddenCharacters() { | ||
this.viaFabricPlus$forbiddenCharactersUnlocked = true; | ||
} | ||
} |
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