mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2025-01-22 21:42:44 +01:00
Don't expose some functions to the API
This commit is contained in:
parent
b34f7770fe
commit
075ea45cc3
@ -21,7 +21,9 @@
|
|||||||
|
|
||||||
package de.florianmichael.viafabricplus;
|
package de.florianmichael.viafabricplus;
|
||||||
|
|
||||||
|
import de.florianmichael.viafabricplus.save.SaveManager;
|
||||||
import de.florianmichael.viafabricplus.settings.SettingsManager;
|
import de.florianmichael.viafabricplus.settings.SettingsManager;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -34,7 +36,10 @@ public class ViaFabricPlus {
|
|||||||
|
|
||||||
private static final ViaFabricPlus INSTANCE = new ViaFabricPlus();
|
private static final ViaFabricPlus INSTANCE = new ViaFabricPlus();
|
||||||
|
|
||||||
|
private final Logger logger = LogManager.getLogger("ViaFabricPlus-Legacy");
|
||||||
|
|
||||||
private final SettingsManager settingsManager = new SettingsManager();
|
private final SettingsManager settingsManager = new SettingsManager();
|
||||||
|
private final SaveManager saveManager = new SaveManager();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static ViaFabricPlus global() {
|
public static ViaFabricPlus global() {
|
||||||
@ -43,7 +48,7 @@ public class ViaFabricPlus {
|
|||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Logger getLogger() {
|
public Logger getLogger() {
|
||||||
return com.viaversion.viafabricplus.ViaFabricPlus.getImpl().logger();
|
return logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@ -52,13 +57,13 @@ public class ViaFabricPlus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Object getSettingsManager() {
|
public SettingsManager getSettingsManager() {
|
||||||
return settingsManager;
|
return settingsManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Object getSaveManager() {
|
public SaveManager getSaveManager() {
|
||||||
throw new IllegalArgumentException("ViaFabricPlus#getSaveManager is not supported anymore.");
|
return saveManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -54,7 +54,7 @@ public class ProtocolTranslator {
|
|||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static UserConnection createDummyUserConnection(final ProtocolVersion clientVersion, final ProtocolVersion serverVersion) {
|
public static UserConnection createDummyUserConnection(final ProtocolVersion clientVersion, final ProtocolVersion serverVersion) {
|
||||||
return ViaFabricPlus.getImpl().createDummyUserConnection(clientVersion, serverVersion);
|
throw new UnsupportedOperationException("This method is not supported anymore");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* 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 de.florianmichael.viafabricplus.save;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Please migrate to the general {@link com.viaversion.viafabricplus.ViaFabricPlus} API point.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public class SaveManager {
|
||||||
|
|
||||||
|
}
|
@ -51,13 +51,6 @@ public interface ViaFabricPlusBase {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the logger for this mod.
|
|
||||||
*
|
|
||||||
* @return The logger
|
|
||||||
*/
|
|
||||||
Logger logger();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the root path of the mod.
|
* Get the root path of the mod.
|
||||||
*
|
*
|
||||||
@ -103,13 +96,6 @@ public interface ViaFabricPlusBase {
|
|||||||
*/
|
*/
|
||||||
void setTargetVersion(final ProtocolVersion newVersion, final boolean revertOnDisconnect);
|
void setTargetVersion(final ProtocolVersion newVersion, final boolean revertOnDisconnect);
|
||||||
|
|
||||||
/**
|
|
||||||
* @param clientVersion The client version
|
|
||||||
* @param serverVersion The server version
|
|
||||||
* @return Creates a dummy UserConnection class with a valid protocol pipeline to emulate packets
|
|
||||||
*/
|
|
||||||
UserConnection createDummyUserConnection(final ProtocolVersion clientVersion, final ProtocolVersion serverVersion);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the current UserConnection of the connection to the server, if the player isn't connected to a server it will return null
|
* @return the current UserConnection of the connection to the server, if the player isn't connected to a server it will return null
|
||||||
*/
|
*/
|
||||||
|
@ -32,7 +32,7 @@ dependencies {
|
|||||||
modJij fabricApi.module("fabric-registry-sync-v0", project.fabric_api_version)
|
modJij fabricApi.module("fabric-registry-sync-v0", project.fabric_api_version)
|
||||||
|
|
||||||
// Sub projects, since they are Fabric mods as well (mainly to access the game code) we have to first
|
// Sub projects, since they are Fabric mods as well (mainly to access the game code) we have to first
|
||||||
// implement the namedElements (raw output) to compile against, then include the mappedElements into the output jar1
|
// implement the namedElements (raw output) to compile against, then include the mappedElements into the output jar
|
||||||
implementation project(path: ":viafabricplus-api", configuration: "namedElements")
|
implementation project(path: ":viafabricplus-api", configuration: "namedElements")
|
||||||
implementation project(path: ":viafabricplus-api-legacy", configuration: "namedElements")
|
implementation project(path: ":viafabricplus-api-legacy", configuration: "namedElements")
|
||||||
implementation project(path: ":viafabricplus-visuals", configuration: "namedElements")
|
implementation project(path: ":viafabricplus-visuals", configuration: "namedElements")
|
||||||
|
@ -144,11 +144,6 @@ public final class ViaFabricPlusImpl implements ViaFabricPlusBase {
|
|||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
// Proxy the most important/used internals to a general API point for mods
|
// Proxy the most important/used internals to a general API point for mods
|
||||||
|
|
||||||
@Override
|
|
||||||
public Logger logger() {
|
|
||||||
return logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Path rootPath() {
|
public Path rootPath() {
|
||||||
return path;
|
return path;
|
||||||
@ -179,11 +174,6 @@ public final class ViaFabricPlusImpl implements ViaFabricPlusBase {
|
|||||||
ProtocolTranslator.setTargetVersion(newVersion, revertOnDisconnect);
|
ProtocolTranslator.setTargetVersion(newVersion, revertOnDisconnect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserConnection createDummyUserConnection(ProtocolVersion clientVersion, ProtocolVersion serverVersion) {
|
|
||||||
return ProtocolTranslator.createDummyUserConnection(clientVersion, serverVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserConnection getPlayNetworkUserConnection() {
|
public UserConnection getPlayNetworkUserConnection() {
|
||||||
return ProtocolTranslator.getPlayNetworkUserConnection();
|
return ProtocolTranslator.getPlayNetworkUserConnection();
|
||||||
@ -269,4 +259,8 @@ public final class ViaFabricPlusImpl implements ViaFabricPlusBase {
|
|||||||
return NegativeItemUtil.getCount(stack);
|
return NegativeItemUtil.getCount(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Logger logger() {
|
||||||
|
return logger;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
package com.viaversion.viafabricplus.screen;
|
package com.viaversion.viafabricplus.screen;
|
||||||
|
|
||||||
import com.viaversion.viafabricplus.ViaFabricPlus;
|
import com.viaversion.viafabricplus.ViaFabricPlusImpl;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
import net.minecraft.client.gui.screen.ConfirmLinkScreen;
|
import net.minecraft.client.gui.screen.ConfirmLinkScreen;
|
||||||
@ -233,7 +233,7 @@ public class VFPScreen extends Screen {
|
|||||||
* @param next The screen which should be opened after the error screen is closed
|
* @param next The screen which should be opened after the error screen is closed
|
||||||
*/
|
*/
|
||||||
public static void showErrorScreen(final Text title, final Throwable throwable, final Screen next) {
|
public static void showErrorScreen(final Text title, final Throwable throwable, final Screen next) {
|
||||||
ViaFabricPlus.getImpl().logger().error("Something went wrong!", throwable);
|
ViaFabricPlusImpl.INSTANCE.logger().error("Something went wrong!", throwable);
|
||||||
|
|
||||||
final MinecraftClient client = MinecraftClient.getInstance();
|
final MinecraftClient client = MinecraftClient.getInstance();
|
||||||
client.execute(() -> client.setScreen(new NoticeScreen(() -> client.setScreen(next), title, Text.translatable("base.viafabricplus.something_went_wrong").append("\n" + throwable.getMessage()), Text.translatable("base.viafabricplus.cancel"), false)));
|
client.execute(() -> client.setScreen(new NoticeScreen(() -> client.setScreen(next), title, Text.translatable("base.viafabricplus.something_went_wrong").append("\n" + throwable.getMessage()), Text.translatable("base.viafabricplus.cancel"), false)));
|
@ -30,9 +30,15 @@ import com.viaversion.viafabricplus.visuals.features.classic_creative_menu.GridI
|
|||||||
import com.viaversion.viafabricplus.visuals.settings.VisualSettings;
|
import com.viaversion.viafabricplus.visuals.settings.VisualSettings;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
public class ViaFabricPlusVisuals implements ViaFabricPlusLoadEntrypoint {
|
public class ViaFabricPlusVisuals implements ViaFabricPlusLoadEntrypoint {
|
||||||
|
|
||||||
|
public static final ViaFabricPlusVisuals INSTANCE = new ViaFabricPlusVisuals();
|
||||||
|
|
||||||
|
private final Logger logger = LogManager.getLogger("ViaFabricPlus-Visuals");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlatformLoad(ViaFabricPlusBase platform) {
|
public void onPlatformLoad(ViaFabricPlusBase platform) {
|
||||||
UnicodeFontFix1_12_2.init();
|
UnicodeFontFix1_12_2.init();
|
||||||
@ -55,4 +61,8 @@ public class ViaFabricPlusVisuals implements ViaFabricPlusLoadEntrypoint {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Logger logger() {
|
||||||
|
return logger;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
package com.viaversion.viafabricplus.visuals.features.armor_hud;
|
package com.viaversion.viafabricplus.visuals.features.armor_hud;
|
||||||
|
|
||||||
import com.viaversion.viafabricplus.ViaFabricPlus;
|
import com.viaversion.viafabricplus.ViaFabricPlus;
|
||||||
|
import com.viaversion.viafabricplus.visuals.ViaFabricPlusVisuals;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.type.Types;
|
import com.viaversion.viaversion.api.type.Types;
|
||||||
@ -54,7 +55,7 @@ public final class ArmorHudEmulation1_8 {
|
|||||||
try {
|
try {
|
||||||
sendArmorUpdate(userConnection);
|
sendArmorUpdate(userConnection);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
ViaFabricPlus.getImpl().logger().error("Error sending armor update", t);
|
ViaFabricPlusVisuals.INSTANCE.logger().error("Error sending armor update", t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -22,20 +22,22 @@
|
|||||||
package com.viaversion.viafabricplus.visuals.features.classic_creative_menu;
|
package com.viaversion.viafabricplus.visuals.features.classic_creative_menu;
|
||||||
|
|
||||||
import com.viaversion.viafabricplus.ViaFabricPlus;
|
import com.viaversion.viafabricplus.ViaFabricPlus;
|
||||||
import com.viaversion.viafabricplus.screen.VFPScreen;
|
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
|
import net.minecraft.client.gui.widget.ClickableWidget;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.registry.Registries;
|
import net.minecraft.registry.Registries;
|
||||||
import net.minecraft.resource.featuretoggle.FeatureFlags;
|
import net.minecraft.resource.featuretoggle.FeatureFlags;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@SuppressWarnings("DataFlowIssue")
|
@SuppressWarnings("DataFlowIssue")
|
||||||
public final class GridItemSelectionScreen extends VFPScreen {
|
public final class GridItemSelectionScreen extends Screen {
|
||||||
|
|
||||||
public static final GridItemSelectionScreen INSTANCE = new GridItemSelectionScreen();
|
public static final GridItemSelectionScreen INSTANCE = new GridItemSelectionScreen();
|
||||||
|
|
||||||
@ -48,7 +50,7 @@ public final class GridItemSelectionScreen extends VFPScreen {
|
|||||||
public ItemStack selectedItem = null;
|
public ItemStack selectedItem = null;
|
||||||
|
|
||||||
public GridItemSelectionScreen() {
|
public GridItemSelectionScreen() {
|
||||||
super("Classic item selection", false);
|
super(Text.of("Classic item selection"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -88,7 +90,7 @@ public final class GridItemSelectionScreen extends VFPScreen {
|
|||||||
this.client.player.getInventory().main.set(client.player.getInventory().selectedSlot, selectedItem);
|
this.client.player.getInventory().main.set(client.player.getInventory().selectedSlot, selectedItem);
|
||||||
this.client.player.playerScreenHandler.sendContentUpdates();
|
this.client.player.playerScreenHandler.sendContentUpdates();
|
||||||
|
|
||||||
playClickSound();
|
ClickableWidget.playClickSound(this.client.getSoundManager());
|
||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
return super.mouseClicked(mouseX, mouseY, button);
|
return super.mouseClicked(mouseX, mouseY, button);
|
||||||
|
Loading…
Reference in New Issue
Block a user