mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2025-01-02 18:39:16 +01:00
Recoded and improved everything (1/2)™️
This commit is contained in:
parent
0220b7dc48
commit
10851b48bf
46
build.gradle
46
build.gradle
@ -10,12 +10,7 @@ base {
|
||||
}
|
||||
|
||||
configurations {
|
||||
// Jar in sources
|
||||
api.extendsFrom jis
|
||||
|
||||
// Jar in jar
|
||||
include.extendsFrom jij
|
||||
implementation.extendsFrom jij
|
||||
jij
|
||||
}
|
||||
|
||||
repositories {
|
||||
@ -54,33 +49,33 @@ dependencies {
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
|
||||
|
||||
// ViaVersion Libraries
|
||||
jis "com.viaversion:viaversion-common:${project.viaversion_version}"
|
||||
jis ("com.viaversion:viabackwards-common:${project.viabackwards_version}") {
|
||||
jij "com.viaversion:viaversion-common:${project.viaversion_version}"
|
||||
jij ("com.viaversion:viabackwards-common:${project.viabackwards_version}") {
|
||||
exclude group: "com.viaversion", module: "viaversion"
|
||||
exclude group: "io.netty", module: "netty-all"
|
||||
exclude group: "com.google.guava", module: "guava"
|
||||
}
|
||||
jis ("net.raphimc:ViaLegacy:${project.vialegacy_version}") {
|
||||
jij ("net.raphimc:ViaLegacy:${project.vialegacy_version}") {
|
||||
exclude group: "com.google.code.gson", module: "gson"
|
||||
}
|
||||
jis "net.raphimc:ViaAprilFools:${project.viaaprilfools_version}"
|
||||
jis ("net.raphimc:ViaBedrock:${project.viabedrock_version}") {
|
||||
jij "net.raphimc:ViaAprilFools:${project.viaaprilfools_version}"
|
||||
jij ("net.raphimc:ViaBedrock:${project.viabedrock_version}") {
|
||||
exclude group: "io.netty"
|
||||
exclude group: "io.jsonwebtoken"
|
||||
exclude group: "net.lenni0451.mcstructs", module: "text"
|
||||
exclude group: "com.mojang", module: "brigadier"
|
||||
}
|
||||
jis ("net.raphimc:ViaLoader:${project.vialoader_version}") {
|
||||
jij ("net.raphimc:ViaLoader:${project.vialoader_version}") {
|
||||
exclude group: "com.google.guava", module: "guava"
|
||||
exclude group: "org.slf4j", module: "slf4j-api"
|
||||
}
|
||||
|
||||
// RaphiMC Libraries
|
||||
jis ("net.raphimc:MinecraftAuth:${project.minecraftauth_version}") {
|
||||
jij ("net.raphimc:MinecraftAuth:${project.minecraftauth_version}") {
|
||||
exclude group: "com.google.code.gson", module: "gson"
|
||||
exclude group: "org.slf4j", module: "slf4j-api"
|
||||
}
|
||||
jis("org.cloudburstmc.netty:netty-transport-raknet:${project.raknet_transport_version}") {
|
||||
jij("org.cloudburstmc.netty:netty-transport-raknet:${project.raknet_transport_version}") {
|
||||
exclude group: "io.netty"
|
||||
}
|
||||
|
||||
@ -88,9 +83,15 @@ dependencies {
|
||||
jij "net.lenni0451:Reflect:${project.reflect_version}"
|
||||
|
||||
// Misc Libraries
|
||||
modApi "com.terraformersmc:modmenu:${project.mod_menu_version}"
|
||||
include implementation(annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-fabric:${project.mixin_extras_version}"))
|
||||
jis "de.florianmichael:Classic4J:${project.classic4j_version}"
|
||||
modCompileOnly "com.terraformersmc:modmenu:${project.mod_menu_version}"
|
||||
jij(annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-fabric:${project.mixin_extras_version}"))
|
||||
jij "de.florianmichael:Classic4J:${project.classic4j_version}"
|
||||
|
||||
afterEvaluate {
|
||||
configurations.jij.incoming.resolutionResult.allDependencies {
|
||||
dependencies.include(dependencies.implementation(requested.toString()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processResources {
|
||||
@ -109,17 +110,6 @@ java {
|
||||
}
|
||||
|
||||
jar {
|
||||
// Add all dependencies which are included using "jis" to the jar file and exclude the META-INF folder
|
||||
dependsOn configurations.jis
|
||||
from {
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
configurations.jis.collect {
|
||||
zipTree(it)
|
||||
}
|
||||
} {
|
||||
exclude "META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA"
|
||||
}
|
||||
|
||||
// Rename the project's license file to LICENSE_<project_name> to avoid conflicts
|
||||
from("LICENSE") {
|
||||
rename {
|
||||
|
@ -19,21 +19,20 @@ package de.florianmichael.viafabricplus;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import de.florianmichael.viafabricplus.protocolhack.util.ViaJarReplacer;
|
||||
import de.florianmichael.viafabricplus.event.FinishMinecraftLoadCallback;
|
||||
import de.florianmichael.viafabricplus.event.PreLoadCallback;
|
||||
import de.florianmichael.viafabricplus.settings.SettingsSystem;
|
||||
import de.florianmichael.viafabricplus.definition.ClientsideFixes;
|
||||
import de.florianmichael.viafabricplus.definition.account.BedrockAccountHandler;
|
||||
import de.florianmichael.viafabricplus.definition.account.ClassiCubeAccountHandler;
|
||||
import de.florianmichael.viafabricplus.definition.classic.CustomClassicProtocolExtensions;
|
||||
import de.florianmichael.viafabricplus.definition.classic.screen.ClassicItemSelectionScreen;
|
||||
import de.florianmichael.viafabricplus.event.FinishMinecraftLoadCallback;
|
||||
import de.florianmichael.viafabricplus.event.PreLoadCallback;
|
||||
import de.florianmichael.viafabricplus.information.InformationSystem;
|
||||
import de.florianmichael.viafabricplus.mappings.CharacterMappings;
|
||||
import de.florianmichael.viafabricplus.mappings.ItemReleaseVersionMappings;
|
||||
import de.florianmichael.viafabricplus.mappings.PackFormatsMappings;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.definition.classic.screen.ClassicItemSelectionScreen;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import de.florianmichael.viafabricplus.protocolhack.util.ViaJarReplacer;
|
||||
import de.florianmichael.viafabricplus.settings.SettingsSystem;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@ -57,9 +56,19 @@ import java.io.File;
|
||||
* - X/Z Face based jump movement in <= 1.13.2 is broken (https://github.com/ViaVersion/ViaFabricPlus/issues/189)
|
||||
* - Collision hit boxes has been changed (https://github.com/ViaVersion/ViaFabricPlus/issues/195)
|
||||
* - Blit-jump is not supported in <= 1.8.9 (https://github.com/ViaVersion/ViaFabricPlus/issues/225)
|
||||
*
|
||||
* TODO | Migration v3
|
||||
* - Fix classic login input field (MixinSharedConstants)
|
||||
* - Make recipe fixes dynamic instead of a data dump in java classes
|
||||
* - Make mixin injection methods private
|
||||
* - Make mixins abstract
|
||||
* - Rename all methods
|
||||
* - Use ViaProxy config patch for some clientside fixes options (Remove ViaFabricPlusVLViaConfig)
|
||||
* - Is de.florianmichael.viafabricplus.injection.mixin.jsonwebtoken.* still needed?
|
||||
* - Apply MixinAutoRefillHandler_ItemSlotMonitor only when mod is actually installed
|
||||
* - Make block shapes static
|
||||
*/
|
||||
public class ViaFabricPlus {
|
||||
public final static VersionEnum NATIVE_VERSION = VersionEnum.r1_20_2;
|
||||
|
||||
public final static Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
public final static Logger LOGGER = LogManager.getLogger("ViaFabricPlus");
|
||||
@ -93,6 +102,7 @@ public class ViaFabricPlus {
|
||||
CharacterMappings.load();
|
||||
|
||||
// Protocol Translator
|
||||
ProtocolHack.initCommands();
|
||||
ProtocolHack.init();
|
||||
|
||||
// Stuff which requires Minecraft to be initialized
|
||||
|
@ -17,14 +17,13 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.definition;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ArmorType;
|
||||
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
|
||||
import de.florianmichael.viafabricplus.event.FinishMinecraftLoadCallback;
|
||||
import de.florianmichael.viafabricplus.event.LoadClassicProtocolExtensionCallback;
|
||||
import de.florianmichael.viafabricplus.injection.MixinPlugin;
|
||||
import de.florianmichael.viafabricplus.injection.access.IFontStorage;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.FontStorage;
|
||||
@ -103,30 +102,35 @@ public class ClientsideFixes {
|
||||
});
|
||||
|
||||
// Reloads some clientside stuff when the protocol version changes
|
||||
ChangeProtocolVersionCallback.EVENT.register(protocolVersion -> {
|
||||
ChangeProtocolVersionCallback.EVENT.register(protocolVersion -> MinecraftClient.getInstance().execute(() -> {
|
||||
if (MinecraftClient.getInstance() == null) return;
|
||||
|
||||
// Reloads all bounding boxes
|
||||
if (MinecraftClient.getInstance() != null && MinecraftClient.getInstance().player != null) { // Make sure that the game is loaded when reloading the cache
|
||||
for (Block block : RELOADABLE_BLOCKS) {
|
||||
block.getDefaultState().initShapeCache();
|
||||
for (Block block : RELOADABLE_BLOCKS) {
|
||||
for (BlockState state : block.getStateManager().getStates()) {
|
||||
state.initShapeCache();
|
||||
}
|
||||
}
|
||||
|
||||
// Calculates the current chat limit, since it changes depending on the protocol version
|
||||
currentChatLimit = 256;
|
||||
if (protocolVersion.isOlderThanOrEqualTo(VersionEnum.r1_10)) {
|
||||
if (protocolVersion.isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
|
||||
currentChatLimit = 64 - (MinecraftClient.getInstance().getSession().getUsername().length() + 2);
|
||||
} else if (protocolVersion.equals(VersionEnum.bedrockLatest)) {
|
||||
currentChatLimit = 512;
|
||||
} else if (protocolVersion.isOlderThanOrEqualTo(VersionEnum.r1_9_3tor1_9_4)) {
|
||||
currentChatLimit = 100;
|
||||
if (protocolVersion.isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
|
||||
currentChatLimit = 64 - MinecraftClient.getInstance().getSession().getUsername().length() - 2;
|
||||
}
|
||||
} else {
|
||||
currentChatLimit = 256;
|
||||
}
|
||||
|
||||
if (!MixinPlugin.DASH_LOADER_PRESENT) {
|
||||
// Reloads all font storages to fix the font renderer
|
||||
for (FontStorage storage : MinecraftClient.getInstance().fontManager.fontStorages.values()) {
|
||||
RenderSystem.recordRenderCall(() -> ((IFontStorage) storage).viafabricplus_clearCaches());
|
||||
storage.glyphRendererCache.clear();
|
||||
storage.glyphCache.clear();
|
||||
}
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
// Calculates the current chat limit, since it changes depending on the protocol version
|
||||
LoadClassicProtocolExtensionCallback.EVENT.register(classicProtocolExtension -> {
|
||||
|
@ -29,11 +29,10 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.model.ClassicLevel;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.providers.ClassicWorldHeightProvider;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.storage.ClassicLevelStorage;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
@ -46,7 +45,7 @@ public class ClassicWorldHeightInjection {
|
||||
parentHandler.handle(wrapper);
|
||||
if (wrapper.isCancelled()) return;
|
||||
|
||||
if (ProtocolHack.getTargetVersion(wrapper.user().getChannel()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
|
||||
if (VersionEnum.fromUserConnection(wrapper.user()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
|
||||
for (Tag dimension : wrapper.get(Type.NAMED_COMPOUND_TAG, 0).<CompoundTag>get("minecraft:dimension_type").<ListTag>get("value")) {
|
||||
changeDimensionTagHeight(wrapper.user(), ((CompoundTag) dimension).get("element"));
|
||||
}
|
||||
@ -60,7 +59,7 @@ public class ClassicWorldHeightInjection {
|
||||
parentHandler.handle(wrapper);
|
||||
if (wrapper.isCancelled()) return;
|
||||
|
||||
if (ProtocolHack.getTargetVersion(wrapper.user().getChannel()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
|
||||
if (VersionEnum.fromUserConnection(wrapper.user()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
|
||||
changeDimensionTagHeight(wrapper.user(), wrapper.get(Type.NAMED_COMPOUND_TAG, 0));
|
||||
}
|
||||
};
|
||||
@ -71,7 +70,7 @@ public class ClassicWorldHeightInjection {
|
||||
parentHandler.handle(wrapper);
|
||||
if (wrapper.isCancelled()) return;
|
||||
|
||||
if (ProtocolHack.getTargetVersion(wrapper.user().getChannel()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
|
||||
if (VersionEnum.fromUserConnection(wrapper.user()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
|
||||
wrapper.resetReader();
|
||||
final Chunk chunk = wrapper.read(new ChunkType1_17(16));
|
||||
wrapper.write(new ChunkType1_17(chunk.getSections().length), chunk);
|
||||
@ -161,7 +160,7 @@ public class ClassicWorldHeightInjection {
|
||||
};
|
||||
|
||||
return wrapper -> {
|
||||
if (ProtocolHack.getTargetVersion(wrapper.user().getChannel()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
|
||||
if (VersionEnum.fromUserConnection(wrapper.user()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
|
||||
classicLightHandler.handle(wrapper);
|
||||
} else {
|
||||
parentHandler.handle(wrapper);
|
||||
|
@ -22,8 +22,8 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.definition.classic.command.ClassicViaSubCommand;
|
||||
import de.florianmichael.viafabricplus.injection.access.IExtensionProtocolMetadataStorage;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.storage.ExtensionProtocolMetadataStorage;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
public class ListExtensionsCommand extends ClassicViaSubCommand {
|
||||
@Override
|
||||
@ -43,7 +43,7 @@ public class ListExtensionsCommand extends ClassicViaSubCommand {
|
||||
sendMessage(sender, Formatting.RED + "Only for " + VersionEnum.c0_30cpe.getName());
|
||||
return true;
|
||||
}
|
||||
((IExtensionProtocolMetadataStorage) connection.get(ExtensionProtocolMetadataStorage.class)).getServerExtensions().forEach((extension, version) -> {
|
||||
((IExtensionProtocolMetadataStorage) connection.get(ExtensionProtocolMetadataStorage.class)).viaFabricPlus$getServerExtensions().forEach((extension, version) -> {
|
||||
sendMessage(sender, Formatting.GREEN + extension.getName() + Formatting.GOLD + " v" + version);
|
||||
});
|
||||
return true;
|
||||
|
@ -32,7 +32,7 @@ public class GeneralInformation extends AbstractInformationGroup {
|
||||
@Override
|
||||
public void applyInformation(UserConnection userConnection, List<String> output) {
|
||||
output.add("Pipeline count: " + userConnection.getProtocolInfo().getPipeline().pipes().size());
|
||||
output.add("Selected version (in the GUI): " + ProtocolHack.targetVersion.getName() + " (" + ProtocolHack.targetVersion.getVersion() + ")");
|
||||
output.add("Selected version (in the GUI): " + ProtocolHack.getTargetVersion().getName() + " (" + ProtocolHack.getTargetVersion().getVersion() + ")");
|
||||
output.add("Connected version: " + ProtocolHack.getTargetVersion().getName() + " (" + ProtocolHack.getTargetVersion().getVersion() + ")");
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +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.injection.access;
|
||||
|
||||
public interface IBoatEntity {
|
||||
|
||||
void viafabricplus_setBoatEmpty(boolean boatEmpty);
|
||||
}
|
@ -17,21 +17,17 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.access;
|
||||
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
import javax.crypto.SecretKey;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
public interface IClientConnection {
|
||||
|
||||
void viafabricplus_setupPreNettyDecryption();
|
||||
void viaFabricPlus$setupPreNettyDecryption();
|
||||
|
||||
InetSocketAddress viafabricplus_capturedAddress();
|
||||
void viafabricplus_captureAddress(final InetSocketAddress socketAddress);
|
||||
VersionEnum viaFabricPlus$getServerVersion();
|
||||
void viaFabricPlus$setServerVersion(final VersionEnum serverVersion);
|
||||
|
||||
UserConnection viaFabricPlus$getUserConnection();
|
||||
void viaFabricPlus$setUserConnection(final UserConnection userConnection);
|
||||
|
||||
void viafabricplus_enableZLibCompression();
|
||||
void viafabricplus_enableSnappyCompression();
|
||||
void viafabricplus_enableAesGcmEncryption(final SecretKey secretKey) throws InvalidAlgorithmParameterException, NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException;
|
||||
}
|
||||
|
@ -1,23 +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.injection.access;
|
||||
|
||||
public interface IClientPlayerEntity {
|
||||
|
||||
void viafabricplus_cancelSwingOnce();
|
||||
}
|
@ -23,5 +23,5 @@ import java.util.EnumMap;
|
||||
|
||||
public interface IExtensionProtocolMetadataStorage {
|
||||
|
||||
EnumMap<ClassicProtocolExtension, Integer> getServerExtensions();
|
||||
EnumMap<ClassicProtocolExtension, Integer> viaFabricPlus$getServerExtensions();
|
||||
}
|
||||
|
@ -1,23 +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.injection.access;
|
||||
|
||||
public interface IFontStorage {
|
||||
|
||||
void viafabricplus_clearCaches();
|
||||
}
|
@ -4,7 +4,7 @@ import java.nio.ByteBuffer;
|
||||
|
||||
public interface IKeyPairResponse {
|
||||
|
||||
ByteBuffer viafabricplus_getLegacyPublicKeySignature();
|
||||
ByteBuffer viafabricplus$getLegacyPublicKeySignature();
|
||||
|
||||
void viafabricplus_setLegacyPublicKeySignature(final ByteBuffer signature);
|
||||
void viafabricplus$setLegacyPublicKeySignature(final ByteBuffer signature);
|
||||
}
|
||||
|
@ -1,26 +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.injection.access;
|
||||
|
||||
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||
|
||||
public interface IMinecraftClient {
|
||||
|
||||
ConcurrentLinkedDeque<Runnable> viafabricplus_getMouseInteractions();
|
||||
ConcurrentLinkedDeque<Runnable> viafabricplus_getKeyboardInteractions();
|
||||
}
|
@ -17,9 +17,11 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.access;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
public interface IProtocol1_13To1_12_2 {
|
||||
public interface IPerformanceLog {
|
||||
|
||||
VersionEnum viaFabricPlus$getForcedVersion();
|
||||
void viaFabricPlus$setForcedVersion(final VersionEnum version);
|
||||
|
||||
void viafabricplus_writeDeclareRecipes(final PacketWrapper recipesPacket);
|
||||
}
|
@ -21,6 +21,6 @@ import java.nio.ByteBuffer;
|
||||
|
||||
public interface IPublicKeyData {
|
||||
|
||||
ByteBuffer viafabricplus_getV1Key();
|
||||
void viafabricplus_setV1Key(final ByteBuffer oldKey);
|
||||
ByteBuffer viaFabricPlus$getV1Key();
|
||||
void viaFabricPlus$setV1Key(final ByteBuffer oldKey);
|
||||
}
|
||||
|
@ -19,5 +19,5 @@ package de.florianmichael.viafabricplus.injection.access;
|
||||
|
||||
public interface IScreenHandler {
|
||||
|
||||
short viafabricplus_getAndIncrementLastActionId();
|
||||
short viaFabricPlus$getAndIncrementLastActionId();
|
||||
}
|
||||
|
@ -21,12 +21,13 @@ import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
public interface IServerInfo {
|
||||
|
||||
VersionEnum viafabricplus_forcedVersion();
|
||||
void viafabricplus_forceVersion(VersionEnum version);
|
||||
VersionEnum viaFabricPlus$forcedVersion();
|
||||
void viaFabricPlus$forceVersion(final VersionEnum version);
|
||||
|
||||
boolean viafabricplus_enabled();
|
||||
void viafabricplus_enable();
|
||||
boolean viaFabricPlus$enabled();
|
||||
void viaFabricPlus$enable();
|
||||
|
||||
int viaFabricPlus$translatingVersion();
|
||||
void viaFabricPlus$setTranslatingVersion(final int version);
|
||||
|
||||
int viafabricplus_translatingVersion();
|
||||
void viafabricplus_setTranslatingVersion(final int version);
|
||||
}
|
||||
|
@ -17,9 +17,9 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
|
||||
import de.florianmichael.viafabricplus.settings.impl.GeneralSettings;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import de.florianmichael.viafabricplus.screen.common.ForceVersionScreen;
|
||||
import de.florianmichael.viafabricplus.settings.impl.GeneralSettings;
|
||||
import net.minecraft.client.gui.screen.AddServerScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
@ -42,36 +42,39 @@ public class MixinAddServerScreen extends Screen {
|
||||
@Final
|
||||
private ServerInfo server;
|
||||
|
||||
@Shadow private TextFieldWidget serverNameField;
|
||||
@Shadow private TextFieldWidget addressField;
|
||||
@Shadow
|
||||
private TextFieldWidget serverNameField;
|
||||
|
||||
@Shadow
|
||||
private TextFieldWidget addressField;
|
||||
|
||||
@Unique
|
||||
private String viafabricplus_nameField;
|
||||
private String viaFabricPlus$nameField;
|
||||
|
||||
@Unique
|
||||
private String viafabricplus_addressField;
|
||||
private String viaFabricPlus$addressField;
|
||||
|
||||
public MixinAddServerScreen(Text title) {
|
||||
super(title);
|
||||
}
|
||||
|
||||
@Inject(method = "init", at = @At("RETURN"))
|
||||
public void injectButton(CallbackInfo ci) {
|
||||
final VersionEnum forcedVersion = ((IServerInfo) server).viafabricplus_forcedVersion();
|
||||
private void injectButton(CallbackInfo ci) {
|
||||
final VersionEnum forcedVersion = ((IServerInfo) server).viaFabricPlus$forcedVersion();
|
||||
|
||||
if (viafabricplus_nameField != null && viafabricplus_addressField != null) {
|
||||
this.serverNameField.setText(viafabricplus_nameField);
|
||||
this.addressField.setText(viafabricplus_addressField);
|
||||
if (viaFabricPlus$nameField != null && viaFabricPlus$addressField != null) {
|
||||
this.serverNameField.setText(viaFabricPlus$nameField);
|
||||
this.addressField.setText(viaFabricPlus$addressField);
|
||||
|
||||
viafabricplus_nameField = null;
|
||||
viafabricplus_addressField = null;
|
||||
viaFabricPlus$nameField = null;
|
||||
viaFabricPlus$addressField = null;
|
||||
}
|
||||
|
||||
var builder = ButtonWidget.builder(forcedVersion == null ? Text.translatable("misc.viafabricplus.addserverscreenbuttontitle") : Text.literal(forcedVersion.getName()), button -> {
|
||||
viafabricplus_nameField = serverNameField.getText();
|
||||
viafabricplus_addressField = addressField.getText();
|
||||
viaFabricPlus$nameField = serverNameField.getText();
|
||||
viaFabricPlus$addressField = addressField.getText();
|
||||
|
||||
client.setScreen(new ForceVersionScreen(this, version -> ((IServerInfo) server).viafabricplus_forceVersion(version)));
|
||||
client.setScreen(new ForceVersionScreen(this, version -> ((IServerInfo) server).viaFabricPlus$forceVersion(version)));
|
||||
});
|
||||
|
||||
final int orientation = GeneralSettings.INSTANCE.addServerScreenButtonOrientation.getIndex();
|
||||
|
@ -17,54 +17,66 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
|
||||
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.event.DisconnectConnectionCallback;
|
||||
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
|
||||
import de.florianmichael.viafabricplus.injection.access.IPerformanceLog;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.protocolhack.netty.ViaFabricPlusVLLegacyPipeline;
|
||||
import de.florianmichael.viafabricplus.protocolhack.netty.viabedrock.RakNetClientConnection;
|
||||
import io.netty.bootstrap.AbstractBootstrap;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.channel.*;
|
||||
import io.netty.channel.epoll.EpollDatagramChannel;
|
||||
import io.netty.channel.epoll.EpollSocketChannel;
|
||||
import io.netty.channel.socket.nio.NioDatagramChannel;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.encryption.PacketDecryptor;
|
||||
import net.minecraft.network.encryption.PacketEncryptor;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.text.Text;
|
||||
import net.raphimc.viabedrock.netty.*;
|
||||
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.minecraft.util.profiler.PerformanceLog;
|
||||
import net.raphimc.vialoader.netty.CompressionReorderEvent;
|
||||
import org.spongepowered.asm.mixin.*;
|
||||
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
||||
import net.raphimc.vialoader.netty.VLPipeline;
|
||||
import net.raphimc.vialoader.netty.viabedrock.PingEncapsulationCodec;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.cloudburstmc.netty.channel.raknet.RakChannelFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
import javax.crypto.SecretKey;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
@Mixin(ClientConnection.class)
|
||||
public abstract class MixinClientConnection extends SimpleChannelInboundHandler<Packet<?>> implements IClientConnection {
|
||||
|
||||
@Shadow private Channel channel;
|
||||
@Shadow
|
||||
public Channel channel;
|
||||
|
||||
@Shadow private boolean encrypted;
|
||||
@Shadow
|
||||
private boolean encrypted;
|
||||
|
||||
@Shadow public abstract void channelActive(ChannelHandlerContext context) throws Exception;
|
||||
@Shadow
|
||||
public abstract void channelActive(@NotNull ChannelHandlerContext context) throws Exception;
|
||||
|
||||
@Unique
|
||||
private Cipher viafabricplus_decryptionCipher;
|
||||
private UserConnection viaFabricPlus$userConnection;
|
||||
|
||||
@Unique
|
||||
private boolean viafabricplus_compressionEnabled = false;
|
||||
private VersionEnum viaFabricPlus$serverVersion;
|
||||
|
||||
@Unique
|
||||
private InetSocketAddress viafabricplus_capturedAddress;
|
||||
private Cipher viaFabricPlus$decryptionCipher;
|
||||
|
||||
|
||||
@Inject(method = "setCompressionThreshold", at = @At("RETURN"))
|
||||
private void reorderCompression(int compressionThreshold, boolean rejectBad, CallbackInfo ci) {
|
||||
@ -73,81 +85,114 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
|
||||
|
||||
@Inject(method = "setupEncryption", at = @At("HEAD"), cancellable = true)
|
||||
private void storeEncryptionCiphers(Cipher decryptionCipher, Cipher encryptionCipher, CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion(channel).isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
if (this.viaFabricPlus$serverVersion.isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
ci.cancel();
|
||||
this.viafabricplus_decryptionCipher = decryptionCipher;
|
||||
this.viafabricplus_setupPreNettyEncryption(encryptionCipher);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;group(Lio/netty/channel/EventLoopGroup;)Lio/netty/bootstrap/AbstractBootstrap;", shift = At.Shift.BEFORE), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private static void captureAddress(InetSocketAddress address, boolean useEpoll, ClientConnection connection, CallbackInfoReturnable<ChannelFuture> cir, Class channelType, EventLoopGroup eventLoopGroup) {
|
||||
((IClientConnection) connection).viafabricplus_captureAddress(address);
|
||||
|
||||
if (ProtocolHack.getTargetVersion(address) == VersionEnum.bedrockLatest) {
|
||||
cir.setReturnValue(RakNetClientConnection.connectRakNet(connection, address, eventLoopGroup, channelType));
|
||||
this.viaFabricPlus$decryptionCipher = decryptionCipher;
|
||||
this.viaFabricPlus$setupPreNettyEncryption(encryptionCipher);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
|
||||
super.channelRegistered(ctx);
|
||||
|
||||
if (RakNetClientConnection.getRakNetPingSessions().contains(viafabricplus_capturedAddress)) {
|
||||
channelActive(ctx);
|
||||
RakNetClientConnection.getRakNetPingSessions().remove(viafabricplus_capturedAddress);
|
||||
if (VersionEnum.bedrockLatest.equals(this.viaFabricPlus$serverVersion)) {
|
||||
this.channelActive(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "channelActive", at = @At(value = "INVOKE", target = "Lio/netty/channel/SimpleChannelInboundHandler;channelActive(Lio/netty/channel/ChannelHandlerContext;)V"), remap = false)
|
||||
private void dontCallChannelActive(SimpleChannelInboundHandler<Packet<?>> instance, ChannelHandlerContext ctx) throws Exception {
|
||||
if (!VersionEnum.bedrockLatest.equals(this.viaFabricPlus$serverVersion)) {
|
||||
super.channelActive(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/util/profiler/PerformanceLog;)Lnet/minecraft/network/ClientConnection;", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;", shift = At.Shift.BEFORE))
|
||||
private static void setServerVersion(InetSocketAddress address, boolean useEpoll, PerformanceLog packetSizeLog, CallbackInfoReturnable<ClientConnection> cir, @Local ClientConnection clientConnection) {
|
||||
if (packetSizeLog instanceof IPerformanceLog mixinPerformanceLog && mixinPerformanceLog.viaFabricPlus$getForcedVersion() != null) {
|
||||
((IClientConnection) clientConnection).viaFabricPlus$setServerVersion(mixinPerformanceLog.viaFabricPlus$getForcedVersion());
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/util/profiler/PerformanceLog;)Lnet/minecraft/network/ClientConnection;", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;resetPacketSizeLog(Lnet/minecraft/util/profiler/PerformanceLog;)V"))
|
||||
private static void dontSetPerformanceLog(ClientConnection instance, PerformanceLog performanceLog) {
|
||||
if (performanceLog instanceof IPerformanceLog mixinPerformanceLog && mixinPerformanceLog.viaFabricPlus$getForcedVersion() != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
instance.resetPacketSizeLog(performanceLog);
|
||||
}
|
||||
|
||||
@Inject(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;", at = @At("HEAD"))
|
||||
private static void setServerVersion(InetSocketAddress address, boolean useEpoll, ClientConnection connection, CallbackInfoReturnable<ChannelFuture> cir) {
|
||||
if (((IClientConnection) connection).viaFabricPlus$getServerVersion() == null) {
|
||||
((IClientConnection) connection).viaFabricPlus$setServerVersion(ProtocolHack.getTargetVersion());
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;channel(Ljava/lang/Class;)Lio/netty/bootstrap/AbstractBootstrap;", remap = false))
|
||||
private static AbstractBootstrap<?, ?> applyRakNetChannelFactory(Bootstrap instance, Class<? extends Channel> channelTypeClass, @Local(argsOnly = true) ClientConnection clientConnection) {
|
||||
if (VersionEnum.bedrockLatest.equals(((IClientConnection) clientConnection).viaFabricPlus$getServerVersion())) {
|
||||
return instance.channelFactory(channelTypeClass == EpollSocketChannel.class ? RakChannelFactory.client(EpollDatagramChannel.class) : RakChannelFactory.client(NioDatagramChannel.class));
|
||||
}
|
||||
|
||||
return instance.channel(channelTypeClass);
|
||||
}
|
||||
|
||||
@Redirect(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;connect(Ljava/net/InetAddress;I)Lio/netty/channel/ChannelFuture;"))
|
||||
private static ChannelFuture applyRakNetPing(Bootstrap instance, InetAddress inetHost, int inetPort, @Local(argsOnly = true) ClientConnection clientConnection, @Local(argsOnly = true) boolean isConnecting) {
|
||||
if (VersionEnum.bedrockLatest.equals(((IClientConnection) clientConnection).viaFabricPlus$getServerVersion()) && !isConnecting) {
|
||||
return instance.register().syncUninterruptibly().channel().bind(new InetSocketAddress(0)).addListeners(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE, (ChannelFutureListener) f -> {
|
||||
if (f.isSuccess()) {
|
||||
f.channel().pipeline().replace(VLPipeline.VIABEDROCK_FRAME_ENCAPSULATION_HANDLER_NAME, ViaFabricPlusVLLegacyPipeline.VIABEDROCK_PING_ENCAPSULATION_HANDLER_NAME, new PingEncapsulationCodec(new InetSocketAddress(inetHost, inetPort)));
|
||||
f.channel().pipeline().remove(VLPipeline.VIABEDROCK_PACKET_ENCAPSULATION_HANDLER_NAME);
|
||||
f.channel().pipeline().remove("splitter");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return instance.connect(inetHost, inetPort);
|
||||
}
|
||||
|
||||
@Inject(method = "disconnect", at = @At("RETURN"))
|
||||
public void resetStorages(Text disconnectReason, CallbackInfo ci) {
|
||||
ChangeProtocolVersionCallback.EVENT.invoker().onChangeProtocolVersion(ProtocolHack.getTargetVersion());
|
||||
private void resetStorages(Text disconnectReason, CallbackInfo ci) {
|
||||
DisconnectConnectionCallback.EVENT.invoker().onDisconnect();
|
||||
}
|
||||
|
||||
@Unique
|
||||
public void viafabricplus_setupPreNettyEncryption(final Cipher encryptionCipher) {
|
||||
public void viaFabricPlus$setupPreNettyEncryption(final Cipher encryptionCipher) {
|
||||
if (encryptionCipher == null) throw new IllegalStateException("Encryption cipher is null");
|
||||
|
||||
this.encrypted = true;
|
||||
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "encrypt", new PacketEncryptor(encryptionCipher));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viafabricplus_setupPreNettyDecryption() {
|
||||
public void viaFabricPlus$setupPreNettyDecryption() {
|
||||
if (this.viaFabricPlus$decryptionCipher == null) throw new IllegalStateException("Decryption cipher is null");
|
||||
|
||||
this.encrypted = true;
|
||||
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_PREPENDER_NAME, "decrypt", new PacketDecryptor(this.viafabricplus_decryptionCipher));
|
||||
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_PREPENDER_NAME, "decrypt", new PacketDecryptor(this.viaFabricPlus$decryptionCipher));
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetSocketAddress viafabricplus_capturedAddress() {
|
||||
return viafabricplus_capturedAddress;
|
||||
public UserConnection viaFabricPlus$getUserConnection() {
|
||||
return this.viaFabricPlus$userConnection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viafabricplus_captureAddress(InetSocketAddress socketAddress) {
|
||||
viafabricplus_capturedAddress = socketAddress;
|
||||
public void viaFabricPlus$setUserConnection(UserConnection userConnection) {
|
||||
this.viaFabricPlus$userConnection = userConnection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viafabricplus_enableZLibCompression() {
|
||||
if (this.viafabricplus_compressionEnabled) throw new IllegalStateException("Compression is already enabled");
|
||||
this.viafabricplus_compressionEnabled = true;
|
||||
|
||||
this.channel.pipeline().addBefore("splitter", ViaFabricPlusVLLegacyPipeline.VIABEDROCK_COMPRESSION_HANDLER_NAME, new ZLibCompression());
|
||||
public VersionEnum viaFabricPlus$getServerVersion() {
|
||||
return this.viaFabricPlus$serverVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viafabricplus_enableSnappyCompression() {
|
||||
if (this.viafabricplus_compressionEnabled) throw new IllegalStateException("Compression is already enabled");
|
||||
this.viafabricplus_compressionEnabled = true;
|
||||
|
||||
this.channel.pipeline().addBefore("splitter", ViaFabricPlusVLLegacyPipeline.VIABEDROCK_COMPRESSION_HANDLER_NAME, new SnappyCompression());
|
||||
public void viaFabricPlus$setServerVersion(final VersionEnum serverVersion) {
|
||||
this.viaFabricPlus$serverVersion = serverVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viafabricplus_enableAesGcmEncryption(final SecretKey secretKey) throws InvalidAlgorithmParameterException, NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException {
|
||||
if (this.encrypted) throw new IllegalStateException("Encryption is already enabled");
|
||||
this.encrypted = true;
|
||||
|
||||
this.channel.pipeline().addAfter(ViaFabricPlusVLLegacyPipeline.VIABEDROCK_FRAME_ENCAPSULATION_HANDLER_NAME, ViaFabricPlusVLLegacyPipeline.VIABEDROCK_ENCRYPTION_HANDLER_NAME, new AesEncryption(secretKey));
|
||||
}
|
||||
}
|
||||
|
@ -17,10 +17,8 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
|
||||
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@ -37,9 +35,8 @@ public class MixinClientConnection_1 {
|
||||
ClientConnection field_11663;
|
||||
|
||||
@Inject(method = "initChannel", at = @At("RETURN"))
|
||||
public void hackNettyPipeline(Channel channel, CallbackInfo ci) {
|
||||
if (channel instanceof SocketChannel) {
|
||||
ProtocolHack.injectVLBPipeline(field_11663, channel, ((IClientConnection) field_11663).viafabricplus_capturedAddress());
|
||||
}
|
||||
private void injectViaIntoPipeline(Channel channel, CallbackInfo ci) {
|
||||
ProtocolHack.injectViaPipeline(this.field_11663, channel);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,14 +17,12 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
|
||||
import net.minecraft.client.network.ClientLoginNetworkHandler;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.text.Text;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.ProtocolMetadataStorage;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -36,14 +34,18 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
@Mixin(ClientLoginNetworkHandler.class)
|
||||
public class MixinClientLoginNetworkHandler {
|
||||
|
||||
@Shadow @Final private ClientConnection connection;
|
||||
@Shadow
|
||||
@Final
|
||||
private ClientConnection connection;
|
||||
|
||||
@Inject(method = "joinServerSession", at = @At("HEAD"), cancellable = true)
|
||||
public void dontVerifySessionIfCracked(String serverId, CallbackInfoReturnable<Text> cir) {
|
||||
if (ProtocolHack.getTargetVersion(connection.channel).isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
if (!connection.channel.attr(ProtocolHack.LOCAL_VIA_CONNECTION).get().get(ProtocolMetadataStorage.class).authenticate) {
|
||||
final IClientConnection mixinClientConnection = (IClientConnection) connection;
|
||||
if (mixinClientConnection.viaFabricPlus$getServerVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
if (!mixinClientConnection.viaFabricPlus$getUserConnection().get(ProtocolMetadataStorage.class).authenticate) {
|
||||
cir.setReturnValue(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,24 +17,16 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
|
||||
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
|
||||
import de.florianmichael.viafabricplus.definition.ClientsideFixes;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.client.network.AllowedAddressResolver;
|
||||
import net.minecraft.client.network.ServerAddress;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Optional;
|
||||
|
||||
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
|
||||
@Mixin(targets = "net.minecraft.client.gui.screen.ConnectScreen$1")
|
||||
public class MixinConnectScreen_1 {
|
||||
|
||||
@ -42,27 +34,11 @@ public class MixinConnectScreen_1 {
|
||||
@Shadow
|
||||
ServerInfo field_40415;
|
||||
|
||||
@Final
|
||||
@Shadow
|
||||
ServerAddress field_33737;
|
||||
|
||||
@Redirect(method = "run", at = @At(value = "INVOKE", target = "Ljava/util/Optional;get()Ljava/lang/Object;"))
|
||||
public Object mapSocketAddress(Optional<InetSocketAddress> instance) {
|
||||
final var original = instance.orElse(null); // original invoke
|
||||
@Inject(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;"))
|
||||
public void setForcedServerVersion(CallbackInfo ci) {
|
||||
if (field_40415 != null) {
|
||||
// Handle forced version system
|
||||
final VersionEnum forcedVersion = ((IServerInfo) field_40415).viafabricplus_forcedVersion();
|
||||
if (forcedVersion != null) {
|
||||
ProtocolHack.getForcedVersions().put(original, forcedVersion);
|
||||
ChangeProtocolVersionCallback.EVENT.invoker().onChangeProtocolVersion(forcedVersion);
|
||||
}
|
||||
ProtocolHack.setTargetVersion(((IServerInfo) field_40415).viaFabricPlus$forcedVersion());
|
||||
}
|
||||
|
||||
if (ClientsideFixes.LEGACY_SRV_RESOLVE.contains(ProtocolHack.getTargetVersion(original))) {
|
||||
final var direct = AllowedAddressResolver.DEFAULT.addressResolver.resolve(this.field_33737).orElse(null);
|
||||
|
||||
if (direct != null) return direct.getInetSocketAddress();
|
||||
}
|
||||
return original; // original invoke
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,13 +17,11 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
|
||||
import de.florianmichael.viafabricplus.event.FinishMinecraftLoadCallback;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.RunArgs;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@ -31,18 +29,14 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@Mixin(MinecraftClient.class)
|
||||
public abstract class MixinMinecraftClient {
|
||||
|
||||
@Shadow public abstract boolean isInSingleplayer();
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
public void postLoad(RunArgs args, CallbackInfo ci) {
|
||||
FinishMinecraftLoadCallback.EVENT.invoker().onFinishMinecraftLoad();
|
||||
}
|
||||
|
||||
@Inject(method = "setWorld", at = @At("HEAD"))
|
||||
public void preSetWorld(CallbackInfo ci) {
|
||||
if (isInSingleplayer()) {
|
||||
// We call this here, so client side fixes are disabled in singleplayer
|
||||
ChangeProtocolVersionCallback.EVENT.invoker().onChangeProtocolVersion(ViaFabricPlus.NATIVE_VERSION);
|
||||
}
|
||||
@Inject(method = "startIntegratedServer", at = @At("HEAD"))
|
||||
private void disableProtocolHack(CallbackInfo ci) {
|
||||
ProtocolHack.setTargetVersion(ProtocolHack.NATIVE_VERSION);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,34 +17,35 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import de.florianmichael.viafabricplus.injection.access.IPerformanceLog;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.protocolhack.netty.viabedrock.RakNetClientConnection;
|
||||
import net.minecraft.client.network.MultiplayerServerListPinger;
|
||||
import net.minecraft.client.network.ServerAddress;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.util.profiler.PerformanceLog;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Optional;
|
||||
|
||||
@Mixin(MultiplayerServerListPinger.class)
|
||||
public class MixinMultiplayerServerListPinger {
|
||||
public abstract class MixinMultiplayerServerListPinger {
|
||||
|
||||
@Inject(method = "add", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/util/profiler/PerformanceLog;)Lnet/minecraft/network/ClientConnection;"), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
public void trackSessions(ServerInfo entry, Runnable saver, CallbackInfo ci, ServerAddress serverAddress, Optional optional, InetSocketAddress inetSocketAddress) {
|
||||
final VersionEnum version = ((IServerInfo) entry).viafabricplus_forcedVersion();
|
||||
@Redirect(method = "add", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/util/profiler/PerformanceLog;)Lnet/minecraft/network/ClientConnection;"))
|
||||
private ClientConnection setForcedVersion(InetSocketAddress address, boolean useEpoll, PerformanceLog packetSizeLog, @Local ServerInfo serverInfo) {
|
||||
final VersionEnum forcedVersion = ((IServerInfo) serverInfo).viaFabricPlus$forcedVersion();
|
||||
if (forcedVersion != null) {
|
||||
if (packetSizeLog == null) {
|
||||
packetSizeLog = new PerformanceLog();
|
||||
}
|
||||
|
||||
if (version != null) {
|
||||
ProtocolHack.getForcedVersions().put(inetSocketAddress, version);
|
||||
}
|
||||
if (ProtocolHack.getTargetVersion(inetSocketAddress) == VersionEnum.bedrockLatest) {
|
||||
RakNetClientConnection.getRakNetPingSessions().add(inetSocketAddress);
|
||||
((IPerformanceLog) packetSizeLog).viaFabricPlus$setForcedVersion(forcedVersion);
|
||||
}
|
||||
|
||||
return ClientConnection.connect(address, useEpoll, packetSizeLog);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,12 +17,18 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.listener.ClientQueryPacketListener;
|
||||
import net.minecraft.network.packet.s2c.query.QueryResponseS2CPacket;
|
||||
import net.raphimc.viabedrock.api.BedrockProtocolVersion;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -33,21 +39,37 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@Mixin(targets = "net.minecraft.client.network.MultiplayerServerListPinger$1")
|
||||
public abstract class MixinMultiplayerServerListPinger_1 implements ClientQueryPacketListener {
|
||||
|
||||
@Final
|
||||
@Shadow
|
||||
ClientConnection field_3774;
|
||||
|
||||
@Final
|
||||
@Shadow
|
||||
ServerInfo field_3776;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
ClientConnection field_3774;
|
||||
|
||||
@Inject(method = "onResponse(Lnet/minecraft/network/packet/s2c/query/QueryResponseS2CPacket;)V", at = @At("HEAD"))
|
||||
public void trackTranslatingState(QueryResponseS2CPacket packet, CallbackInfo ci) {
|
||||
if (field_3774.channel.hasAttr(ProtocolHack.LOCAL_VIA_CONNECTION)) {
|
||||
((IServerInfo) field_3776).viafabricplus_enable();
|
||||
|
||||
final var userConnection = field_3774.channel.attr(ProtocolHack.LOCAL_VIA_CONNECTION).get();
|
||||
((IServerInfo) field_3776).viafabricplus_setTranslatingVersion(userConnection.getProtocolInfo().getServerProtocolVersion());
|
||||
final UserConnection userConnection = ((IClientConnection) field_3774).viaFabricPlus$getUserConnection();
|
||||
if (userConnection != null) {
|
||||
((IServerInfo) field_3776).viaFabricPlus$enable();
|
||||
((IServerInfo) field_3776).viaFabricPlus$setTranslatingVersion(userConnection.getProtocolInfo().getServerProtocolVersion());
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "onResponse", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/ServerMetadata;version()Ljava/util/Optional;", shift = At.Shift.AFTER))
|
||||
private void setProtocolVersion(CallbackInfo ci) {
|
||||
final boolean isCompatible;
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
isCompatible = LegacyProtocolVersion.getRealProtocolVersion(((IClientConnection) this.field_3774).viaFabricPlus$getServerVersion().getVersion()) == this.field_3776.protocolVersion;
|
||||
} else if (ProtocolHack.getTargetVersion().equals(VersionEnum.bedrockLatest)) {
|
||||
isCompatible = ((IClientConnection) this.field_3774).viaFabricPlus$getServerVersion().getVersion() - BedrockProtocolVersion.PROTOCOL_ID_OVERLAP_PREVENTION_OFFSET == this.field_3776.protocolVersion;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isCompatible) {
|
||||
this.field_3776.protocolVersion = SharedConstants.getProtocolVersion();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,22 +17,18 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
|
||||
import de.florianmichael.viafabricplus.settings.impl.GeneralSettings;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.settings.impl.GeneralSettings;
|
||||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
|
||||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerServerListWidget;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import net.minecraft.text.Text;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -40,28 +36,23 @@ import java.util.List;
|
||||
@Mixin(MultiplayerServerListWidget.ServerEntry.class)
|
||||
public class MixinMultiplayerServerListWidget_ServerEntry {
|
||||
|
||||
@Shadow @Final private ServerInfo server;
|
||||
@Shadow
|
||||
@Final
|
||||
private ServerInfo server;
|
||||
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;setMultiplayerScreenTooltip(Ljava/util/List;)V", ordinal = 0))
|
||||
public void showTranslatingInformation(MultiplayerScreen instance, List<Text> tooltip) {
|
||||
final List<Text> tooltipOverwrite = new ArrayList<>(tooltip);
|
||||
if (GeneralSettings.INSTANCE.showAdvertisedServerVersion.getValue()) {
|
||||
final IServerInfo accessor = ((IServerInfo) server);
|
||||
if (accessor.viafabricplus_enabled()) {
|
||||
final var versionEnum = VersionEnum.fromProtocolId(accessor.viafabricplus_translatingVersion());
|
||||
if (accessor.viaFabricPlus$enabled()) {
|
||||
final var versionEnum = VersionEnum.fromProtocolId(accessor.viaFabricPlus$translatingVersion());
|
||||
|
||||
tooltipOverwrite.add(Text.translatable("misc.viafabricplus.translate", versionEnum != VersionEnum.UNKNOWN ? versionEnum.getName() + " (" + versionEnum.getVersion() + ")" : accessor.viafabricplus_translatingVersion()));
|
||||
tooltipOverwrite.add(Text.translatable("misc.viafabricplus.translate", versionEnum != VersionEnum.UNKNOWN ? versionEnum.getName() + " (" + versionEnum.getVersion() + ")" : accessor.viaFabricPlus$translatingVersion()));
|
||||
tooltipOverwrite.add(Text.translatable("misc.viafabricplus.serverversion", server.version.getString() + " (" + server.protocolVersion + ")"));
|
||||
}
|
||||
}
|
||||
instance.setMultiplayerScreenTooltip(tooltipOverwrite);
|
||||
}
|
||||
|
||||
@Inject(method = "protocolVersionMatches", at = @At("HEAD"), cancellable = true)
|
||||
public void supportViaLegacyVersionRanges(CallbackInfoReturnable<Boolean> cir) {
|
||||
final var version = ProtocolHack.getTargetVersion(server);
|
||||
if (version.isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
cir.setReturnValue(LegacyProtocolVersion.getRealProtocolVersion(version.getVersion()) == server.protocolVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,19 +17,26 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
|
||||
import de.florianmichael.viafabricplus.screen.classic4j.classicube.ClassiCubeLoginScreen;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import de.florianmichael.viafabricplus.injection.access.IPerformanceLog;
|
||||
import net.minecraft.util.profiler.PerformanceLog;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@Mixin(SharedConstants.class)
|
||||
public class MixinSharedConstants {
|
||||
@Mixin(PerformanceLog.class)
|
||||
public abstract class MixinPerformanceLog implements IPerformanceLog {
|
||||
|
||||
@Inject(method = "isValidChar", at = @At("HEAD"), cancellable = true)
|
||||
private static void allowEveryCharacter(char chr, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (MinecraftClient.getInstance().currentScreen instanceof ClassiCubeLoginScreen) cir.setReturnValue(true);
|
||||
@Unique
|
||||
private VersionEnum viaFabricPlus$forcedVersion;
|
||||
|
||||
@Override
|
||||
public VersionEnum viaFabricPlus$getForcedVersion() {
|
||||
return this.viaFabricPlus$forcedVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaFabricPlus$setForcedVersion(VersionEnum version) {
|
||||
this.viaFabricPlus$forcedVersion = version;
|
||||
}
|
||||
|
||||
}
|
@ -33,67 +33,69 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
@Mixin(ServerInfo.class)
|
||||
public class MixinServerInfo implements IServerInfo {
|
||||
|
||||
@Shadow public String name;
|
||||
@Shadow
|
||||
public String name;
|
||||
|
||||
@Unique
|
||||
private VersionEnum viafabricplus_forcedVersion = null;
|
||||
private VersionEnum viaFabricPlus$forcedVersion = null;
|
||||
|
||||
@Override
|
||||
public VersionEnum viafabricplus_forcedVersion() {
|
||||
return viafabricplus_forcedVersion;
|
||||
public VersionEnum viaFabricPlus$forcedVersion() {
|
||||
return viaFabricPlus$forcedVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viafabricplus_forceVersion(VersionEnum version) {
|
||||
viafabricplus_forcedVersion = version;
|
||||
public void viaFabricPlus$forceVersion(VersionEnum version) {
|
||||
viaFabricPlus$forcedVersion = version;
|
||||
}
|
||||
|
||||
@Inject(method = "toNbt", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
public void saveForcedVersion(CallbackInfoReturnable<NbtCompound> cir, NbtCompound nbtCompound) {
|
||||
if (viafabricplus_forcedVersion == null) return;
|
||||
if (viaFabricPlus$forcedVersion == null) return;
|
||||
|
||||
nbtCompound.putInt("viafabricplus_forcedversion", viafabricplus_forcedVersion.getVersion());
|
||||
nbtCompound.putInt("viafabricplus_forcedversion", viaFabricPlus$forcedVersion.getOriginalVersion());
|
||||
}
|
||||
|
||||
@Inject(method = "fromNbt", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private static void loadForcedVersion(NbtCompound root, CallbackInfoReturnable<ServerInfo> cir, ServerInfo serverInfo) {
|
||||
if (root.contains("viafabricplus_forcedversion")) {
|
||||
try {
|
||||
((IServerInfo) serverInfo).viafabricplus_forceVersion(VersionEnum.fromProtocolId(root.getInt("viafabricplus_forcedversion")));
|
||||
} catch (Exception ignored) {
|
||||
// Version doesn't exist anymore
|
||||
final VersionEnum version = VersionEnum.fromProtocolId(root.getInt("viafabricplus_forcedversion"));
|
||||
if (VersionEnum.UNKNOWN.equals(version)) {
|
||||
((IServerInfo) serverInfo).viaFabricPlus$forceVersion(null);
|
||||
} else {
|
||||
((IServerInfo) serverInfo).viaFabricPlus$forceVersion(version);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "copyFrom", at = @At("RETURN"))
|
||||
public void trackForcedVersion(ServerInfo serverInfo, CallbackInfo ci) {
|
||||
viafabricplus_forceVersion(((IServerInfo) serverInfo).viafabricplus_forcedVersion());
|
||||
viaFabricPlus$forceVersion(((IServerInfo) serverInfo).viaFabricPlus$forcedVersion());
|
||||
}
|
||||
|
||||
@Unique
|
||||
private boolean viafabricplus_enabled;
|
||||
private boolean viaFabricPlus$enabled;
|
||||
|
||||
@Override
|
||||
public boolean viafabricplus_enabled() {
|
||||
return viafabricplus_enabled;
|
||||
public boolean viaFabricPlus$enabled() {
|
||||
return viaFabricPlus$enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viafabricplus_enable() {
|
||||
viafabricplus_enabled = true;
|
||||
public void viaFabricPlus$enable() {
|
||||
viaFabricPlus$enabled = true;
|
||||
}
|
||||
|
||||
@Unique
|
||||
private int viafabricplus_translatingVersion;
|
||||
private int viaFabricPlus$translatingVersion;
|
||||
|
||||
@Override
|
||||
public int viafabricplus_translatingVersion() {
|
||||
return viafabricplus_translatingVersion;
|
||||
public int viaFabricPlus$translatingVersion() {
|
||||
return viaFabricPlus$translatingVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viafabricplus_setTranslatingVersion(int version) {
|
||||
viafabricplus_translatingVersion = version;
|
||||
public void viaFabricPlus$setTranslatingVersion(int version) {
|
||||
viaFabricPlus$translatingVersion = version;
|
||||
}
|
||||
}
|
||||
|
@ -1,39 +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.injection.mixin.compat.sodium;
|
||||
|
||||
import de.florianmichael.viafabricplus.settings.impl.VisualSettings;
|
||||
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Pseudo;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Pseudo
|
||||
@Mixin(targets = "me.jellysquid.mods.sodium.client.render.chunk.ChunkTracker", remap = false)
|
||||
public abstract class MixinChunkTracker {
|
||||
|
||||
@Redirect(method = "recalculateChunks", at = @At(value = "INVOKE", target = "Lit/unimi/dsi/fastutil/longs/Long2IntOpenHashMap;get(J)I"))
|
||||
private int modifyRenderCondition(Long2IntOpenHashMap instance, long k) {
|
||||
if (VisualSettings.INSTANCE.fixSodiumChunkRendering.isEnabled()) {
|
||||
return instance.getOrDefault(k, -1);
|
||||
}
|
||||
|
||||
return instance.get(k);
|
||||
}
|
||||
}
|
@ -11,15 +11,15 @@ import java.nio.ByteBuffer;
|
||||
public class MixinKeyPairResponse implements IKeyPairResponse {
|
||||
|
||||
@Unique
|
||||
private ByteBuffer viafabricplus_legacyKeySignature;
|
||||
private ByteBuffer viaFabricPlus$legacyKeySignature;
|
||||
|
||||
@Override
|
||||
public ByteBuffer viafabricplus_getLegacyPublicKeySignature() {
|
||||
return this.viafabricplus_legacyKeySignature;
|
||||
public ByteBuffer viafabricplus$getLegacyPublicKeySignature() {
|
||||
return this.viaFabricPlus$legacyKeySignature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viafabricplus_setLegacyPublicKeySignature(ByteBuffer signature) {
|
||||
this.viafabricplus_legacyKeySignature = signature;
|
||||
public void viafabricplus$setLegacyPublicKeySignature(ByteBuffer signature) {
|
||||
this.viaFabricPlus$legacyKeySignature = signature;
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class MixinYggdrasilUserApiService {
|
||||
}
|
||||
|
||||
final var keyPairResponse = new KeyPairResponse(response.keyPair(), response.publicKeySignatureV2(), response.expiresAt(), response.refreshedAfter());
|
||||
((IKeyPairResponse) (Object) keyPairResponse).viafabricplus_setLegacyPublicKeySignature(response.publicKeySignature());
|
||||
((IKeyPairResponse) (Object) keyPairResponse).viafabricplus$setLegacyPublicKeySignature(response.publicKeySignature());
|
||||
|
||||
cir.setReturnValue(keyPairResponse);
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ServerboundPac
|
||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.Protocol1_17To1_16_4;
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.definition.ClientPlayerInteractionManager1_18_2;
|
||||
import de.florianmichael.viafabricplus.injection.access.IClientPlayerEntity;
|
||||
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
|
||||
import de.florianmichael.viafabricplus.injection.access.IScreenHandler;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.protocolhack.provider.viaversion.ViaFabricPlusHandItemProvider;
|
||||
@ -35,7 +35,6 @@ import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.client.network.ClientPlayerInteractionManager;
|
||||
import net.minecraft.client.network.SequencedPacketCreator;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
@ -77,10 +76,10 @@ public abstract class MixinClientPlayerInteractionManager {
|
||||
|
||||
@Shadow private float currentBreakingProgress;
|
||||
@Unique
|
||||
private ItemStack viafabricplus_oldCursorStack;
|
||||
private ItemStack viaFabricPlus$oldCursorStack;
|
||||
|
||||
@Unique
|
||||
private List<ItemStack> viafabricplus_oldItems;
|
||||
private List<ItemStack> viaFabricPlus$oldItems;
|
||||
|
||||
@Inject(method = "breakBlock", at = @At("TAIL"))
|
||||
public void resetBlockBreaking(BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
|
||||
@ -89,24 +88,16 @@ public abstract class MixinClientPlayerInteractionManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "attackEntity", at = @At("HEAD"))
|
||||
private void injectAttackEntity(PlayerEntity player, Entity target, CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8) && player instanceof IClientPlayerEntity) {
|
||||
player.swingHand(Hand.MAIN_HAND);
|
||||
((IClientPlayerEntity) player).viafabricplus_cancelSwingOnce();
|
||||
}
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "clickSlot", at = @At(value = "STORE"), ordinal = 0)
|
||||
private List<ItemStack> captureOldItems(List<ItemStack> oldItems) {
|
||||
assert client.player != null;
|
||||
viafabricplus_oldCursorStack = client.player.currentScreenHandler.getCursorStack().copy();
|
||||
return this.viafabricplus_oldItems = oldItems;
|
||||
viaFabricPlus$oldCursorStack = client.player.currentScreenHandler.getCursorStack().copy();
|
||||
return this.viaFabricPlus$oldItems = oldItems;
|
||||
}
|
||||
|
||||
// Special Cases
|
||||
@Unique
|
||||
private boolean viafabricplus_shouldEmpty(final SlotActionType type, final int slot) {
|
||||
private boolean viaFabricPlus$shouldEmpty(final SlotActionType type, final int slot) {
|
||||
// quick craft always uses empty stack for verification
|
||||
if (type == SlotActionType.QUICK_CRAFT) return true;
|
||||
|
||||
@ -122,19 +113,19 @@ public abstract class MixinClientPlayerInteractionManager {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5) && packet instanceof ClickSlotC2SPacket clickSlot) {
|
||||
ItemStack slotItemBeforeModification;
|
||||
|
||||
if (this.viafabricplus_shouldEmpty(clickSlot.getActionType(), clickSlot.getSlot()))
|
||||
if (this.viaFabricPlus$shouldEmpty(clickSlot.getActionType(), clickSlot.getSlot()))
|
||||
slotItemBeforeModification = ItemStack.EMPTY;
|
||||
else if (clickSlot.getSlot() < 0 || clickSlot.getSlot() >= viafabricplus_oldItems.size())
|
||||
slotItemBeforeModification = viafabricplus_oldCursorStack;
|
||||
else if (clickSlot.getSlot() < 0 || clickSlot.getSlot() >= viaFabricPlus$oldItems.size())
|
||||
slotItemBeforeModification = viaFabricPlus$oldCursorStack;
|
||||
else
|
||||
slotItemBeforeModification = viafabricplus_oldItems.get(clickSlot.getSlot());
|
||||
slotItemBeforeModification = viaFabricPlus$oldItems.get(clickSlot.getSlot());
|
||||
|
||||
final var clickSlotPacket = PacketWrapper.create(ServerboundPackets1_16_2.CLICK_WINDOW, networkHandler.getConnection().channel.attr(ProtocolHack.LOCAL_VIA_CONNECTION).get());
|
||||
final var clickSlotPacket = PacketWrapper.create(ServerboundPackets1_16_2.CLICK_WINDOW, ((IClientConnection)networkHandler.getConnection()).viaFabricPlus$getUserConnection());
|
||||
|
||||
clickSlotPacket.write(Type.UNSIGNED_BYTE, (short) clickSlot.getSyncId());
|
||||
clickSlotPacket.write(Type.SHORT, (short) clickSlot.getSlot());
|
||||
clickSlotPacket.write(Type.BYTE, (byte) clickSlot.getButton());
|
||||
clickSlotPacket.write(Type.SHORT, ((IScreenHandler) client.player.currentScreenHandler).viafabricplus_getAndIncrementLastActionId());
|
||||
clickSlotPacket.write(Type.SHORT, ((IScreenHandler) client.player.currentScreenHandler).viaFabricPlus$getAndIncrementLastActionId());
|
||||
clickSlotPacket.write(Type.VAR_INT, clickSlot.getActionType().ordinal());
|
||||
clickSlotPacket.write(Type.ITEM1_13_2, ItemTranslator.MC_TO_VIA_LATEST_TO_TARGET(slotItemBeforeModification, VersionEnum.r1_16));
|
||||
|
||||
@ -144,8 +135,8 @@ public abstract class MixinClientPlayerInteractionManager {
|
||||
ViaFabricPlus.LOGGER.error("Failed to send Click Slot Packet", e);
|
||||
}
|
||||
|
||||
viafabricplus_oldCursorStack = null;
|
||||
viafabricplus_oldItems = null;
|
||||
viaFabricPlus$oldCursorStack = null;
|
||||
viaFabricPlus$oldItems = null;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -169,15 +160,15 @@ public abstract class MixinClientPlayerInteractionManager {
|
||||
}
|
||||
|
||||
@Unique
|
||||
private ActionResult viafabricplus_actionResult;
|
||||
private ActionResult viaFabricPlus$actionResult;
|
||||
|
||||
@Inject(method = "interactBlock", at = @At("HEAD"), cancellable = true)
|
||||
public void cacheActionResult(ClientPlayerEntity player, Hand hand, BlockHitResult hitResult, CallbackInfoReturnable<ActionResult> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
this.viafabricplus_actionResult = this.interactBlockInternal(player, hand, hitResult);
|
||||
this.viaFabricPlus$actionResult = this.interactBlockInternal(player, hand, hitResult);
|
||||
|
||||
if (this.viafabricplus_actionResult == ActionResult.FAIL) {
|
||||
cir.setReturnValue(this.viafabricplus_actionResult);
|
||||
if (this.viaFabricPlus$actionResult == ActionResult.FAIL) {
|
||||
cir.setReturnValue(this.viaFabricPlus$actionResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -185,7 +176,7 @@ public abstract class MixinClientPlayerInteractionManager {
|
||||
@Redirect(method = "method_41933", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;interactBlockInternal(Lnet/minecraft/client/network/ClientPlayerEntity;Lnet/minecraft/util/Hand;Lnet/minecraft/util/hit/BlockHitResult;)Lnet/minecraft/util/ActionResult;"))
|
||||
public ActionResult provideCachedResult(ClientPlayerInteractionManager instance, ClientPlayerEntity player, Hand hand, BlockHitResult hitResult) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
return this.viafabricplus_actionResult;
|
||||
return this.viaFabricPlus$actionResult;
|
||||
}
|
||||
return interactBlockInternal(player, hand, hitResult);
|
||||
}
|
||||
|
@ -17,13 +17,11 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import de.florianmichael.viafabricplus.settings.impl.VisualSettings;
|
||||
import de.florianmichael.viafabricplus.definition.model.BuiltinEmptyGlyph1_12_2;
|
||||
import de.florianmichael.viafabricplus.injection.access.IFontStorage;
|
||||
import de.florianmichael.viafabricplus.mappings.CharacterMappings;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.settings.impl.VisualSettings;
|
||||
import net.minecraft.client.font.*;
|
||||
import net.minecraft.client.font.Font;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
@ -41,29 +39,31 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mixin(FontStorage.class)
|
||||
public abstract class MixinFontStorage implements IFontStorage {
|
||||
public abstract class MixinFontStorage {
|
||||
|
||||
@Shadow protected abstract GlyphRenderer getGlyphRenderer(RenderableGlyph c);
|
||||
@Shadow
|
||||
protected abstract GlyphRenderer getGlyphRenderer(RenderableGlyph c);
|
||||
|
||||
@Shadow @Final private GlyphContainer<GlyphRenderer> glyphRendererCache;
|
||||
@Shadow @Final private GlyphContainer<FontStorage.GlyphPair> glyphCache;
|
||||
@Shadow private GlyphRenderer blankGlyphRenderer;
|
||||
@Shadow
|
||||
private GlyphRenderer blankGlyphRenderer;
|
||||
|
||||
@Shadow @Final private Identifier id;
|
||||
@Shadow
|
||||
@Final
|
||||
private Identifier id;
|
||||
|
||||
@Unique
|
||||
private Map<String, List<Integer>> viafabricplus_forbiddenCharacters;
|
||||
private Map<String, List<Integer>> viaFabricPlus$forbiddenCharacters;
|
||||
|
||||
@Unique
|
||||
private boolean viafabricplus_obfuscation;
|
||||
private boolean viaFabricPlus$obfuscation;
|
||||
|
||||
@Inject(method = "setFonts", at = @At("HEAD"))
|
||||
public void trackForbiddenCharacters(List<Font> fonts, CallbackInfo ci) {
|
||||
viafabricplus_forbiddenCharacters = CharacterMappings.getForbiddenCharactersForID(this.id);
|
||||
viaFabricPlus$forbiddenCharacters = CharacterMappings.getForbiddenCharactersForID(this.id);
|
||||
}
|
||||
|
||||
@Unique
|
||||
private boolean viafabricplus_isForbiddenCharacter(final Font font, final int codePoint) {
|
||||
private boolean viaFabricPlus$isForbiddenCharacter(final Font font, final int codePoint) {
|
||||
String fontName = null;
|
||||
if (font instanceof BitmapFont) {
|
||||
fontName = "BitmapFont";
|
||||
@ -75,7 +75,7 @@ public abstract class MixinFontStorage implements IFontStorage {
|
||||
fontName = "UnihexFont";
|
||||
}
|
||||
if (fontName == null) return false;
|
||||
final var forbiddenCodepoints = viafabricplus_forbiddenCharacters.get(fontName);
|
||||
final var forbiddenCodepoints = viaFabricPlus$forbiddenCharacters.get(fontName);
|
||||
if (forbiddenCodepoints == null) return false;
|
||||
return forbiddenCodepoints.contains(codePoint);
|
||||
}
|
||||
@ -85,7 +85,7 @@ public abstract class MixinFontStorage implements IFontStorage {
|
||||
if (!this.id.getNamespace().equals("minecraft")) return;
|
||||
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_4)) {
|
||||
if (viafabricplus_isForbiddenCharacter(font, codePoint)) cir.setReturnValue(FontStorage.GlyphPair.MISSING);
|
||||
if (viaFabricPlus$isForbiddenCharacter(font, codePoint)) cir.setReturnValue(FontStorage.GlyphPair.MISSING);
|
||||
|
||||
if (VisualSettings.INSTANCE.changeFontRendererBehaviour.isEnabled() && cir.getReturnValue() == FontStorage.GlyphPair.MISSING) {
|
||||
cir.setReturnValue(new FontStorage.GlyphPair(BuiltinEmptyGlyph1_12_2.VERY_MISSING, BuiltinEmptyGlyph1_12_2.VERY_MISSING));
|
||||
@ -97,8 +97,8 @@ public abstract class MixinFontStorage implements IFontStorage {
|
||||
public void injectFindGlyphRenderer(int codePoint, CallbackInfoReturnable<GlyphRenderer> cir, Iterator var2, Font font) {
|
||||
if (!this.id.getNamespace().equals("minecraft")) return;
|
||||
|
||||
if (!viafabricplus_obfuscation && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_4)) {
|
||||
if (viafabricplus_isForbiddenCharacter(font, codePoint)) cir.setReturnValue(this.blankGlyphRenderer);
|
||||
if (!viaFabricPlus$obfuscation && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_4)) {
|
||||
if (viaFabricPlus$isForbiddenCharacter(font, codePoint)) cir.setReturnValue(this.blankGlyphRenderer);
|
||||
|
||||
if (VisualSettings.INSTANCE.changeFontRendererBehaviour.isEnabled() && cir.getReturnValue() == this.blankGlyphRenderer) {
|
||||
cir.setReturnValue(BuiltinEmptyGlyph1_12_2.VERY_MISSING.bake(this::getGlyphRenderer));
|
||||
@ -113,17 +113,12 @@ public abstract class MixinFontStorage implements IFontStorage {
|
||||
|
||||
@Inject(method = "getObfuscatedGlyphRenderer", at = @At("HEAD"))
|
||||
public void trackObfuscationState(Glyph glyph, CallbackInfoReturnable<GlyphRenderer> cir) {
|
||||
viafabricplus_obfuscation = true;
|
||||
viaFabricPlus$obfuscation = true;
|
||||
}
|
||||
|
||||
@Inject(method = "getGlyphRenderer(I)Lnet/minecraft/client/font/GlyphRenderer;", at = @At("RETURN"))
|
||||
public void revertObfuscationState(int codePoint, CallbackInfoReturnable<GlyphRenderer> cir) {
|
||||
viafabricplus_obfuscation = false;
|
||||
viaFabricPlus$obfuscation = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viafabricplus_clearCaches() {
|
||||
this.glyphRendererCache.clear();
|
||||
this.glyphCache.clear();
|
||||
}
|
||||
}
|
||||
|
@ -25,10 +25,8 @@ import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.injection.access.IMinecraftClient;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
@ -36,6 +34,7 @@ import net.minecraft.client.render.item.HeldItemRenderer;
|
||||
import net.minecraft.item.SwordItem;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -49,7 +48,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||
|
||||
@Mixin(MinecraftClient.class)
|
||||
public abstract class MixinMinecraftClient implements IMinecraftClient {
|
||||
public abstract class MixinMinecraftClient {
|
||||
|
||||
@Shadow
|
||||
@Nullable
|
||||
@ -103,10 +102,10 @@ public abstract class MixinMinecraftClient implements IMinecraftClient {
|
||||
}
|
||||
|
||||
@Unique
|
||||
private final ConcurrentLinkedDeque<Runnable> viafabricplus_mouseInteractions = new ConcurrentLinkedDeque<>();
|
||||
private final ConcurrentLinkedDeque<Runnable> viaFabricPlus$mouseInteractions = new ConcurrentLinkedDeque<>();
|
||||
|
||||
@Unique
|
||||
private final ConcurrentLinkedDeque<Runnable> viafabricplus_keyboardInteractions = new ConcurrentLinkedDeque<>();
|
||||
private final ConcurrentLinkedDeque<Runnable> viaFabricPlus$keyboardInteractions = new ConcurrentLinkedDeque<>();
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Inject(method = "tick", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;",
|
||||
@ -116,11 +115,11 @@ public abstract class MixinMinecraftClient implements IMinecraftClient {
|
||||
return;
|
||||
}
|
||||
|
||||
while (!viafabricplus_mouseInteractions.isEmpty()) {
|
||||
viafabricplus_mouseInteractions.poll().run();
|
||||
while (!viaFabricPlus$mouseInteractions.isEmpty()) {
|
||||
viaFabricPlus$mouseInteractions.poll().run();
|
||||
}
|
||||
while (!viafabricplus_keyboardInteractions.isEmpty()) {
|
||||
viafabricplus_keyboardInteractions.poll().run();
|
||||
while (!viaFabricPlus$keyboardInteractions.isEmpty()) {
|
||||
viaFabricPlus$keyboardInteractions.poll().run();
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,13 +141,4 @@ public abstract class MixinMinecraftClient implements IMinecraftClient {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConcurrentLinkedDeque<Runnable> viafabricplus_getMouseInteractions() {
|
||||
return this.viafabricplus_mouseInteractions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConcurrentLinkedDeque<Runnable> viafabricplus_getKeyboardInteractions() {
|
||||
return this.viafabricplus_keyboardInteractions;
|
||||
}
|
||||
}
|
||||
|
@ -28,15 +28,15 @@ import java.nio.ByteBuffer;
|
||||
public class MixinPlayerPublicKey_PublicKeyData implements IPublicKeyData {
|
||||
|
||||
@Unique
|
||||
private ByteBuffer viafabricplus_v1_key;
|
||||
private ByteBuffer viaFabricPlus$v1_key;
|
||||
|
||||
@Override
|
||||
public ByteBuffer viafabricplus_getV1Key() {
|
||||
return viafabricplus_v1_key;
|
||||
public ByteBuffer viaFabricPlus$getV1Key() {
|
||||
return viaFabricPlus$v1_key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viafabricplus_setV1Key(ByteBuffer byteBuffer) {
|
||||
this.viafabricplus_v1_key = byteBuffer;
|
||||
public void viaFabricPlus$setV1Key(ByteBuffer byteBuffer) {
|
||||
this.viaFabricPlus$v1_key = byteBuffer;
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,6 @@ public class MixinProfileKeysImpl {
|
||||
|
||||
@Inject(method = "decodeKeyPairResponse", at = @At("RETURN"))
|
||||
private static void trackLegacyKey(KeyPairResponse keyPairResponse, CallbackInfoReturnable<PlayerPublicKey.PublicKeyData> cir) {
|
||||
((IPublicKeyData) (Object) cir.getReturnValue()).viafabricplus_setV1Key(((IKeyPairResponse) (Object) keyPairResponse).viafabricplus_getLegacyPublicKeySignature());
|
||||
((IPublicKeyData) (Object) cir.getReturnValue()).viaFabricPlus$setV1Key(((IKeyPairResponse) (Object) keyPairResponse).viafabricplus$getLegacyPublicKeySignature());
|
||||
}
|
||||
}
|
||||
|
@ -20,12 +20,11 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
import com.google.common.hash.HashCode;
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.google.common.io.Files;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.mappings.PackFormatsMappings;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.GameVersion;
|
||||
import net.minecraft.client.resource.ServerResourcePackProvider;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
@ -45,7 +44,7 @@ import java.util.Map;
|
||||
public class MixinServerResourcePackProvider {
|
||||
|
||||
@Unique
|
||||
private File viafabricplus_trackedFile;
|
||||
private File viaFabricPlus$trackedFile;
|
||||
|
||||
@Redirect(method = "getDownloadHeaders", at = @At(value = "INVOKE", target = "Lnet/minecraft/SharedConstants;getGameVersion()Lnet/minecraft/GameVersion;"))
|
||||
private static GameVersion editHeaders() {
|
||||
@ -68,7 +67,7 @@ public class MixinServerResourcePackProvider {
|
||||
|
||||
@Inject(method = "verifyFile", at = @At("HEAD"))
|
||||
public void keepFile(String expectedSha1, File file, CallbackInfoReturnable<Boolean> cir) {
|
||||
viafabricplus_trackedFile = file;
|
||||
viaFabricPlus$trackedFile = file;
|
||||
}
|
||||
|
||||
@Redirect(method = "verifyFile", at = @At(value = "INVOKE", target = "Lcom/google/common/hash/HashCode;toString()Ljava/lang/String;", remap = false))
|
||||
@ -76,9 +75,9 @@ public class MixinServerResourcePackProvider {
|
||||
try {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
//noinspection deprecation
|
||||
return Hashing.sha1().hashBytes(Files.toByteArray(viafabricplus_trackedFile)).toString();
|
||||
return Hashing.sha1().hashBytes(Files.toByteArray(viaFabricPlus$trackedFile)).toString();
|
||||
} else if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_18tor1_18_1)) {
|
||||
return DigestUtils.sha1Hex(new FileInputStream(viafabricplus_trackedFile));
|
||||
return DigestUtils.sha1Hex(new FileInputStream(viaFabricPlus$trackedFile));
|
||||
}
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
|
@ -17,16 +17,14 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.InfestedBlock;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -36,33 +34,46 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
public abstract class MixinAbstractBlock_AbstractBlockState {
|
||||
|
||||
@Shadow
|
||||
protected abstract BlockState asBlockState();
|
||||
public abstract Block getBlock();
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private boolean toolRequired;
|
||||
|
||||
/**
|
||||
* @author RK_01
|
||||
* @reason Change block break speed for protocol hack
|
||||
*/
|
||||
@Overwrite
|
||||
public boolean isToolRequired() {
|
||||
final Block block = this.getBlock();
|
||||
if (block instanceof ShulkerBoxBlock && ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_14)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return this.toolRequired;
|
||||
}
|
||||
|
||||
@Inject(method = "getHardness", at = @At("RETURN"), cancellable = true)
|
||||
public void changeHardness(BlockView world, BlockPos pos, CallbackInfoReturnable<Float> cir) {
|
||||
final BlockState state = this.asBlockState();
|
||||
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
if (state.getBlock() instanceof InfestedBlock) {
|
||||
final Block block = this.getBlock();
|
||||
if (block.equals(Blocks.OBSIDIAN)) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
||||
cir.setReturnValue(10.0F);
|
||||
}
|
||||
} else if (block instanceof InfestedBlock) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
cir.setReturnValue(0.75F);
|
||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
|
||||
cir.setReturnValue(0F);
|
||||
}
|
||||
}
|
||||
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
||||
if (state.getBlock() == Blocks.END_STONE_BRICKS || state.getBlock() == Blocks.END_STONE_BRICK_SLAB || state.getBlock() == Blocks.END_STONE_BRICK_STAIRS || state.getBlock() == Blocks.END_STONE_BRICK_WALL) {
|
||||
cir.setReturnValue(0.8F);
|
||||
}
|
||||
}
|
||||
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
|
||||
if (state.getBlock() == Blocks.PISTON || state.getBlock() == Blocks.STICKY_PISTON || state.getBlock() == Blocks.PISTON_HEAD) {
|
||||
} else if (block.equals(Blocks.PISTON) || block.equals(Blocks.STICKY_PISTON) || block.equals(Blocks.PISTON_HEAD)) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
|
||||
cir.setReturnValue(0.5F);
|
||||
}
|
||||
}
|
||||
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
|
||||
if (state.getBlock() instanceof InfestedBlock) {
|
||||
cir.setReturnValue(0F);
|
||||
} else if (block.equals(Blocks.END_STONE_BRICKS) || block.equals(Blocks.END_STONE_BRICK_SLAB) || block.equals(Blocks.END_STONE_BRICK_STAIRS) || block.equals(Blocks.END_STONE_BRICK_WALL)) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
||||
cir.setReturnValue(0.8F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,9 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.AbstractSignBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.SignBlockEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.DyeItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.ActionResult;
|
||||
@ -17,29 +17,23 @@ import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(AbstractSignBlock.class)
|
||||
public abstract class MixinAbstractSignBlock {
|
||||
|
||||
@Redirect(method = "onUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/entity/SignBlockEntity;isWaxed()Z", ordinal = 1))
|
||||
public boolean removeCondition(SignBlockEntity instance) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_4)) {
|
||||
return false;
|
||||
}
|
||||
return instance.isWaxed();
|
||||
}
|
||||
|
||||
@Inject(method = "onUse", at = @At("HEAD"), cancellable = true)
|
||||
public void changeSignApplicators(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ActionResult> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_19_4)) return;
|
||||
private void alwaysReturnSuccess(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ActionResult> cir) {
|
||||
if (!world.isClient) return;
|
||||
|
||||
// Remove HoneycombItem interactions
|
||||
if (world.getBlockEntity(pos) instanceof SignBlockEntity signBlockEntity && world.isClient) {
|
||||
final ItemStack item = player.getStackInHand(hand);
|
||||
|
||||
cir.setReturnValue(!((item.isOf(Items.GLOW_INK_SAC) || item.isOf(Items.INK_SAC) || item.getItem() instanceof DyeItem) && player.canModifyBlocks()) && !signBlockEntity.isWaxed() ? ActionResult.CONSUME : ActionResult.SUCCESS);
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
||||
cir.setReturnValue(ActionResult.SUCCESS);
|
||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_4)) {
|
||||
final ItemStack itemStack = player.getStackInHand(hand);
|
||||
final Item item = itemStack.getItem();
|
||||
final boolean isSuccess = (item instanceof DyeItem || itemStack.isOf(Items.GLOW_INK_SAC) || itemStack.isOf(Items.INK_SAC)) && player.canModifyBlocks();
|
||||
cir.setReturnValue(isSuccess ? ActionResult.SUCCESS : ActionResult.CONSUME);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,15 +17,14 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import net.minecraft.block.*;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.state.property.DirectionProperty;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -38,10 +37,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
public class MixinAnvilBlock extends FallingBlock {
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape viafabricplus_x_axis_shape_v1_12_2 = Block.createCuboidShape(0, 0, 2, 16, 16, 14);
|
||||
private final static VoxelShape viaFabricPlus$x_axis_shape_r1_12_2 = Block.createCuboidShape(0, 0, 2, 16, 16, 14);
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape viafabricplus_z_axis_shape_v1_12_2 = Block.createCuboidShape(2, 0, 0, 14, 16, 16);
|
||||
private final static VoxelShape viaFabricPlus$z_axis_shape_r1_12_2 = Block.createCuboidShape(2, 0, 0, 14, 16, 16);
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
@ -52,22 +51,22 @@ public class MixinAnvilBlock extends FallingBlock {
|
||||
}
|
||||
|
||||
@Unique
|
||||
private boolean viafabricplus_requireOriginalShape;
|
||||
private boolean viaFabricPlus$requireOriginalShape;
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (viafabricplus_requireOriginalShape) {
|
||||
viafabricplus_requireOriginalShape = false;
|
||||
if (viaFabricPlus$requireOriginalShape) {
|
||||
viaFabricPlus$requireOriginalShape = false;
|
||||
return;
|
||||
}
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
cir.setReturnValue(state.get(FACING).getAxis() == Direction.Axis.X ? viafabricplus_x_axis_shape_v1_12_2 : viafabricplus_z_axis_shape_v1_12_2);
|
||||
cir.setReturnValue(state.get(FACING).getAxis() == Direction.Axis.X ? viaFabricPlus$x_axis_shape_r1_12_2 : viaFabricPlus$z_axis_shape_r1_12_2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCullingShape(BlockState state, BlockView world, BlockPos pos) {
|
||||
viafabricplus_requireOriginalShape = true;
|
||||
viaFabricPlus$requireOriginalShape = true;
|
||||
return super.getCullingShape(state, world, pos);
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,6 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.BedBlock;
|
||||
import net.minecraft.block.Block;
|
||||
@ -28,6 +26,7 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -39,7 +38,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
public class MixinBedBlock {
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape viafabricplus_bed_shape_v1_13_2 = Block.createCuboidShape(0, 0, 0, 16, 9, 16);
|
||||
private final static VoxelShape viaFabricPlus$shape_r1_13_2 = Block.createCuboidShape(0, 0, 0, 16, 9, 16);
|
||||
|
||||
@Inject(method = "bounceEntity", at = @At("HEAD"), cancellable = true)
|
||||
public void injectBounceEntity(Entity entity, CallbackInfo ci) {
|
||||
@ -51,7 +50,7 @@ public class MixinBedBlock {
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
|
||||
cir.setReturnValue(viafabricplus_bed_shape_v1_13_2);
|
||||
cir.setReturnValue(viaFabricPlus$shape_r1_13_2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,56 +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.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.InfestedBlock;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Block.class)
|
||||
public class MixinBlock {
|
||||
|
||||
@Inject(method = "getBlastResistance", at = @At("RETURN"), cancellable = true)
|
||||
private void modifyBlastResistance(CallbackInfoReturnable<Float> ci) {
|
||||
final Block block = ((Block) (Object) this);
|
||||
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
||||
if (block == Blocks.END_STONE_BRICKS || block == Blocks.END_STONE_BRICK_SLAB || block == Blocks.END_STONE_BRICK_STAIRS || block == Blocks.END_STONE_BRICK_WALL) {
|
||||
ci.setReturnValue(0.8F);
|
||||
}
|
||||
}
|
||||
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
|
||||
if (block == Blocks.PISTON || block == Blocks.STICKY_PISTON || block == Blocks.PISTON_HEAD) {
|
||||
ci.setReturnValue(0.5F);
|
||||
}
|
||||
}
|
||||
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
|
||||
if (block instanceof InfestedBlock) {
|
||||
ci.setReturnValue(0.75F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,40 +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.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(BlockView.class)
|
||||
public interface MixinBlockView {
|
||||
|
||||
@Redirect(method = "raycastBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;getRaycastShape(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/util/shape/VoxelShape;"))
|
||||
default VoxelShape hookedGetRaycastShape(BlockState instance, BlockView blockView, BlockPos blockPos) {
|
||||
VoxelShape shape = instance.getRaycastShape(blockView, blockPos);
|
||||
// It appears, that certain game states react unstable to the shape changes we are producing.
|
||||
if (shape == null)
|
||||
shape = VoxelShapes.empty();
|
||||
return shape;
|
||||
}
|
||||
}
|
@ -17,8 +17,6 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@ -28,6 +26,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -38,7 +37,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
public class MixinBrewingStandBlock {
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape viafabricplus_base_shape_v1_12_2 = VoxelShapes.union(
|
||||
private final static VoxelShape viaFabricPlus$shape_r1_12_2 = VoxelShapes.union(
|
||||
Block.createCuboidShape(0, 0, 0, 16, 2, 16) /* Base */,
|
||||
Block.createCuboidShape(7, 0, 7, 9, 14, 9) /* Stick */
|
||||
);
|
||||
@ -46,7 +45,7 @@ public class MixinBrewingStandBlock {
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
cir.setReturnValue(viafabricplus_base_shape_v1_12_2);
|
||||
cir.setReturnValue(viaFabricPlus$shape_r1_12_2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.CarpetBlock;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@Mixin(CarpetBlock.class)
|
||||
public abstract class MixinCarpetBlock extends Block {
|
||||
|
||||
@Unique
|
||||
private static final VoxelShape viaFabricPlus$shape_r1_7_10 = Block.createCuboidShape(0.0D, -0.00001D/*0.0D*/, 0.0D, 16.0D, 0.0D, 16.0D);
|
||||
|
||||
public MixinCarpetBlock(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10)) {
|
||||
return viaFabricPlus$shape_r1_7_10;
|
||||
}
|
||||
|
||||
return super.getCollisionShape(state, world, pos, context);
|
||||
}
|
||||
|
||||
}
|
@ -17,8 +17,6 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.cauldron.CauldronBehavior;
|
||||
@ -28,6 +26,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@ -37,7 +36,7 @@ import java.util.Map;
|
||||
public abstract class MixinCauldronBlock extends AbstractCauldronBlock {
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape viafabricplus_cauldron_shape_v1_12_2 = VoxelShapes.combineAndSimplify(
|
||||
private final static VoxelShape viaFabricPlus$shape_r1_12_2 = VoxelShapes.combineAndSimplify(
|
||||
VoxelShapes.fullCube(),
|
||||
Block.createCuboidShape(2.0D, 5.0D, 2.0D, 14.0D, 16.0D, 14.0D),
|
||||
BooleanBiFunction.ONLY_FIRST
|
||||
@ -50,7 +49,7 @@ public abstract class MixinCauldronBlock extends AbstractCauldronBlock {
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
return viafabricplus_cauldron_shape_v1_12_2;
|
||||
return viaFabricPlus$shape_r1_12_2;
|
||||
}
|
||||
return super.getOutlineShape(state, world, pos, context);
|
||||
}
|
||||
|
@ -18,31 +18,78 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.AbstractChestBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ChestBlock;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.block.entity.ChestBlockEntity;
|
||||
import net.minecraft.block.enums.ChestType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Mixin(ChestBlock.class)
|
||||
public abstract class MixinChestBlock extends AbstractChestBlock<ChestBlockEntity> {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
protected static VoxelShape SINGLE_SHAPE;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
protected static VoxelShape DOUBLE_NORTH_SHAPE;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
protected static VoxelShape DOUBLE_SOUTH_SHAPE;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
protected static VoxelShape DOUBLE_WEST_SHAPE;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
protected static VoxelShape DOUBLE_EAST_SHAPE;
|
||||
|
||||
protected MixinChestBlock(Settings settings, Supplier<BlockEntityType<? extends ChestBlockEntity>> blockEntityTypeSupplier) {
|
||||
super(settings, blockEntityTypeSupplier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_4_2)) {
|
||||
return VoxelShapes.fullCube();
|
||||
cir.setReturnValue(VoxelShapes.fullCube());
|
||||
}
|
||||
return super.getCollisionShape(state, world, pos, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCullingShape(BlockState state, BlockView view, BlockPos pos) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_4_2)) {
|
||||
if (state.get(ChestBlock.CHEST_TYPE) == ChestType.SINGLE) {
|
||||
return SINGLE_SHAPE;
|
||||
} else {
|
||||
return switch (ChestBlock.getFacing(state)) {
|
||||
case NORTH -> DOUBLE_NORTH_SHAPE;
|
||||
case SOUTH -> DOUBLE_SOUTH_SHAPE;
|
||||
case WEST -> DOUBLE_WEST_SHAPE;
|
||||
case EAST -> DOUBLE_EAST_SHAPE;
|
||||
default -> throw new IllegalStateException("Invalid facing");
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return super.getCullingShape(state, view, pos);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,12 +32,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
public class MixinCropBlock {
|
||||
|
||||
@Unique
|
||||
private final VoxelShape viafabricplus_shape_v1_8_x = Block.createCuboidShape(0.0, 0.0, 0.0, 16.0, 4.0, 16.0);
|
||||
private final VoxelShape viaFabricPlus$shape_r1_8_x = Block.createCuboidShape(0.0, 0.0, 0.0, 16.0, 4.0, 16.0);
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetOutlineShape(CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
cir.setReturnValue(viafabricplus_shape_v1_8_x);
|
||||
cir.setReturnValue(viaFabricPlus$shape_r1_8_x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,14 +17,12 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -35,10 +33,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
public abstract class MixinEndPortalBlock extends BlockWithEntity {
|
||||
|
||||
@Unique
|
||||
private final VoxelShape viafabricplus_shape_v1_8_x = Block.createCuboidShape(0.0, 0.0, 0.0, 16.0, 1.0, 16.0);
|
||||
private final VoxelShape viaFabricPlus$shape_r1_8_x = Block.createCuboidShape(0.0, 0.0, 0.0, 16.0, 1.0, 16.0);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape viafabricplus_shape_v1_16_5 = Block.createCuboidShape(0.0, 0.0, 0.0, 16.0, 12.0, 16.0);
|
||||
private final VoxelShape viaFabricPlus$shape_r1_16_5 = Block.createCuboidShape(0.0, 0.0, 0.0, 16.0, 12.0, 16.0);
|
||||
|
||||
protected MixinEndPortalBlock(Settings settings) {
|
||||
super(settings);
|
||||
@ -46,13 +44,10 @@ public abstract class MixinEndPortalBlock extends BlockWithEntity {
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (MinecraftClient.getInstance() == null) return;
|
||||
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
cir.setReturnValue(viafabricplus_shape_v1_8_x);
|
||||
}
|
||||
else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
|
||||
cir.setReturnValue(viafabricplus_shape_v1_16_5);
|
||||
cir.setReturnValue(viaFabricPlus$shape_r1_8_x);
|
||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
|
||||
cir.setReturnValue(viaFabricPlus$shape_r1_16_5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,37 +17,60 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.EndPortalFrameBlock;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(EndPortalFrameBlock.class)
|
||||
public class MixinEndPortalFrameBlock {
|
||||
public class MixinEndPortalFrameBlock extends Block {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
protected static VoxelShape FRAME_SHAPE;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
protected static VoxelShape FRAME_WITH_EYE_SHAPE;
|
||||
@Unique
|
||||
private final VoxelShape viafabricplus_eye_shape_v1_12_2 = Block.createCuboidShape(5.0, 13.0, 5.0, 11.0, 16.0, 11.0);
|
||||
public static BooleanProperty EYE;
|
||||
|
||||
@Redirect(method = "getOutlineShape", at = @At(value = "FIELD", target = "Lnet/minecraft/block/EndPortalFrameBlock;FRAME_WITH_EYE_SHAPE:Lnet/minecraft/util/shape/VoxelShape;"))
|
||||
public VoxelShape redirectGetOutlineShape() {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
return VoxelShapes.union(FRAME_SHAPE, viafabricplus_eye_shape_v1_12_2);
|
||||
}
|
||||
return FRAME_WITH_EYE_SHAPE;
|
||||
@Unique
|
||||
private static final VoxelShape viaFabricPlus$eye_shape_r1_12_2 = Block.createCuboidShape(5.0, 13.0, 5.0, 11.0, 16.0, 11.0);
|
||||
|
||||
@Unique
|
||||
private static final VoxelShape viaFabricPlus$frame_with_eye_shape_r1_12_2 = VoxelShapes.union(FRAME_SHAPE, viaFabricPlus$eye_shape_r1_12_2);
|
||||
|
||||
public MixinEndPortalFrameBlock(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At(value = "HEAD"), cancellable = true)
|
||||
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
cir.setReturnValue(FRAME_SHAPE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
return state.get(EYE) ? viaFabricPlus$frame_with_eye_shape_r1_12_2 : FRAME_SHAPE;
|
||||
}
|
||||
|
||||
return super.getCollisionShape(state, world, pos, context);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,47 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.BlockWithEntity;
|
||||
import net.minecraft.block.EnderChestBlock;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(EnderChestBlock.class)
|
||||
public abstract class MixinEnderChestBlock extends BlockWithEntity {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
protected static VoxelShape SHAPE;
|
||||
|
||||
protected MixinEnderChestBlock(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_4_2)) {
|
||||
cir.setReturnValue(VoxelShapes.fullCube());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCullingShape(BlockState state, BlockView view, BlockPos pos) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_4_2)) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
return super.getCullingShape(state, view, pos);
|
||||
}
|
||||
|
||||
}
|
@ -17,8 +17,6 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@ -28,10 +26,10 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
@ -39,8 +37,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
@Mixin(FarmlandBlock.class)
|
||||
public class MixinFarmlandBlock extends Block {
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape viafabricplus_shape_v1_9_4 = VoxelShapes.fullCube();
|
||||
@Shadow
|
||||
@Final
|
||||
protected static VoxelShape SHAPE;
|
||||
@ -52,12 +48,16 @@ public class MixinFarmlandBlock extends Block {
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_9_3tor1_9_4)) {
|
||||
cir.setReturnValue(viafabricplus_shape_v1_9_4);
|
||||
cir.setReturnValue(VoxelShapes.fullCube());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCullingShape(BlockState state, BlockView world, BlockPos pos) {
|
||||
return SHAPE; // Always use the real outline shape for culling
|
||||
public VoxelShape getCullingShape(BlockState state, BlockView view, BlockPos pos) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_9_3tor1_9_4)) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
return super.getCullingShape(state, view, pos);
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,5 @@
|
||||
/*
|
||||
* 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.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.util.ActionResult;
|
||||
@ -27,43 +8,102 @@ import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(FenceBlock.class)
|
||||
public class MixinFenceBlock extends HorizontalConnectingBlock {
|
||||
public abstract class MixinFenceBlock extends HorizontalConnectingBlock {
|
||||
|
||||
@Unique
|
||||
private VoxelShape[] collisionShapes1_4_7;
|
||||
|
||||
@Unique
|
||||
private VoxelShape[] boundingShapes1_4_7;
|
||||
|
||||
@Unique
|
||||
private static final VoxelShape _b1_8_1_OUTLINE_SHAPE = VoxelShapes.fullCube();
|
||||
|
||||
@Unique
|
||||
private static final VoxelShape _b1_8_1_COLLISION_SHAPE = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 24.0D, 16.0D);
|
||||
|
||||
protected MixinFenceBlock(float radius1, float radius2, float boundingHeight1, float boundingHeight2, float collisionHeight, Settings settings) {
|
||||
super(radius1, radius2, boundingHeight1, boundingHeight2, collisionHeight, settings);
|
||||
}
|
||||
|
||||
@Inject(method = "onUse", at = @At("HEAD"), cancellable = true)
|
||||
private void injectOnUse(CallbackInfoReturnable<ActionResult> ci) {
|
||||
private void modifyOnUse(CallbackInfoReturnable<ActionResult> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_10)) {
|
||||
ci.setReturnValue(ActionResult.SUCCESS);
|
||||
cir.setReturnValue(ActionResult.SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape viafabricplus_fence_shape_b1_8_1 = Block.createCuboidShape(0, 0, 0, 16, 32, 16);
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
||||
return viafabricplus_fence_shape_b1_8_1;
|
||||
}
|
||||
return super.getCollisionShape(state, world, pos, context);
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
private void initShapes(Settings settings, CallbackInfo ci) {
|
||||
this.collisionShapes1_4_7 = this.createShapes1_4_7(2.0F, 2.0F, 24.0F, 0.0F, 24.0F);
|
||||
this.boundingShapes1_4_7 = this.createShapes1_4_7(2.0F, 2.0F, 16.0F, 0.0F, 16.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
||||
return VoxelShapes.fullCube();
|
||||
return _b1_8_1_OUTLINE_SHAPE;
|
||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_4_6tor1_4_7)) {
|
||||
return this.boundingShapes1_4_7[this.getShapeIndex(state)];
|
||||
}
|
||||
|
||||
return super.getOutlineShape(state, world, pos, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
||||
return _b1_8_1_COLLISION_SHAPE;
|
||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_4_6tor1_4_7)) {
|
||||
return this.collisionShapes1_4_7[this.getShapeIndex(state)];
|
||||
}
|
||||
|
||||
return super.getCollisionShape(state, world, pos, context);
|
||||
}
|
||||
|
||||
@Unique
|
||||
private VoxelShape[] createShapes1_4_7(float radius1, float radius2, float height1, float offset2, float height2) {
|
||||
final float f = 8.0F - radius1;
|
||||
final float g = 8.0F + radius1;
|
||||
final float h = 8.0F - radius2;
|
||||
final float i = 8.0F + radius2;
|
||||
final VoxelShape baseShape = Block.createCuboidShape(f, 0.0, f, g, height1, g);
|
||||
final VoxelShape northShape = Block.createCuboidShape(h, offset2, 0.0, i, height2, i);
|
||||
final VoxelShape southShape = Block.createCuboidShape(h, offset2, h, i, height2, 16.0);
|
||||
final VoxelShape westShape = Block.createCuboidShape(0.0, offset2, h, i, height2, i);
|
||||
final VoxelShape eastShape = Block.createCuboidShape(h, offset2, h, 16.0, height2, i);
|
||||
final VoxelShape[] voxelShapes = new VoxelShape[]{
|
||||
VoxelShapes.empty(),
|
||||
Block.createCuboidShape(f, offset2, h, g, height1, 16.0D),
|
||||
Block.createCuboidShape(0.0D, offset2, f, i, height1, g),
|
||||
Block.createCuboidShape(f - 6, offset2, h, g, height1, 16.0D),
|
||||
Block.createCuboidShape(f, offset2, 0.0D, g, height1, i),
|
||||
VoxelShapes.union(southShape, northShape),
|
||||
Block.createCuboidShape(f - 6, offset2, 0.0D, g, height1, i),
|
||||
Block.createCuboidShape(f - 6, offset2, h - 5, g, height1, 16.0D),
|
||||
Block.createCuboidShape(h, offset2, f, 16.0D, height1, g),
|
||||
Block.createCuboidShape(h, offset2, f, 16.0D, height1, g + 6),
|
||||
VoxelShapes.union(westShape, eastShape),
|
||||
Block.createCuboidShape(h - 5, offset2, f, 16.0D, height1, g + 6),
|
||||
Block.createCuboidShape(f, offset2, 0.0D, g + 6, height1, i),
|
||||
Block.createCuboidShape(f, offset2, 0.0D, g + 6, height1, i + 5),
|
||||
Block.createCuboidShape(h - 5, offset2, f - 6, 16.0D, height1, g),
|
||||
Block.createCuboidShape(0, offset2, 0, 16.0D, height1, 16.0D)
|
||||
};
|
||||
|
||||
for (int j = 0; j < 16; ++j) {
|
||||
voxelShapes[j] = VoxelShapes.union(baseShape, voxelShapes[j]);
|
||||
}
|
||||
|
||||
return voxelShapes;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,50 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(FenceGateBlock.class)
|
||||
public abstract class MixinFenceGateBlock extends HorizontalFacingBlock {
|
||||
|
||||
@Unique
|
||||
private static final VoxelShape _b1_8_1_X_AXIS_SHAPE = VoxelShapes.fullCube();
|
||||
|
||||
@Unique
|
||||
private static final VoxelShape _b1_8_1_Z_AXIS_SHAPE = VoxelShapes.fullCube();
|
||||
|
||||
@Unique
|
||||
private static final VoxelShape _b1_8_1_X_AXIS_COLLISION_SHAPE = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 24.0D, 16.0D);
|
||||
|
||||
@Unique
|
||||
private static final VoxelShape _b1_8_1_Z_AXIS_COLLISION_SHAPE = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 24.0D, 16.0D);
|
||||
|
||||
protected MixinFenceGateBlock(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (!state.get(FenceGateBlock.IN_WALL) && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
||||
cir.setReturnValue(state.get(FACING).getAxis() == Direction.Axis.X ? _b1_8_1_X_AXIS_SHAPE : _b1_8_1_Z_AXIS_SHAPE);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getCollisionShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (!state.get(FenceGateBlock.OPEN) && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
||||
cir.setReturnValue(state.get(FACING).getAxis() == Direction.Axis.X ? _b1_8_1_X_AXIS_COLLISION_SHAPE : _b1_8_1_Z_AXIS_COLLISION_SHAPE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -36,12 +36,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
public class MixinFlowerbedBlock {
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape viafabricplus_shape_v1_20_1 = Block.createCuboidShape(0.0, 0.0, 0.0, 16.0, 3.0, 16.0);
|
||||
private final static VoxelShape viaFabricPlus$shape_r1_20_1 = Block.createCuboidShape(0.0, 0.0, 0.0, 16.0, 3.0, 16.0);
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
public void replaceShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) {
|
||||
cir.setReturnValue(viafabricplus_shape_v1_20_1);
|
||||
cir.setReturnValue(viaFabricPlus$shape_r1_20_1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,15 +17,14 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import net.minecraft.block.*;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.util.function.BooleanBiFunction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -36,13 +35,13 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
public abstract class MixinHopperBlock extends BlockWithEntity {
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape viafabricplus_inside_shape_v1_12_2 = Block.createCuboidShape(2, 10, 2, 14, 16, 14);
|
||||
private final static VoxelShape viaFabricPlus$inside_shape_r1_12_2 = Block.createCuboidShape(2, 10, 2, 14, 16, 14);
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape viafabricplus_hopper_shape_v1_12_2 = VoxelShapes.combineAndSimplify(VoxelShapes.fullCube(), viafabricplus_inside_shape_v1_12_2, BooleanBiFunction.ONLY_FIRST);
|
||||
private final static VoxelShape viaFabricPlus$hopper_shape_r1_12_2 = VoxelShapes.combineAndSimplify(VoxelShapes.fullCube(), viaFabricPlus$inside_shape_r1_12_2, BooleanBiFunction.ONLY_FIRST);
|
||||
|
||||
@Unique
|
||||
private boolean viafabricplus_requireOriginalShape;
|
||||
private boolean viaFabricPlus$requireOriginalShape;
|
||||
|
||||
public MixinHopperBlock(Settings settings) {
|
||||
super(settings);
|
||||
@ -50,25 +49,25 @@ public abstract class MixinHopperBlock extends BlockWithEntity {
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (viafabricplus_requireOriginalShape) {
|
||||
viafabricplus_requireOriginalShape = false;
|
||||
if (viaFabricPlus$requireOriginalShape) {
|
||||
viaFabricPlus$requireOriginalShape = false;
|
||||
return;
|
||||
}
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
cir.setReturnValue(viafabricplus_hopper_shape_v1_12_2);
|
||||
cir.setReturnValue(viaFabricPlus$hopper_shape_r1_12_2);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getRaycastShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetRaycastShape(BlockState state, BlockView world, BlockPos pos, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
cir.setReturnValue(viafabricplus_inside_shape_v1_12_2);
|
||||
cir.setReturnValue(viaFabricPlus$inside_shape_r1_12_2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCullingShape(BlockState state, BlockView world, BlockPos pos) {
|
||||
viafabricplus_requireOriginalShape = true;
|
||||
viaFabricPlus$requireOriginalShape = true;
|
||||
return super.getCullingShape(state, world, pos);
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,6 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@ -27,6 +25,7 @@ import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -37,25 +36,25 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
public class MixinLadderBlock {
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape viafabricplus_east_shape_v1_8_x = Block.createCuboidShape(0, 0, 0, 2, 16, 16);
|
||||
private final static VoxelShape viaFabricPlus$east_shape_r1_8_x = Block.createCuboidShape(0, 0, 0, 2, 16, 16);
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape viafabricplus_west_shape_v1_8_x = Block.createCuboidShape(14, 0, 0, 16, 16, 16);
|
||||
private final static VoxelShape viaFabricPlus$west_shape_r1_8_x = Block.createCuboidShape(14, 0, 0, 16, 16, 16);
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape viafabricplus_south_shape_v1_8_x = Block.createCuboidShape(0, 0, 0, 16, 16, 2);
|
||||
private final static VoxelShape viaFabricPlus$south_shape_r1_8_x = Block.createCuboidShape(0, 0, 0, 16, 16, 2);
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape viafabricplus_north_shape_v1_8_x = Block.createCuboidShape(0, 0, 14, 16, 16, 16);
|
||||
private final static VoxelShape viaFabricPlus$north_shape_r1_8_x = Block.createCuboidShape(0, 0, 14, 16, 16, 16);
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
private void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
switch (state.get(LadderBlock.FACING)) {
|
||||
case NORTH -> ci.setReturnValue(viafabricplus_north_shape_v1_8_x);
|
||||
case SOUTH -> ci.setReturnValue(viafabricplus_south_shape_v1_8_x);
|
||||
case WEST -> ci.setReturnValue(viafabricplus_west_shape_v1_8_x);
|
||||
default -> ci.setReturnValue(viafabricplus_east_shape_v1_8_x);
|
||||
case NORTH -> ci.setReturnValue(viaFabricPlus$north_shape_r1_8_x);
|
||||
case SOUTH -> ci.setReturnValue(viaFabricPlus$south_shape_r1_8_x);
|
||||
case WEST -> ci.setReturnValue(viaFabricPlus$west_shape_r1_8_x);
|
||||
default -> ci.setReturnValue(viaFabricPlus$east_shape_r1_8_x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,30 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.LeavesBlock;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(LeavesBlock.class)
|
||||
public abstract class MixinLeavesBlock extends Block {
|
||||
|
||||
public MixinLeavesBlock(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Inject(method = "getSidesShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeSidesShape(BlockState state, BlockView world, BlockPos pos, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isBetweenInclusive(VersionEnum.r1_14, VersionEnum.r1_15_2)) {
|
||||
cir.setReturnValue(super.getSidesShape(state, world, pos));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,40 +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.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.LightBlock;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(LightBlock.class)
|
||||
public class MixinLightBlock {
|
||||
|
||||
// Not relevant for GamePlay
|
||||
@Redirect(method = "onUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isCreativeLevelTwoOp()Z"))
|
||||
public boolean removeIf(PlayerEntity instance) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) {
|
||||
return true;
|
||||
}
|
||||
return instance.isCreativeLevelTwoOp();
|
||||
}
|
||||
}
|
@ -17,8 +17,6 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@ -27,6 +25,7 @@ import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -37,12 +36,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
public class MixinLilyPadBlock {
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape viafabricplus_shape_v1_8_x = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 0.015625D /* 1 / 64 */ * 16, 16.0D);
|
||||
private final static VoxelShape viaFabricPlus$shape_r1_8_x = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 0.25D, 16.0D);
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
public void changeBoundingBox(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
cir.setReturnValue(viafabricplus_shape_v1_8_x);
|
||||
cir.setReturnValue(viaFabricPlus$shape_r1_8_x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.NoteBlock;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(NoteBlock.class)
|
||||
public abstract class MixinNoteBlock {
|
||||
|
||||
@Inject(method = "onUse", at = @At("HEAD"), cancellable = true)
|
||||
private void cancelMobHeadUsage(CallbackInfoReturnable<ActionResult> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_4)) {
|
||||
cir.setReturnValue(ActionResult.SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,99 +1,93 @@
|
||||
/*
|
||||
* 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.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(PaneBlock.class)
|
||||
public class MixinPaneBlock extends HorizontalConnectingBlock {
|
||||
public abstract class MixinPaneBlock extends HorizontalConnectingBlock {
|
||||
|
||||
public MixinPaneBlock(float radius1, float radius2, float boundingHeight1, float boundingHeight2, float collisionHeight, Settings settings) {
|
||||
@Unique
|
||||
private VoxelShape[] collisionShapes1_8;
|
||||
|
||||
@Unique
|
||||
private VoxelShape[] boundingShapes1_8;
|
||||
|
||||
protected MixinPaneBlock(float radius1, float radius2, float boundingHeight1, float boundingHeight2, float collisionHeight, Settings settings) {
|
||||
super(radius1, radius2, boundingHeight1, boundingHeight2, collisionHeight, settings);
|
||||
}
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
private void initShapes(Settings settings, CallbackInfo ci) {
|
||||
this.collisionShapes1_8 = this.createShapes1_8(1.0F, 1.0F, 16.0F, 0.0F, 16.0F);
|
||||
this.boundingShapes1_8 = this.createShapes1_8(1.0F, 1.0F, 16.0F, 0.0F, 16.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
return viafabricplus_get1_8Shape(state);
|
||||
return this.boundingShapes1_8[this.getShapeIndex(state)];
|
||||
}
|
||||
|
||||
return super.getOutlineShape(state, world, pos, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
return viafabricplus_get1_8Shape(state);
|
||||
return this.collisionShapes1_8[this.getShapeIndex(state)];
|
||||
}
|
||||
|
||||
return super.getCollisionShape(state, world, pos, context);
|
||||
}
|
||||
|
||||
@Unique
|
||||
private final VoxelShape viafabricplus_west_shape_v1_8_x = Block.createCuboidShape(0, 0, 7, 8, 16, 9);
|
||||
private VoxelShape[] createShapes1_8(float radius1, float radius2, float height1, float offset2, float height2) {
|
||||
final float f = 8.0F - radius1;
|
||||
final float g = 8.0F + radius1;
|
||||
final float h = 8.0F - radius2;
|
||||
final float i = 8.0F + radius2;
|
||||
final VoxelShape baseShape = Block.createCuboidShape(f, 0.0, f, g, height1, g);
|
||||
final VoxelShape northShape = Block.createCuboidShape(h, offset2, 0.0, i, height2, i);
|
||||
final VoxelShape southShape = Block.createCuboidShape(h, offset2, h, i, height2, 16.0);
|
||||
final VoxelShape westShape = Block.createCuboidShape(0.0, offset2, h, i, height2, i);
|
||||
final VoxelShape eastShape = Block.createCuboidShape(h, offset2, h, 16.0, height2, i);
|
||||
final VoxelShape northEastCornerShape = VoxelShapes.union(northShape, eastShape);
|
||||
final VoxelShape southWestCornerShape = VoxelShapes.union(southShape, westShape);
|
||||
final VoxelShape[] voxelShapes = new VoxelShape[]{
|
||||
VoxelShapes.empty(),
|
||||
Block.createCuboidShape(h, offset2, h + 1, i, height2, 16.0D), // south
|
||||
Block.createCuboidShape(0.0D, offset2, h, i - 1, height2, i), // west
|
||||
southWestCornerShape,
|
||||
Block.createCuboidShape(h, offset2, 0.0D, i, height2, i - 1), // north
|
||||
VoxelShapes.union(southShape, northShape),
|
||||
VoxelShapes.union(westShape, northShape),
|
||||
VoxelShapes.union(southWestCornerShape, northShape),
|
||||
Block.createCuboidShape(h + 1, offset2, h, 16.0D, height2, i), // east
|
||||
VoxelShapes.union(southShape, eastShape),
|
||||
VoxelShapes.union(westShape, eastShape),
|
||||
VoxelShapes.union(southWestCornerShape, eastShape),
|
||||
northEastCornerShape,
|
||||
VoxelShapes.union(southShape, northEastCornerShape),
|
||||
VoxelShapes.union(westShape, northEastCornerShape),
|
||||
VoxelShapes.union(southWestCornerShape, northEastCornerShape)
|
||||
};
|
||||
|
||||
@Unique
|
||||
private final VoxelShape viafabricplus_east_shape_v1_8_x = Block.createCuboidShape(8, 0, 7, 16, 16, 9);
|
||||
for (int j = 0; j < 16; ++j) {
|
||||
if (j == 1 || j == 2 || j == 4 || j == 8) continue;
|
||||
voxelShapes[j] = VoxelShapes.union(baseShape, voxelShapes[j]);
|
||||
}
|
||||
|
||||
@Unique
|
||||
private final VoxelShape viafabricplus_west_east_combined_shape_v1_8_x = Block.createCuboidShape(0, 0, 7, 16, 16, 9);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape viafabricplus_north_shape_v1_8_x = Block.createCuboidShape(7, 0, 0, 9, 16, 8);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape viafabricplus_south_shape_v1_8_x = Block.createCuboidShape(7, 0, 8, 9, 16, 16);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape viafabricplus_north_south_combined_shape_v1_8_x = Block.createCuboidShape(7, 0, 0, 9, 16, 16);
|
||||
|
||||
@Unique
|
||||
public VoxelShape viafabricplus_get1_8Shape(BlockState state) {
|
||||
VoxelShape finalShape = VoxelShapes.empty();
|
||||
|
||||
final boolean isNorthFacing = state.get(NORTH);
|
||||
final boolean isSouthFacing = state.get(SOUTH);
|
||||
final boolean isWestFacing = state.get(WEST);
|
||||
final boolean isEastFacing = state.get(EAST);
|
||||
|
||||
if ((!isWestFacing || !isEastFacing) && (isWestFacing || isEastFacing || isNorthFacing || isSouthFacing)) {
|
||||
if (isWestFacing)
|
||||
finalShape = VoxelShapes.union(finalShape, viafabricplus_west_shape_v1_8_x);
|
||||
else if (isEastFacing)
|
||||
finalShape = VoxelShapes.union(finalShape, viafabricplus_east_shape_v1_8_x);
|
||||
} else
|
||||
finalShape = VoxelShapes.union(finalShape, viafabricplus_west_east_combined_shape_v1_8_x);
|
||||
|
||||
if ((!isNorthFacing || !isSouthFacing) && (isWestFacing || isEastFacing || isNorthFacing || isSouthFacing)) {
|
||||
if (isNorthFacing)
|
||||
finalShape = VoxelShapes.union(finalShape, viafabricplus_north_shape_v1_8_x);
|
||||
else if (isSouthFacing)
|
||||
finalShape = VoxelShapes.union(finalShape, viafabricplus_south_shape_v1_8_x);
|
||||
} else
|
||||
finalShape = VoxelShapes.union(finalShape, viafabricplus_north_south_combined_shape_v1_8_x);
|
||||
|
||||
return finalShape;
|
||||
return voxelShapes;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,82 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.FacingBlock;
|
||||
import net.minecraft.block.PistonBlock;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(PistonBlock.class)
|
||||
public abstract class MixinPistonBlock extends FacingBlock {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
protected static VoxelShape EXTENDED_DOWN_SHAPE;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
protected static VoxelShape EXTENDED_UP_SHAPE;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
protected static VoxelShape EXTENDED_NORTH_SHAPE;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
protected static VoxelShape EXTENDED_SOUTH_SHAPE;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
protected static VoxelShape EXTENDED_WEST_SHAPE;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
protected static VoxelShape EXTENDED_EAST_SHAPE;
|
||||
|
||||
@Unique
|
||||
private static final VoxelShape _1_1_SHAPE = VoxelShapes.fullCube();
|
||||
|
||||
protected MixinPistonBlock(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_1)) {
|
||||
cir.setReturnValue(_1_1_SHAPE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCullingShape(BlockState state, BlockView world, BlockPos pos) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_1)) {
|
||||
if (state.get(PistonBlock.EXTENDED)) {
|
||||
return switch (state.get(FACING)) {
|
||||
case DOWN -> EXTENDED_DOWN_SHAPE;
|
||||
case UP -> EXTENDED_UP_SHAPE;
|
||||
case NORTH -> EXTENDED_NORTH_SHAPE;
|
||||
case SOUTH -> EXTENDED_SOUTH_SHAPE;
|
||||
case WEST -> EXTENDED_WEST_SHAPE;
|
||||
case EAST -> EXTENDED_EAST_SHAPE;
|
||||
};
|
||||
} else {
|
||||
return VoxelShapes.fullCube();
|
||||
}
|
||||
}
|
||||
|
||||
return super.getCullingShape(state, world, pos);
|
||||
}
|
||||
|
||||
}
|
@ -1,32 +1,12 @@
|
||||
/*
|
||||
* 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.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -36,101 +16,82 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(PistonHeadBlock.class)
|
||||
public class MixinPistonHeadBlock extends FacingBlock {
|
||||
public abstract class MixinPistonHeadBlock extends FacingBlock {
|
||||
|
||||
@Shadow @Final public static BooleanProperty SHORT;
|
||||
@Shadow
|
||||
@Final
|
||||
protected static VoxelShape DOWN_HEAD_SHAPE;
|
||||
|
||||
@Shadow @Final private static VoxelShape[] SHORT_HEAD_SHAPES;
|
||||
@Shadow
|
||||
@Final
|
||||
protected static VoxelShape UP_HEAD_SHAPE;
|
||||
|
||||
@Shadow @Final private static VoxelShape[] HEAD_SHAPES;
|
||||
@Shadow
|
||||
@Final
|
||||
protected static VoxelShape NORTH_HEAD_SHAPE;
|
||||
|
||||
public MixinPistonHeadBlock(Settings settings) {
|
||||
@Shadow
|
||||
@Final
|
||||
protected static VoxelShape SOUTH_HEAD_SHAPE;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
protected static VoxelShape WEST_HEAD_SHAPE;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
protected static VoxelShape EAST_HEAD_SHAPE;
|
||||
|
||||
@Unique
|
||||
private static final VoxelShape _1_8_UP_ARM_SHAPE = Block.createCuboidShape(6.0, 0.0, 6.0, 10.0, 12.0, 10.0);
|
||||
|
||||
@Unique
|
||||
private static final VoxelShape _1_8_DOWN_ARM_SHAPE = Block.createCuboidShape(6.0, 4.0, 6.0, 10.0, 16.0, 10.0);
|
||||
|
||||
@Unique
|
||||
private static final VoxelShape _1_8_SOUTH_ARM_SHAPE = Block.createCuboidShape(4.0, 6.0, 0.0, 12.0, 10.0, 12.0);
|
||||
|
||||
@Unique
|
||||
private static final VoxelShape _1_8_NORTH_ARM_SHAPE = Block.createCuboidShape(4.0, 6.0, 4.0, 12.0, 10.0, 16.0);
|
||||
|
||||
@Unique
|
||||
private static final VoxelShape _1_8_EAST_ARM_SHAPE = Block.createCuboidShape(0.0, 6.0, 4.0, 12.0, 10.0, 12.0);
|
||||
|
||||
@Unique
|
||||
private static final VoxelShape _1_8_WEST_ARM_SHAPE = Block.createCuboidShape(6.0, 4.0, 4.0, 10.0, 12.0, 16.0);
|
||||
|
||||
protected MixinPistonHeadBlock(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Unique
|
||||
private boolean viafabricplus_skipOutlineChange;
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (viafabricplus_skipOutlineChange) {
|
||||
viafabricplus_skipOutlineChange = false;
|
||||
return;
|
||||
}
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_11)) {
|
||||
cir.setReturnValue(viafabricplus_getHeadShape_v1_8_x(state));
|
||||
private void changeShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
cir.setReturnValue(switch (state.get(PistonHeadBlock.FACING)) {
|
||||
case DOWN -> DOWN_HEAD_SHAPE;
|
||||
case UP -> UP_HEAD_SHAPE;
|
||||
case NORTH -> NORTH_HEAD_SHAPE;
|
||||
case SOUTH -> SOUTH_HEAD_SHAPE;
|
||||
case WEST -> WEST_HEAD_SHAPE;
|
||||
case EAST -> EAST_HEAD_SHAPE;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
return VoxelShapes.union(viafabricplus_getHeadShape_v1_8_x(state), viafabricplus_getCoreShape_v1_8_x(state));
|
||||
return switch (state.get(PistonHeadBlock.FACING)) {
|
||||
case DOWN -> VoxelShapes.union(DOWN_HEAD_SHAPE, _1_8_DOWN_ARM_SHAPE);
|
||||
case UP -> VoxelShapes.union(UP_HEAD_SHAPE, _1_8_UP_ARM_SHAPE);
|
||||
case NORTH -> VoxelShapes.union(NORTH_HEAD_SHAPE, _1_8_NORTH_ARM_SHAPE);
|
||||
case SOUTH -> VoxelShapes.union(SOUTH_HEAD_SHAPE, _1_8_SOUTH_ARM_SHAPE);
|
||||
case WEST -> VoxelShapes.union(WEST_HEAD_SHAPE, _1_8_WEST_ARM_SHAPE);
|
||||
case EAST -> VoxelShapes.union(EAST_HEAD_SHAPE, _1_8_EAST_ARM_SHAPE);
|
||||
};
|
||||
}
|
||||
|
||||
viafabricplus_skipOutlineChange = true;
|
||||
return super.getCollisionShape(state, world, pos, context);
|
||||
}
|
||||
|
||||
@Unique
|
||||
private final VoxelShape viafabricplus_core_down_shape_v1_8_x = Block.createCuboidShape(6, 4, 6, 10, 16, 10);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape viafabricplus_core_up_shape_v1_8_x = Block.createCuboidShape(6, 0, 6, 10, 12, 10);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape viafabricplus_core_north_shape_v1_8_x = Block.createCuboidShape(4, 6, 4, 12, 10, 16);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape viafabricplus_core_south_shape_v1_8_x = Block.createCuboidShape(4, 6, 0, 12, 10, 12);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape viafabricplus_core_west_shape_v1_8_x = Block.createCuboidShape(6, 4, 4, 10, 12, 16);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape viafabricplus_core_east_shape_v1_8_x = Block.createCuboidShape(0, 6, 4, 12, 10, 12);
|
||||
|
||||
@Unique
|
||||
private VoxelShape viafabricplus_getCoreShape_v1_8_x(BlockState state) {
|
||||
final Direction direction = state.get(FACING);
|
||||
|
||||
return switch (direction) {
|
||||
case DOWN -> viafabricplus_core_down_shape_v1_8_x;
|
||||
case UP -> viafabricplus_core_up_shape_v1_8_x;
|
||||
case NORTH -> viafabricplus_core_north_shape_v1_8_x;
|
||||
case SOUTH -> viafabricplus_core_south_shape_v1_8_x;
|
||||
case WEST -> viafabricplus_core_west_shape_v1_8_x;
|
||||
case EAST -> viafabricplus_core_east_shape_v1_8_x;
|
||||
};
|
||||
}
|
||||
|
||||
@Unique
|
||||
private final VoxelShape viafabricplus_head_down_shape_v1_8_x = Block.createCuboidShape(0, 0, 0, 16, 4, 16);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape viafabricplus_head_up_shape_v1_8_x = Block.createCuboidShape(0, 12, 0, 16, 16, 16);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape viafabricplus_head_north_shape_v1_8_x = Block.createCuboidShape(0, 0, 0, 16, 16, 4);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape viafabricplus_head_south_shape_v1_8_x = Block.createCuboidShape(0, 0, 12, 16, 16, 16);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape viafabricplus_head_west_shape_v1_8_x = Block.createCuboidShape(0, 0, 0, 4, 16, 16);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape viafabricplus_head_east_shape_v1_8_x = Block.createCuboidShape(12, 0, 0, 16, 16, 16);
|
||||
|
||||
@Unique
|
||||
private VoxelShape viafabricplus_getHeadShape_v1_8_x(BlockState state) {
|
||||
return switch (state.get(FACING)) {
|
||||
case DOWN -> viafabricplus_head_down_shape_v1_8_x;
|
||||
case UP -> viafabricplus_head_up_shape_v1_8_x;
|
||||
case NORTH -> viafabricplus_head_north_shape_v1_8_x;
|
||||
case SOUTH -> viafabricplus_head_south_shape_v1_8_x;
|
||||
case WEST -> viafabricplus_head_west_shape_v1_8_x;
|
||||
case EAST -> viafabricplus_head_east_shape_v1_8_x;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,6 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@ -28,6 +26,7 @@ import net.minecraft.state.property.IntProperty;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -40,8 +39,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
public class MixinSnowBlock {
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape[] viafabricplus_layers_to_shape_v1_12_2 = new VoxelShape[]{
|
||||
Block.createCuboidShape(0, -0.00001 /* Bypass for Minecraft-Fixes */, 0, 16, 0, 16),
|
||||
private final static VoxelShape[] viaFabricPlus$layers_to_shape_r1_12_2 = new VoxelShape[]{
|
||||
Block.createCuboidShape(0, -0.00001 /* 0D */, 0, 16, 0, 16),
|
||||
Block.createCuboidShape(0, 0, 0, 16, 2, 16),
|
||||
Block.createCuboidShape(0, 0, 0, 16, 4, 16),
|
||||
Block.createCuboidShape(0, 0, 0, 16, 6, 16),
|
||||
@ -58,7 +57,7 @@ public class MixinSnowBlock {
|
||||
@Inject(method = "getCollisionShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
cir.setReturnValue(viafabricplus_layers_to_shape_v1_12_2[state.get(LAYERS) - 1]);
|
||||
cir.setReturnValue(viaFabricPlus$layers_to_shape_r1_12_2[state.get(LAYERS) - 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,46 +17,41 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.SoulSandBlock;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(SoulSandBlock.class)
|
||||
public class MixinSoulSandBlock extends Block {
|
||||
|
||||
@Unique
|
||||
private boolean viafabricplus_forceValue;
|
||||
public abstract class MixinSoulSandBlock extends Block {
|
||||
|
||||
public MixinSoulSandBlock(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Inject(method = "getSidesShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeSidesShape(BlockState state, BlockView world, BlockPos pos, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isBetweenInclusive(VersionEnum.r1_13, VersionEnum.r1_15_2)) {
|
||||
cir.setReturnValue(VoxelShapes.empty());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
|
||||
super.onEntityCollision(state, world, pos, entity);
|
||||
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
||||
final Vec3d velocity = entity.getVelocity();
|
||||
this.viafabricplus_forceValue = true;
|
||||
entity.setVelocity(velocity.getX() * this.getVelocityMultiplier(), velocity.getY(), velocity.getZ() * this.getVelocityMultiplier());
|
||||
this.viafabricplus_forceValue = false;
|
||||
entity.setVelocity(entity.getVelocity().multiply(0.4D, 1, 0.4D));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getVelocityMultiplier() {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4) && !this.viafabricplus_forceValue) {
|
||||
return 1.0F;
|
||||
}
|
||||
return super.getVelocityMultiplier();
|
||||
}
|
||||
}
|
||||
|
@ -1,42 +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.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.SugarCaneBlock;
|
||||
import net.minecraft.registry.tag.TagKey;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(SugarCaneBlock.class)
|
||||
public class MixinSugarCaneBlock {
|
||||
|
||||
@Redirect(method = "canPlaceAt", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;isIn(Lnet/minecraft/registry/tag/TagKey;)Z"))
|
||||
public boolean changePlaceTarget(BlockState instance, TagKey<Block> tagKey) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_17)) {
|
||||
return instance.isOf(Blocks.GRASS_BLOCK) || instance.isOf(Blocks.DIRT) || instance.isOf(Blocks.COARSE_DIRT) || instance.isOf(Blocks.PODZOL);
|
||||
}
|
||||
return instance.isIn(tagKey);
|
||||
}
|
||||
}
|
@ -1,119 +1,72 @@
|
||||
/*
|
||||
* 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.injection.mixin.fixes.minecraft.block;
|
||||
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.block.WallBlock;
|
||||
import net.minecraft.block.enums.WallShape;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.state.property.EnumProperty;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Mixin(WallBlock.class)
|
||||
public class MixinWallBlock extends Block {
|
||||
public abstract class MixinWallBlock extends Block {
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape[] viafabricplus_shape_by_index_v1_12_2 = new VoxelShape[]{
|
||||
Block.createCuboidShape(4, 0, 4, 12, 16, 12),
|
||||
Block.createCuboidShape(4, 0, 4, 12, 16, 16),
|
||||
Block.createCuboidShape(0, 0, 4, 12, 16, 12),
|
||||
Block.createCuboidShape(0, 0, 4, 12, 16, 16),
|
||||
Block.createCuboidShape(4, 0, 0, 12, 16, 12),
|
||||
|
||||
Block.createCuboidShape(5, 0, 0, 11, 14, 16),
|
||||
|
||||
Block.createCuboidShape(0, 0, 0, 12, 16, 12),
|
||||
Block.createCuboidShape(0, 0, 0, 12, 16, 16),
|
||||
Block.createCuboidShape(4, 0, 4, 16, 16, 12),
|
||||
Block.createCuboidShape(4, 0, 4, 16, 16, 16),
|
||||
|
||||
Block.createCuboidShape(0, 0, 5, 16, 14, 11),
|
||||
|
||||
Block.createCuboidShape(0, 0, 4, 16, 16, 16),
|
||||
Block.createCuboidShape(4, 0, 0, 16, 16, 12),
|
||||
Block.createCuboidShape(4, 0, 0, 16, 16, 16),
|
||||
Block.createCuboidShape(0, 0, 0, 16, 16, 12),
|
||||
Block.createCuboidShape(0, 0, 0, 16, 16, 16)
|
||||
};
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape[] viafabricplus_cip_shape_by_index_v1_12_2 = new VoxelShape[]{
|
||||
Block.createCuboidShape(4, 0, 4, 12, 24, 12),
|
||||
Block.createCuboidShape(4, 0, 4, 12, 24, 16),
|
||||
Block.createCuboidShape(0, 0, 4, 12, 24, 12),
|
||||
Block.createCuboidShape(0, 0, 4, 12, 24, 16),
|
||||
Block.createCuboidShape(4, 0, 0, 12, 24, 12),
|
||||
|
||||
Block.createCuboidShape(5, 0, 0, 11, 24, 16),
|
||||
|
||||
Block.createCuboidShape(0, 0, 0, 12, 24, 12),
|
||||
Block.createCuboidShape(0, 0, 0, 12, 24, 16),
|
||||
Block.createCuboidShape(4, 0, 4, 16, 24, 12),
|
||||
Block.createCuboidShape(4, 0, 4, 16, 24, 16),
|
||||
|
||||
Block.createCuboidShape(0, 0, 5, 16, 24, 11),
|
||||
|
||||
Block.createCuboidShape(0, 0, 4, 16, 24, 16),
|
||||
Block.createCuboidShape(4, 0, 0, 16, 24, 12),
|
||||
Block.createCuboidShape(4, 0, 0, 16, 24, 16),
|
||||
Block.createCuboidShape(0, 0, 0, 16, 24, 12),
|
||||
Block.createCuboidShape(0, 0, 0, 16, 24, 16)
|
||||
};
|
||||
@Shadow
|
||||
@Final
|
||||
public static EnumProperty<WallShape> EAST_SHAPE;
|
||||
@Shadow
|
||||
@Final
|
||||
public static EnumProperty<WallShape> NORTH_SHAPE;
|
||||
@Shadow
|
||||
@Final
|
||||
public static EnumProperty<WallShape> WEST_SHAPE;
|
||||
@Shadow
|
||||
@Final
|
||||
public static EnumProperty<WallShape> SOUTH_SHAPE;
|
||||
@Shadow
|
||||
@Final
|
||||
private Map<BlockState, VoxelShape> shapeMap;
|
||||
|
||||
@Unique
|
||||
private VoxelShape[] collisionShapes1_12_2;
|
||||
|
||||
@Unique
|
||||
private VoxelShape[] boundingShapes1_12_2;
|
||||
|
||||
@Unique
|
||||
private final Object2IntMap<BlockState> SHAPE_INDEX_CACHE1_12_2 = new Object2IntOpenHashMap<>();
|
||||
|
||||
public MixinWallBlock(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
private void initShapes(Settings settings, CallbackInfo ci) {
|
||||
this.collisionShapes1_12_2 = this.createShapes1_12_2(4.0F, 3.0F, 24.0F, 0.0F, 24.0F);
|
||||
this.boundingShapes1_12_2 = this.createShapes1_12_2(4.0F, 3.0F, 16.0F, 0.0F, 14.0F);
|
||||
}
|
||||
|
||||
@Inject(method = "getPlacementState", at = @At("RETURN"), cancellable = true)
|
||||
private void modifyPlacementState(CallbackInfoReturnable<BlockState> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
|
||||
cir.setReturnValue(oldWallPlacementLogic(cir.getReturnValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getStateForNeighborUpdate", at = @At("RETURN"), cancellable = true)
|
||||
private void modifyBlockState(CallbackInfoReturnable<BlockState> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
|
||||
cir.setReturnValue(oldWallPlacementLogic(cir.getReturnValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@Unique
|
||||
private static BlockState viafabricplus_oldWallPlacementLogic(BlockState state) {
|
||||
private static BlockState oldWallPlacementLogic(BlockState state) {
|
||||
boolean addUp = false;
|
||||
if (state.get(WallBlock.NORTH_SHAPE) == WallShape.TALL) {
|
||||
state = state.with(WallBlock.NORTH_SHAPE, WallShape.LOW);
|
||||
@ -137,48 +90,93 @@ public class MixinWallBlock extends Block {
|
||||
return state;
|
||||
}
|
||||
|
||||
@Unique
|
||||
private static int viafabricplus_getShapeIndex_v1_12_2(BlockState state) {
|
||||
int i = 0;
|
||||
|
||||
if (state.get(NORTH_SHAPE) != WallShape.NONE) i |= 1 << Direction.NORTH.getHorizontal();
|
||||
if (state.get(EAST_SHAPE) != WallShape.NONE) i |= 1 << Direction.EAST.getHorizontal();
|
||||
if (state.get(SOUTH_SHAPE) != WallShape.NONE) i |= 1 << Direction.SOUTH.getHorizontal();
|
||||
if (state.get(WEST_SHAPE) != WallShape.NONE) i |= 1 << Direction.WEST.getHorizontal();
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
@Inject(method = "getPlacementState", at = @At("RETURN"), cancellable = true)
|
||||
public void injectGetPlacementState(ItemPlacementContext ctx, CallbackInfoReturnable<BlockState> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
|
||||
cir.setReturnValue(viafabricplus_oldWallPlacementLogic(cir.getReturnValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getStateForNeighborUpdate", at = @At("RETURN"), cancellable = true)
|
||||
public void injectGetStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos, CallbackInfoReturnable<BlockState> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
|
||||
cir.setReturnValue(viafabricplus_oldWallPlacementLogic(cir.getReturnValue()));
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (state.get(WallBlock.UP) && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
cir.setReturnValue(this.boundingShapes1_12_2[this.getShapeIndex(state)]);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getCollisionShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
cir.setReturnValue(viafabricplus_cip_shape_by_index_v1_12_2[viafabricplus_getShapeIndex_v1_12_2(state)]);
|
||||
private void changeCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (state.get(WallBlock.UP) && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
cir.setReturnValue(this.collisionShapes1_12_2[this.getShapeIndex(state)]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCullingShape(BlockState state, BlockView world, BlockPos pos) {
|
||||
return this.shapeMap.get(state); // Always use the real outline shape for culling
|
||||
if (state.get(WallBlock.UP) && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
return this.shapeMap.get(state);
|
||||
}
|
||||
|
||||
return super.getCullingShape(state, world, pos);
|
||||
}
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
cir.setReturnValue(viafabricplus_shape_by_index_v1_12_2[viafabricplus_getShapeIndex_v1_12_2(state)]);
|
||||
@Unique
|
||||
private VoxelShape[] createShapes1_12_2(float radius1, float radius2, float height1, float offset2, float height2) {
|
||||
final float f = 8.0F - radius1;
|
||||
final float g = 8.0F + radius1;
|
||||
final float h = 8.0F - radius2;
|
||||
final float i = 8.0F + radius2;
|
||||
final VoxelShape baseShape = Block.createCuboidShape(f, 0.0D, f, g, height1, g);
|
||||
final VoxelShape northShape = Block.createCuboidShape(h, offset2, 0.0D, i, height2, i);
|
||||
final VoxelShape southShape = Block.createCuboidShape(h, offset2, h, i, height2, 16.0D);
|
||||
final VoxelShape westShape = Block.createCuboidShape(0.0D, offset2, h, i, height2, i);
|
||||
final VoxelShape eastShape = Block.createCuboidShape(h, offset2, h, 16.0D, height2, i);
|
||||
final VoxelShape[] voxelShapes = new VoxelShape[]{
|
||||
VoxelShapes.empty(),
|
||||
Block.createCuboidShape(f, offset2, h, g, height1, 16.0D),
|
||||
Block.createCuboidShape(0.0D, offset2, f, i, height1, g),
|
||||
Block.createCuboidShape(f - 4, offset2, h - 1, g, height1, 16.0D),
|
||||
Block.createCuboidShape(f, offset2, 0.0D, g, height1, i),
|
||||
VoxelShapes.union(southShape, northShape),
|
||||
Block.createCuboidShape(f - 4, offset2, 0.0D, g, height1, i + 1),
|
||||
Block.createCuboidShape(f - 4, offset2, h - 5, g, height1, 16.0D),
|
||||
Block.createCuboidShape(h, offset2, f, 16.0D, height1, g),
|
||||
Block.createCuboidShape(h - 1, offset2, f, 16.0D, height1, g + 4),
|
||||
VoxelShapes.union(westShape, eastShape),
|
||||
Block.createCuboidShape(h - 5, offset2, f, 16.0D, height1, g + 4),
|
||||
Block.createCuboidShape(f, offset2, 0.0D, g + 4, height1, i + 1),
|
||||
Block.createCuboidShape(f, offset2, 0.0D, g + 4, height1, i + 5),
|
||||
Block.createCuboidShape(h - 5, offset2, f - 4, 16.0D, height1, g),
|
||||
Block.createCuboidShape(0, offset2, 0, 16.0D, height1, 16.0D)
|
||||
};
|
||||
|
||||
for (int j = 0; j < 16; ++j) {
|
||||
voxelShapes[j] = VoxelShapes.union(baseShape, voxelShapes[j]);
|
||||
}
|
||||
|
||||
return voxelShapes;
|
||||
}
|
||||
|
||||
@Unique
|
||||
private static int getDirectionMask(Direction dir) {
|
||||
return 1 << dir.getHorizontal();
|
||||
}
|
||||
|
||||
@Unique
|
||||
private int getShapeIndex(BlockState state) {
|
||||
return this.SHAPE_INDEX_CACHE1_12_2.computeIntIfAbsent(state, statex -> {
|
||||
int i = 0;
|
||||
if (!WallShape.NONE.equals(statex.get(WallBlock.NORTH_SHAPE))) {
|
||||
i |= getDirectionMask(Direction.NORTH);
|
||||
}
|
||||
|
||||
if (!WallShape.NONE.equals(statex.get(WallBlock.EAST_SHAPE))) {
|
||||
i |= getDirectionMask(Direction.EAST);
|
||||
}
|
||||
|
||||
if (!WallShape.NONE.equals(statex.get(WallBlock.SOUTH_SHAPE))) {
|
||||
i |= getDirectionMask(Direction.SOUTH);
|
||||
}
|
||||
|
||||
if (!WallShape.NONE.equals(statex.get(WallBlock.WEST_SHAPE))) {
|
||||
i |= getDirectionMask(Direction.WEST);
|
||||
}
|
||||
|
||||
return i;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,327 +0,0 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
||||
|
||||
import de.florianmichael.viafabricplus.settings.impl.ExperimentalSettings;
|
||||
import de.florianmichael.viafabricplus.definition.EntityHeightOffsetsPre1_20_2;
|
||||
import de.florianmichael.viafabricplus.injection.access.IBoatEntity;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.*;
|
||||
import net.minecraft.entity.vehicle.BoatEntity;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.registry.tag.FluidTags;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.*;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(BoatEntity.class)
|
||||
public abstract class MixinBoatEntity extends Entity implements IBoatEntity {
|
||||
|
||||
@Shadow
|
||||
private double x;
|
||||
|
||||
@Shadow
|
||||
private double y;
|
||||
|
||||
@Shadow
|
||||
private double z;
|
||||
|
||||
@Shadow
|
||||
private double boatYaw;
|
||||
|
||||
@Shadow
|
||||
private double boatPitch;
|
||||
|
||||
@Shadow
|
||||
public abstract int getDamageWobbleTicks();
|
||||
|
||||
@Shadow
|
||||
public abstract void setDamageWobbleTicks(int wobbleTicks);
|
||||
|
||||
@Shadow
|
||||
public abstract float getDamageWobbleStrength();
|
||||
|
||||
@Shadow
|
||||
public abstract void setDamageWobbleStrength(float wobbleStrength);
|
||||
|
||||
@Shadow
|
||||
public abstract @Nullable LivingEntity getControllingPassenger();
|
||||
|
||||
@Shadow
|
||||
private BoatEntity.Location location;
|
||||
|
||||
public MixinBoatEntity(EntityType<?> type, World world) {
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
@Unique
|
||||
private boolean viafabricplus_boatEmpty = true;
|
||||
|
||||
@Unique
|
||||
private double viafabricplus_speedMultiplier = 0.07;
|
||||
|
||||
@Unique
|
||||
private int viafabricplus_boatPosRotationIncrements;
|
||||
|
||||
@Unique
|
||||
private double viafabricplus_velocityX;
|
||||
|
||||
@Unique
|
||||
private double viafabricplus_velocityY;
|
||||
|
||||
@Unique
|
||||
private double viafabricplus_velocityZ;
|
||||
|
||||
@Inject(method = "pushAwayFrom", at = @At("HEAD"), cancellable = true)
|
||||
private void onPushAwayFrom(Entity entity, CallbackInfo ci) {
|
||||
if (this.viafabricplus_boatMovementEmulation()) {
|
||||
super.pushAwayFrom(entity);
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "updateTrackedPositionAndAngles", at = @At("HEAD"), cancellable = true)
|
||||
private void onUpdateTrackedPositionAndAngles(double x, double y, double z, float yaw, float pitch, int interpolationSteps, CallbackInfo ci) {
|
||||
if (this.viafabricplus_boatMovementEmulation()) {
|
||||
if (hasPassengers()) {
|
||||
this.prevX = x;
|
||||
this.prevY = y;
|
||||
this.prevZ = z;
|
||||
this.viafabricplus_boatPosRotationIncrements = 0;
|
||||
setPosition(x, y, z);
|
||||
setRotation(yaw, pitch);
|
||||
setVelocity(Vec3d.ZERO);
|
||||
viafabricplus_velocityX = viafabricplus_velocityY = viafabricplus_velocityZ = 0;
|
||||
} else {
|
||||
if (viafabricplus_boatEmpty) {
|
||||
viafabricplus_boatPosRotationIncrements = interpolationSteps + 5;
|
||||
} else {
|
||||
if (squaredDistanceTo(x, y, z) <= 1) {
|
||||
return;
|
||||
}
|
||||
viafabricplus_boatPosRotationIncrements = 3;
|
||||
}
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.boatYaw = yaw;
|
||||
this.boatPitch = pitch;
|
||||
setVelocity(viafabricplus_velocityX, viafabricplus_velocityY, viafabricplus_velocityZ);
|
||||
}
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVelocityClient(double x, double y, double z) {
|
||||
super.setVelocityClient(x, y, z);
|
||||
viafabricplus_velocityX = x;
|
||||
viafabricplus_velocityY = y;
|
||||
viafabricplus_velocityZ = z;
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At("HEAD"), cancellable = true)
|
||||
private void onTick(CallbackInfo ci) {
|
||||
if (this.viafabricplus_boatMovementEmulation()) {
|
||||
super.tick();
|
||||
|
||||
if (getDamageWobbleTicks() > 0) {
|
||||
setDamageWobbleTicks(getDamageWobbleTicks() - 1);
|
||||
}
|
||||
if (getDamageWobbleStrength() > 0) {
|
||||
setDamageWobbleStrength(getDamageWobbleStrength() - 1);
|
||||
}
|
||||
prevX = getX();
|
||||
prevY = getY();
|
||||
prevZ = getZ();
|
||||
|
||||
// calculate how submerged in water the boat is
|
||||
final int yPartitions = 5;
|
||||
double percentSubmerged = 0;
|
||||
for (int partitionIndex = 0; partitionIndex < yPartitions; partitionIndex++) {
|
||||
double minY = getBoundingBox().minY + getBoundingBox().getLengthY() * partitionIndex / yPartitions - 0.125;
|
||||
double maxY = getBoundingBox().minY + getBoundingBox().getLengthY() * (partitionIndex + 1) / yPartitions - 0.125;
|
||||
Box box = new Box(getBoundingBox().minX, minY, getBoundingBox().minZ, getBoundingBox().maxX, maxY, getBoundingBox().maxZ);
|
||||
if (BlockPos.stream(box).anyMatch(pos -> getWorld().getFluidState(pos).isIn(FluidTags.WATER))) {
|
||||
percentSubmerged += 1.0 / yPartitions;
|
||||
}
|
||||
}
|
||||
|
||||
// spawn boat movement splash particles
|
||||
double oldHorizontalSpeed = Math.sqrt(getVelocity().x * getVelocity().x + getVelocity().z * getVelocity().z);
|
||||
if (oldHorizontalSpeed > 0.2975) {
|
||||
double rx = Math.cos(getYaw() * Math.PI / 180);
|
||||
double rz = Math.sin(getYaw() * Math.PI / 180);
|
||||
for (int i = 0; i < 1 + oldHorizontalSpeed * 60; i++) {
|
||||
double dForward = random.nextFloat() * 2 - 1;
|
||||
double dSideways = (random.nextInt(2) * 2 - 1) * 0.7;
|
||||
if (random.nextBoolean()) {
|
||||
// particles on the side of the boat
|
||||
double x = getX() - rx * dForward * 0.8 + rz * dSideways;
|
||||
double z = getZ() - rz * dForward * 0.8 - rx * dSideways;
|
||||
getWorld().addParticle(ParticleTypes.SPLASH, x, getY() - 0.125, z, getVelocity().x, getVelocity().y, getVelocity().z);
|
||||
} else {
|
||||
// particles trailing behind the boat
|
||||
double x = getX() + rx + rz * dForward * 0.7;
|
||||
double z = getZ() + rz - rx * dForward * 0.7;
|
||||
getWorld().addParticle(ParticleTypes.SPLASH, x, getY() - 0.125, z, getVelocity().x, getVelocity().y, getVelocity().z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (viafabricplus_boatEmpty) {
|
||||
if (viafabricplus_boatPosRotationIncrements > 0) {
|
||||
double newX = getX() + (this.x - getX()) / viafabricplus_boatPosRotationIncrements;
|
||||
double newY = getY() + (this.y - getY()) / viafabricplus_boatPosRotationIncrements;
|
||||
double newZ = getZ() + (this.z - getZ()) / viafabricplus_boatPosRotationIncrements;
|
||||
double newYaw = this.getYaw() + (this.boatYaw - this.getYaw()) / viafabricplus_boatPosRotationIncrements;
|
||||
double newPitch = this.getPitch() + (this.boatPitch - this.getPitch()) / viafabricplus_boatPosRotationIncrements;
|
||||
viafabricplus_boatPosRotationIncrements--;
|
||||
setPosition(newX, newY, newZ);
|
||||
setRotation((float) newYaw, (float) newPitch);
|
||||
} else {
|
||||
setPosition(getX() + getVelocity().x, getY() + getVelocity().y, getZ() + getVelocity().z);
|
||||
if (isOnGround()) {
|
||||
setVelocity(getVelocity().multiply(0.5));
|
||||
}
|
||||
setVelocity(getVelocity().multiply(0.99, 0.95, 0.99));
|
||||
}
|
||||
} else {
|
||||
if (percentSubmerged < 1) {
|
||||
double normalizedDistanceFromMiddle = percentSubmerged * 2 - 1;
|
||||
setVelocity(getVelocity().add(0, 0.04 * normalizedDistanceFromMiddle, 0));
|
||||
} else {
|
||||
if (getVelocity().y < 0) {
|
||||
setVelocity(getVelocity().multiply(1, 0.5, 1));
|
||||
}
|
||||
setVelocity(getVelocity().add(0, 0.007, 0));
|
||||
}
|
||||
|
||||
if (getControllingPassenger() != null) {
|
||||
final LivingEntity passenger = getControllingPassenger();
|
||||
|
||||
float boatAngle = passenger.getYaw() - passenger.sidewaysSpeed * 90;
|
||||
double xAcceleration = -Math.sin(boatAngle * Math.PI / 180) * viafabricplus_speedMultiplier * passenger.forwardSpeed * 0.05;
|
||||
double zAcceleration = Math.cos(boatAngle * Math.PI / 180) * viafabricplus_speedMultiplier * passenger.forwardSpeed * 0.05;
|
||||
setVelocity(getVelocity().add(xAcceleration, 0, zAcceleration));
|
||||
}
|
||||
|
||||
double newHorizontalSpeed = Math.sqrt(getVelocity().x * getVelocity().x + getVelocity().z * getVelocity().z);
|
||||
// cap horizontal speed at 0.35
|
||||
if (newHorizontalSpeed > 0.35) {
|
||||
double multiplier = 0.35 / newHorizontalSpeed;
|
||||
setVelocity(getVelocity().multiply(multiplier, 1, multiplier));
|
||||
newHorizontalSpeed = 0.35;
|
||||
}
|
||||
|
||||
if (newHorizontalSpeed > oldHorizontalSpeed && viafabricplus_speedMultiplier < 0.35) {
|
||||
viafabricplus_speedMultiplier += (0.35 - viafabricplus_speedMultiplier) / 35;
|
||||
if (viafabricplus_speedMultiplier > 0.35) {
|
||||
viafabricplus_speedMultiplier = 0.35;
|
||||
}
|
||||
} else {
|
||||
viafabricplus_speedMultiplier -= (viafabricplus_speedMultiplier - 0.07) / 35;
|
||||
if (viafabricplus_speedMultiplier < 0.07) {
|
||||
viafabricplus_speedMultiplier = 0.07;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
int dx = MathHelper.floor(getX() + ((i % 2) - 0.5) * 0.8);
|
||||
//noinspection IntegerDivisionInFloatingPointContext
|
||||
int dz = MathHelper.floor(getZ() + ((i / 2) - 0.5) * 0.8);
|
||||
for (int ddy = 0; ddy < 2; ddy++) {
|
||||
int dy = MathHelper.floor(getY()) + ddy;
|
||||
BlockPos pos = new BlockPos(dx, dy, dz);
|
||||
Block block = getWorld().getBlockState(pos).getBlock();
|
||||
if (block == Blocks.SNOW) {
|
||||
getWorld().setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||
horizontalCollision = false;
|
||||
} else if (block == Blocks.LILY_PAD) {
|
||||
getWorld().breakBlock(pos, true);
|
||||
horizontalCollision = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isOnGround()) {
|
||||
setVelocity(getVelocity().multiply(0.5));
|
||||
}
|
||||
|
||||
move(MovementType.SELF, getVelocity());
|
||||
|
||||
if (!horizontalCollision || oldHorizontalSpeed <= 0.2975) {
|
||||
setVelocity(getVelocity().multiply(0.99, 0.95, 0.99));
|
||||
}
|
||||
|
||||
setPitch(0);
|
||||
double deltaX = prevX - getX();
|
||||
double deltaZ = prevZ - getZ();
|
||||
if (deltaX * deltaX + deltaZ * deltaZ > 0.001) {
|
||||
setYaw(MathHelper.clampAngle(getYaw(), (float) (MathHelper.atan2(deltaZ, deltaX) * 180 / Math.PI), 20));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "updatePassengerPosition", at = @At("HEAD"), cancellable = true)
|
||||
private void emulatePassengerOffset1_8(Entity passenger, PositionUpdater positionUpdater, CallbackInfo ci) {
|
||||
if (this.viafabricplus_boatMovementEmulation()) {
|
||||
if (hasPassenger(passenger)) {
|
||||
double dx = Math.cos(this.getYaw() * Math.PI / 180) * 0.4;
|
||||
double dz = Math.sin(this.getYaw() * Math.PI / 180) * 0.4;
|
||||
passenger.setPosition(getX() + dx, getY() + EntityHeightOffsetsPre1_20_2.getMountedHeightOffset(this, passenger).y, getZ() + dz);
|
||||
}
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "onPassengerLookAround", at = @At("HEAD"), cancellable = true)
|
||||
private void onOnPassengerLookAround(Entity passenger, CallbackInfo ci) {
|
||||
if (this.viafabricplus_boatMovementEmulation()) {
|
||||
// don't prevent entities looking around in the boat
|
||||
super.onPassengerLookAround(passenger);
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "fall", at = @At("HEAD"))
|
||||
private void onFall(CallbackInfo ci) {
|
||||
if (this.viafabricplus_boatMovementEmulation()) {
|
||||
// prevent falling from being negated
|
||||
location = BoatEntity.Location.ON_LAND;
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "canAddPassenger", at = @At("HEAD"), cancellable = true)
|
||||
private void onCanAddPassenger(Entity passenger, CallbackInfoReturnable<Boolean> ci) {
|
||||
if (this.viafabricplus_boatMovementEmulation()) {
|
||||
// only one entity can ride a boat at a time
|
||||
ci.setReturnValue(super.canAddPassenger(passenger));
|
||||
}
|
||||
}
|
||||
|
||||
@Unique
|
||||
private boolean viafabricplus_boatMovementEmulation() {
|
||||
return ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8) && ExperimentalSettings.INSTANCE.emulateBoatMovement.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viafabricplus_setBoatEmpty(boolean boatEmpty) {
|
||||
viafabricplus_boatEmpty = boatEmpty;
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
||||
|
||||
import de.florianmichael.viafabricplus.definition.EntityHeightOffsetsPre1_20_2;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
@ -30,7 +29,7 @@ public abstract class MixinCamelEntity extends AbstractHorseEntity {
|
||||
}
|
||||
|
||||
@Unique
|
||||
public void viafabricplus_clamPassengerYaw(final Entity passenger) {
|
||||
public void viaFabricPlus$clamPassengerYaw(final Entity passenger) {
|
||||
passenger.setBodyYaw(this.getYaw());
|
||||
final float passengerYaw = passenger.getYaw();
|
||||
|
||||
@ -46,7 +45,7 @@ public abstract class MixinCamelEntity extends AbstractHorseEntity {
|
||||
@Override
|
||||
public void onPassengerLookAround(Entity passenger) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1) && this.getControllingPassenger() != passenger) {
|
||||
viafabricplus_clamPassengerYaw(passenger);
|
||||
viaFabricPlus$clamPassengerYaw(passenger);
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,7 +54,7 @@ public abstract class MixinCamelEntity extends AbstractHorseEntity {
|
||||
super.updatePassengerPosition(passenger, positionUpdater);
|
||||
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) {
|
||||
viafabricplus_clamPassengerYaw(passenger);
|
||||
viaFabricPlus$clamPassengerYaw(passenger);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,12 +19,9 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import de.florianmichael.viafabricplus.definition.ClientsideFixes;
|
||||
import net.minecraft.world.GameMode;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
|
||||
import de.florianmichael.viafabricplus.injection.access.IClientPlayerEntity;
|
||||
import de.florianmichael.viafabricplus.settings.impl.VisualSettings;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
|
||||
import de.florianmichael.viafabricplus.settings.impl.VisualSettings;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.input.Input;
|
||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||
@ -32,6 +29,8 @@ import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.GameMode;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -41,7 +40,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@SuppressWarnings("ConstantValue")
|
||||
@Mixin(value = ClientPlayerEntity.class, priority = 2000)
|
||||
public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity implements IClientPlayerEntity {
|
||||
public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity {
|
||||
|
||||
@Shadow
|
||||
public Input input;
|
||||
@ -57,7 +56,7 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
|
||||
private int ticksSinceLastPositionPacketSent;
|
||||
|
||||
@Unique
|
||||
private boolean viafabricplus_areSwingCanceledThisTick = false;
|
||||
private boolean viaFabricPlus$areSwingCanceledThisTick = false;
|
||||
|
||||
public MixinClientPlayerEntity(ClientWorld world, GameProfile profile) {
|
||||
super(world, profile);
|
||||
@ -99,11 +98,11 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
|
||||
|
||||
@Inject(method = "swingHand", at = @At("HEAD"), cancellable = true)
|
||||
public void injectSwingHand(Hand hand, CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8) && viafabricplus_areSwingCanceledThisTick) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8) && viaFabricPlus$areSwingCanceledThisTick) {
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
viafabricplus_areSwingCanceledThisTick = false;
|
||||
viaFabricPlus$areSwingCanceledThisTick = false;
|
||||
}
|
||||
|
||||
@Inject(
|
||||
@ -242,8 +241,4 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
|
||||
return super.getArmor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viafabricplus_cancelSwingOnce() {
|
||||
viafabricplus_areSwingCanceledThisTick = true;
|
||||
}
|
||||
}
|
||||
|
@ -17,9 +17,9 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
||||
|
||||
import de.florianmichael.viafabricplus.settings.impl.ExperimentalSettings;
|
||||
import de.florianmichael.viafabricplus.definition.BoatRenderer_1_8;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.settings.impl.ExperimentalSettings;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.render.entity.EntityRenderer;
|
||||
import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||
@ -39,18 +39,18 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
public class MixinEntityRenderDispatcher {
|
||||
|
||||
@Unique
|
||||
private BoatRenderer_1_8 viafabricplus_boatRenderer;
|
||||
private BoatRenderer_1_8 viaFabricPlus$boatRenderer;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Inject(method = "getRenderer", at = @At("HEAD"), cancellable = true)
|
||||
private <T extends Entity> void onGetRenderer(T entity, CallbackInfoReturnable<EntityRenderer<? super T>> ci) {
|
||||
if (ExperimentalSettings.INSTANCE.emulateBoatMovement.getValue() && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8) && entity instanceof BoatEntity) {
|
||||
ci.setReturnValue((EntityRenderer<? super T>) viafabricplus_boatRenderer);
|
||||
ci.setReturnValue((EntityRenderer<? super T>) viaFabricPlus$boatRenderer);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "reload", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private void onReload(ResourceManager manager, CallbackInfo ci, EntityRendererFactory.Context context) {
|
||||
viafabricplus_boatRenderer = new BoatRenderer_1_8(context);
|
||||
viaFabricPlus$boatRenderer = new BoatRenderer_1_8(context);
|
||||
}
|
||||
}
|
||||
|
@ -17,18 +17,21 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
||||
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.entity.*;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import de.florianmichael.viafabricplus.settings.impl.VisualSettings;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.settings.impl.VisualSettings;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.entity.EntityDimensions;
|
||||
import net.minecraft.entity.EntityPose;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.entity.player.PlayerAbilities;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.World;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -42,10 +45,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
public abstract class MixinPlayerEntity extends LivingEntity {
|
||||
|
||||
@Unique
|
||||
private final static EntityDimensions viafabricplus_sneaking_dimensions_v1_13_2 = EntityDimensions.changing(0.6f, 1.65f);
|
||||
private final static EntityDimensions viaFabricPlus$sneaking_dimensions_v1_13_2 = EntityDimensions.changing(0.6f, 1.65f);
|
||||
|
||||
@Unique
|
||||
private final static SoundEvent viafabricplus_random_hurt = SoundEvent.of(new Identifier("viafabricplus", "random.hurt"));
|
||||
private final static SoundEvent viaFabricPlus$random_hurt = SoundEvent.of(new Identifier("viafabricplus", "random.hurt"));
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
@ -84,7 +87,7 @@ public abstract class MixinPlayerEntity extends LivingEntity {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
ci.setReturnValue(PlayerEntity.STANDING_DIMENSIONS);
|
||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2) || ProtocolHack.getTargetVersion() == VersionEnum.bedrockLatest) {
|
||||
ci.setReturnValue(viafabricplus_sneaking_dimensions_v1_13_2);
|
||||
ci.setReturnValue(viaFabricPlus$sneaking_dimensions_v1_13_2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -99,7 +102,7 @@ public abstract class MixinPlayerEntity extends LivingEntity {
|
||||
@Inject(method = "getHurtSound", at = @At("HEAD"), cancellable = true)
|
||||
public void replaceSound(DamageSource source, CallbackInfoReturnable<SoundEvent> cir) {
|
||||
if (VisualSettings.INSTANCE.replaceHurtSoundWithOOFSound.isEnabled()) {
|
||||
cir.setReturnValue(viafabricplus_random_hurt);
|
||||
cir.setReturnValue(viaFabricPlus$random_hurt);
|
||||
}
|
||||
}
|
||||
|
||||
@ -120,17 +123,17 @@ public abstract class MixinPlayerEntity extends LivingEntity {
|
||||
}
|
||||
|
||||
@Unique
|
||||
public boolean viafabricplus_isSprinting;
|
||||
public boolean viaFabricPlus$isSprinting;
|
||||
|
||||
@Inject(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;setMovementSpeed(F)V"))
|
||||
public void trackOldField(CallbackInfo ci) {
|
||||
viafabricplus_isSprinting = this.isSprinting();
|
||||
viaFabricPlus$isSprinting = this.isSprinting();
|
||||
}
|
||||
|
||||
@Redirect(method = "getOffGroundSpeed", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isSprinting()Z"))
|
||||
public boolean useOldField(PlayerEntity instance) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) {
|
||||
return viafabricplus_isSprinting;
|
||||
return viaFabricPlus$isSprinting;
|
||||
}
|
||||
return instance.isSprinting();
|
||||
}
|
||||
|
@ -1,51 +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.injection.mixin.fixes.minecraft.input;
|
||||
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import de.florianmichael.viafabricplus.injection.access.IMinecraftClient;
|
||||
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.client.Keyboard;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(Keyboard.class)
|
||||
public class MixinKeyboard {
|
||||
|
||||
@Redirect(method = "*", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;execute(Ljava/lang/Runnable;)V"))
|
||||
public void redirectSync(MinecraftClient instance, Runnable runnable) {
|
||||
if (DebugSettings.INSTANCE.executeInputsInSync.isEnabled()) {
|
||||
((IMinecraftClient) MinecraftClient.getInstance()).viafabricplus_getKeyboardInteractions().add(runnable);
|
||||
return;
|
||||
}
|
||||
|
||||
instance.execute(runnable);
|
||||
}
|
||||
|
||||
@Redirect(method = "processF3", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendCommand(Ljava/lang/String;)Z", ordinal = 0))
|
||||
public boolean replaceSpectatorCommand(ClientPlayNetworkHandler instance, String command) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_8)) {
|
||||
return false;
|
||||
}
|
||||
return instance.sendCommand(command);
|
||||
}
|
||||
}
|
@ -1,40 +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.injection.mixin.fixes.minecraft.input;
|
||||
|
||||
import de.florianmichael.viafabricplus.injection.access.IMinecraftClient;
|
||||
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.Mouse;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(value = Mouse.class, priority = 1001)
|
||||
public class MixinMouse {
|
||||
|
||||
@Redirect(method = { "method_29615", "method_22685", "method_22684" }, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;execute(Ljava/lang/Runnable;)V"))
|
||||
public void redirectSync(MinecraftClient instance, Runnable runnable) {
|
||||
if (DebugSettings.INSTANCE.executeInputsInSync.isEnabled()) {
|
||||
((IMinecraftClient) MinecraftClient.getInstance()).viafabricplus_getMouseInteractions().add(runnable);
|
||||
return;
|
||||
}
|
||||
|
||||
instance.execute(runnable);
|
||||
}
|
||||
}
|
@ -18,8 +18,6 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@ -29,6 +27,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.MiningToolItem;
|
||||
import net.minecraft.item.ToolMaterial;
|
||||
import net.minecraft.registry.tag.TagKey;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@ -38,7 +37,7 @@ import java.util.Set;
|
||||
public abstract class MixinHoeItem extends MiningToolItem {
|
||||
|
||||
@Unique
|
||||
private final static Set<Block> viafabricplus_EFFECTIVE_BLOCKS_1165 = ImmutableSet.of(
|
||||
private final static Set<Block> viaFabricPlus$EFFECTIVE_BLOCKS_1165 = ImmutableSet.of(
|
||||
Blocks.NETHER_WART_BLOCK,
|
||||
Blocks.WARPED_WART_BLOCK,
|
||||
Blocks.HAY_BLOCK,
|
||||
@ -74,7 +73,7 @@ public abstract class MixinHoeItem extends MiningToolItem {
|
||||
return 1.0F;
|
||||
}
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
|
||||
return viafabricplus_EFFECTIVE_BLOCKS_1165.contains(state.getBlock()) ? this.miningSpeed : 1.0F;
|
||||
return viaFabricPlus$EFFECTIVE_BLOCKS_1165.contains(state.getBlock()) ? this.miningSpeed : 1.0F;
|
||||
}
|
||||
return super.getMiningSpeedMultiplier(stack, state);
|
||||
}
|
||||
|
@ -17,8 +17,8 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
|
||||
|
||||
import de.florianmichael.viafabricplus.settings.impl.GeneralSettings;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.settings.impl.GeneralSettings;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemGroups;
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
@ -41,16 +41,16 @@ public abstract class MixinItemGroups {
|
||||
protected static void updateEntries(ItemGroup.DisplayContext displayContext) {
|
||||
}
|
||||
@Unique
|
||||
private static VersionEnum viafabricplus_version;
|
||||
private static VersionEnum viaFabricPlus$version;
|
||||
|
||||
@Unique
|
||||
private static int viafabricplus_state;
|
||||
private static int viaFabricPlus$state;
|
||||
|
||||
@Inject(method = "updateDisplayContext", at = @At("HEAD"), cancellable = true)
|
||||
private static void trackLastVersion(FeatureSet enabledFeatures, boolean operatorEnabled, RegistryWrapper.WrapperLookup lookup, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (viafabricplus_version != ProtocolHack.getTargetVersion() || viafabricplus_state != GeneralSettings.INSTANCE.removeNotAvailableItemsFromCreativeTab.getIndex()) {
|
||||
viafabricplus_version = ProtocolHack.getTargetVersion();
|
||||
viafabricplus_state = GeneralSettings.INSTANCE.removeNotAvailableItemsFromCreativeTab.getIndex();
|
||||
if (viaFabricPlus$version != ProtocolHack.getTargetVersion() || viaFabricPlus$state != GeneralSettings.INSTANCE.removeNotAvailableItemsFromCreativeTab.getIndex()) {
|
||||
viaFabricPlus$version = ProtocolHack.getTargetVersion();
|
||||
viaFabricPlus$state = GeneralSettings.INSTANCE.removeNotAvailableItemsFromCreativeTab.getIndex();
|
||||
|
||||
displayContext = new ItemGroup.DisplayContext(enabledFeatures, operatorEnabled, lookup);
|
||||
updateEntries(displayContext);
|
||||
|
@ -19,9 +19,8 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.entity.attribute.EntityAttribute;
|
||||
@ -29,8 +28,12 @@ import net.minecraft.entity.attribute.EntityAttributeModifier;
|
||||
import net.minecraft.entity.attribute.EntityAttributes;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.*;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.*;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.*;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@ -84,7 +87,7 @@ public abstract class MixinItemStack {
|
||||
|
||||
modifiers = HashMultimap.create(modifiers);
|
||||
modifiers.removeAll(EntityAttributes.GENERIC_ATTACK_DAMAGE);
|
||||
OptionalDouble defaultAttackDamage = viafabricplus_getDefaultAttackDamage(getItem());
|
||||
OptionalDouble defaultAttackDamage = viaFabricPlus$getDefaultAttackDamage(getItem());
|
||||
if (defaultAttackDamage.isPresent()) {
|
||||
modifiers.put(EntityAttributes.GENERIC_ATTACK_DAMAGE, new EntityAttributeModifier(Item.ATTACK_DAMAGE_MODIFIER_ID, "Weapon Modifier", defaultAttackDamage.getAsDouble(), EntityAttributeModifier.Operation.ADDITION));
|
||||
}
|
||||
@ -95,7 +98,7 @@ public abstract class MixinItemStack {
|
||||
}
|
||||
|
||||
@Unique
|
||||
private OptionalDouble viafabricplus_getDefaultAttackDamage(Item item) {
|
||||
private OptionalDouble viaFabricPlus$getDefaultAttackDamage(Item item) {
|
||||
if (item instanceof ToolItem) {
|
||||
ToolMaterial material = ((ToolItem) item).getMaterial();
|
||||
int materialBonus;
|
||||
|
File diff suppressed because one or more lines are too long
@ -18,14 +18,15 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.network;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.WrapWithCondition;
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.definition.RecipesPre1_12;
|
||||
import de.florianmichael.viafabricplus.settings.impl.VisualSettings;
|
||||
import de.florianmichael.viafabricplus.injection.access.IBoatEntity;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.settings.impl.VisualSettings;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.DownloadingTerrainScreen;
|
||||
import net.minecraft.client.network.*;
|
||||
import net.minecraft.client.network.ClientConnectionState;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.client.network.PlayerListEntry;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.vehicle.BoatEntity;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
@ -111,16 +112,6 @@ public abstract class MixinClientPlayNetworkHandler {
|
||||
return constant;
|
||||
}
|
||||
|
||||
@Inject(method = "onEntityPassengersSet", at = @At("RETURN"))
|
||||
private void handle1_8BoatPassengers(EntityPassengersSetS2CPacket packet, CallbackInfo ci) {
|
||||
if (!ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) return;
|
||||
|
||||
final var entity = this.world.getEntityById(packet.getId());
|
||||
if (entity instanceof IBoatEntity boatEntity) {
|
||||
boatEntity.viafabricplus_setBoatEmpty(packet.getPassengerIds().length == 0);
|
||||
}
|
||||
}
|
||||
|
||||
@WrapWithCondition(method = "onPlayerList", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V", remap = false))
|
||||
public boolean removeWarning(Logger instance, String s, Object o) {
|
||||
return ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_19_3);
|
||||
|
@ -21,12 +21,10 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.ProfileKey;
|
||||
import com.viaversion.viaversion.api.minecraft.signature.storage.ChatSession1_19_0;
|
||||
import com.viaversion.viaversion.api.minecraft.signature.storage.ChatSession1_19_1;
|
||||
import net.raphimc.minecraftauth.MinecraftAuth;
|
||||
import net.raphimc.minecraftauth.util.MicrosoftConstants;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.definition.account.BedrockAccountHandler;
|
||||
import de.florianmichael.viafabricplus.definition.account.ClassiCubeAccountHandler;
|
||||
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
|
||||
import de.florianmichael.viafabricplus.injection.access.IPublicKeyData;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.protocolhack.provider.vialegacy.ViaFabricPlusClassicMPPassProvider;
|
||||
@ -38,7 +36,10 @@ import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.encryption.PlayerPublicKey;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.c2s.login.LoginHelloC2SPacket;
|
||||
import net.raphimc.minecraftauth.MinecraftAuth;
|
||||
import net.raphimc.minecraftauth.util.MicrosoftConstants;
|
||||
import net.raphimc.viabedrock.protocol.storage.AuthChainData;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@ -64,7 +65,7 @@ public class MixinConnectScreen_1 {
|
||||
|
||||
@Redirect(method = "run", at = @At(value = "INVOKE", target = "Ljava/net/InetSocketAddress;getHostName()Ljava/lang/String;", ordinal = 0))
|
||||
public String replaceAddress(InetSocketAddress instance) {
|
||||
if (ProtocolHack.getTargetVersion(instance).isOlderThanOrEqualTo(VersionEnum.r1_17) || ProtocolHack.getTargetVersion(instance) == VersionEnum.bedrockLatest) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_17) || ProtocolHack.getTargetVersion() == VersionEnum.bedrockLatest) {
|
||||
return field_33737.getAddress();
|
||||
}
|
||||
return instance.getHostName();
|
||||
@ -72,7 +73,7 @@ public class MixinConnectScreen_1 {
|
||||
|
||||
@Redirect(method = "run", at = @At(value = "INVOKE", target = "Ljava/net/InetSocketAddress;getPort()I"))
|
||||
public int replacePort(InetSocketAddress instance) {
|
||||
if (ProtocolHack.getTargetVersion(instance).isOlderThanOrEqualTo(VersionEnum.r1_17) || ProtocolHack.getTargetVersion(instance) == VersionEnum.bedrockLatest) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_17) || ProtocolHack.getTargetVersion() == VersionEnum.bedrockLatest) {
|
||||
return field_33737.getPort();
|
||||
}
|
||||
return instance.getPort();
|
||||
@ -92,10 +93,10 @@ public class MixinConnectScreen_1 {
|
||||
final ClientConnection connection = field_2416.connection;
|
||||
if (connection == null || connection.channel == null) return;
|
||||
|
||||
final UserConnection userConnection = connection.channel.attr(ProtocolHack.LOCAL_VIA_CONNECTION).get();
|
||||
final UserConnection userConnection = ((IClientConnection) connection).viaFabricPlus$getUserConnection();
|
||||
if (userConnection == null) return;
|
||||
|
||||
final VersionEnum targetVersion = ProtocolHack.getTargetVersion(connection.channel);
|
||||
final VersionEnum targetVersion = VersionEnum.fromUserConnection(userConnection);
|
||||
|
||||
if (targetVersion == VersionEnum.bedrockLatest) {
|
||||
var bedrockSession = BedrockAccountHandler.INSTANCE.getBedrockSession();
|
||||
@ -128,7 +129,7 @@ public class MixinConnectScreen_1 {
|
||||
|
||||
userConnection.put(new ChatSession1_19_1(playerUuid, profile.privateKey(), new ProfileKey(publicKeyData.expiresAt().toEpochMilli(), publicKeyData.key().getEncoded(), publicKeyData.keySignature())));
|
||||
if (targetVersion == VersionEnum.r1_19) {
|
||||
final var legacyKey = ((IPublicKeyData) (Object) publicKeyData).viafabricplus_getV1Key();
|
||||
final var legacyKey = ((IPublicKeyData) (Object) publicKeyData).viaFabricPlus$getV1Key();
|
||||
if (legacyKey != null) {
|
||||
userConnection.put(new ChatSession1_19_0(playerUuid, profile.privateKey(), new ProfileKey(publicKeyData.expiresAt().toEpochMilli(), publicKeyData.key().getEncoded(), legacyKey.array())));
|
||||
} else {
|
||||
|
@ -17,14 +17,14 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
|
||||
|
||||
import net.minecraft.network.packet.c2s.common.KeepAliveC2SPacket;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.DownloadingTerrainScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.network.packet.c2s.common.KeepAliveC2SPacket;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -40,7 +40,7 @@ public class MixinDownloadingTerrainScreen extends Screen {
|
||||
@Shadow private boolean closeOnNextTick;
|
||||
@Shadow private boolean ready;
|
||||
@Unique
|
||||
private int viafabricplus_tickCounter;
|
||||
private int viaFabricPlus$tickCounter;
|
||||
|
||||
public MixinDownloadingTerrainScreen(Text title) {
|
||||
super(title);
|
||||
@ -49,9 +49,9 @@ public class MixinDownloadingTerrainScreen extends Screen {
|
||||
@Inject(method = "tick", at = @At("HEAD"), cancellable = true)
|
||||
public void injectTick(CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_1)) {
|
||||
viafabricplus_tickCounter++;
|
||||
viaFabricPlus$tickCounter++;
|
||||
|
||||
if (viafabricplus_tickCounter % 20 == 0) {
|
||||
if (viaFabricPlus$tickCounter % 20 == 0) {
|
||||
MinecraftClient.getInstance().getNetworkHandler().sendPacket(new KeepAliveC2SPacket(0));
|
||||
}
|
||||
}
|
||||
|
@ -17,11 +17,11 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.client.gui.screen.GameModeSelectionScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.text.Text;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.client.gui.screen.GameModeSelectionScreen;
|
||||
import org.spongepowered.asm.mixin.*;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -39,7 +39,7 @@ public class MixinGameModeSelectionScreen extends Screen {
|
||||
@Shadow @Final private static int UI_WIDTH;
|
||||
|
||||
@Unique
|
||||
private GameModeSelectionScreen.GameModeSelection[] viafabricplus_unwrappedGameModes;
|
||||
private GameModeSelectionScreen.GameModeSelection[] viaFabricPlus$unwrappedGameModes;
|
||||
|
||||
public MixinGameModeSelectionScreen(Text title) {
|
||||
super(title);
|
||||
@ -53,8 +53,8 @@ public class MixinGameModeSelectionScreen extends Screen {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_3_1tor1_3_2)) gameModeSelections.remove(GameModeSelectionScreen.GameModeSelection.ADVENTURE);
|
||||
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_8)) gameModeSelections.remove(GameModeSelectionScreen.GameModeSelection.SPECTATOR);
|
||||
|
||||
viafabricplus_unwrappedGameModes = gameModeSelections.toArray(GameModeSelectionScreen.GameModeSelection[]::new);
|
||||
UI_WIDTH = viafabricplus_unwrappedGameModes.length * 31 - 5;
|
||||
viaFabricPlus$unwrappedGameModes = gameModeSelections.toArray(GameModeSelectionScreen.GameModeSelection[]::new);
|
||||
UI_WIDTH = viaFabricPlus$unwrappedGameModes.length * 31 - 5;
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ public class MixinGameModeSelectionScreen extends Screen {
|
||||
@Redirect(method = "init", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/screen/GameModeSelectionScreen$GameModeSelection;VALUES:[Lnet/minecraft/client/gui/screen/GameModeSelectionScreen$GameModeSelection;"))
|
||||
public GameModeSelectionScreen.GameModeSelection[] removeNewerGameModes() {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_8)) {
|
||||
return viafabricplus_unwrappedGameModes;
|
||||
return viaFabricPlus$unwrappedGameModes;
|
||||
}
|
||||
return GameModeSelectionScreen.GameModeSelection.values();
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public abstract class MixinMerchantScreen extends HandledScreen<MerchantScreenHa
|
||||
private int selectedIndex;
|
||||
|
||||
@Unique
|
||||
private int viafabricplus_previousRecipeIndex;
|
||||
private int viaFabricPlus$previousRecipeIndex;
|
||||
|
||||
public MixinMerchantScreen(MerchantScreenHandler handler, PlayerInventory inventory, Text title) {
|
||||
super(handler, inventory, title);
|
||||
@ -46,18 +46,18 @@ public abstract class MixinMerchantScreen extends HandledScreen<MerchantScreenHa
|
||||
|
||||
@Inject(method = "init", at = @At("HEAD"))
|
||||
public void reset(CallbackInfo ci) {
|
||||
viafabricplus_previousRecipeIndex = 0;
|
||||
viaFabricPlus$previousRecipeIndex = 0;
|
||||
}
|
||||
|
||||
@Inject(method = "syncRecipeIndex", at = @At("HEAD"))
|
||||
public void smoothOutRecipeIndex(CallbackInfo ci) {
|
||||
if (DebugSettings.INSTANCE.smoothOutMerchantScreens.isEnabled()) {
|
||||
if (viafabricplus_previousRecipeIndex != selectedIndex) {
|
||||
int direction = viafabricplus_previousRecipeIndex < selectedIndex ? 1 : -1;
|
||||
for (int smooth = viafabricplus_previousRecipeIndex + direction /* don't send the page we already are on */; smooth != selectedIndex; smooth += direction) {
|
||||
if (viaFabricPlus$previousRecipeIndex != selectedIndex) {
|
||||
int direction = viaFabricPlus$previousRecipeIndex < selectedIndex ? 1 : -1;
|
||||
for (int smooth = viaFabricPlus$previousRecipeIndex + direction /* don't send the page we already are on */; smooth != selectedIndex; smooth += direction) {
|
||||
client.getNetworkHandler().sendPacket(new SelectMerchantTradeC2SPacket(smooth));
|
||||
}
|
||||
viafabricplus_previousRecipeIndex = selectedIndex;
|
||||
viaFabricPlus$previousRecipeIndex = selectedIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,13 +17,12 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen.screenhandler;
|
||||
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.injection.access.IScreenHandler;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.screen.slot.SlotActionType;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@ -34,7 +33,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
public class MixinScreenHandler implements IScreenHandler {
|
||||
|
||||
@Unique
|
||||
private short viafabricplus_lastActionId = 0;
|
||||
private short viaFabricPlus$lastActionId = 0;
|
||||
|
||||
@Inject(method = "internalOnSlotClick", at = @At("HEAD"), cancellable = true)
|
||||
private void injectInternalOnSlotClick(int slot, int clickData, SlotActionType actionType, PlayerEntity player, CallbackInfo ci) {
|
||||
@ -44,7 +43,7 @@ public class MixinScreenHandler implements IScreenHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public short viafabricplus_getAndIncrementLastActionId() {
|
||||
return ++viafabricplus_lastActionId;
|
||||
public short viaFabricPlus$getAndIncrementLastActionId() {
|
||||
return ++viaFabricPlus$lastActionId;
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,8 @@
|
||||
*/
|
||||
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.injection.access.IExtensionProtocolMetadataStorage;
|
||||
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;
|
||||
@ -41,7 +41,8 @@ public class MixinExtensionProtocolMetadataStorage implements IExtensionProtocol
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumMap<ClassicProtocolExtension, Integer> getServerExtensions() {
|
||||
public EnumMap<ClassicProtocolExtension, Integer> viaFabricPlus$getServerExtensions() {
|
||||
return this.serverExtensions;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,22 +33,22 @@ public class MixinInventoryAcknowledgements {
|
||||
@Mutable
|
||||
@Shadow @Final private IntList ids;
|
||||
@Unique
|
||||
private it.unimi.dsi.fastutil.ints.IntList viafabricplus_ids;
|
||||
private it.unimi.dsi.fastutil.ints.IntList viaFabricPlus$ids;
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
public void fixJavaIssue(CallbackInfo ci) {
|
||||
this.ids = null;
|
||||
this.viafabricplus_ids = IntLists.synchronize(new IntArrayList());
|
||||
this.viaFabricPlus$ids = IntLists.synchronize(new IntArrayList());
|
||||
}
|
||||
|
||||
@Inject(method = "addId", at = @At("HEAD"), cancellable = true)
|
||||
public void forwardAdd(int id, CallbackInfo ci) {
|
||||
viafabricplus_ids.add(id);
|
||||
viaFabricPlus$ids.add(id);
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "removeId", at = @At("HEAD"), cancellable = true)
|
||||
public void forwardRemove(int id, CallbackInfoReturnable<Boolean> cir) {
|
||||
cir.setReturnValue(viafabricplus_ids.rem(id));
|
||||
cir.setReturnValue(viaFabricPlus$ids.rem(id));
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
public class MixinNamedCompoundTagType {
|
||||
|
||||
@Unique
|
||||
private final static TagLimiter viafabricplus_tag_limiter = new TagLimiter() {
|
||||
private final static TagLimiter viaFabricPlus$tag_limiter = new TagLimiter() {
|
||||
private final int maxBytes = 2097152;
|
||||
private int bytes;
|
||||
|
||||
@ -61,6 +61,6 @@ public class MixinNamedCompoundTagType {
|
||||
|
||||
@Redirect(method = "read(Lio/netty/buffer/ByteBuf;Z)Lcom/viaversion/viaversion/libs/opennbt/tag/builtin/CompoundTag;", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/libs/opennbt/tag/limiter/TagLimiter;create(II)Lcom/viaversion/viaversion/libs/opennbt/tag/limiter/TagLimiter;"))
|
||||
private static TagLimiter replaceTagLimiter(int maxBytes, int maxLevels) {
|
||||
return viafabricplus_tag_limiter;
|
||||
return viaFabricPlus$tag_limiter;
|
||||
}
|
||||
}
|
||||
|
@ -1,45 +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.injection.mixin.fixes.viaversion;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
||||
import de.florianmichael.viafabricplus.injection.access.IProtocol1_13To1_12_2;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(targets = "com.viaversion.viaversion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1$3", remap = false)
|
||||
public class MixinProtocol1_12To1_11_1_3 {
|
||||
|
||||
@Redirect(method = "lambda$register$1", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/protocol/packet/PacketWrapper;create(Lcom/viaversion/viaversion/api/protocol/packet/PacketType;Lcom/viaversion/viaversion/api/protocol/remapper/PacketHandler;)Lcom/viaversion/viaversion/api/protocol/packet/PacketWrapper;"))
|
||||
private static PacketWrapper writeRecipes(PacketWrapper instance, PacketType packetType, PacketHandler handler) throws Exception {
|
||||
return instance.create(packetType, wrapper -> {
|
||||
final IProtocol1_13To1_12_2 protocol = (IProtocol1_13To1_12_2) wrapper.user().getProtocolInfo().getPipeline().getProtocol(Protocol1_13To1_12_2.class);
|
||||
if (protocol == null) {
|
||||
Via.getPlatform().getLogger().warning("Cannot write recipes! 1.13 -> 1.12.2 protocol not found!");
|
||||
return;
|
||||
}
|
||||
|
||||
protocol.viafabricplus_writeDeclareRecipes(wrapper);
|
||||
});
|
||||
}
|
||||
}
|
@ -1,35 +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.injection.mixin.viaversion;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
||||
import de.florianmichael.viafabricplus.injection.access.IProtocol1_13To1_12_2;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(value = Protocol1_13To1_12_2.class, remap = false)
|
||||
public abstract class MixinProtocol1_13To1_12_2 implements IProtocol1_13To1_12_2 {
|
||||
|
||||
@Shadow protected abstract void writeDeclareRecipes(PacketWrapper recipesPacket);
|
||||
|
||||
@Override
|
||||
public void viafabricplus_writeDeclareRecipes(PacketWrapper recipesPacket) {
|
||||
writeDeclareRecipes(recipesPacket);
|
||||
}
|
||||
}
|
@ -34,24 +34,24 @@ import java.util.Map;
|
||||
public abstract class MixinProtocolVersion {
|
||||
|
||||
@Unique
|
||||
private static Map<String, Pair<String, VersionRange>> viafabricplus_remaps;
|
||||
private static Map<String, Pair<String, VersionRange>> viaFabricPlus$remaps;
|
||||
|
||||
@Inject(method = "<clinit>", at = @At("HEAD"))
|
||||
private static void initMaps(CallbackInfo ci) {
|
||||
viafabricplus_remaps = new HashMap<>();
|
||||
viafabricplus_remaps.put("1.7-1.7.5", new Pair<>("1.7.2-1.7.5", new VersionRange("1.7", 2, 5)));
|
||||
viafabricplus_remaps.put("1.9.3/4", new Pair<>("1.9.3-1.9.4", null));
|
||||
viafabricplus_remaps.put("1.11.1/2", new Pair<>("1.11.1-1.11.2", null));
|
||||
viafabricplus_remaps.put("1.16.4/5", new Pair<>("1.16.4-1.16.5", null));
|
||||
viafabricplus_remaps.put("1.18/1.18.1", new Pair<>("1.18-1.18.1", null));
|
||||
viafabricplus_remaps.put("1.19.1/2", new Pair<>("1.19.1-1.19.2", null));
|
||||
viafabricplus_remaps.put("1.20/1.20.1", new Pair<>("1.20-1.20.1", null));
|
||||
viafabricplus_remaps.put("1.20.3", new Pair<>("1.20.3-pre2", null));
|
||||
viaFabricPlus$remaps = new HashMap<>();
|
||||
viaFabricPlus$remaps.put("1.7-1.7.5", new Pair<>("1.7.2-1.7.5", new VersionRange("1.7", 2, 5)));
|
||||
viaFabricPlus$remaps.put("1.9.3/4", new Pair<>("1.9.3-1.9.4", null));
|
||||
viaFabricPlus$remaps.put("1.11.1/2", new Pair<>("1.11.1-1.11.2", null));
|
||||
viaFabricPlus$remaps.put("1.16.4/5", new Pair<>("1.16.4-1.16.5", null));
|
||||
viaFabricPlus$remaps.put("1.18/1.18.1", new Pair<>("1.18-1.18.1", null));
|
||||
viaFabricPlus$remaps.put("1.19.1/2", new Pair<>("1.19.1-1.19.2", null));
|
||||
viaFabricPlus$remaps.put("1.20/1.20.1", new Pair<>("1.20-1.20.1", null));
|
||||
viaFabricPlus$remaps.put("1.20.3", new Pair<>("1.20.3-pre2", null));
|
||||
}
|
||||
|
||||
@Redirect(method = "<clinit>", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/protocol/version/ProtocolVersion;register(ILjava/lang/String;)Lcom/viaversion/viaversion/api/protocol/version/ProtocolVersion;"))
|
||||
private static ProtocolVersion unregisterAndRenameVersions(int version, String name) {
|
||||
final Pair<String, VersionRange> remapEntry = viafabricplus_remaps.get(name);
|
||||
final Pair<String, VersionRange> remapEntry = viaFabricPlus$remaps.get(name);
|
||||
if (remapEntry != null) {
|
||||
if (remapEntry.key() != null) name = remapEntry.key();
|
||||
}
|
||||
@ -62,7 +62,7 @@ public abstract class MixinProtocolVersion {
|
||||
@SuppressWarnings({"UnresolvedMixinReference", "MixinAnnotationTarget", "InvalidInjectorMethodSignature"}) // Optional injection
|
||||
@Redirect(method = "<clinit>", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/protocol/version/ProtocolVersion;register(IILjava/lang/String;)Lcom/viaversion/viaversion/api/protocol/version/ProtocolVersion;"), require = 0)
|
||||
private static ProtocolVersion unregisterAndRenameVersions(int version, int snapshotVersion, String name) {
|
||||
final Pair<String, VersionRange> remapEntry = viafabricplus_remaps.get(name);
|
||||
final Pair<String, VersionRange> remapEntry = viaFabricPlus$remaps.get(name);
|
||||
if (remapEntry != null) {
|
||||
if (remapEntry.key() != null) name = remapEntry.key();
|
||||
}
|
||||
@ -72,7 +72,7 @@ public abstract class MixinProtocolVersion {
|
||||
|
||||
@Redirect(method = "<clinit>", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/protocol/version/ProtocolVersion;register(ILjava/lang/String;Lcom/viaversion/viaversion/api/protocol/version/VersionRange;)Lcom/viaversion/viaversion/api/protocol/version/ProtocolVersion;"))
|
||||
private static ProtocolVersion unregisterAndRenameVersions(int version, String name, VersionRange versionRange) {
|
||||
final Pair<String, VersionRange> remapEntry = viafabricplus_remaps.get(name);
|
||||
final Pair<String, VersionRange> remapEntry = viaFabricPlus$remaps.get(name);
|
||||
if (remapEntry != null) {
|
||||
if (remapEntry.key() != null) name = remapEntry.key();
|
||||
if (remapEntry.value() != null) versionRange = remapEntry.value();
|
||||
|
@ -29,7 +29,7 @@ import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.storage.Configur
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
|
||||
import de.florianmichael.viafabricplus.event.FinishViaVersionStartupCallback;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
|
||||
import de.florianmichael.viafabricplus.protocolhack.command.ViaFabricPlusVLCommandHandler;
|
||||
import de.florianmichael.viafabricplus.protocolhack.impl.ViaFabricPlusVLInjector;
|
||||
import de.florianmichael.viafabricplus.protocolhack.impl.ViaFabricPlusVLLoader;
|
||||
@ -41,17 +41,15 @@ import io.netty.util.AttributeKey;
|
||||
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
|
||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.raphimc.vialoader.ViaLoader;
|
||||
import net.raphimc.vialoader.impl.platform.ViaAprilFoolsPlatformImpl;
|
||||
import net.raphimc.vialoader.impl.platform.ViaBackwardsPlatformImpl;
|
||||
import net.raphimc.vialoader.impl.platform.ViaBedrockPlatformImpl;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import org.cloudburstmc.netty.channel.raknet.config.RakChannelOption;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
/**
|
||||
* This class represents the whole Protocol Translator, here all important variables are stored
|
||||
@ -60,108 +58,55 @@ public class ProtocolHack {
|
||||
/**
|
||||
* These attribute keys are used to track the main connections of Minecraft and ViaVersion, so that they can be used later during the connection to send packets.
|
||||
*/
|
||||
public final static AttributeKey<ClientConnection> LOCAL_MINECRAFT_CONNECTION = AttributeKey.newInstance("viafabricplus-minecraft-connection");
|
||||
public final static AttributeKey<UserConnection> LOCAL_VIA_CONNECTION = AttributeKey.newInstance("viafabricplus-via-connection");
|
||||
|
||||
/**
|
||||
* This list is temporary and is used during the connection to the server to create the FORCED_VERSION attribute.
|
||||
*/
|
||||
private final static Map<InetSocketAddress, VersionEnum> forcedVersions = new HashMap<>();
|
||||
public final static AttributeKey<ClientConnection> CLIENT_CONNECTION_ATTRIBUTE_KEY = AttributeKey.newInstance("viafabricplus-clientconnection");
|
||||
|
||||
/**
|
||||
* This attribute stores the forced version for the current connection (if you set a specific version in the Edit Server screen)
|
||||
*/
|
||||
public final static AttributeKey<VersionEnum> FORCED_VERSION = AttributeKey.newInstance("viafabricplus-forced-version");
|
||||
public final static AttributeKey<VersionEnum> SERVER_VERSION_ATTRIBUTE_KEY = AttributeKey.newInstance("viafabricplus-serverversion");
|
||||
|
||||
/**
|
||||
* The native version of the client
|
||||
*/
|
||||
public final static VersionEnum NATIVE_VERSION = VersionEnum.r1_20_2;
|
||||
|
||||
/**
|
||||
* This field stores the target version that you set in the GUI
|
||||
*/
|
||||
public static VersionEnum targetVersion = ViaFabricPlus.NATIVE_VERSION;
|
||||
|
||||
/**
|
||||
* This method is used when you need the target version after connecting to the server.
|
||||
*
|
||||
* @return the target version
|
||||
*/
|
||||
public static VersionEnum getTargetVersion() {
|
||||
if (MinecraftClient.getInstance() == null || MinecraftClient.getInstance().getNetworkHandler() == null) {
|
||||
return getTargetVersion((Channel) null);
|
||||
}
|
||||
|
||||
return getTargetVersion(MinecraftClient.getInstance().getNetworkHandler().getConnection().channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used when you need the target version while connecting to the server before Netty is started
|
||||
*
|
||||
* @param socketAddress the target address
|
||||
* @return the target version
|
||||
*/
|
||||
public static VersionEnum getTargetVersion(final InetSocketAddress socketAddress) {
|
||||
if (forcedVersions.containsKey(socketAddress)) {
|
||||
return forcedVersions.get(socketAddress);
|
||||
}
|
||||
return getTargetVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used when you need the target version while connecting to the server after Netty is started and before ViaVersion is finished loading.
|
||||
*
|
||||
* @param channel channel of the current connection
|
||||
* @return the target version
|
||||
*/
|
||||
public static VersionEnum getTargetVersion(final Channel channel) {
|
||||
if (channel != null && channel.hasAttr(FORCED_VERSION)) {
|
||||
return channel.attr(FORCED_VERSION).get();
|
||||
}
|
||||
|
||||
if (MinecraftClient.getInstance() == null || MinecraftClient.getInstance().isInSingleplayer()) return ViaFabricPlus.NATIVE_VERSION;
|
||||
|
||||
return targetVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used when you need the target version while connecting to the server after Netty is started and after ViaVersion is finished loading.
|
||||
*
|
||||
* @param serverInfo the current server info
|
||||
* @return the target version
|
||||
*/
|
||||
public static VersionEnum getTargetVersion(final ServerInfo serverInfo) {
|
||||
final var forcedVersion = ((IServerInfo) serverInfo).viafabricplus_forcedVersion();
|
||||
if (forcedVersion == null) return getTargetVersion();
|
||||
|
||||
return forcedVersion;
|
||||
}
|
||||
|
||||
public static Map<InetSocketAddress, VersionEnum> getForcedVersions() {
|
||||
return forcedVersions;
|
||||
}
|
||||
private static VersionEnum targetVersion = NATIVE_VERSION;
|
||||
|
||||
/**
|
||||
* Injects the ViaFabricPlus pipeline with all ViaVersion elements into a Minecraft pipeline
|
||||
*
|
||||
* @param connection the Minecraft connection
|
||||
* @param channel the current channel
|
||||
* @param address the target address
|
||||
*/
|
||||
public static void injectVLBPipeline(final ClientConnection connection, final Channel channel, final InetSocketAddress address) {
|
||||
if (ProtocolHack.getForcedVersions().containsKey(address)) {
|
||||
channel.attr(ProtocolHack.FORCED_VERSION).set(ProtocolHack.getForcedVersions().get(address));
|
||||
ProtocolHack.getForcedVersions().remove(address);
|
||||
public static void injectViaPipeline(final ClientConnection connection, final Channel channel) {
|
||||
final IClientConnection mixinClientConnection = (IClientConnection) connection;
|
||||
final VersionEnum serverVersion = mixinClientConnection.viaFabricPlus$getServerVersion();
|
||||
|
||||
if (serverVersion != ProtocolHack.NATIVE_VERSION) {
|
||||
channel.attr(ProtocolHack.CLIENT_CONNECTION_ATTRIBUTE_KEY).set(connection);
|
||||
channel.attr(ProtocolHack.SERVER_VERSION_ATTRIBUTE_KEY).set(serverVersion);
|
||||
|
||||
if (VersionEnum.bedrockLatest.equals(serverVersion)) {
|
||||
channel.config().setOption(RakChannelOption.RAK_PROTOCOL_VERSION, 11);
|
||||
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());
|
||||
}
|
||||
|
||||
final UserConnection user = new UserConnectionImpl(channel, true);
|
||||
new ProtocolPipelineImpl(user);
|
||||
mixinClientConnection.viaFabricPlus$setUserConnection(user);
|
||||
|
||||
channel.pipeline().addLast(new ViaFabricPlusVLLegacyPipeline(user, serverVersion));
|
||||
}
|
||||
final UserConnection user = new UserConnectionImpl(channel, true);
|
||||
channel.attr(ProtocolHack.LOCAL_VIA_CONNECTION).set(user);
|
||||
channel.attr(ProtocolHack.LOCAL_MINECRAFT_CONNECTION).set(connection);
|
||||
|
||||
new ProtocolPipelineImpl(user);
|
||||
|
||||
channel.pipeline().addLast(new ViaFabricPlusVLLegacyPipeline(user, ProtocolHack.getTargetVersion(channel), address));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adding ViaVersion's command system into Fabric
|
||||
*/
|
||||
private static void initCommands() {
|
||||
public static void initCommands() {
|
||||
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> {
|
||||
final ViaFabricPlusVLCommandHandler commandHandler = (ViaFabricPlusVLCommandHandler) Via.getManager().getCommandHandler();
|
||||
|
||||
@ -174,18 +119,31 @@ public class ProtocolHack {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the target version of the GUI
|
||||
* This method is used when you need the target version after connecting to the server.
|
||||
*
|
||||
* @param targetVersion the target version
|
||||
* @return the target version
|
||||
*/
|
||||
public static void setTargetVersion(VersionEnum targetVersion) {
|
||||
ProtocolHack.targetVersion = targetVersion;
|
||||
ChangeProtocolVersionCallback.EVENT.invoker().onChangeProtocolVersion(targetVersion);
|
||||
public static VersionEnum getTargetVersion() {
|
||||
return targetVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the target version
|
||||
*
|
||||
* @param newVersion the target version
|
||||
*/
|
||||
public static void setTargetVersion(VersionEnum newVersion) {
|
||||
if (newVersion == null) return;
|
||||
|
||||
final VersionEnum oldVersion = targetVersion;
|
||||
targetVersion = newVersion;
|
||||
if (oldVersion != newVersion) ChangeProtocolVersionCallback.EVENT.invoker().onChangeProtocolVersion(targetVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Creates a Fake UserConnection class with a valid protocol pipeline to emulate packets
|
||||
*/
|
||||
@Deprecated
|
||||
public static UserConnection createFakerUserConnection() {
|
||||
return createFakerUserConnection(getMainUserConnection().getChannel());
|
||||
}
|
||||
@ -194,6 +152,7 @@ public class ProtocolHack {
|
||||
* @param channel the current channel
|
||||
* @return Creates a Fake UserConnection class with a valid protocol pipeline to emulate packets
|
||||
*/
|
||||
@Deprecated
|
||||
public static UserConnection createFakerUserConnection(final Channel channel) {
|
||||
final var fake = new UserConnectionImpl(channel, true);
|
||||
fake.getProtocolInfo().setPipeline(new ProtocolPipelineImpl(fake));
|
||||
@ -210,13 +169,12 @@ public class ProtocolHack {
|
||||
/**
|
||||
* @return Returns the current ViaVersion UserConnection via the LOCAL_VIA_CONNECTION channel attribute
|
||||
*/
|
||||
@Deprecated
|
||||
public static UserConnection getMainUserConnection() {
|
||||
final MinecraftClient client = MinecraftClient.getInstance();
|
||||
if (client.getNetworkHandler() == null) return null;
|
||||
final var channel = client.getNetworkHandler().getConnection().channel;
|
||||
if (!channel.hasAttr(LOCAL_VIA_CONNECTION)) return null;
|
||||
|
||||
return channel.attr(LOCAL_VIA_CONNECTION).get();
|
||||
return ((IClientConnection) client.getNetworkHandler().getConnection()).viaFabricPlus$getUserConnection();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -224,8 +182,6 @@ public class ProtocolHack {
|
||||
*/
|
||||
public static void init() {
|
||||
ViaLoader.init(new ViaFabricPlusViaVersionPlatformImpl(ViaFabricPlus.RUN_DIRECTORY), new ViaFabricPlusVLLoader(), new ViaFabricPlusVLInjector(), new ViaFabricPlusVLCommandHandler(), ViaBackwardsPlatformImpl::new, ViaFabricPlusViaLegacyPlatformImpl::new, ViaAprilFoolsPlatformImpl::new, ViaBedrockPlatformImpl::new);
|
||||
initCommands();
|
||||
|
||||
FinishViaVersionStartupCallback.EVENT.invoker().onFinishViaVersionStartup();
|
||||
}
|
||||
}
|
||||
|
@ -19,27 +19,21 @@ package de.florianmichael.viafabricplus.protocolhack.netty;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.protocolhack.netty.viabedrock.RakNetClientConnection;
|
||||
import de.florianmichael.viafabricplus.protocolhack.netty.viaversion.ViaFabricPlusViaDecoder;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import net.raphimc.vialoader.netty.CompressionReorderEvent;
|
||||
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
||||
import net.raphimc.vialoader.netty.viabedrock.PingEncapsulationCodec;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
public class ViaFabricPlusVLLegacyPipeline extends VLLegacyPipeline {
|
||||
|
||||
public final static String VIABEDROCK_COMPRESSION_HANDLER_NAME = "viabedrock-compression";
|
||||
public final static String VIABEDROCK_ENCRYPTION_HANDLER_NAME = "viabedrock-encryption";
|
||||
public final static String VIABEDROCK_PING_ENCAPSULATION_HANDLER_NAME = "viabedrock-ping-encapsulation";
|
||||
|
||||
private final InetSocketAddress address;
|
||||
|
||||
public ViaFabricPlusVLLegacyPipeline(UserConnection user, VersionEnum version, final InetSocketAddress address) {
|
||||
public ViaFabricPlusVLLegacyPipeline(UserConnection user, VersionEnum version) {
|
||||
super(user, version);
|
||||
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -47,18 +41,6 @@ public class ViaFabricPlusVLLegacyPipeline extends VLLegacyPipeline {
|
||||
return new ViaFabricPlusViaDecoder(this.user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerAdded(ChannelHandlerContext ctx) {
|
||||
super.handlerAdded(ctx);
|
||||
|
||||
if (this.version == VersionEnum.bedrockLatest && RakNetClientConnection.getRakNetPingSessions().contains(address)) {
|
||||
ctx.pipeline().replace(VIABEDROCK_FRAME_ENCAPSULATION_HANDLER_NAME, VIABEDROCK_FRAME_ENCAPSULATION_HANDLER_NAME, new PingEncapsulationCodec(address));
|
||||
|
||||
ctx.pipeline().remove(VIABEDROCK_PACKET_ENCAPSULATION_HANDLER_NAME);
|
||||
ctx.pipeline().remove(this.lengthSplitterName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
// Bypass, because Krypton overwrites the entire compression instead of modifying the handlers.
|
||||
@ -101,4 +83,5 @@ public class ViaFabricPlusVLLegacyPipeline extends VLLegacyPipeline {
|
||||
protected String lengthPrependerName() {
|
||||
return "prepender";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,77 +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.protocolhack.netty.viabedrock;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.channel.*;
|
||||
import io.netty.channel.epoll.EpollDatagramChannel;
|
||||
import io.netty.channel.epoll.EpollSocketChannel;
|
||||
import io.netty.channel.socket.nio.NioDatagramChannel;
|
||||
import io.netty.handler.timeout.ReadTimeoutHandler;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.NetworkSide;
|
||||
import org.cloudburstmc.netty.channel.raknet.RakChannelFactory;
|
||||
import org.cloudburstmc.netty.channel.raknet.config.RakChannelOption;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class RakNetClientConnection {
|
||||
private final static List<InetSocketAddress> rakNetPingSessions = new ArrayList<>();
|
||||
|
||||
public static ChannelFuture connectRakNet(final ClientConnection clientConnection, final InetSocketAddress address, final EventLoopGroup eventLoopGroup, final Class channelType) {
|
||||
final Bootstrap nettyBoostrap = new Bootstrap().group(eventLoopGroup).handler(new ChannelInitializer<>() {
|
||||
@Override
|
||||
protected void initChannel(@NotNull Channel channel) {
|
||||
// Mojang Code start
|
||||
ClientConnection.setHandlers(channel);
|
||||
// Mojang Code end
|
||||
|
||||
try {
|
||||
channel.config().setOption(RakChannelOption.RAK_PROTOCOL_VERSION, 11);
|
||||
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());
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
// Mojang Code start
|
||||
ChannelPipeline channelPipeline = channel.pipeline().addLast("timeout", new ReadTimeoutHandler(30));
|
||||
ClientConnection.addHandlers(channelPipeline, NetworkSide.CLIENTBOUND, clientConnection.packetSizeLogger);
|
||||
clientConnection.addFlowControlHandler(channelPipeline);
|
||||
// Mojang Code end
|
||||
|
||||
ProtocolHack.injectVLBPipeline(clientConnection, channel, address);
|
||||
}
|
||||
}).channelFactory(channelType == EpollSocketChannel.class ? RakChannelFactory.client(EpollDatagramChannel.class) : RakChannelFactory.client(NioDatagramChannel.class));
|
||||
|
||||
if (getRakNetPingSessions().contains(address)) {
|
||||
return nettyBoostrap.bind(new InetSocketAddress(0)).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
||||
} else {
|
||||
return nettyBoostrap.connect(address.getAddress(), address.getPort());
|
||||
}
|
||||
}
|
||||
|
||||
public static List<InetSocketAddress> getRakNetPingSessions() {
|
||||
return rakNetPingSessions;
|
||||
}
|
||||
}
|
@ -34,12 +34,12 @@ public class ViaFabricPlusBlobCacheProvider extends BlobCacheProvider {
|
||||
@Override
|
||||
public byte[] addBlob(final long hash, final byte[] compressedBlob) {
|
||||
synchronized (this.blobs) {
|
||||
if (this.blobs.containsKey(hash)) { // In case the server overwrites a blob
|
||||
size -= this.blobs.get(hash).length;
|
||||
this.blobs.remove(hash);
|
||||
final byte[] previousBlob = this.blobs.put(hash, compressedBlob);
|
||||
if (previousBlob != null) { // In case the server overwrites a blob
|
||||
this.size -= previousBlob.length;
|
||||
}
|
||||
size += compressedBlob.length;
|
||||
return this.blobs.put(hash, compressedBlob);
|
||||
this.size += compressedBlob.length;
|
||||
return previousBlob;
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,6 +62,7 @@ public class ViaFabricPlusBlobCacheProvider extends BlobCacheProvider {
|
||||
}
|
||||
|
||||
public long getSize() {
|
||||
return size;
|
||||
return this.size;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,42 +18,46 @@
|
||||
package de.florianmichael.viafabricplus.protocolhack.provider.viabedrock;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.protocolhack.netty.ViaFabricPlusVLLegacyPipeline;
|
||||
import io.netty.channel.Channel;
|
||||
import net.raphimc.viabedrock.netty.AesEncryption;
|
||||
import net.raphimc.viabedrock.netty.SnappyCompression;
|
||||
import net.raphimc.viabedrock.netty.ZLibCompression;
|
||||
import net.raphimc.viabedrock.protocol.providers.NettyPipelineProvider;
|
||||
import net.raphimc.vialoader.netty.VLPipeline;
|
||||
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
import javax.crypto.SecretKey;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class ViaFabricPlusNettyPipelineProvider extends NettyPipelineProvider {
|
||||
|
||||
@Override
|
||||
public void enableCompression(UserConnection user, int threshold, int algorithm) {
|
||||
final IClientConnection currentConnection = (IClientConnection) user.getChannel().attr(ProtocolHack.LOCAL_MINECRAFT_CONNECTION).get();
|
||||
final Channel channel = user.getChannel();
|
||||
|
||||
try {
|
||||
switch (algorithm) {
|
||||
case 0 -> currentConnection.viafabricplus_enableZLibCompression();
|
||||
case 1 -> currentConnection.viafabricplus_enableSnappyCompression();
|
||||
if (channel.pipeline().names().contains(ViaFabricPlusVLLegacyPipeline.VIABEDROCK_COMPRESSION_HANDLER_NAME)) {
|
||||
throw new IllegalStateException("Compression already enabled");
|
||||
}
|
||||
|
||||
default -> throw new IllegalStateException("Invalid compression algorithm: " + algorithm);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException(e);
|
||||
switch (algorithm) {
|
||||
case 0 -> channel.pipeline().addBefore("splitter", ViaFabricPlusVLLegacyPipeline.VIABEDROCK_COMPRESSION_HANDLER_NAME, new ZLibCompression());
|
||||
case 1 -> channel.pipeline().addBefore("splitter", ViaFabricPlusVLLegacyPipeline.VIABEDROCK_COMPRESSION_HANDLER_NAME, new SnappyCompression());
|
||||
default -> throw new IllegalStateException("Invalid compression algorithm: " + algorithm);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableEncryption(UserConnection user, SecretKey key) {
|
||||
final IClientConnection currentConnection = (IClientConnection) user.getChannel().attr(ProtocolHack.LOCAL_MINECRAFT_CONNECTION).get();
|
||||
final Channel channel = user.getChannel();
|
||||
|
||||
if (channel.pipeline().names().contains(ViaFabricPlusVLLegacyPipeline.VIABEDROCK_ENCRYPTION_HANDLER_NAME)) {
|
||||
throw new IllegalStateException("Encryption already enabled");
|
||||
}
|
||||
|
||||
try {
|
||||
currentConnection.viafabricplus_enableAesGcmEncryption(key);
|
||||
} catch (InvalidAlgorithmParameterException | NoSuchPaddingException | NoSuchAlgorithmException | InvalidKeyException e) {
|
||||
channel.pipeline().addAfter(VLPipeline.VIABEDROCK_FRAME_ENCAPSULATION_HANDLER_NAME, ViaFabricPlusVLLegacyPipeline.VIABEDROCK_ENCRYPTION_HANDLER_NAME, new AesEncryption(key));
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,16 +33,8 @@ import java.net.InetSocketAddress;
|
||||
|
||||
public class ViaFabricPlusTransferProvider extends TransferProvider {
|
||||
|
||||
private void connect(final InetSocketAddress newAddress) {
|
||||
final var mc = MinecraftClient.getInstance();
|
||||
mc.world.disconnect();
|
||||
|
||||
final var serverInfo = new ServerInfo(newAddress.getHostName(), newAddress.getHostName() + ":" + newAddress.getPort(), ServerInfo.ServerType.OTHER);
|
||||
ConnectScreen.connect(new MultiplayerScreen(new TitleScreen()), mc, ServerAddress.parse(serverInfo.address), serverInfo, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectToServer(UserConnection user, InetSocketAddress newAddress) throws Exception {
|
||||
public void connectToServer(UserConnection user, InetSocketAddress newAddress) {
|
||||
final var mc = MinecraftClient.getInstance();
|
||||
mc.execute(() -> {
|
||||
if (BedrockSettings.INSTANCE.confirmServerTransferInBedrockEdition.getValue()) {
|
||||
@ -61,4 +53,13 @@ public class ViaFabricPlusTransferProvider extends TransferProvider {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void connect(final InetSocketAddress newAddress) {
|
||||
final var mc = MinecraftClient.getInstance();
|
||||
mc.world.disconnect();
|
||||
|
||||
final var serverInfo = new ServerInfo(newAddress.getHostName(), newAddress.getHostName() + ":" + newAddress.getPort(), ServerInfo.ServerType.OTHER);
|
||||
ConnectScreen.connect(new MultiplayerScreen(new TitleScreen()), mc, ServerAddress.parse(serverInfo.address), serverInfo, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,9 +27,9 @@ public class ViaFabricPlusEncryptionProvider extends EncryptionProvider {
|
||||
|
||||
@Override
|
||||
public void enableDecryption(UserConnection user) {
|
||||
final ClientConnection clientConnection = user.getChannel().attr(ProtocolHack.LOCAL_MINECRAFT_CONNECTION).get();
|
||||
final ClientConnection clientConnection = user.getChannel().attr(ProtocolHack.CLIENT_CONNECTION_ATTRIBUTE_KEY).get();
|
||||
if (clientConnection != null) {
|
||||
((IClientConnection) clientConnection).viafabricplus_setupPreNettyDecryption();
|
||||
((IClientConnection) clientConnection).viaFabricPlus$setupPreNettyDecryption();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class ViaFabricPlusGameProfileFetcher extends GameProfileFetcher {
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfile loadGameProfile(UUID uuid) throws Exception {
|
||||
public GameProfile loadGameProfile(UUID uuid) {
|
||||
final var result = SESSION_SERVICE.fetchProfile(uuid, true);
|
||||
if (result == null) throw new ProfileNotFoundException();
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class ViaFabricPlusOldAuthProvider extends OldAuthProvider {
|
||||
ViaFabricPlus.LOGGER.error("Error occurred while calling join server to verify session", e);
|
||||
|
||||
if (AuthenticationSettings.INSTANCE.disconnectIfJoinServerCallFails.getValue()) {
|
||||
user.getChannel().attr(ProtocolHack.LOCAL_MINECRAFT_CONNECTION).get().disconnect(ChatUtil.prefixText(Text.translatable("authentication.viafabricplus.error")));
|
||||
user.getChannel().attr(ProtocolHack.CLIENT_CONNECTION_ATTRIBUTE_KEY).get().disconnect(ChatUtil.prefixText(Text.translatable("authentication.viafabricplus.error")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user