-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More work, start new features package
- Loading branch information
1 parent
61b8228
commit c326444
Showing
45 changed files
with
565 additions
and
261 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
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
49 changes: 49 additions & 0 deletions
49
...ain/java/com/viaversion/viafabricplus/features2/item/negative_items/NegativeItemUtil.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,49 @@ | ||
/* | ||
* This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus | ||
* Copyright (C) 2021-2024 the original authors | ||
* - FlorianMichael/EnZaXD <[email protected]> | ||
* - RK_01/RaphiMC | ||
* Copyright (C) 2023-2024 ViaVersion 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 com.viaversion.viafabricplus.features2.item.negative_items; | ||
|
||
import com.viaversion.viafabricplus.util.ItemUtil; | ||
import com.viaversion.viaversion.protocols.v1_10to1_11.Protocol1_10To1_11; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.nbt.NbtCompound; | ||
|
||
public class NegativeItemUtil { | ||
|
||
private static final String VV_IDENTIFIER = "VV|" + Protocol1_10To1_11.class.getSimpleName(); // ItemRewriter#nbtTagName | ||
|
||
/** | ||
* Returns the actual amount of items in the stack, versions older or equal to 1.10 can have negative stack sizes | ||
* which are not represented by {@link ItemStack#getCount()}. | ||
* | ||
* @param stack The stack to get the count from | ||
* @return The actual amount of items in the stack | ||
*/ | ||
public static int getCount(final ItemStack stack) { | ||
final NbtCompound tag = ItemUtil.getTagOrNull(stack); | ||
if (tag != null && tag.contains(VV_IDENTIFIER)) { | ||
return tag.getInt(VV_IDENTIFIER); | ||
} else { | ||
return stack.getCount(); | ||
} | ||
} | ||
|
||
} |
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
60 changes: 60 additions & 0 deletions
60
src/main/java/com/viaversion/viafabricplus/features2/max_chat_length/MaxChatLength.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,60 @@ | ||
/* | ||
* This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus | ||
* Copyright (C) 2021-2024 the original authors | ||
* - FlorianMichael/EnZaXD <[email protected]> | ||
* - RK_01/RaphiMC | ||
* Copyright (C) 2023-2024 ViaVersion 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 com.viaversion.viafabricplus.features2.max_chat_length; | ||
|
||
import com.viaversion.viafabricplus.injection.access.IClientConnection; | ||
import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; | ||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.network.ClientPlayNetworkHandler; | ||
import net.raphimc.viabedrock.api.BedrockProtocolVersion; | ||
import net.raphimc.vialegacy.api.LegacyProtocolVersion; | ||
import net.raphimc.vialegacy.protocol.classic.c0_30cpetoc0_28_30.data.ClassicProtocolExtension; | ||
import net.raphimc.vialegacy.protocol.classic.c0_30cpetoc0_28_30.storage.ExtensionProtocolMetadataStorage; | ||
|
||
public class MaxChatLength { | ||
|
||
/** | ||
* Calculates the maximum chat length for the selected protocol version in {@link ProtocolTranslator#getTargetVersion()} | ||
* | ||
* @return The maximum chat length | ||
*/ | ||
public static int getChatLength() { | ||
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) { | ||
final ClientPlayNetworkHandler handler = MinecraftClient.getInstance().getNetworkHandler(); | ||
final ExtensionProtocolMetadataStorage extensionProtocol = ((IClientConnection) handler.getConnection()).viaFabricPlus$getUserConnection().get(ExtensionProtocolMetadataStorage.class); | ||
|
||
if (extensionProtocol != null && extensionProtocol.hasServerExtension(ClassicProtocolExtension.LONGER_MESSAGES)) { | ||
return Short.MAX_VALUE * 2; | ||
} else { | ||
return 64 - (MinecraftClient.getInstance().getSession().getUsername().length() + 2); | ||
} | ||
} else if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { | ||
return 512; | ||
} else if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_9_3)) { | ||
return 100; | ||
} else { | ||
return 256; | ||
} | ||
} | ||
|
||
} |
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
72 changes: 72 additions & 0 deletions
72
...a/com/viaversion/viafabricplus/injection/mixin/base/integration/MixinConnectScreen_1.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,72 @@ | ||
/* | ||
* This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus | ||
* Copyright (C) 2021-2024 the original authors | ||
* - FlorianMichael/EnZaXD <[email protected]> | ||
* - RK_01/RaphiMC | ||
* Copyright (C) 2023-2024 ViaVersion 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 com.viaversion.viafabricplus.injection.mixin.base.integration; | ||
|
||
import com.llamalad7.mixinextras.sugar.Local; | ||
import com.viaversion.viaversion.api.connection.UserConnection; | ||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; | ||
import com.viaversion.viafabricplus.ViaFabricPlus; | ||
import com.viaversion.viafabricplus.injection.access.IClientConnection; | ||
import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; | ||
import net.minecraft.client.network.ServerAddress; | ||
import net.minecraft.network.ClientConnection; | ||
import net.raphimc.minecraftauth.step.bedrock.StepMCChain; | ||
import net.raphimc.minecraftauth.step.bedrock.session.StepFullBedrockSession; | ||
import net.raphimc.viabedrock.api.BedrockProtocolVersion; | ||
import net.raphimc.viabedrock.protocol.storage.AuthChainData; | ||
import org.spongepowered.asm.mixin.Final; | ||
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.Inject; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import java.net.InetSocketAddress; | ||
import java.util.UUID; | ||
|
||
@Mixin(targets = "net.minecraft.client.gui.screen.multiplayer.ConnectScreen$1") | ||
public abstract class MixinConnectScreen_1 { | ||
|
||
@Final | ||
@Shadow | ||
ServerAddress field_33737; | ||
|
||
@Inject(method = "run", at = @At(value = "INVOKE", target = "Lio/netty/channel/ChannelFuture;syncUninterruptibly()Lio/netty/channel/ChannelFuture;", remap = false, shift = At.Shift.AFTER)) | ||
private void setupBedrockAccount(CallbackInfo ci, @Local ClientConnection clientConnection) { | ||
final UserConnection userConnection = ((IClientConnection) clientConnection).viaFabricPlus$getUserConnection(); | ||
|
||
if (ProtocolTranslator.getTargetVersion() == BedrockProtocolVersion.bedrockLatest) { | ||
final StepFullBedrockSession.FullBedrockSession bedrockSession = ViaFabricPlus.global().getSaveManager().getAccountsSave().refreshAndGetBedrockAccount(); | ||
if (bedrockSession != null) { | ||
final StepMCChain.MCChain mcChain = bedrockSession.getMcChain(); | ||
final UUID deviceId = mcChain.getXblXsts().getInitialXblSession().getXblDeviceToken().getId(); | ||
final String playFabId = bedrockSession.getPlayFabToken().getPlayFabId(); | ||
|
||
userConnection.put(new AuthChainData(mcChain.getMojangJwt(), mcChain.getIdentityJwt(), mcChain.getPublicKey(), mcChain.getPrivateKey(), deviceId, playFabId)); | ||
} else { | ||
ViaFabricPlus.global().getLogger().warn("Could not get Bedrock account. Joining online mode servers will not work!"); | ||
} | ||
} | ||
} | ||
|
||
} |
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
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
Oops, something went wrong.