Merge remote-tracking branch 'origin/main' into 1.20-recode

# Conflicts:
#	src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/MixinConnectScreen.java
#	src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/MixinDownloadingTerrainScreen.java
#	src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinInGameHud.java
#	src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinItemRenderer.java
#	src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinClientPlayerEntity.java
#	src/main/java/de/florianmichael/viafabricplus/ui/screen/MappedSlotEntry.java
#	src/main/java/de/florianmichael/viafabricplus/ui/screen/impl/ClassicItemSelectionScreen.java
#	src/main/java/de/florianmichael/viafabricplus/ui/screen/impl/base/ForceVersionScreen.java
#	src/main/java/de/florianmichael/viafabricplus/ui/screen/impl/base/ProtocolSelectionScreen.java
#	src/main/java/de/florianmichael/viafabricplus/ui/screen/impl/settings/SettingsScreen.java
#	src/main/java/de/florianmichael/viafabricplus/ui/screen/impl/settings/settingrenderer/BooleanSettingRenderer.java
#	src/main/java/de/florianmichael/viafabricplus/ui/screen/impl/settings/settingrenderer/ButtonSettingRenderer.java
#	src/main/java/de/florianmichael/viafabricplus/ui/screen/impl/settings/settingrenderer/ModeSettingRenderer.java
#	src/main/java/de/florianmichael/viafabricplus/ui/screen/impl/settings/settingrenderer/ProtocolSyncBooleanSettingRenderer.java
#	src/main/java/de/florianmichael/viafabricplus/ui/screen/impl/settings/settingrenderer/meta/TitleRenderer.java
#	src/main/java/de/florianmichael/viafabricplus/ui/screen/impl/thirdparty/BetaCraftScreen.java
#	src/main/java/de/florianmichael/viafabricplus/ui/screen/impl/thirdparty/classicube/ClassiCubeLoginScreen.java
#	src/main/java/de/florianmichael/viafabricplus/ui/screen/impl/thirdparty/classicube/ClassiCubeMFAScreen.java
#	src/main/java/de/florianmichael/viafabricplus/ui/screen/impl/thirdparty/classicube/ClassiCubeServerListScreen.java
This commit is contained in:
FlorianMichael 2023-05-13 16:21:47 +02:00
commit dac8f0deef
105 changed files with 638 additions and 699 deletions

View File

@ -11,7 +11,7 @@ public class ViaFabricPlusExampleAddon implements ClientModInitializer {
}
}
```
#### ViaFabricPlus has 8 events at the moment:
#### ViaFabricPlus has 7 events at the moment:
| Callback class name | Description |
|--------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ChangeProtocolVersionCallback | Called when the user changes the target version in the screen, or if you connect to a server for which a specific version has been selected, you disconnect, the event for the actual version is also called. |
@ -20,11 +20,10 @@ public class ViaFabricPlusExampleAddon implements ClientModInitializer {
| InitializeSettingsCallback | Called after the default setting groups are loaded and before the setting config is loaded |
| LoadClassicProtocolExtensionCallback | Called when the classic server sends the protocol extensions (only in **c0.30 CPE**) |
| PreLoadCallback | Called before everything (Pre-pre load) |
| SkipIdlePacketCallback | Called as soon as the idle packet is skipped in the <= 1.8 |
| ViaLoadingBaseBuilderCallback | Called when Via* is initialized |
### General API
#### Get the release version of an material:
#### Get the release version of a material:
```java
final ProtocolRange range = ItemReleaseVersionDefinition.INSTANCE.getItemMap().get(Items.WRITABLE_BOOK); // If an item does not appear in the item map, it has always existed
@ -52,32 +51,6 @@ PreLoadCallback.EVENT.register(() -> {
});
```
#### Implementing classic protocol commands:
```java
public class ExampleCommand implements ICommand {
@Override
public String name() {
return "example";
}
@Override
public String description() {
return null;
}
@Override
public void execute(String[] args) {
}
}
```
and then you register the command in your onLoad method:
```java
PreLoadCallback.EVENT.register(() -> {
ClassicProtocolCommands.commands.add(new ExampleCommand());
});
```
#### Implementing custom classic protocol extensions:
```java
public class ExampleExtensionSupport implements ClientModInitializer {

View File

@ -53,33 +53,36 @@ dependencies {
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
libs "com.github.FlorianMichael:ViaLoadingBase:${project.vialoadingbase_version}"
libs("org.cloudburstmc.netty:netty-transport-raknet:${project.raknet_transport_version}") {
exclude group: "io.netty", module: "netty-common"
exclude group: "io.netty", module: "netty-buffer"
exclude group: "io.netty", module: "netty-codec"
exclude group: "io.netty", module: "netty-transport"
}
libs "com.github.FlorianMichael:Classic4J:${project.classic4j_version}"
libs "com.viaversion:viaversion:${project.viaversion_version}"
libs "com.viaversion:viabackwards-common:${project.viabackwards_version}"
libs "org.yaml:snakeyaml:${project.snake_yml_version}"
libs "net.raphimc:ViaLegacy:${project.vialegacy_version}"
libs ("net.raphimc:ViaLegacy:${project.vialegacy_version}") {
exclude group: "net.lenni0451.mcstructs", module: "text"
}
libs "net.raphimc:ViaAprilFools:${project.viaaprilfools_version}"
libs ("net.raphimc:ViaBedrock:${project.viabedrock_version}") {
exclude group: "io.jsonwebtoken", module: "jjwt-api"
exclude group: "net.lenni0451.mcstructs", module: "text"
exclude group: "io.jsonwebtoken", module: "jjwt-impl"
exclude group: "io.jsonwebtoken", module: "jjwt-gson"
}
libs "io.netty:netty-codec-http:${project.netty_codec_http_version}" // Some people don't know how to define dependencies properly in a build.gradle
libs ("net.raphimc:MinecraftAuth:${project.minecraftauth_version}") {
exclude group: "com.google.code.gson", module: "gson"
exclude group: "org.slf4j", module: "slf4j-api"
}
libs "net.lenni0451.mcstructs:text:${project.mcstructs_text_version}"
libs("org.cloudburstmc.netty:netty-transport-raknet:${project.raknet_transport_version}") {
exclude group: "io.netty", module: "netty-common"
exclude group: "io.netty", module: "netty-buffer"
exclude group: "io.netty", module: "netty-codec"
exclude group: "io.netty", module: "netty-transport"
}
libs ("net.lenni0451.mcstructs:text:${project.mcstructs_text_version}") {
exclude group: "com.google.code.gson", module: "gson"
}
libs "net.lenni0451:Reflect:${project.reflect_version}"
modImplementation "com.terraformersmc:modmenu:${project.mod_menu_version}"

View File

@ -9,7 +9,7 @@ loader_version=0.14.19
fabric_api_version=0.80.1+1.20
# viafabricplus
mod_version=2.6.9
mod_version=2.7.1
maven_group=de.florianmichael
archives_base_name=viafabricplus
@ -27,7 +27,7 @@ snake_yml_version=2.0
vialegacy_version=2.2.16
viaaprilfools_version=2.0.7-SNAPSHOT
viabedrock_version=0.0.1-SNAPSHOT
minecraftauth_version=2.0.1
minecraftauth_version=2.1.1
# lenni0451 libs
mcstructs_text_version=2.2.5

View File

@ -24,15 +24,15 @@ import de.florianmichael.viafabricplus.definition.v1_12_2.FontCacheFix;
import de.florianmichael.viafabricplus.mappings.ItemReleaseVersionMappings;
import de.florianmichael.viafabricplus.mappings.PackFormatsMappings;
import de.florianmichael.viafabricplus.definition.bedrock.BedrockAccountHandler;
import de.florianmichael.viafabricplus.screen.ClassicItemSelectionScreen;
import de.florianmichael.viafabricplus.ui.screen.impl.ClassicItemSelectionScreen;
import de.florianmichael.viafabricplus.definition.c0_30.ClassiCubeAccountHandler;
import de.florianmichael.viafabricplus.definition.c0_30.protocol.CustomClassicProtocolExtensions;
import de.florianmichael.viafabricplus.mappings.ArmorPointsMappings;
import de.florianmichael.viafabricplus.event.FinishMinecraftLoadCallback;
import de.florianmichael.viafabricplus.event.PreLoadCallback;
import de.florianmichael.viafabricplus.information.InformationSystem;
import de.florianmichael.viafabricplus.definition.v1_8.ArmorPointCalculation;
import de.florianmichael.viafabricplus.base.event.FinishMinecraftLoadCallback;
import de.florianmichael.viafabricplus.base.event.PreLoadCallback;
import de.florianmichael.viafabricplus.ui.information.InformationSystem;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.settings.SettingsSystem;
import de.florianmichael.viafabricplus.base.settings.SettingsSystem;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -88,7 +88,7 @@ public class ViaFabricPlus {
// Version related mappings
PackFormatsMappings.load();
ItemReleaseVersionMappings.create();
ArmorPointsMappings.load();
ArmorPointCalculation.load();
});
}

View File

@ -15,7 +15,7 @@
* 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.util;
package de.florianmichael.viafabricplus.base;
import com.google.gson.JsonObject;
import de.florianmichael.viafabricplus.ViaFabricPlus;

View File

@ -15,7 +15,7 @@
* 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.event;
package de.florianmichael.viafabricplus.base.event;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
import net.fabricmc.fabric.api.event.Event;

View File

@ -15,7 +15,7 @@
* 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.event;
package de.florianmichael.viafabricplus.base.event;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;

View File

@ -15,7 +15,7 @@
* 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.event;
package de.florianmichael.viafabricplus.base.event;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;

View File

@ -15,7 +15,7 @@
* 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.event;
package de.florianmichael.viafabricplus.base.event;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;

View File

@ -15,7 +15,7 @@
* 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.event;
package de.florianmichael.viafabricplus.base.event;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;

View File

@ -15,7 +15,7 @@
* 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.event;
package de.florianmichael.viafabricplus.base.event;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;

View File

@ -15,7 +15,7 @@
* 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.event;
package de.florianmichael.viafabricplus.base.event;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;

View File

@ -15,7 +15,7 @@
* 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.event;
package de.florianmichael.viafabricplus.base.event;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import net.fabricmc.fabric.api.event.Event;

View File

@ -15,15 +15,16 @@
* 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.settings;
package de.florianmichael.viafabricplus.base.settings;
import com.google.gson.JsonObject;
import de.florianmichael.viafabricplus.event.InitializeSettingsCallback;
import de.florianmichael.viafabricplus.settings.base.AbstractSetting;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.settings.groups.*;
import de.florianmichael.viafabricplus.util.FileSaver;
import de.florianmichael.viafabricplus.base.event.InitializeSettingsCallback;
import de.florianmichael.viafabricplus.base.settings.base.AbstractSetting;
import de.florianmichael.viafabricplus.base.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.base.settings.groups.*;
import de.florianmichael.viafabricplus.base.FileSaver;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
import java.util.ArrayList;
import java.util.Collections;
@ -64,7 +65,9 @@ public class SettingsSystem extends FileSaver {
@Override
public void read(JsonObject object) {
if (object.has("protocol")) {
ViaLoadingBase.getInstance().reload(ViaLoadingBase.fromProtocolId(object.get("protocol").getAsInt()));
final ComparableProtocolVersion protocolVersion = ViaLoadingBase.fromProtocolId(object.get("protocol").getAsInt());
if (protocolVersion != null) ViaLoadingBase.getInstance().reload(protocolVersion);
}
for (SettingGroup group : groups) {
for (AbstractSetting<?> setting : group.getSettings()) {

View File

@ -15,11 +15,10 @@
* 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.settings.base;
package de.florianmichael.viafabricplus.base.settings.base;
import com.google.gson.JsonObject;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import de.florianmichael.viafabricplus.settings.ConfigRemapper;
import de.florianmichael.viafabricplus.ui.screen.MappedSlotEntry;
import net.minecraft.text.MutableText;
import net.minecraft.text.TranslatableTextContent;
@ -48,7 +47,7 @@ public abstract class AbstractSetting<T> {
}
public String getTranslationKey() {
return ConfigRemapper.remapp(((TranslatableTextContent) name.getContent()).getKey());
return ((TranslatableTextContent) name.getContent()).getKey();
}
public T getDefaultValue() {

View File

@ -15,7 +15,7 @@
* 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.settings.base;
package de.florianmichael.viafabricplus.base.settings.base;
import java.util.ArrayList;
import java.util.List;

View File

@ -15,14 +15,14 @@
* 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.settings.groups;
package de.florianmichael.viafabricplus.base.settings.groups;
import de.florianmichael.viafabricplus.definition.bedrock.BedrockAccountHandler;
import de.florianmichael.viafabricplus.screen.ProtocolSelectionScreen;
import de.florianmichael.viafabricplus.screen.settings.SettingsScreen;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.settings.type_impl.BooleanSetting;
import de.florianmichael.viafabricplus.settings.type_impl.ButtonSetting;
import de.florianmichael.viafabricplus.ui.screen.impl.base.ProtocolSelectionScreen;
import de.florianmichael.viafabricplus.ui.screen.impl.settings.SettingsScreen;
import de.florianmichael.viafabricplus.base.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.base.settings.type_impl.BooleanSetting;
import de.florianmichael.viafabricplus.base.settings.type_impl.ButtonSetting;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ConfirmScreen;
import net.minecraft.client.gui.screen.NoticeScreen;
@ -32,6 +32,9 @@ import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Util;
import net.raphimc.mcauth.MinecraftAuth;
import net.raphimc.mcauth.step.msa.StepMsaDeviceCode;
import net.raphimc.mcauth.util.MicrosoftConstants;
import org.apache.http.impl.client.CloseableHttpClient;
import java.net.URI;
import java.net.URISyntaxException;
@ -45,23 +48,25 @@ public class AuthenticationSettings extends SettingGroup {
public final BooleanSetting disconnectIfJoinServerCallFails = new BooleanSetting(this, Text.translatable("authentication.viafabricplus.fail"), true);
public final ButtonSetting BEDROCK_ACCOUNT = new ButtonSetting(this, Text.translatable("authentication.viafabricplus.bedrock"), () -> CompletableFuture.runAsync(() -> {
try {
BedrockAccountHandler.INSTANCE.setAccount(MinecraftAuth.requestBedrockLogin(msaDeviceCode -> {
MinecraftClient.getInstance().execute(() -> MinecraftClient.getInstance().setScreen(new ConfirmScreen(consumer -> {
if (consumer) {
MinecraftClient.getInstance().keyboard.setClipboard(msaDeviceCode.userCode());
} else {
MinecraftClient.getInstance().setScreen(SettingsScreen.get(new MultiplayerScreen(new TitleScreen())));
Thread.currentThread().interrupt();
try (final CloseableHttpClient httpClient = MicrosoftConstants.createHttpClient()) {
BedrockAccountHandler.INSTANCE.setAccount(MinecraftAuth.BEDROCK_DEVICE_CODE_LOGIN.getFromInput(httpClient, new StepMsaDeviceCode.MsaDeviceCodeCallback(msaDeviceCode -> {
MinecraftClient.getInstance().execute(() -> MinecraftClient.getInstance().setScreen(new ConfirmScreen(consumer -> {
if (consumer) {
MinecraftClient.getInstance().keyboard.setClipboard(msaDeviceCode.userCode());
} else {
SettingsScreen.INSTANCE.open(new MultiplayerScreen(new TitleScreen()));
Thread.currentThread().interrupt();
}
}, Text.literal("Microsoft Bedrock login"), Text.translatable("bedrocklogin.viafabricplus.text", msaDeviceCode.userCode()), Text.translatable("words.viafabricplus.copy"), Text.translatable("words.viafabricplus.cancel"))));
try {
Util.getOperatingSystem().open(new URI(msaDeviceCode.verificationUri()));
} catch (URISyntaxException e) {
e.printStackTrace();
MinecraftClient.getInstance().execute(() -> MinecraftClient.getInstance().setScreen(new NoticeScreen(() -> Thread.currentThread().interrupt(), Text.literal("Microsoft Bedrock login"), Text.translatable("bedrocklogin.viafabricplus.error"), Text.translatable("words.viafabricplus.cancel"), false)));
}
}, Text.literal("Microsoft Bedrock login"), Text.translatable("bedrocklogin.viafabricplus.text", msaDeviceCode.userCode()), Text.translatable("words.viafabricplus.copy"), Text.translatable("words.viafabricplus.cancel"))));
try {
Util.getOperatingSystem().open(new URI(msaDeviceCode.verificationUri()));
} catch (URISyntaxException e) {
e.printStackTrace();
MinecraftClient.getInstance().execute(() -> MinecraftClient.getInstance().setScreen(new NoticeScreen(() -> Thread.currentThread().interrupt(), Text.literal("Microsoft Bedrock login"), Text.translatable("bedrocklogin.viafabricplus.error"), Text.translatable("words.viafabricplus.cancel"), false)));
}
}));
ProtocolSelectionScreen.open(new MultiplayerScreen(new TitleScreen()));
})));
}
ProtocolSelectionScreen.INSTANCE.open(new MultiplayerScreen(new TitleScreen()));
} catch (Throwable e) {
e.printStackTrace();
}
@ -78,7 +83,7 @@ public class AuthenticationSettings extends SettingGroup {
public final BooleanSetting spoofUserNameIfUsingClassiCube = new BooleanSetting(this, Text.translatable("authentication.viafabricplus.spoof"), true);
public final BooleanSetting allowViaLegacyToLoadSkinsInLegacyVersions = new BooleanSetting(this, Text.translatable("authentication.viafabricplus.skin"), true);
public AuthenticationSettings() {
super("Authentication");
}

View File

@ -15,11 +15,11 @@
* 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.settings.groups;
package de.florianmichael.viafabricplus.base.settings.groups;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.settings.type_impl.ProtocolSyncBooleanSetting;
import de.florianmichael.viafabricplus.base.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.base.settings.type_impl.ProtocolSyncBooleanSetting;
import de.florianmichael.vialoadingbase.model.ProtocolRange;
import net.minecraft.text.Text;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;

View File

@ -15,10 +15,10 @@
* 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.settings.groups;
package de.florianmichael.viafabricplus.base.settings.groups;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.settings.type_impl.BooleanSetting;
import de.florianmichael.viafabricplus.base.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.base.settings.type_impl.BooleanSetting;
import net.minecraft.text.Text;
public class ExperimentalSettings extends SettingGroup {

View File

@ -15,11 +15,11 @@
* 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.settings.groups;
package de.florianmichael.viafabricplus.base.settings.groups;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.settings.type_impl.BooleanSetting;
import de.florianmichael.viafabricplus.settings.type_impl.ModeSetting;
import de.florianmichael.viafabricplus.base.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.base.settings.type_impl.BooleanSetting;
import de.florianmichael.viafabricplus.base.settings.type_impl.ModeSetting;
import net.minecraft.text.Text;
public class GeneralSettings extends SettingGroup {

View File

@ -15,11 +15,11 @@
* 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.settings.groups;
package de.florianmichael.viafabricplus.base.settings.groups;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.settings.type_impl.ProtocolSyncBooleanSetting;
import de.florianmichael.viafabricplus.base.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.base.settings.type_impl.ProtocolSyncBooleanSetting;
import de.florianmichael.vialoadingbase.model.ProtocolRange;
import net.minecraft.text.Text;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;

View File

@ -15,13 +15,13 @@
* 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.settings.type_impl;
package de.florianmichael.viafabricplus.base.settings.type_impl;
import com.google.gson.JsonObject;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import de.florianmichael.viafabricplus.screen.settings.settingrenderer.BooleanSettingRenderer;
import de.florianmichael.viafabricplus.settings.base.AbstractSetting;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.ui.screen.MappedSlotEntry;
import de.florianmichael.viafabricplus.ui.screen.impl.settings.settingrenderer.BooleanSettingRenderer;
import de.florianmichael.viafabricplus.base.settings.base.AbstractSetting;
import de.florianmichael.viafabricplus.base.settings.base.SettingGroup;
import net.minecraft.text.MutableText;
public class BooleanSetting extends AbstractSetting<Boolean> {

View File

@ -15,13 +15,13 @@
* 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.settings.type_impl;
package de.florianmichael.viafabricplus.base.settings.type_impl;
import com.google.gson.JsonObject;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import de.florianmichael.viafabricplus.screen.settings.settingrenderer.ButtonSettingRenderer;
import de.florianmichael.viafabricplus.settings.base.AbstractSetting;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.ui.screen.MappedSlotEntry;
import de.florianmichael.viafabricplus.ui.screen.impl.settings.settingrenderer.ButtonSettingRenderer;
import de.florianmichael.viafabricplus.base.settings.base.AbstractSetting;
import de.florianmichael.viafabricplus.base.settings.base.SettingGroup;
import net.minecraft.text.MutableText;
public class ButtonSetting extends AbstractSetting<Runnable> {

View File

@ -15,13 +15,13 @@
* 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.settings.type_impl;
package de.florianmichael.viafabricplus.base.settings.type_impl;
import com.google.gson.JsonObject;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import de.florianmichael.viafabricplus.screen.settings.settingrenderer.ModeSettingRenderer;
import de.florianmichael.viafabricplus.settings.base.AbstractSetting;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.ui.screen.MappedSlotEntry;
import de.florianmichael.viafabricplus.ui.screen.impl.settings.settingrenderer.ModeSettingRenderer;
import de.florianmichael.viafabricplus.base.settings.base.AbstractSetting;
import de.florianmichael.viafabricplus.base.settings.base.SettingGroup;
import net.minecraft.text.MutableText;
import java.util.Arrays;

View File

@ -15,13 +15,13 @@
* 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.settings.type_impl;
package de.florianmichael.viafabricplus.base.settings.type_impl;
import com.google.gson.JsonObject;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import de.florianmichael.viafabricplus.screen.settings.settingrenderer.ProtocolSyncBooleanSettingRenderer;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.settings.groups.GeneralSettings;
import de.florianmichael.viafabricplus.ui.screen.MappedSlotEntry;
import de.florianmichael.viafabricplus.ui.screen.impl.settings.settingrenderer.ProtocolSyncBooleanSettingRenderer;
import de.florianmichael.viafabricplus.base.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.base.settings.groups.GeneralSettings;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.vialoadingbase.model.ProtocolRange;
import net.minecraft.text.MutableText;

View File

@ -18,8 +18,8 @@
package de.florianmichael.viafabricplus.definition;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.event.LoadClassicProtocolExtensionCallback;
import de.florianmichael.viafabricplus.base.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.base.event.LoadClassicProtocolExtensionCallback;
import net.minecraft.client.MinecraftClient;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.data.ClassicProtocolExtension;

View File

@ -19,8 +19,8 @@ package de.florianmichael.viafabricplus.definition.bedrock;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import de.florianmichael.viafabricplus.util.FileSaver;
import de.florianmichael.viafabricplus.util.ScreenUtil;
import de.florianmichael.viafabricplus.ViaFabricPlus;
import de.florianmichael.viafabricplus.base.FileSaver;
import net.raphimc.mcauth.MinecraftAuth;
import net.raphimc.mcauth.step.bedrock.StepMCChain;
import net.raphimc.mcauth.util.MicrosoftConstants;
@ -54,13 +54,12 @@ public class BedrockAccountHandler extends FileSaver {
@Override
public void read(JsonObject object) {
try {
account = MinecraftAuth.Bedrock.Title.MC_CHAIN.fromJson(object);
account = MinecraftAuth.BEDROCK_DEVICE_CODE_LOGIN.fromJson(object);
try (final CloseableHttpClient httpClient = MicrosoftConstants.createHttpClient()) {
account = MinecraftAuth.Bedrock.Title.MC_CHAIN.refresh(httpClient, account);
account = MinecraftAuth.BEDROCK_DEVICE_CODE_LOGIN.refresh(httpClient, account);
}
} catch (Exception e) {
ScreenUtil.crash("Failed to log into Bedrock account!", e);
ViaFabricPlus.LOGGER.warn("No Bedrock account could be found");
}
}

View File

@ -20,10 +20,10 @@ package de.florianmichael.viafabricplus.definition.c0_30;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import de.florianmichael.classic4j.model.classicube.highlevel.CCAccount;
import de.florianmichael.viafabricplus.event.DisconnectConnectionCallback;
import de.florianmichael.viafabricplus.ViaFabricPlus;
import de.florianmichael.viafabricplus.base.event.DisconnectConnectionCallback;
import de.florianmichael.viafabricplus.protocolhack.provider.vialegacy.ViaFabricPlusClassicMPPassProvider;
import de.florianmichael.viafabricplus.util.FileSaver;
import de.florianmichael.viafabricplus.util.ScreenUtil;
import de.florianmichael.viafabricplus.base.FileSaver;
import java.util.Map;
@ -37,6 +37,9 @@ public class ClassiCubeAccountHandler extends FileSaver {
private CCAccount account;
private String username;
private String password;
public ClassiCubeAccountHandler() {
super("classicube.account");
@ -45,28 +48,33 @@ public class ClassiCubeAccountHandler extends FileSaver {
@Override
public void write(JsonObject object) {
if (account == null) return;
account.token = null; // Token has to be created next time
for (Map.Entry<String, JsonElement> entry : account.asJson().entrySet()) {
object.add(entry.getKey(), entry.getValue());
}
object.addProperty("username", username);
object.addProperty("password", password);
}
@Override
public void read(JsonObject object) {
try {
account = CCAccount.fromJson(object);
} catch (Exception e) {
ScreenUtil.crash("Failed to log into ClassiCube account!", e);
}
if (object.has("username")) username = object.get("username").getAsString();
if (object.has("password")) password = object.get("password").getAsString();
}
public CCAccount getAccount() {
return account;
}
public String getUsername() {
return username;
}
public String getPassword() {
return password;
}
public void setAccount(CCAccount account) {
this.account = account;
if (account != null) {
username = account.username();
password = account.password();
}
}
}

View File

@ -18,8 +18,8 @@
package de.florianmichael.viafabricplus.definition.c0_30.protocol;
import com.viaversion.viaversion.api.connection.UserConnection;
import de.florianmichael.viafabricplus.screen.ClassicItemSelectionScreen;
import de.florianmichael.viafabricplus.event.LoadClassicProtocolExtensionCallback;
import de.florianmichael.viafabricplus.ui.screen.impl.ClassicItemSelectionScreen;
import de.florianmichael.viafabricplus.base.event.LoadClassicProtocolExtensionCallback;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import io.netty.buffer.ByteBuf;
import net.lenni0451.reflect.Enums;

View File

@ -19,10 +19,9 @@ package de.florianmichael.viafabricplus.definition.v1_12_2;
import com.mojang.blaze3d.systems.RenderSystem;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.base.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.injection.access.IFontStorage;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.settings.groups.ExperimentalSettings;
import de.florianmichael.viafabricplus.base.settings.groups.ExperimentalSettings;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
import net.fabricmc.loader.api.FabricLoader;

View File

@ -15,7 +15,7 @@
* 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.mappings;
package de.florianmichael.viafabricplus.definition.v1_8;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ArmorType;
import net.minecraft.client.MinecraftClient;
@ -29,7 +29,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ArmorPointsMappings {
public class ArmorPointCalculation {
public final static List<Item> ARMOR_ITEMS_IN_1_8 = Arrays.asList(
Items.LEATHER_HELMET,
Items.LEATHER_CHESTPLATE,
@ -66,6 +66,6 @@ public class ArmorPointsMappings {
}
public static int sum() {
return MinecraftClient.getInstance().player.getInventory().armor.stream().mapToInt(ArmorPointsMappings::getArmorPoints).sum();
return MinecraftClient.getInstance().player.getInventory().armor.stream().mapToInt(ArmorPointCalculation::getArmorPoints).sum();
}
}

View File

@ -1,32 +0,0 @@
/*
* 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.event;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
public interface SkipIdlePacketCallback {
Event<SkipIdlePacketCallback> EVENT = EventFactory.createArrayBacked(SkipIdlePacketCallback.class, listeners -> () -> {
for (SkipIdlePacketCallback listener : listeners) {
listener.onSkipIdlePacket();
}
});
void onSkipIdlePacket();
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.base;
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
import de.florianmichael.viafabricplus.screen.ForceVersionScreen;
import de.florianmichael.viafabricplus.ui.screen.impl.base.ForceVersionScreen;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
import net.minecraft.client.gui.screen.AddServerScreen;
import net.minecraft.client.gui.screen.Screen;

View File

@ -17,8 +17,8 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.base;
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.event.DisconnectConnectionCallback;
import de.florianmichael.viafabricplus.base.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.base.event.DisconnectConnectionCallback;
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.protocolhack.netty.ViaFabricPlusVLBPipeline;

View File

@ -18,6 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.base;
import de.florianmichael.viafabricplus.definition.c0_30.ClassicProgressRenderer;
import de.florianmichael.viafabricplus.base.settings.groups.GeneralSettings;
import de.florianmichael.viafabricplus.settings.groups.GeneralSettings;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ConnectScreen;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.base;
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.base.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;

View File

@ -19,12 +19,12 @@ package de.florianmichael.viafabricplus.injection.mixin.base;
import com.viaversion.viaversion.api.connection.UserConnection;
import de.florianmichael.viafabricplus.ViaFabricPlus;
import de.florianmichael.viafabricplus.information.AbstractInformationGroup;
import de.florianmichael.viafabricplus.ui.information.AbstractInformationGroup;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.settings.groups.GeneralSettings;
import de.florianmichael.viafabricplus.util.ScreenUtil;
import de.florianmichael.viafabricplus.base.settings.groups.GeneralSettings;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.hud.DebugHud;
import net.minecraft.util.Formatting;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@ -45,7 +45,7 @@ public class MixinDebugHud {
final UserConnection userConnection = MinecraftClient.getInstance().getNetworkHandler().getConnection().channel.attr(ProtocolHack.LOCAL_VIA_CONNECTION).get();
information.add("");
information.add(ScreenUtil.prefixedMessage("").trim());
information.add(Formatting.GOLD + "[ViaFabricPlus] " + Formatting.WHITE);
for (AbstractInformationGroup group : ViaFabricPlus.INSTANCE.getInformationSystem().getGroups()) {
if (group.getProtocolRange() != null && !group.getProtocolRange().contains(ProtocolHack.getTargetVersion())) continue;

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.base;
import de.florianmichael.viafabricplus.definition.c0_30.ClassicProgressRenderer;
import de.florianmichael.viafabricplus.settings.groups.GeneralSettings;
import de.florianmichael.viafabricplus.base.settings.groups.GeneralSettings;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.DownloadingTerrainScreen;
import net.minecraft.client.util.math.MatrixStack;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.base;
import de.florianmichael.viafabricplus.event.FinishMinecraftLoadCallback;
import de.florianmichael.viafabricplus.base.event.FinishMinecraftLoadCallback;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.RunArgs;
import org.spongepowered.asm.mixin.Mixin;

View File

@ -19,8 +19,8 @@ package de.florianmichael.viafabricplus.injection.mixin.base;
import de.florianmichael.viafabricplus.definition.v1_14_4.LegacyServerAddress;
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
import de.florianmichael.viafabricplus.screen.ProtocolSelectionScreen;
import de.florianmichael.viafabricplus.settings.groups.GeneralSettings;
import de.florianmichael.viafabricplus.ui.screen.impl.base.ProtocolSelectionScreen;
import de.florianmichael.viafabricplus.base.settings.groups.GeneralSettings;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
@ -43,7 +43,7 @@ public class MixinMultiplayerScreen extends Screen {
@Inject(method = "init", at = @At("RETURN"))
public void addProtocolSelectionButton(CallbackInfo ci) {
ButtonWidget.Builder builder = ButtonWidget.builder(Text.literal("ViaFabricPlus"), button -> ProtocolSelectionScreen.open(this));
ButtonWidget.Builder builder = ButtonWidget.builder(Text.literal("ViaFabricPlus"), button -> ProtocolSelectionScreen.INSTANCE.open(this));
final int orientation = GeneralSettings.INSTANCE.mainButtonOrientation.getIndex();
switch (orientation) {

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.base;
import de.florianmichael.viafabricplus.settings.groups.GeneralSettings;
import de.florianmichael.viafabricplus.base.settings.groups.GeneralSettings;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.option.OptionsScreen;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.base;
import de.florianmichael.viafabricplus.screen.classicube.ClassiCubeLoginScreen;
import de.florianmichael.viafabricplus.ui.screen.impl.thirdparty.classicube.ClassiCubeLoginScreen;
import net.minecraft.SharedConstants;
import net.minecraft.client.MinecraftClient;
import org.spongepowered.asm.mixin.Mixin;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
import de.florianmichael.viafabricplus.settings.groups.VisualSettings;
import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings;
import net.minecraft.client.model.ModelPart;
import net.minecraft.client.render.entity.model.BipedEntityModel;
import net.minecraft.entity.LivingEntity;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
import de.florianmichael.viafabricplus.settings.groups.DebugSettings;
import de.florianmichael.viafabricplus.base.settings.groups.DebugSettings;
import net.minecraft.client.render.Camera;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;

View File

@ -20,7 +20,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
import com.mojang.authlib.GameProfile;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.ViaFabricPlus;
import de.florianmichael.viafabricplus.settings.groups.VisualSettings;
import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.DownloadingTerrainScreen;

View File

@ -17,8 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
import de.florianmichael.viafabricplus.settings.groups.VisualSettings;
import net.minecraft.client.gui.DrawContext;
import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings;
import net.minecraft.client.gui.hud.InGameHud;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.JumpingMount;
@ -41,17 +40,17 @@ public abstract class MixinInGameHud {
// Removing newer elements
@Inject(method = "renderExperienceBar", at = @At("HEAD"), cancellable = true)
public void removeExperienceBar(DrawContext context, int x, CallbackInfo ci) {
public void removeExperienceBar(MatrixStack matrices, int x, CallbackInfo ci) {
if (VisualSettings.INSTANCE.removeNewerHudElements.getValue()) ci.cancel();
}
@Inject(method = "renderMountJumpBar", at = @At("HEAD"), cancellable = true)
public void removeMountJumpBar(JumpingMount mount, DrawContext context, int x, CallbackInfo ci) {
public void removeMountJumpBar(JumpingMount mount, MatrixStack matrices, int x, CallbackInfo ci) {
if (VisualSettings.INSTANCE.removeNewerHudElements.getValue()) ci.cancel();
}
@Inject(method = "renderMountHealth", at = @At("HEAD"), cancellable = true)
public void removeMountHealth(DrawContext context, CallbackInfo ci) {
public void removeMountHealth(MatrixStack matrices, CallbackInfo ci) {
if (VisualSettings.INSTANCE.removeNewerHudElements.getValue()) ci.cancel();
}
@ -70,7 +69,7 @@ public abstract class MixinInGameHud {
return scaledHeight;
}
@ModifyArg(method = "renderStatusBars", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIIIII)V"), slice = @Slice(
@ModifyArg(method = "renderStatusBars", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/InGameHud;drawTexture(Lnet/minecraft/client/util/math/MatrixStack;IIIIII)V"), slice = @Slice(
from = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;push(Ljava/lang/String;)V"),
to = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", ordinal = 0)), index = 1)
private int moveArmor(int old) {
@ -78,7 +77,7 @@ public abstract class MixinInGameHud {
return old;
}
@ModifyArg(method = "renderStatusBars", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIIIII)V"), slice = @Slice(
@ModifyArg(method = "renderStatusBars", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/InGameHud;drawTexture(Lnet/minecraft/client/util/math/MatrixStack;IIIIII)V"), slice = @Slice(
from = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;push(Ljava/lang/String;)V"),
to = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", ordinal = 0)), index = 2)
private int moveArmorDown(int old) {
@ -86,7 +85,7 @@ public abstract class MixinInGameHud {
return old;
}
@ModifyArg(method = "renderStatusBars", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIIIII)V"), slice = @Slice(
@ModifyArg(method = "renderStatusBars", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/InGameHud;drawTexture(Lnet/minecraft/client/util/math/MatrixStack;IIIIII)V"), slice = @Slice(
from = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", ordinal = 2),
to = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;pop()V")), index = 1)
private int moveAir(int old) {

View File

@ -17,7 +17,11 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
import de.florianmichael.viafabricplus.settings.groups.VisualSettings;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.item.ItemModels;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.render.model.BakedModel;

View File

@ -24,7 +24,7 @@ import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.Protocol1_12To1_
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
import de.florianmichael.viafabricplus.injection.access.IMinecraftClient;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.settings.groups.DebugSettings;
import de.florianmichael.viafabricplus.base.settings.groups.DebugSettings;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
import de.florianmichael.viafabricplus.settings.groups.DebugSettings;
import de.florianmichael.viafabricplus.base.settings.groups.DebugSettings;
import net.minecraft.client.network.PendingUpdateManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
import de.florianmichael.viafabricplus.settings.groups.DebugSettings;
import de.florianmichael.viafabricplus.base.settings.groups.DebugSettings;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;

View File

@ -19,22 +19,18 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import com.mojang.authlib.GameProfile;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.mappings.ArmorPointsMappings;
import de.florianmichael.viafabricplus.event.SkipIdlePacketCallback;
import de.florianmichael.viafabricplus.base.settings.groups.DebugSettings;
import de.florianmichael.viafabricplus.definition.v1_8.ArmorPointCalculation;
import de.florianmichael.viafabricplus.injection.access.IClientPlayerEntity;
import de.florianmichael.viafabricplus.settings.groups.DebugSettings;
import de.florianmichael.viafabricplus.settings.groups.VisualSettings;
import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.input.Input;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
import net.minecraft.util.Hand;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@ -51,28 +47,17 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
@Shadow
public Input input;
@Shadow
private float lastYaw;
@Shadow
private float lastPitch;
@Shadow
@Final
public ClientPlayNetworkHandler networkHandler;
@Shadow
private boolean autoJumpEnabled;
@Shadow
@Final
protected MinecraftClient client;
@Shadow
private boolean lastOnGround;
@Shadow
private int ticksSinceLastPositionPacketSent;
@Shadow
private double lastX;
@Shadow
private double lastBaseY;
@Shadow
private double lastZ;
@Unique
private boolean viafabricplus_areSwingCanceledThisTick = false;
@ -80,62 +65,38 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
super(world, profile);
}
@Shadow
protected abstract boolean isCamera();
@Shadow protected abstract void sendSprintingPacket();
@Redirect(method = "sendMovementPackets", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isCamera()Z"))
public boolean fixMovement(ClientPlayerEntity instance) {
if (this.isCamera()) {
boolean bl4;
double d = this.getX() - this.lastX;
double e = this.getY() - this.lastBaseY;
double f = this.getZ() - this.lastZ;
double g = this.getYaw() - this.lastYaw;
double h = this.getPitch() - this.lastPitch;
if (ProtocolHack.getTargetVersion().isNewerThan(ProtocolVersion.v1_8)) {
++this.ticksSinceLastPositionPacketSent;
}
double n = MathHelper.square(2.05E-4);
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_18_2)) {
n = 9.0E-4D;
}
boolean bl3 = MathHelper.squaredMagnitude(d, e, f) > n || this.ticksSinceLastPositionPacketSent >= 20;
bl4 = g != 0.0 || h != 0.0;
if (this.hasVehicle()) {
Vec3d vec3d = this.getVelocity();
this.networkHandler.sendPacket(new PlayerMoveC2SPacket.Full(vec3d.x, -999.0, vec3d.z, this.getYaw(), this.getPitch(), this.isOnGround()));
bl3 = false;
} else if (bl3 && bl4) {
this.networkHandler.sendPacket(new PlayerMoveC2SPacket.Full(this.getX(), this.getY(), this.getZ(), this.getYaw(), this.getPitch(), this.isOnGround()));
} else if (bl3) {
this.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(this.getX(), this.getY(), this.getZ(), this.isOnGround()));
} else if (bl4) {
this.networkHandler.sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(this.getYaw(), this.getPitch(), this.isOnGround()));
} else if ((this.lastOnGround != this.isOnGround() && !DebugSettings.INSTANCE.sendIdlePacket.getValue()) || DebugSettings.INSTANCE.sendIdlePacket.getValue()) {
this.networkHandler.sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(this.isOnGround()));
} else {
SkipIdlePacketCallback.EVENT.invoker().onSkipIdlePacket();
}
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
++this.ticksSinceLastPositionPacketSent;
}
if (bl3) {
this.lastX = this.getX();
this.lastBaseY = this.getY();
this.lastZ = this.getZ();
this.ticksSinceLastPositionPacketSent = 0;
}
if (bl4) {
this.lastYaw = this.getYaw();
this.lastPitch = this.getPitch();
}
this.lastOnGround = this.isOnGround();
this.autoJumpEnabled = this.client.options.getAutoJump().getValue();
@Redirect(method = "sendMovementPackets", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;square(D)D"))
public double changeMagnitude(double n) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_18_2)) {
n = 9.0E-4D;
}
return false;
return MathHelper.square(n);
}
@Redirect(method = "sendMovementPackets", at = @At(value = "FIELD", target = "Lnet/minecraft/client/network/ClientPlayerEntity;ticksSinceLastPositionPacketSent:I", ordinal = 0))
public int revertLastPositionPacketSentIncrementor(ClientPlayerEntity instance) {
// Mixin calls the redirector and sets the original field to the return value of the redirector + 1, therefore the -1 results, so we truncate the + 1 again and the field does not change
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
return ticksSinceLastPositionPacketSent - 1;
}
return ticksSinceLastPositionPacketSent;
}
@Inject(method = "sendMovementPackets", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z"))
public void incrementLastPositionPacketSentCounter(CallbackInfo ci) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_8)) {
++this.ticksSinceLastPositionPacketSent;
}
}
@Redirect(method = "sendMovementPackets", at = @At(value = "FIELD", target = "Lnet/minecraft/client/network/ClientPlayerEntity;lastOnGround:Z", ordinal = 0))
public boolean sendIdlePacket(ClientPlayerEntity instance) {
if (DebugSettings.INSTANCE.sendIdlePacket.getValue()) {
return !onGround;
}
return lastOnGround;
}
@Inject(method = "swingHand", at = @At("HEAD"), cancellable = true)
@ -221,7 +182,7 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
@Override
public int getArmor() {
if (VisualSettings.INSTANCE.emulateArmorHud.getValue()) {
return ArmorPointsMappings.sum();
return ArmorPointCalculation.sum();
}
return super.getArmor();
}

View File

@ -19,7 +19,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.settings.groups.ExperimentalSettings;
import de.florianmichael.viafabricplus.base.settings.groups.ExperimentalSettings;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.EquipmentSlot;

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.settings.groups.VisualSettings;
import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityPose;

View File

@ -19,7 +19,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.input;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.injection.access.IMinecraftClient;
import de.florianmichael.viafabricplus.settings.groups.DebugSettings;
import de.florianmichael.viafabricplus.base.settings.groups.DebugSettings;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.Keyboard;
import net.minecraft.client.MinecraftClient;

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.input;
import de.florianmichael.viafabricplus.injection.access.IMinecraftClient;
import de.florianmichael.viafabricplus.settings.groups.DebugSettings;
import de.florianmichael.viafabricplus.base.settings.groups.DebugSettings;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.Mouse;
import org.spongepowered.asm.mixin.Mixin;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import de.florianmichael.viafabricplus.settings.groups.DebugSettings;
import de.florianmichael.viafabricplus.base.settings.groups.DebugSettings;
import net.minecraft.entity.player.ItemCooldownManager;
import net.minecraft.item.Item;
import org.spongepowered.asm.mixin.Mixin;

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import de.florianmichael.viafabricplus.mappings.ItemReleaseVersionMappings;
import de.florianmichael.viafabricplus.settings.groups.GeneralSettings;
import de.florianmichael.viafabricplus.base.settings.groups.GeneralSettings;
import net.minecraft.client.MinecraftClient;
import net.minecraft.item.Item;
import net.minecraft.resource.featuretoggle.FeatureSet;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import de.florianmichael.viafabricplus.settings.groups.GeneralSettings;
import de.florianmichael.viafabricplus.base.settings.groups.GeneralSettings;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
import net.minecraft.item.ItemGroup;

View File

@ -20,7 +20,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.settings.groups.DebugSettings;
import de.florianmichael.viafabricplus.base.settings.groups.DebugSettings;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.block.BlockState;
import net.minecraft.entity.attribute.EntityAttribute;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
import de.florianmichael.viafabricplus.settings.groups.VisualSettings;
import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings;
import net.minecraft.client.gui.hud.ChatHud;
import net.minecraft.client.gui.hud.ChatHudLine;
import net.minecraft.client.gui.hud.MessageIndicator;

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
import de.florianmichael.viafabricplus.definition.ChatLengthCalculation;
import de.florianmichael.viafabricplus.settings.groups.VisualSettings;
import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings;
import net.minecraft.client.gui.hud.ChatHud;
import net.minecraft.client.gui.hud.MessageIndicator;
import net.minecraft.client.gui.screen.ChatScreen;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
import de.florianmichael.viafabricplus.settings.groups.VisualSettings;
import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings;
import net.minecraft.block.entity.CommandBlockBlockEntity;
import net.minecraft.client.gui.screen.ingame.CommandBlockScreen;
import net.minecraft.client.gui.widget.CyclingButtonWidget;

View File

@ -28,7 +28,7 @@ import de.florianmichael.viafabricplus.definition.v1_19_0.storage.ChatSession1_1
import de.florianmichael.viafabricplus.definition.v1_19_2.storage.ChatSession1_19_2;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.protocolhack.provider.vialegacy.ViaFabricPlusClassicMPPassProvider;
import de.florianmichael.viafabricplus.settings.groups.AuthenticationSettings;
import de.florianmichael.viafabricplus.base.settings.groups.AuthenticationSettings;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ConnectScreen;

View File

@ -17,8 +17,8 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
import de.florianmichael.viafabricplus.screen.ClassicItemSelectionScreen;
import de.florianmichael.viafabricplus.settings.groups.VisualSettings;
import de.florianmichael.viafabricplus.ui.screen.impl.ClassicItemSelectionScreen;
import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
import org.spongepowered.asm.mixin.Mixin;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
import de.florianmichael.viafabricplus.settings.groups.VisualSettings;
import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings;
import net.minecraft.block.entity.JigsawBlockEntity;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen.merchant;
import de.florianmichael.viafabricplus.settings.groups.DebugSettings;
import de.florianmichael.viafabricplus.base.settings.groups.DebugSettings;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.gui.screen.ingame.MerchantScreen;
import net.minecraft.entity.player.PlayerInventory;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.sodium;
import de.florianmichael.viafabricplus.settings.groups.VisualSettings;
import de.florianmichael.viafabricplus.base.settings.groups.VisualSettings;
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Pseudo;

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.vialegacy;
import de.florianmichael.viafabricplus.injection.access.IExtensionProtocolMetadataStorage;
import de.florianmichael.viafabricplus.event.LoadClassicProtocolExtensionCallback;
import de.florianmichael.viafabricplus.base.event.LoadClassicProtocolExtensionCallback;
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.data.ClassicProtocolExtension;
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.storage.ExtensionProtocolMetadataStorage;
import org.spongepowered.asm.mixin.Final;

View File

@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.vialegacy;
import de.florianmichael.viafabricplus.settings.groups.AuthenticationSettings;
import de.florianmichael.viafabricplus.base.settings.groups.AuthenticationSettings;
import net.raphimc.vialegacy.ViaLegacyConfig;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.vialoadingbase;
import com.viaversion.viaversion.configuration.AbstractViaConfig;
import de.florianmichael.viafabricplus.settings.groups.ExperimentalSettings;
import de.florianmichael.viafabricplus.base.settings.groups.ExperimentalSettings;
import de.florianmichael.vialoadingbase.platform.viaversion.VLBViaConfig;
import org.spongepowered.asm.mixin.Mixin;

View File

@ -19,13 +19,15 @@ package de.florianmichael.viafabricplus.integration;
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
import de.florianmichael.viafabricplus.screen.settings.SettingsScreen;
import net.minecraft.client.gui.screen.Screen;
import de.florianmichael.viafabricplus.ui.screen.impl.settings.SettingsScreen;
public class ModMenuImpl implements ModMenuApi {
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return (ConfigScreenFactory<Screen>) SettingsScreen::get;
return parent -> {
SettingsScreen.INSTANCE.prevScreen = parent;
return SettingsScreen.INSTANCE;
};
}
}

View File

@ -18,7 +18,7 @@
package de.florianmichael.viafabricplus.mappings;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.base.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
import de.florianmichael.vialoadingbase.model.ProtocolRange;

View File

@ -34,9 +34,9 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.HandItemPr
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
import de.florianmichael.viafabricplus.ViaFabricPlus;
import de.florianmichael.viafabricplus.definition.v1_19_0.provider.CommandArgumentsProvider;
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.event.FinishViaLoadingBaseStartupCallback;
import de.florianmichael.viafabricplus.event.ViaLoadingBaseBuilderCallback;
import de.florianmichael.viafabricplus.base.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.base.event.FinishViaLoadingBaseStartupCallback;
import de.florianmichael.viafabricplus.base.event.ViaLoadingBaseBuilderCallback;
import de.florianmichael.viafabricplus.protocolhack.command.ViaFabricPlusVLBViaCommandHandler;
import de.florianmichael.viafabricplus.protocolhack.netty.ViaFabricPlusVLBPipeline;
import de.florianmichael.viafabricplus.protocolhack.platform.ViaAprilFoolsPlatformImpl;

View File

@ -20,12 +20,10 @@ package de.florianmichael.viafabricplus.protocolhack.provider.vialegacy;
import com.viaversion.viaversion.api.connection.UserConnection;
import de.florianmichael.classic4j.JSPBetaCraftHandler;
import de.florianmichael.viafabricplus.integration.Classic4JImpl;
import de.florianmichael.viafabricplus.settings.groups.AuthenticationSettings;
import de.florianmichael.viafabricplus.base.settings.groups.AuthenticationSettings;
import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.providers.ClassicMPPassProvider;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.HandshakeStorage;
import java.util.concurrent.atomic.AtomicReference;
public class ViaFabricPlusClassicMPPassProvider extends ClassicMPPassProvider {
public static String classiCubeMPPass;

View File

@ -19,10 +19,10 @@ package de.florianmichael.viafabricplus.protocolhack.provider.vialegacy;
import com.viaversion.viaversion.api.connection.UserConnection;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.settings.groups.AuthenticationSettings;
import de.florianmichael.viafabricplus.util.ScreenUtil;
import de.florianmichael.viafabricplus.base.settings.groups.AuthenticationSettings;
import net.minecraft.client.MinecraftClient;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.providers.OldAuthProvider;
public class ViaFabricPlusOldAuthProvider extends OldAuthProvider {
@ -37,7 +37,8 @@ public class ViaFabricPlusOldAuthProvider extends OldAuthProvider {
mc.getSessionService().joinServer(mc.getSession().getProfile(), mc.getSession().getAccessToken(), serverId);
} catch (Exception e) {
if (AuthenticationSettings.INSTANCE.disconnectIfJoinServerCallFails.getValue()) {
user.getChannel().attr(ProtocolHack.LOCAL_MINECRAFT_CONNECTION).get().disconnect(Text.literal(ScreenUtil.prefixedMessage("ViaLegacy fails to verify your session! Please log in into an Account or disable the BetaCraft authentication in the ViaFabricPlus Settings")));
user.getChannel().attr(ProtocolHack.LOCAL_MINECRAFT_CONNECTION).get().
disconnect(Text.literal(Formatting.GOLD + "[ViaFabricPlus] " + Formatting.WHITE + Text.translatable("authentication.viafabricplus.error")));
} else {
e.printStackTrace();
}

View File

@ -24,7 +24,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.ViaFabricPlus;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.settings.groups.GeneralSettings;
import de.florianmichael.viafabricplus.base.settings.groups.GeneralSettings;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
import de.florianmichael.vialoadingbase.provider.VLBBaseVersionProvider;

View File

@ -1,34 +0,0 @@
/*
* 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.settings;
@Deprecated
public class ConfigRemapper {
/**
* Remaps the old config format to the new one, will be removed in the future
*/
public static String remapp(String key) {
if (key.equals("bedrock.viafabricplus.set")) key = "authentication.viafabricplus.bedrock";
if (key.startsWith("mppass")) key = key.replace("mppass", "authentication");
if (key.equals("visual.viafabricplus.chunkborderfix")) key = "experimental.viafabricplus.chunkborderfix";
if (key.startsWith("bridge")) key = key.replace("bridge", "general");
return key;
}
}

View File

@ -15,7 +15,7 @@
* 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.information;
package de.florianmichael.viafabricplus.ui.information;
import com.viaversion.viaversion.api.connection.UserConnection;
import de.florianmichael.vialoadingbase.model.ProtocolRange;
@ -31,6 +31,23 @@ public abstract class AbstractInformationGroup {
public abstract void applyInformation(final UserConnection userConnection, final List<String> output);
public String format(double a) {
return String.format("%.2f", a);
}
public String formatBytes(long value) {
if (value < 1024L)
return value + " B";
else if (value < 1024L * 1024L)
return format(((double) value / 1024.0)) + " Kb";
else if (value < 1024L * 1024L * 1024L)
return format(((double) value / 1024.0 / 1024.0)) + " Mb";
else if (value < 1024L * 1024L * 1024L * 1024L)
return format(((double) value / 1024.0 / 1024.0 / 1024.0)) + " Gb";
else
return format(((double) value / 1024.0 / 1024.0 / 1024.0 / 1024.0)) + " Tb";
}
public ProtocolRange getProtocolRange() {
return protocolRange;
}

View File

@ -15,9 +15,9 @@
* 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.information;
package de.florianmichael.viafabricplus.ui.information;
import de.florianmichael.viafabricplus.information.impl.*;
import de.florianmichael.viafabricplus.ui.information.impl.*;
import java.util.ArrayList;
import java.util.Collections;

View File

@ -15,15 +15,14 @@
* 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.information.impl;
package de.florianmichael.viafabricplus.ui.information.impl;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.UserConnection;
import de.florianmichael.viafabricplus.definition.bedrock.storage.JoinGameStorage;
import de.florianmichael.viafabricplus.definition.bedrock.ModelFormats;
import de.florianmichael.viafabricplus.information.AbstractInformationGroup;
import de.florianmichael.viafabricplus.ui.information.AbstractInformationGroup;
import de.florianmichael.viafabricplus.protocolhack.provider.viabedrock.ViaFabricPlusBlobCacheProvider;
import de.florianmichael.viafabricplus.util.ScreenUtil;
import de.florianmichael.vialoadingbase.model.ProtocolRange;
import net.lenni0451.reflect.stream.RStream;
import net.lenni0451.reflect.stream.field.FieldStream;
@ -58,7 +57,7 @@ public class BedrockInformation extends AbstractInformationGroup {
output.add("Blob Cache:");
}
if (totalSize != 0) output.add("Total size: " + ScreenUtil.formatBytes(totalSize));
if (totalSize != 0) output.add("Total size: " + formatBytes(totalSize));
if (blobCount != 0) output.add("Blob count: " + blobCount);
if (pendingCount != 0) output.add("Pending count: " + pendingCount);
}

View File

@ -15,10 +15,10 @@
* 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.information.impl;
package de.florianmichael.viafabricplus.ui.information.impl;
import com.viaversion.viaversion.api.connection.UserConnection;
import de.florianmichael.viafabricplus.information.AbstractInformationGroup;
import de.florianmichael.viafabricplus.ui.information.AbstractInformationGroup;
import de.florianmichael.vialoadingbase.model.ProtocolRange;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.storage.ExtensionProtocolMetadataStorage;

View File

@ -15,10 +15,10 @@
* 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.information.impl;
package de.florianmichael.viafabricplus.ui.information.impl;
import com.viaversion.viaversion.api.connection.UserConnection;
import de.florianmichael.viafabricplus.information.AbstractInformationGroup;
import de.florianmichael.viafabricplus.ui.information.AbstractInformationGroup;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.vialoadingbase.ViaLoadingBase;

View File

@ -15,10 +15,10 @@
* 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.information.impl;
package de.florianmichael.viafabricplus.ui.information.impl;
import com.viaversion.viaversion.api.connection.UserConnection;
import de.florianmichael.viafabricplus.information.AbstractInformationGroup;
import de.florianmichael.viafabricplus.ui.information.AbstractInformationGroup;
import de.florianmichael.vialoadingbase.model.ProtocolRange;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import net.raphimc.vialegacy.protocols.release.protocol1_2_1_3to1_1.storage.SeedStorage;

View File

@ -15,10 +15,10 @@
* 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.information.impl;
package de.florianmichael.viafabricplus.ui.information.impl;
import com.viaversion.viaversion.api.connection.UserConnection;
import de.florianmichael.viafabricplus.information.AbstractInformationGroup;
import de.florianmichael.viafabricplus.ui.information.AbstractInformationGroup;
import de.florianmichael.vialoadingbase.model.ProtocolRange;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.storage.EntityTracker;

View File

@ -15,10 +15,10 @@
* 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.information.impl;
package de.florianmichael.viafabricplus.ui.information.impl;
import com.viaversion.viaversion.api.connection.UserConnection;
import de.florianmichael.viafabricplus.information.AbstractInformationGroup;
import de.florianmichael.viafabricplus.ui.information.AbstractInformationGroup;
import de.florianmichael.vialoadingbase.model.ProtocolRange;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import net.raphimc.vialegacy.protocols.release.protocol1_6_1to1_5_2.storage.EntityTracker;

View File

@ -15,11 +15,11 @@
* 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.information.impl;
package de.florianmichael.viafabricplus.ui.information.impl;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.information.AbstractInformationGroup;
import de.florianmichael.viafabricplus.ui.information.AbstractInformationGroup;
import de.florianmichael.vialoadingbase.model.ProtocolRange;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.storage.EntityTracker;

View File

@ -15,7 +15,7 @@
* 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.screen.base;
package de.florianmichael.viafabricplus.ui.screen;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.widget.AlwaysSelectedEntryListWidget;
@ -23,7 +23,16 @@ import net.minecraft.client.util.math.MatrixStack;
public abstract class MappedSlotEntry extends AlwaysSelectedEntryListWidget.Entry<MappedSlotEntry> {
public abstract void mappedRenderer(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta);
public abstract void mappedRender(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta);
public void mappedMouseClicked(double mouseX, double mouseY, int button) {
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
mappedMouseClicked(mouseX, mouseY, button);
VFPScreen.playClickSound();
return super.mouseClicked(mouseX, mouseY, button);
}
@Override
public void render(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
@ -32,7 +41,7 @@ public abstract class MappedSlotEntry extends AlwaysSelectedEntryListWidget.Entr
matrices.push();
matrices.translate(x, y, 0);
context.fill(0, 0, entryWidth - 4 /* int i = this.left + (this.width - entryWidth) / 2; int j = this.left + (this.width + entryWidth) / 2; */, entryHeight, Integer.MIN_VALUE);
mappedRenderer(context, index, y, x, entryWidth, entryHeight, mouseX, mouseY, hovered, tickDelta);
mappedRender(context, index, y, x, entryWidth, entryHeight, mouseX, mouseY, hovered, tickDelta);
matrices.pop();
}
}

View File

@ -0,0 +1,83 @@
/*
* 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.ui.screen;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.NoticeScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
import java.awt.*;
public class VFPScreen extends Screen {
private final boolean backButton;
public Screen prevScreen;
public VFPScreen(String title, boolean backButton) {
super(Text.of(title));
this.backButton = backButton;
}
public void open(final Screen prevScreen) {
this.prevScreen = prevScreen;
RenderSystem.recordRenderCall(() -> MinecraftClient.getInstance().setScreen(this));
}
@Override
protected void init() {
if (backButton) {
this.addDrawableChild(ButtonWidget.builder(Text.literal("<-"), button -> this.close()).position(5, 5).size(20, 20).build());
}
}
@Override
public void close() {
MinecraftClient.getInstance().setScreen(prevScreen);
}
public void renderTitle(final MatrixStack matrices) {
renderTitle(matrices, Text.of("https://github.com/FlorianMichael/ViaFabricPlus"));
}
public void renderTitle(final MatrixStack matrices, final Text subTitle) {
matrices.push();
matrices.scale(2F, 2F, 2F);
drawCenteredTextWithShadow(matrices, textRenderer, "ViaFabricPlus", width / 4, 3, Color.ORANGE.getRGB());
matrices.pop();
drawCenteredTextWithShadow(matrices, textRenderer, subTitle, width / 2, (textRenderer.fontHeight + 2) * 2 + 3, -1);
}
public static void playClickSound() {
MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
}
public void showErrorScreen(final String title, final Throwable throwable) {
MinecraftClient.getInstance().execute(() -> MinecraftClient.getInstance().setScreen(new NoticeScreen(() ->
RenderSystem.recordRenderCall(() -> MinecraftClient.getInstance().setScreen(this)), Text.of(title),
Text.translatable("words.viafabricplus.error").append("\n" + throwable.getMessage()),
Text.translatable("words.viafabricplus.cancel"), false)));
}
}

View File

@ -15,9 +15,10 @@
* 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.screen;
package de.florianmichael.viafabricplus.ui.screen.impl;
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.base.event.ChangeProtocolVersionCallback;
import de.florianmichael.viafabricplus.ui.screen.VFPScreen;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
@ -27,8 +28,6 @@ import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
import net.minecraft.util.math.MathHelper;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
@ -36,7 +35,7 @@ import java.util.ArrayList;
import java.util.List;
@SuppressWarnings("DataFlowIssue")
public class ClassicItemSelectionScreen extends Screen {
public class ClassicItemSelectionScreen extends VFPScreen {
public static ClassicItemSelectionScreen INSTANCE;
@ -59,7 +58,7 @@ public class ClassicItemSelectionScreen extends Screen {
public ItemStack selectedItem = null;
public ClassicItemSelectionScreen() {
super(Text.literal("Classic item selection"));
super("Classic item selection", false);
}
public void reload(final ComparableProtocolVersion version, final boolean hasCustomBlocksV1) {
@ -139,12 +138,12 @@ public class ClassicItemSelectionScreen extends Screen {
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (selectedItem != null) {
this.client.interactionManager.clickCreativeStack(selectedItem, MinecraftClient.getInstance().player.getInventory().selectedSlot + 36); // Beta Inventory Tracker
this.client.interactionManager.clickCreativeStack(selectedItem, client.player.getInventory().selectedSlot + 36); // Beta Inventory Tracker
this.client.player.getInventory().main.set(MinecraftClient.getInstance().player.getInventory().selectedSlot, selectedItem);
this.client.player.getInventory().main.set(client.player.getInventory().selectedSlot, selectedItem);
this.client.player.playerScreenHandler.sendContentUpdates();
this.client.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
playClickSound();
this.close();
}

View File

@ -15,9 +15,10 @@
* 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.screen;
package de.florianmichael.viafabricplus.ui.screen.impl.base;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.ui.screen.VFPScreen;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
import net.minecraft.client.MinecraftClient;
@ -25,23 +26,18 @@ import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.AlwaysSelectedEntryListWidget;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import java.awt.*;
import java.util.function.Consumer;
@SuppressWarnings({"DataFlowIssue", "DuplicatedCode"})
public class ForceVersionScreen extends Screen {
private final Screen prevScreen;
public class ForceVersionScreen extends VFPScreen {
private final Consumer<ComparableProtocolVersion> selectionConsumer;
public ForceVersionScreen(final Screen prevScreen, final Consumer<ComparableProtocolVersion> selectionConsumer) {
super(Text.literal("Force version"));
super("Force version", false);
this.prevScreen = prevScreen;
this.selectionConsumer = selectionConsumer;
@ -61,16 +57,7 @@ public class ForceVersionScreen extends Screen {
final MatrixStack matrices = context.getMatrices();
matrices.push();
matrices.scale(2F, 2F, 2F);
context.drawCenteredTextWithShadow(textRenderer, "ViaFabricPlus", width / 4, 3, Color.ORANGE.getRGB());
matrices.pop();
context.drawCenteredTextWithShadow(textRenderer, Text.translatable("forceversion.viafabricplus.title"), width / 2, (textRenderer.fontHeight + 2) * 2 + 3, -1);
}
@Override
public void close() {
client.setScreen(prevScreen);
this.renderTitle(matrices, Text.translatable("forceversion.viafabricplus.title"));
}
public class SlotList extends AlwaysSelectedEntryListWidget<DummyProtocolSlot> {
@ -97,9 +84,10 @@ public class ForceVersionScreen extends Screen {
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
ForceVersionScreen.this.selectionConsumer.accept(null);
MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
ForceVersionScreen.this.close();
selectionConsumer.accept(null);
playClickSound();
close();
return super.mouseClicked(mouseX, mouseY, button);
}
@ -124,9 +112,10 @@ public class ForceVersionScreen extends Screen {
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
ForceVersionScreen.this.selectionConsumer.accept(ViaLoadingBase.fromProtocolVersion(protocolVersion));
MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
ForceVersionScreen.this.close();
selectionConsumer.accept(ViaLoadingBase.fromProtocolVersion(protocolVersion));
playClickSound();
close();
return super.mouseClicked(mouseX, mouseY, button);
}

View File

@ -15,18 +15,17 @@
* 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.screen;
package de.florianmichael.viafabricplus.ui.screen.impl.base;
import com.mojang.blaze3d.systems.RenderSystem;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.classic4j.BetaCraftHandler;
import de.florianmichael.classic4j.model.classicube.highlevel.CCAccount;
import de.florianmichael.viafabricplus.definition.c0_30.ClassiCubeAccountHandler;
import de.florianmichael.viafabricplus.screen.classicube.ClassiCubeLoginScreen;
import de.florianmichael.viafabricplus.screen.classicube.ClassiCubeServerListScreen;
import de.florianmichael.viafabricplus.screen.settings.SettingsScreen;
import de.florianmichael.viafabricplus.ui.screen.VFPScreen;
import de.florianmichael.viafabricplus.ui.screen.impl.thirdparty.classicube.ClassiCubeLoginScreen;
import de.florianmichael.viafabricplus.ui.screen.impl.thirdparty.classicube.ClassiCubeServerListScreen;
import de.florianmichael.viafabricplus.ui.screen.impl.thirdparty.BetaCraftScreen;
import de.florianmichael.viafabricplus.ui.screen.impl.settings.SettingsScreen;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.util.ScreenUtil;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
@ -41,56 +40,64 @@ import net.minecraft.text.Text;
import java.awt.*;
@SuppressWarnings({"DataFlowIssue", "DuplicatedCode"})
public class ProtocolSelectionScreen extends Screen {
private final static ProtocolSelectionScreen INSTANCE = new ProtocolSelectionScreen();
public Screen prevScreen;
public class ProtocolSelectionScreen extends VFPScreen {
public final static ProtocolSelectionScreen INSTANCE = new ProtocolSelectionScreen();
private ButtonWidget betaCraftButton;
protected ProtocolSelectionScreen() {
super(Text.literal("Protocol selection"));
}
public static void open(final Screen current) {
INSTANCE.prevScreen = current;
RenderSystem.recordRenderCall(() -> MinecraftClient.getInstance().setScreen(INSTANCE));
super("Protocol selection", true);
}
@Override
protected void init() {
super.init();
// List and Settings
this.addDrawableChild(new SlotList(this.client, width, height, 3 + 3 /* start offset */ + (textRenderer.fontHeight + 2) * 3 /* title is 2 */, height - 30, textRenderer.fontHeight + 4));
this.addDrawableChild(ButtonWidget.builder(Text.literal("<-"), button -> this.close()).position(5, 5).size(20, 20).build());
this.addDrawableChild(ButtonWidget.builder(Text.translatable("words.viafabricplus.settings"), button -> SettingsScreen.INSTANCE.open(this)).position(width - 98 - 5, 5).size(98, 20).build());
// ClassiCube
final boolean loggedIn = ClassiCubeAccountHandler.INSTANCE.getAccount() != null;
this.addDrawableChild(ButtonWidget.builder(Text.translatable("words.viafabricplus.settings"), button -> client.setScreen(SettingsScreen.get(this))).position(width - 98 - 5, 5).size(98, 20).build());
final CCAccount classiCubeAccount = ClassiCubeAccountHandler.INSTANCE.getAccount();
ButtonWidget.Builder classiCubeBuilder = ButtonWidget.builder(Text.literal("ClassiCube"), button -> {
if (classiCubeAccount == null || classiCubeAccount.token == null) {
client.setScreen(ClassiCubeLoginScreen.get(this));
if (!loggedIn) {
ClassiCubeLoginScreen.INSTANCE.open(prevScreen);
return;
}
client.setScreen(ClassiCubeServerListScreen.get(this));
ClassiCubeServerListScreen.INSTANCE.open(prevScreen);
}).position(width - 98 - 5, height - 25).size(98, 20);
if (classiCubeAccount == null || classiCubeAccount.token == null) {
if (!loggedIn) {
classiCubeBuilder = classiCubeBuilder.tooltip(Tooltip.of(Text.translatable("classicube.viafabricplus.warning")));
}
this.addDrawableChild(classiCubeBuilder.build());
// BetaCraft
ButtonWidget.Builder betaCraftBuilder = ButtonWidget.builder(Text.literal("BetaCraft"), button -> {
if (BetaCraftScreen.SERVER_LIST == null) {
BetaCraftHandler.requestServerList(bcServerList -> {
BetaCraftScreen.SERVER_LIST = bcServerList;
betaCraftButton = button;
RenderSystem.recordRenderCall(() -> client.setScreen(BetaCraftScreen.get(this)));
}, throwable -> MinecraftClient.getInstance().execute(() -> MinecraftClient.getInstance().setScreen(new NoticeScreen(() -> RenderSystem.recordRenderCall(() -> client.setScreen(this)), Text.literal("Betacraft"), Text.translatable("betacraft.viafabricplus.error").append("\n" + throwable.getMessage()), Text.translatable("words.viafabricplus.cancel"), false))));
} else client.setScreen(BetaCraftScreen.get(this));
BetaCraftHandler.requestServerList(serverList -> {
BetaCraftScreen.SERVER_LIST = serverList;
button.setMessage(Text.literal("BetaCraft"));
BetaCraftScreen.INSTANCE.open(this);
}, throwable -> showErrorScreen("BetaCraft", throwable));
} else {
BetaCraftScreen.INSTANCE.open(this);
}
}).position(5, height - 25).size(98, 20);
if (BetaCraftScreen.SERVER_LIST == null) {
betaCraftBuilder = betaCraftBuilder.tooltip(Tooltip.of(Text.translatable("betacraft.viafabricplus.warning")));
}
this.addDrawableChild(betaCraftBuilder.build());
super.init();
}
@Override
public void tick() {
if (betaCraftButton != null) betaCraftButton.setMessage(Text.of("Loading..."));
}
@Override
@ -100,16 +107,7 @@ public class ProtocolSelectionScreen extends Screen {
final MatrixStack matrices = context.getMatrices();
matrices.push();
matrices.scale(2F, 2F, 2F);
context.drawCenteredTextWithShadow(textRenderer, "ViaFabricPlus", width / 4, 3, Color.ORANGE.getRGB());
matrices.pop();
context.drawCenteredTextWithShadow(textRenderer, "https://github.com/FlorianMichael/ViaFabricPlus", width / 2, (textRenderer.fontHeight + 2) * 2 + 3, -1);
}
@Override
public void close() {
client.setScreen(prevScreen);
this.renderTitle(matrices);
}
public static class SlotList extends AlwaysSelectedEntryListWidget<ProtocolSlot> {
@ -136,7 +134,7 @@ public class ProtocolSelectionScreen extends Screen {
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
ViaLoadingBase.getInstance().reload(this.protocolVersion);
ScreenUtil.playClickSound();
playClickSound();
return super.mouseClicked(mouseX, mouseY, button);
}

View File

@ -15,43 +15,32 @@
* 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.screen.settings;
package de.florianmichael.viafabricplus.ui.screen.impl.settings;
import de.florianmichael.viafabricplus.ViaFabricPlus;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import de.florianmichael.viafabricplus.screen.settings.settingrenderer.meta.TitleRenderer;
import de.florianmichael.viafabricplus.settings.base.AbstractSetting;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.ui.screen.MappedSlotEntry;
import de.florianmichael.viafabricplus.ui.screen.VFPScreen;
import de.florianmichael.viafabricplus.ui.screen.impl.settings.settingrenderer.meta.TitleRenderer;
import de.florianmichael.viafabricplus.base.settings.base.AbstractSetting;
import de.florianmichael.viafabricplus.base.settings.base.SettingGroup;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.AlwaysSelectedEntryListWidget;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import java.awt.*;
@SuppressWarnings({"DataFlowIssue", "DuplicatedCode"})
public class SettingsScreen extends Screen {
public class SettingsScreen extends VFPScreen {
public final static SettingsScreen INSTANCE = new SettingsScreen();
public Screen prevScreen;
protected SettingsScreen() {
super(Text.literal("Setting"));
}
public static SettingsScreen get(final Screen prevScreen) {
SettingsScreen.INSTANCE.prevScreen = prevScreen;
return SettingsScreen.INSTANCE;
public SettingsScreen() {
super("Setting", true);
}
@Override
protected void init() {
super.init();
this.addDrawableChild(new SlotList(this.client, width, height, 3 + 3 /* start offset */ + (textRenderer.fontHeight + 2) * 3 /* title is 2 */, height + 5, (textRenderer.fontHeight + 2) * 2));
this.addDrawableChild(ButtonWidget.builder(Text.literal("<-"), button -> this.close()).position(5, 5).size(20, 20).build());
super.init();
}
@Override
@ -61,16 +50,7 @@ public class SettingsScreen extends Screen {
final MatrixStack matrices = context.getMatrices();
matrices.push();
matrices.scale(2F, 2F, 2F);
context.drawCenteredTextWithShadow(textRenderer, "ViaFabricPlus", width / 4, 3, Color.ORANGE.getRGB());
matrices.pop();
context.drawCenteredTextWithShadow(textRenderer, "https://github.com/FlorianMichael/ViaFabricPlus", width / 2, (textRenderer.fontHeight + 2) * 2 + 3, -1);
}
@Override
public void close() {
client.setScreen(prevScreen);
this.renderTitle(matrices);
}
public static class SlotList extends AlwaysSelectedEntryListWidget<MappedSlotEntry> {

View File

@ -15,14 +15,12 @@
* 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.screen.settings.settingrenderer;
package de.florianmichael.viafabricplus.ui.screen.impl.settings.settingrenderer;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import de.florianmichael.viafabricplus.settings.type_impl.BooleanSetting;
import de.florianmichael.viafabricplus.util.ScreenUtil;
import de.florianmichael.viafabricplus.ui.screen.MappedSlotEntry;
import de.florianmichael.viafabricplus.base.settings.type_impl.BooleanSetting;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
@ -42,14 +40,12 @@ public class BooleanSettingRenderer extends MappedSlotEntry {
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
public void mappedMouseClicked(double mouseX, double mouseY, int button) {
this.value.setValue(!this.value.getValue());
ScreenUtil.playClickSound();
return super.mouseClicked(mouseX, mouseY, button);
}
@Override
public void mappedRenderer(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
public void mappedRender(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
final Text text = this.value.getValue() ? Text.translatable("words.viafabricplus.on") : Text.translatable("words.viafabricplus.off");

View File

@ -15,11 +15,10 @@
* 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.screen.settings.settingrenderer;
package de.florianmichael.viafabricplus.ui.screen.impl.settings.settingrenderer;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import de.florianmichael.viafabricplus.settings.type_impl.ButtonSetting;
import de.florianmichael.viafabricplus.util.ScreenUtil;
import de.florianmichael.viafabricplus.ui.screen.MappedSlotEntry;
import de.florianmichael.viafabricplus.base.settings.type_impl.ButtonSetting;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
@ -38,14 +37,12 @@ public class ButtonSettingRenderer extends MappedSlotEntry {
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
public void mappedMouseClicked(double mouseX, double mouseY, int button) {
this.value.getValue().run();
ScreenUtil.playClickSound();
return super.mouseClicked(mouseX, mouseY, button);
}
@Override
public void mappedRenderer(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
public void mappedRender(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
context.drawCenteredTextWithShadow(textRenderer, this.value.displayValue(), entryWidth / 2, entryHeight / 2 - textRenderer.fontHeight / 2, -1);

View File

@ -15,11 +15,10 @@
* 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.screen.settings.settingrenderer;
package de.florianmichael.viafabricplus.ui.screen.impl.settings.settingrenderer;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import de.florianmichael.viafabricplus.settings.type_impl.ModeSetting;
import de.florianmichael.viafabricplus.util.ScreenUtil;
import de.florianmichael.viafabricplus.ui.screen.MappedSlotEntry;
import de.florianmichael.viafabricplus.base.settings.type_impl.ModeSetting;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
@ -42,15 +41,13 @@ public class ModeSettingRenderer extends MappedSlotEntry {
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
public void mappedMouseClicked(double mouseX, double mouseY, int button) {
final int currentIndex = Arrays.stream(this.value.getOptions()).toList().indexOf(this.value.value) + 1;
this.value.setValue(currentIndex > this.value.getOptions().length - 1 ? 0 : currentIndex);
ScreenUtil.playClickSound();
return super.mouseClicked(mouseX, mouseY, button);
}
@Override
public void mappedRenderer(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
public void mappedRender(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
context.drawTextWithShadow(textRenderer, this.value.getName().formatted(Formatting.GRAY), 3, entryHeight / 2 - textRenderer.fontHeight / 2, -1);

View File

@ -15,12 +15,11 @@
* 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.screen.settings.settingrenderer;
package de.florianmichael.viafabricplus.ui.screen.impl.settings.settingrenderer;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import de.florianmichael.viafabricplus.settings.groups.GeneralSettings;
import de.florianmichael.viafabricplus.settings.type_impl.ProtocolSyncBooleanSetting;
import de.florianmichael.viafabricplus.util.ScreenUtil;
import de.florianmichael.viafabricplus.ui.screen.MappedSlotEntry;
import de.florianmichael.viafabricplus.base.settings.groups.GeneralSettings;
import de.florianmichael.viafabricplus.base.settings.type_impl.ProtocolSyncBooleanSetting;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
@ -43,14 +42,12 @@ public class ProtocolSyncBooleanSettingRenderer extends MappedSlotEntry {
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
public void mappedMouseClicked(double mouseX, double mouseY, int button) {
this.value.setValue(!this.value.getValue());
ScreenUtil.playClickSound();
return super.mouseClicked(mouseX, mouseY, button);
}
@Override
public void mappedRenderer(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
public void mappedRender(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
final Text text = this.value.getValue() ? Text.translatable("words.viafabricplus.on") : Text.translatable("words.viafabricplus.off");

View File

@ -15,9 +15,9 @@
* 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.screen.settings.settingrenderer.meta;
package de.florianmichael.viafabricplus.ui.screen.impl.settings.settingrenderer.meta;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import de.florianmichael.viafabricplus.ui.screen.MappedSlotEntry;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
@ -40,14 +40,15 @@ public class TitleRenderer extends MappedSlotEntry {
@Override
public void render(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
final MatrixStack matrices = context.getMatrices();
matrices.push();
matrices.translate(x, y, 0);
mappedRenderer(context, index, y, x, entryWidth, entryHeight, mouseX, mouseY, hovered, tickDelta);
mappedRender(context, index, y, x, entryWidth, entryHeight, mouseX, mouseY, hovered, tickDelta);
matrices.pop();
}
@Override
public void mappedRenderer(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
public void mappedRender(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
context.drawTextWithShadow(textRenderer, Formatting.BOLD + this.name, 3, entryHeight / 2 - textRenderer.fontHeight / 2, -1);

View File

@ -15,20 +15,18 @@
* 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.screen;
package de.florianmichael.viafabricplus.ui.screen.impl.thirdparty;
import de.florianmichael.classic4j.model.betacraft.BCServerInfo;
import de.florianmichael.classic4j.model.betacraft.BCServerList;
import de.florianmichael.classic4j.model.betacraft.BCVersion;
import de.florianmichael.viafabricplus.definition.v1_14_4.LegacyServerAddress;
import de.florianmichael.viafabricplus.screen.base.MappedSlotEntry;
import de.florianmichael.viafabricplus.screen.settings.settingrenderer.meta.TitleRenderer;
import de.florianmichael.viafabricplus.util.ScreenUtil;
import de.florianmichael.viafabricplus.ui.screen.MappedSlotEntry;
import de.florianmichael.viafabricplus.ui.screen.VFPScreen;
import de.florianmichael.viafabricplus.ui.screen.impl.settings.settingrenderer.meta.TitleRenderer;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ConnectScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.AlwaysSelectedEntryListWidget;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.network.ServerAddress;
@ -37,34 +35,26 @@ import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import java.awt.*;
import java.util.List;
public class BetaCraftScreen extends Screen {
public class BetaCraftScreen extends VFPScreen {
public static BCServerList SERVER_LIST;
public final static BetaCraftScreen INSTANCE = new BetaCraftScreen();
public Screen prevScreen;
protected BetaCraftScreen() {
super(Text.literal("BetaCraft"));
}
public static BetaCraftScreen get(final Screen prevScreen) {
BetaCraftScreen.INSTANCE.prevScreen = prevScreen;
return BetaCraftScreen.INSTANCE;
super("BetaCraft", true);
}
@Override
protected void init() {
super.init();
this.addDrawableChild(new SlotList(this.client, width, height, 3 + 3 /* start offset */ + (textRenderer.fontHeight + 2) * 3 /* title is 2 */, height + 5, (textRenderer.fontHeight + 2) * 3));
this.addDrawableChild(ButtonWidget.builder(Text.literal("<-"), button -> this.close()).position(5, 5).size(20, 20).build());
this.addDrawableChild(ButtonWidget.builder(Text.translatable("words.viafabricplus.reset"), button -> {
client.setScreen(prevScreen);
SERVER_LIST = null;
client.setScreen(prevScreen);
}).position(width - 98 - 5, 5).size(98, 20).build());
super.init();
}
@Override
@ -74,19 +64,10 @@ public class BetaCraftScreen extends Screen {
final MatrixStack matrices = context.getMatrices();
matrices.push();
matrices.scale(2F, 2F, 2F);
context.drawCenteredTextWithShadow(textRenderer, "ViaFabricPlus", width / 4, 3, Color.ORANGE.getRGB());
matrices.pop();
context.drawCenteredTextWithShadow(textRenderer, "https://github.com/FlorianMichael/ViaFabricPlus", width / 2, (textRenderer.fontHeight + 2) * 2 + 3, -1);
this.renderTitle(matrices);
}
@Override
public void close() {
client.setScreen(prevScreen);
}
public static class SlotList extends AlwaysSelectedEntryListWidget<MappedSlotEntry> {
public class SlotList extends AlwaysSelectedEntryListWidget<MappedSlotEntry> {
public SlotList(MinecraftClient minecraftClient, int width, int height, int top, int bottom, int entryHeight) {
super(minecraftClient, width, height, top, bottom, entryHeight);
@ -125,25 +106,24 @@ public class BetaCraftScreen extends Screen {
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
public void mappedMouseClicked(double mouseX, double mouseY, int button) {
final ServerAddress serverAddress = LegacyServerAddress.parse(null, server.host() + ":" + server.port());
final ServerInfo entry = new ServerInfo(server.name(), serverAddress.getAddress(), false);
ConnectScreen.connect(MinecraftClient.getInstance().currentScreen, MinecraftClient.getInstance(), serverAddress, entry, false);
ScreenUtil.playClickSound();
return super.mouseClicked(mouseX, mouseY, button);
ConnectScreen.connect(MinecraftClient.getInstance().currentScreen, MinecraftClient.getInstance(), serverAddress, entry);
playClickSound();
}
@Override
public void mappedRenderer(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
context.drawCenteredTextWithShadow(textRenderer, server.name() + Formatting.DARK_GRAY + " [" + server.gameVersion() + "]", entryWidth / 2, entryHeight / 2 - textRenderer.fontHeight / 2, -1);
drawCenteredTextWithShadow(matrices, textRenderer, server.name() + Formatting.DARK_GRAY + " [" + server.gameVersion() + "]", entryWidth / 2, entryHeight / 2 - textRenderer.fontHeight / 2, -1);
if (server.onlineMode()) {
context.drawTextWithShadow(textRenderer, Text.translatable("words.viafabricplus.online").formatted(Formatting.GREEN), 1, 1, -1);
drawTextWithShadow(matrices, textRenderer, Text.translatable("words.viafabricplus.online").formatted(Formatting.GREEN), 1, 1, -1);
}
final String playerText = server.playerCount() + "/" + server.playerLimit();
context.drawTextWithShadow(textRenderer, playerText, entryWidth - textRenderer.getWidth(playerText) - 4 /* magic value from line 152 */ - 1, 1, -1);
drawTextWithShadow(matrices, textRenderer, playerText, entryWidth - textRenderer.getWidth(playerText) - 4 /* magic value from MappedSlotEntry#32 */ - 1, 1, -1);
}
}
}

View File

@ -15,13 +15,15 @@
* 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.screen.classicube;
package de.florianmichael.viafabricplus.ui.screen.impl.thirdparty.classicube;
import com.mojang.blaze3d.systems.RenderSystem;
import de.florianmichael.classic4j.ClassiCubeHandler;
import de.florianmichael.classic4j.api.LoginProcessHandler;
import de.florianmichael.classic4j.model.classicube.highlevel.CCAccount;
import de.florianmichael.viafabricplus.ui.screen.impl.base.ProtocolSelectionScreen;
import de.florianmichael.viafabricplus.definition.c0_30.ClassiCubeAccountHandler;
import de.florianmichael.viafabricplus.ui.screen.VFPScreen;
import de.florianmichael.viafabricplus.integration.Classic4JImpl;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
@ -31,18 +33,18 @@ import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
public class ClassiCubeLoginScreen extends Screen {
public class ClassiCubeLoginScreen extends VFPScreen {
public final static ClassiCubeLoginScreen INSTANCE = new ClassiCubeLoginScreen();
public Screen prevScreen;
public ClassiCubeLoginScreen() {
super(Text.literal("ClassiCube Login"));
super("ClassiCube Login", false);
}
public static ClassiCubeLoginScreen get(final Screen prevScreen) {
ClassiCubeLoginScreen.INSTANCE.prevScreen = prevScreen;
ClassiCubeLoginScreen.INSTANCE.status = Text.translatable("classicube.viafabricplus.account");
return ClassiCubeLoginScreen.INSTANCE;
@Override
public void open(Screen prevScreen) {
status = Text.translatable("classicube.viafabricplus.account");
super.open(prevScreen);
}
private TextFieldWidget nameField;
@ -64,11 +66,8 @@ public class ClassiCubeLoginScreen extends Screen {
nameField.setMaxLength(Integer.MAX_VALUE);
passwordField.setMaxLength(Integer.MAX_VALUE);
final CCAccount classiCubeAccount = ClassiCubeAccountHandler.INSTANCE.getAccount();
if (classiCubeAccount != null) {
nameField.setText(classiCubeAccount.username());
passwordField.setText(classiCubeAccount.password());
}
nameField.setText(ClassiCubeAccountHandler.INSTANCE.getUsername());
passwordField.setText(ClassiCubeAccountHandler.INSTANCE.getPassword());
this.addDrawableChild(ButtonWidget.builder(Text.literal("Login"), button -> {
ClassiCubeAccountHandler.INSTANCE.setAccount(new CCAccount(nameField.getText(), passwordField.getText()));
@ -77,12 +76,12 @@ public class ClassiCubeLoginScreen extends Screen {
ClassiCubeHandler.requestAuthentication(ClassiCubeAccountHandler.INSTANCE.getAccount(), null, new LoginProcessHandler() {
@Override
public void handleMfa(CCAccount account) {
RenderSystem.recordRenderCall(() -> MinecraftClient.getInstance().setScreen(ClassiCubeMFAScreen.get(prevScreen)));
ClassiCubeMFAScreen.INSTANCE.open(prevScreen);
}
@Override
public void handleSuccessfulLogin(CCAccount account) {
RenderSystem.recordRenderCall(() -> ClassiCubeServerListScreen.open(MinecraftClient.getInstance().currentScreen, this));
RenderSystem.recordRenderCall(() -> ClassiCubeServerListScreen.open(prevScreen, this));
}
@Override
@ -104,7 +103,8 @@ public class ClassiCubeLoginScreen extends Screen {
@Override
public void close() {
this.client.setScreen(this.prevScreen);
ClassiCubeAccountHandler.INSTANCE.setAccount(null);
ProtocolSelectionScreen.INSTANCE.open(prevScreen);
}
@Override

View File

@ -15,7 +15,7 @@
* 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.screen.classicube;
package de.florianmichael.viafabricplus.ui.screen.impl.thirdparty.classicube;
import com.mojang.blaze3d.systems.RenderSystem;
import de.florianmichael.classic4j.ClassiCubeHandler;
@ -24,30 +24,28 @@ import de.florianmichael.classic4j.model.classicube.highlevel.CCAccount;
import de.florianmichael.classic4j.model.classicube.highlevel.CCError;
import de.florianmichael.viafabricplus.definition.c0_30.ClassiCubeAccountHandler;
import de.florianmichael.viafabricplus.integration.Classic4JImpl;
import de.florianmichael.viafabricplus.ui.screen.VFPScreen;
import de.florianmichael.viafabricplus.ui.screen.impl.base.ProtocolSelectionScreen;
import de.florianmichael.viafabricplus.screen.ProtocolSelectionScreen;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
public class ClassiCubeMFAScreen extends Screen {
public class ClassiCubeMFAScreen extends VFPScreen {
public final static ClassiCubeMFAScreen INSTANCE = new ClassiCubeMFAScreen();
public Screen prevScreen;
public ClassiCubeMFAScreen() {
super(Text.literal("ClassiCube MFA"));
super("ClassiCube MFA", false);
}
public static ClassiCubeMFAScreen get(final Screen prevScreen) {
ClassiCubeMFAScreen.INSTANCE.prevScreen = prevScreen;
ClassiCubeMFAScreen.INSTANCE.status = Classic4JImpl.fromError(CCError.LOGIN_CODE);
return ClassiCubeMFAScreen.INSTANCE;
@Override
public void open(Screen prevScreen) {
status = Classic4JImpl.fromError(CCError.LOGIN_CODE);
super.open(prevScreen);
}
private TextFieldWidget mfaField;
@ -74,7 +72,7 @@ public class ClassiCubeMFAScreen extends Screen {
@Override
public void handleSuccessfulLogin(CCAccount account) {
RenderSystem.recordRenderCall(() -> ClassiCubeServerListScreen.open(MinecraftClient.getInstance().currentScreen, this));
RenderSystem.recordRenderCall(() -> ClassiCubeServerListScreen.open(prevScreen, this));
}
@Override
@ -94,7 +92,8 @@ public class ClassiCubeMFAScreen extends Screen {
@Override
public void close() {
ProtocolSelectionScreen.open(new MultiplayerScreen(new TitleScreen()));
ClassiCubeAccountHandler.INSTANCE.setAccount(null);
ProtocolSelectionScreen.INSTANCE.open(prevScreen);
}
@Override

Some files were not shown because too many files have changed in this diff Show More