Code cleanup

This commit is contained in:
FlorianMichael 2023-11-27 19:59:01 +01:00
parent 8400106095
commit 94471bf961
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
9 changed files with 17 additions and 17 deletions

View File

@ -93,4 +93,5 @@ public class ViaFabricPlus {
public SaveManager getSaveManager() {
return saveManager;
}
}

View File

@ -48,6 +48,7 @@ import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.network.ClientConnection;
import net.raphimc.viabedrock.protocol.data.ProtocolConstants;
import net.raphimc.vialoader.ViaLoader;
import net.raphimc.vialoader.impl.platform.ViaAprilFoolsPlatformImpl;
import net.raphimc.vialoader.impl.platform.ViaBackwardsPlatformImpl;
@ -101,7 +102,7 @@ public class ProtocolHack {
channel.attr(ProtocolHack.TARGET_VERSION_ATTRIBUTE_KEY).set(serverVersion);
if (VersionEnum.bedrockLatest.equals(serverVersion)) {
channel.config().setOption(RakChannelOption.RAK_PROTOCOL_VERSION, 11);
channel.config().setOption(RakChannelOption.RAK_PROTOCOL_VERSION, ProtocolConstants.BEDROCK_RAKNET_PROTOCOL_VERSION);
channel.config().setOption(RakChannelOption.RAK_CONNECT_TIMEOUT, 4_000L);
channel.config().setOption(RakChannelOption.RAK_SESSION_TIMEOUT, 30_000L);
channel.config().setOption(RakChannelOption.RAK_GUID, ThreadLocalRandom.current().nextLong());

View File

@ -66,7 +66,7 @@ public class ViaFabricPlusVLLoader extends VLLoader {
providers.use(GameProfileFetcher.class, new ViaFabricPlusGameProfileFetcher());
providers.use(ClassicMPPassProvider.class, new ViaFabricPlusClassicMPPassProvider());
providers.use(AlphaInventoryProvider.class, new ViaFabricPlusAlphaInventoryProvider(providers.get(TrackingAlphaInventoryProvider.class)));
providers.use(AlphaInventoryProvider.class, new ViaFabricPlusAlphaInventoryProvider(providers.get(AlphaInventoryProvider.class)));
providers.use(NettyPipelineProvider.class, new ViaFabricPlusNettyPipelineProvider());
providers.use(BlobCacheProvider.class, new ViaFabricPlusBlobCacheProvider());

View File

@ -27,8 +27,6 @@ import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.item.ItemStack;
import net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.providers.AlphaInventoryProvider;
import net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.providers.TrackingAlphaInventoryProvider;
import net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.storage.AlphaInventoryTracker;
import net.raphimc.vialoader.util.VersionEnum;
import java.util.List;
@ -36,15 +34,15 @@ import java.util.List;
import static net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.Protocolb1_0_1_1_1toa1_2_3_5_1_2_6.copyItems;
public class ViaFabricPlusAlphaInventoryProvider extends AlphaInventoryProvider {
private final TrackingAlphaInventoryProvider trackingAlphaInventoryProvider;
private final AlphaInventoryProvider alphaInventoryProvider;
public ViaFabricPlusAlphaInventoryProvider(final TrackingAlphaInventoryProvider trackingAlphaInventoryProvider) {
this.trackingAlphaInventoryProvider = trackingAlphaInventoryProvider;
public ViaFabricPlusAlphaInventoryProvider(final AlphaInventoryProvider alphaInventoryProvider) {
this.alphaInventoryProvider = alphaInventoryProvider;
}
@Override
public boolean usesInventoryTracker() {
return !GeneralSettings.global().emulateInventoryActionsInLegacyVersions.getValue();
return !GeneralSettings.global().emulateInventoryActionsInAlphaVersions.getValue();
}
protected Item[] getMinecraftContainerItems(final List<ItemStack> trackingItems) {
@ -62,7 +60,7 @@ public class ViaFabricPlusAlphaInventoryProvider extends AlphaInventoryProvider
@Override
public Item[] getMainInventoryItems(UserConnection user) {
if (usesInventoryTracker()) {
return trackingAlphaInventoryProvider.getMainInventoryItems(user);
return alphaInventoryProvider.getMainInventoryItems(user);
} else if (getPlayer() == null) {
return new Item[37];
}
@ -73,7 +71,7 @@ public class ViaFabricPlusAlphaInventoryProvider extends AlphaInventoryProvider
@Override
public Item[] getCraftingInventoryItems(UserConnection user) {
if (usesInventoryTracker()) {
return trackingAlphaInventoryProvider.getCraftingInventoryItems(user);
return alphaInventoryProvider.getCraftingInventoryItems(user);
} else if (getPlayer() == null) {
return new Item[4];
}
@ -84,7 +82,7 @@ public class ViaFabricPlusAlphaInventoryProvider extends AlphaInventoryProvider
@Override
public Item[] getArmorInventoryItems(UserConnection user) {
if (usesInventoryTracker()) {
return trackingAlphaInventoryProvider.getArmorInventoryItems(user);
return alphaInventoryProvider.getArmorInventoryItems(user);
} else if (getPlayer() == null) {
return new Item[4];
}
@ -95,7 +93,7 @@ public class ViaFabricPlusAlphaInventoryProvider extends AlphaInventoryProvider
@Override
public Item[] getContainerItems(UserConnection user) {
if (usesInventoryTracker()) {
return trackingAlphaInventoryProvider.getContainerItems(user);
return alphaInventoryProvider.getContainerItems(user);
} else if (getPlayer() == null) {
return new Item[37];
}
@ -106,7 +104,7 @@ public class ViaFabricPlusAlphaInventoryProvider extends AlphaInventoryProvider
@Override
public void addToInventory(UserConnection user, Item item) {
if (usesInventoryTracker()) {
trackingAlphaInventoryProvider.addToInventory(user, item);
alphaInventoryProvider.addToInventory(user, item);
} else {
getPlayer().getInventory().insertStack(ItemTranslator.viaB1_8toMc(item));
}

View File

@ -40,7 +40,7 @@ public class ConfigPatcher extends Config {
@Override
public URL getDefaultConfigURL() {
return ConfigPatcher.class.getClassLoader().getResource("assets/viafabricplus/viaversion-config.yml");
return ConfigPatcher.class.getClassLoader().getResource("assets/viafabricplus/dummy-config.yml");
}
@Override

View File

@ -49,7 +49,7 @@ public class DebugSettings extends SettingGroup {
public final VersionedBooleanSetting preventEntityCramming = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.prevent_entity_cramming"), VersionRange.andOlder(VersionEnum.r1_8));
// 1.8.x -> 1.7.6
public final VersionedBooleanSetting replaceSneaking = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.replace_sneaking"), VersionRange.andOlder(VersionEnum.r1_7_6tor1_7_10));
public final VersionedBooleanSetting replaceSneaking = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.replace_sneaking"), VersionRange.andOlder(VersionEnum.r1_8));
public final VersionedBooleanSetting longSneaking = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.long_sneaking"), VersionRange.andOlder(VersionEnum.r1_7_6tor1_7_10));
// 1.5/1.5.1 -> 1.4.6/1.4.7

View File

@ -56,7 +56,7 @@ public class GeneralSettings extends SettingGroup {
Text.translatable("base.viafabricplus.cancel")
);
public final BooleanSetting loadSkinsAndSkullsInLegacyVersions = new BooleanSetting(this, Text.translatable("general_settings.viafabricplus.load_skins_and_skulls_in_legacy_versions"), true);
public final BooleanSetting emulateInventoryActionsInLegacyVersions = new BooleanSetting(this, Text.translatable("general_settings.viafabricplus.emulate_inventory_actions_in_legacy_versions"), true);
public final BooleanSetting emulateInventoryActionsInAlphaVersions = new BooleanSetting(this, Text.translatable("general_settings.viafabricplus.emulate_inventory_actions_in_alpha_versions"), true);
public GeneralSettings() {
super(Text.translatable("setting_group_name.viafabricplus.general"));

View File

@ -42,7 +42,7 @@
"general_settings.viafabricplus.show_advertised_server_version": "Show advertised/server version in Multiplayer",
"general_settings.viafabricplus.ignore_packet_translation_errors": "Ignore packet translation errors",
"general_settings.viafabricplus.load_skins_and_skulls_in_legacy_versions": "Load skins and skulls in legacy versions",
"general_settings.viafabricplus.emulate_inventory_actions_in_legacy_versions": "Emulate inventory actions in legacy versions",
"general_settings.viafabricplus.emulate_inventory_actions_in_alpha_versions": "Emulate inventory actions in alpha versions",
"bedrock_settings.viafabricplus.confirm_transfer_server_prompt": "Open prompt GUI to confirm transferring to other servers",
"bedrock_settings.viafabricplus.click_to_set_bedrock_account": "Click to set account for Bedrock edition",