-
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.
- Loading branch information
Showing
16 changed files
with
70 additions
and
98 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
5 changes: 5 additions & 0 deletions
5
api/src/main/java/xyz/nucleoid/server/translations/impl/LanguageGetter.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,5 @@ | ||
package xyz.nucleoid.server.translations.impl; | ||
|
||
public interface LanguageGetter { | ||
String stapi$getLanguage(); | ||
} |
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
27 changes: 0 additions & 27 deletions
27
api/src/main/java/xyz/nucleoid/server/translations/mixin/ServerPlayNetworkHandlerMixin.java
This file was deleted.
Oops, something went wrong.
11 changes: 5 additions & 6 deletions
11
api/src/main/java/xyz/nucleoid/server/translations/mixin/ServerPlayerEntityMixin.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,17 +1,16 @@ | ||
package xyz.nucleoid.server.translations.mixin; | ||
|
||
import xyz.nucleoid.server.translations.api.LocalizationTarget; | ||
import net.minecraft.server.network.ServerPlayNetworkHandler; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import xyz.nucleoid.server.translations.impl.LanguageGetter; | ||
|
||
@Mixin(ServerPlayerEntity.class) | ||
public class ServerPlayerEntityMixin implements LocalizationTarget { | ||
@Shadow public ServerPlayNetworkHandler networkHandler; | ||
public class ServerPlayerEntityMixin implements LanguageGetter { | ||
@Shadow private String language; | ||
|
||
@Override | ||
public String getLanguageCode() { | ||
return this.networkHandler != null ? ((LocalizationTarget) this.networkHandler).getLanguageCode() : null; | ||
public String stapi$getLanguage() { | ||
return this.language; | ||
} | ||
} |
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
16 changes: 6 additions & 10 deletions
16
...n/java/xyz/nucleoid/server/translations/mixin/packet/BlockEntityUpdateS2CPacketMixin.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,39 +1,35 @@ | ||
package xyz.nucleoid.server.translations.mixin.packet; | ||
|
||
import net.minecraft.nbt.NbtElement; | ||
import net.minecraft.nbt.NbtList; | ||
import net.minecraft.nbt.NbtString; | ||
import net.minecraft.text.Text; | ||
import org.jetbrains.annotations.Nullable; | ||
import xyz.nucleoid.server.translations.api.Localization; | ||
import xyz.nucleoid.server.translations.api.LocalizationTarget; | ||
import net.minecraft.block.entity.BlockEntityType; | ||
import net.minecraft.nbt.NbtCompound; | ||
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.ModifyArg; | ||
import xyz.nucleoid.server.translations.impl.ServerTranslations; | ||
import xyz.nucleoid.server.translations.impl.nbt.SignNbtLocalizer; | ||
|
||
@Mixin(BlockEntityUpdateS2CPacket.class) | ||
public class BlockEntityUpdateS2CPacketMixin { | ||
|
||
@Shadow @Final private BlockEntityType<?> blockEntityType; | ||
|
||
@ModifyArg(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketByteBuf;writeNbt(Lnet/minecraft/nbt/NbtCompound;)Lnet/minecraft/network/PacketByteBuf;")) | ||
private NbtCompound stapi$translateNbt(NbtCompound nbtCompound) { | ||
@Shadow @Final @Nullable private NbtCompound nbt; | ||
|
||
if (SignNbtLocalizer.isSign(this.blockEntityType) && nbtCompound != null) { | ||
@ModifyArg(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketByteBuf;writeNbt(Lnet/minecraft/nbt/NbtElement;)Lnet/minecraft/network/PacketByteBuf;")) | ||
private NbtElement stapi$translateNbt(NbtElement nbt) { | ||
|
||
if (SignNbtLocalizer.isSign(this.blockEntityType) && nbt instanceof NbtCompound nbtCompound) { | ||
var target = LocalizationTarget.forPacket(); | ||
|
||
if (target != null) { | ||
return SignNbtLocalizer.translateNbt(nbtCompound, LocalizationTarget.forPacket()); | ||
} | ||
} | ||
return nbtCompound; | ||
return nbt; | ||
} | ||
} |
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
16 changes: 0 additions & 16 deletions
16
src/main/java/fr/catcore/server/translations/mixin/MixinAdvancementManager.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.