mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2025-01-06 19:18:25 +01:00
Features loading
This commit is contained in:
parent
3a84529cf1
commit
83d4097a31
@ -27,6 +27,7 @@ import com.viaversion.viafabricplus.api.ViaFabricPlusBase;
|
||||
import com.viaversion.viafabricplus.base.Events;
|
||||
import com.viaversion.viafabricplus.base.save.SaveManager;
|
||||
import com.viaversion.viafabricplus.base.settings.SettingsManager;
|
||||
import com.viaversion.viafabricplus.features.FeaturesLoading;
|
||||
import com.viaversion.viafabricplus.features.max_chat_length.MaxChatLength;
|
||||
import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import com.viaversion.viafabricplus.util.ClassLoaderPriorityUtil;
|
||||
@ -102,6 +103,9 @@ public final class ViaFabricPlusImpl implements ViaFabricPlusBase {
|
||||
settingsManager = new SettingsManager();
|
||||
saveManager = new SaveManager(settingsManager);
|
||||
|
||||
// Init features
|
||||
FeaturesLoading.init();
|
||||
|
||||
// Init ViaVersion protocol translator platform
|
||||
loadingFuture = ProtocolTranslator.init(path);
|
||||
|
||||
|
@ -19,99 +19,58 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.viaversion.viafabricplus.old;
|
||||
package com.viaversion.viafabricplus.features;
|
||||
|
||||
import com.viaversion.viafabricplus.api.LoadingCycleCallback;
|
||||
import com.viaversion.viafabricplus.base.Events;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viafabricplus.old.data.EntityDimensionDiff;
|
||||
import com.viaversion.viafabricplus.base.settings.impl.VisualSettings;
|
||||
import com.viaversion.viafabricplus.features.block.CollisionShapes;
|
||||
import com.viaversion.viafabricplus.features.cpe_extensions.CPEAdditions;
|
||||
import com.viaversion.viafabricplus.features.footstep_particle.FootStepParticle1_12_2;
|
||||
import com.viaversion.viafabricplus.features.networking.resource_pack_header.ResourcePackHeaderDiff;
|
||||
import com.viaversion.viafabricplus.features.recipe_emulation.Recipes1_11_2;
|
||||
import com.viaversion.viafabricplus.old.versioned.EnchantmentAttributesEmulation1_20_6;
|
||||
import com.viaversion.viafabricplus.features.cpe_extensions.CPEAdditions;
|
||||
import com.viaversion.viafabricplus.features.ui.classic_creative_menu.GridItemSelectionScreen;
|
||||
import com.viaversion.viafabricplus.features.ui.armor_hud.ArmorHudEmulation1_8;
|
||||
import com.viaversion.viafabricplus.features.footstep_particle.FootStepParticle1_12_2;
|
||||
import com.viaversion.viafabricplus.features.text_rendering.non_existing_characters.UnicodeFontFix1_12_2;
|
||||
import com.viaversion.viafabricplus.base.settings.impl.VisualSettings;
|
||||
import com.viaversion.viafabricplus.features.ui.armor_hud.ArmorHudEmulation1_8;
|
||||
import com.viaversion.viafabricplus.features.ui.classic_creative_menu.GridItemSelectionScreen;
|
||||
import com.viaversion.viafabricplus.old.data.EntityDimensionDiff;
|
||||
import com.viaversion.viafabricplus.old.versioned.EnchantmentAttributesEmulation1_20_6;
|
||||
import com.viaversion.viafabricplus.util.DataCustomPayload;
|
||||
import net.minecraft.block.*;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.raphimc.viaaprilfools.api.AprilFoolsProtocolVersion;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
|
||||
/**
|
||||
* This class contains random fields and methods that are used to fix bugs on the client side
|
||||
*/
|
||||
public class ClientsideFeatures {
|
||||
public class FeaturesLoading {
|
||||
|
||||
static {
|
||||
// Register additional CPE features
|
||||
CPEAdditions.modifyMappings();
|
||||
|
||||
// Check if the pack format mappings are correct
|
||||
ResourcePackHeaderDiff.checkOutdated();
|
||||
|
||||
ResourcePackHeaderDiff.init();
|
||||
CPEAdditions.init();
|
||||
DataCustomPayload.init();
|
||||
UnicodeFontFix1_12_2.init();
|
||||
FootStepParticle1_12_2.init();
|
||||
|
||||
Events.LOADING_CYCLE.register(cycle -> {
|
||||
if (cycle != LoadingCycleCallback.LoadingCycle.POST_GAME_LOAD) {
|
||||
return;
|
||||
if (cycle == LoadingCycleCallback.LoadingCycle.POST_GAME_LOAD) {
|
||||
EntityDimensionDiff.init();
|
||||
EnchantmentAttributesEmulation1_20_6.init();
|
||||
ArmorHudEmulation1_8.init();
|
||||
}
|
||||
|
||||
// Handle clientside enchantment calculations in <= 1.20.6
|
||||
EnchantmentAttributesEmulation1_20_6.init();
|
||||
|
||||
// Handles and updates entity dimension changes in <= 1.17
|
||||
EntityDimensionDiff.init();
|
||||
|
||||
// Ticks the armor hud manually in <= 1.8.x
|
||||
ArmorHudEmulation1_8.init();
|
||||
});
|
||||
|
||||
// Reloads some clientside stuff when the protocol version changes
|
||||
Events.CHANGE_PROTOCOL_VERSION.register((oldVersion, newVersion) -> MinecraftClient.getInstance().execute(() -> {
|
||||
VisualSettings.global().filterNonExistingGlyphs.onValueChanged();
|
||||
CollisionShapes.reloadBlockShapes();
|
||||
|
||||
// Reloads all bounding boxes of the blocks that we changed
|
||||
for (Block block : Registries.BLOCK) {
|
||||
if (block instanceof AnvilBlock || block instanceof BedBlock || block instanceof BrewingStandBlock
|
||||
|| block instanceof CarpetBlock || block instanceof CauldronBlock || block instanceof ChestBlock
|
||||
|| block instanceof EnderChestBlock || block instanceof EndPortalBlock || block instanceof EndPortalFrameBlock
|
||||
|| block instanceof FarmlandBlock || block instanceof FenceBlock || block instanceof FenceGateBlock
|
||||
|| block instanceof HopperBlock || block instanceof LadderBlock || block instanceof LeavesBlock
|
||||
|| block instanceof LilyPadBlock || block instanceof PaneBlock || block instanceof PistonBlock
|
||||
|| block instanceof PistonHeadBlock || block instanceof SnowBlock || block instanceof WallBlock
|
||||
|| block instanceof CropBlock || block instanceof FlowerbedBlock
|
||||
) {
|
||||
for (BlockState state : block.getStateManager().getStates()) {
|
||||
state.initShapeCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Rebuilds the item selection screen grid
|
||||
if (newVersion.olderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
|
||||
GridItemSelectionScreen.INSTANCE.itemGrid = null;
|
||||
}
|
||||
|
||||
// Reloads the clientside recipes
|
||||
if (newVersion.olderThanOrEqualTo(ProtocolVersion.v1_11_1)) {
|
||||
Recipes1_11_2.reset();
|
||||
}
|
||||
|
||||
// Reload sound system when switching between 3D Shareware and normal versions
|
||||
if (oldVersion.equals(AprilFoolsProtocolVersion.s3d_shareware) || newVersion.equals(AprilFoolsProtocolVersion.s3d_shareware)) {
|
||||
MinecraftClient.getInstance().getSoundManager().reloadSounds();
|
||||
}
|
||||
}));
|
||||
|
||||
// Register the footstep particle
|
||||
FootStepParticle1_12_2.init();
|
||||
|
||||
// Register the custom payload packet for sync tasks
|
||||
DataCustomPayload.init();
|
||||
}
|
||||
|
||||
public static void init() {
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus
|
||||
* Copyright (C) 2021-2024 the original authors
|
||||
* - FlorianMichael/EnZaXD <florian.michael07@gmail.com>
|
||||
* - RK_01/RaphiMC
|
||||
* Copyright (C) 2023-2024 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.viaversion.viafabricplus.features.block;
|
||||
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.registry.Registries;
|
||||
|
||||
public final class CollisionShapes {
|
||||
|
||||
public static void reloadBlockShapes() {
|
||||
for (Block block : Registries.BLOCK) {
|
||||
if (block instanceof AnvilBlock || block instanceof BedBlock || block instanceof BrewingStandBlock
|
||||
|| block instanceof CarpetBlock || block instanceof CauldronBlock || block instanceof ChestBlock
|
||||
|| block instanceof EnderChestBlock || block instanceof EndPortalBlock || block instanceof EndPortalFrameBlock
|
||||
|| block instanceof FarmlandBlock || block instanceof FenceBlock || block instanceof FenceGateBlock
|
||||
|| block instanceof HopperBlock || block instanceof LadderBlock || block instanceof LeavesBlock
|
||||
|| block instanceof LilyPadBlock || block instanceof PaneBlock || block instanceof PistonBlock
|
||||
|| block instanceof PistonHeadBlock || block instanceof SnowBlock || block instanceof WallBlock
|
||||
|| block instanceof CropBlock || block instanceof FlowerbedBlock
|
||||
) {
|
||||
for (BlockState state : block.getStateManager().getStates()) {
|
||||
state.initShapeCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -28,7 +28,6 @@ import net.lenni0451.reflect.Enums;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialegacy.protocol.classic.c0_30cpetoc0_28_30.data.ClassicProtocolExtension;
|
||||
import net.raphimc.vialegacy.protocol.classic.c0_30cpetoc0_28_30.packet.ClientboundPacketsc0_30cpe;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -45,7 +44,7 @@ public class CPEAdditions {
|
||||
|
||||
private static boolean snowing = false;
|
||||
|
||||
public static void modifyMappings() {
|
||||
public static void init() {
|
||||
allowExtension(ClassicProtocolExtension.ENV_WEATHER_TYPE);
|
||||
EXT_WEATHER_TYPE = createNewPacket(ClassicProtocolExtension.ENV_WEATHER_TYPE, 31, (user, buf) -> buf.readByte());
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.viaversion.viafabricplus.old.versioned.visual;
|
||||
package com.viaversion.viafabricplus.features.entity.v1_8_boat;
|
||||
|
||||
import net.minecraft.client.model.*;
|
||||
import net.minecraft.client.render.entity.model.EntityModel;
|
@ -19,7 +19,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.viaversion.viafabricplus.old.versioned.visual;
|
||||
package com.viaversion.viafabricplus.features.entity.v1_8_boat;
|
||||
|
||||
import net.minecraft.client.render.OverlayTexture;
|
||||
import net.minecraft.client.render.RenderLayer;
|
@ -19,7 +19,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.viaversion.viafabricplus.old.versioned;
|
||||
package com.viaversion.viafabricplus.features.interaction;
|
||||
|
||||
import net.minecraft.util.ActionResult;
|
||||
|
@ -27,7 +27,6 @@ import net.minecraft.GameVersion;
|
||||
import net.minecraft.SaveVersion;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.resource.ResourceType;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
@ -87,10 +86,11 @@ public class ResourcePackHeaderDiff {
|
||||
registerVersion(ProtocolVersion.v1_7_2, 1, "1.7.5");
|
||||
}
|
||||
|
||||
public static void checkOutdated() {
|
||||
public static void init() {
|
||||
if (!GAME_VERSION_DIFF.containsKey(ProtocolTranslator.NATIVE_VERSION)) {
|
||||
throw new RuntimeException("The native client version is not registered in the resource pack header diff!");
|
||||
}
|
||||
// Also calls the static block
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,7 +22,7 @@
|
||||
package com.viaversion.viafabricplus.injection.mixin.features.entity.v1_8_boat;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.viaversion.viafabricplus.old.versioned.visual.BoatModel1_8;
|
||||
import com.viaversion.viafabricplus.features.entity.v1_8_boat.BoatModel1_8;
|
||||
import net.minecraft.client.model.TexturedModelData;
|
||||
import net.minecraft.client.render.entity.model.EntityModelLayer;
|
||||
import net.minecraft.client.render.entity.model.EntityModels;
|
||||
|
@ -23,7 +23,7 @@ package com.viaversion.viafabricplus.injection.mixin.features.entity.v1_8_boat;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viafabricplus.old.versioned.visual.BoatRenderer1_8;
|
||||
import com.viaversion.viafabricplus.features.entity.v1_8_boat.BoatRenderer1_8;
|
||||
import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.render.entity.EntityRenderer;
|
||||
|
@ -28,7 +28,7 @@ import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.protocols.v1_16_1to1_16_2.packet.ServerboundPackets1_16_2;
|
||||
import com.viaversion.viaversion.protocols.v1_16_4to1_17.Protocol1_16_4To1_17;
|
||||
import com.viaversion.viafabricplus.old.versioned.ActionResultException1_12_2;
|
||||
import com.viaversion.viafabricplus.features.interaction.ActionResultException1_12_2;
|
||||
import com.viaversion.viafabricplus.features.interaction.ClientPlayerInteractionManager1_18_2;
|
||||
import com.viaversion.viafabricplus.injection.access.IClientConnection;
|
||||
import com.viaversion.viafabricplus.injection.access.IClientPlayerInteractionManager;
|
||||
|
@ -25,8 +25,8 @@ import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.suggestion.Suggestions;
|
||||
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
||||
import com.viaversion.viafabricplus.old.versioned.classic.command.ListExtensionsCommand;
|
||||
import com.viaversion.viafabricplus.old.versioned.classic.command.SetTimeCommand;
|
||||
import com.viaversion.viafabricplus.protocoltranslator.impl.command.classic.ListExtensionsCommand;
|
||||
import com.viaversion.viafabricplus.protocoltranslator.impl.command.classic.SetTimeCommand;
|
||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||
import net.raphimc.vialoader.impl.viaversion.VLCommandHandler;
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.viaversion.viafabricplus.old.versioned.classic.command;
|
||||
package com.viaversion.viafabricplus.protocoltranslator.impl.command.classic;
|
||||
|
||||
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
||||
import com.viaversion.viafabricplus.injection.access.IExtensionProtocolMetadataStorage;
|
@ -19,7 +19,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.viaversion.viafabricplus.old.versioned.classic.command;
|
||||
package com.viaversion.viafabricplus.protocoltranslator.impl.command.classic;
|
||||
|
||||
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
||||
import com.viaversion.viafabricplus.protocoltranslator.impl.command.VFPViaSubCommand;
|
Loading…
Reference in New Issue
Block a user