mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-11-25 12:25:22 +01:00
Recoded and improved even more ™️
- Added former contributor to author list as well - Cleanup block changes from RaphiMC's last commit - Fixed some block related issues - Conditionally load IP-Next compat mixin - Made all Mixins abstract and methods private This commit is the initial commit to clean up some fundamental issues of VFP since its release: - Actually start with having a package structure to group mixins - Don't over-engineer debug/information system but keep it simple as it's only debugging - Renamed definition package to fixes to address its purpose - Start with creating proper packages for fixes - Start with documenting the source code tree so new contributors understand what we're doing
This commit is contained in:
parent
472289b37c
commit
a50dc89f2f
2
.github/DEVELOPER_API.md
vendored
2
.github/DEVELOPER_API.md
vendored
@ -40,7 +40,7 @@ final VersionRange range = ItemReleaseVersionDefinition.INSTANCE.getItemMap().ge
|
||||
#### Creating own settings for the settings screen:
|
||||
```java
|
||||
public class ExampleSettingGroup extends SettingGroup {
|
||||
public final static ExampleSettingGroup INSTANCE = new ExampleSettingGroup();
|
||||
public static final ExampleSettingGroup INSTANCE = new ExampleSettingGroup();
|
||||
|
||||
public final BooleanSetting test = new BooleanSetting("Test", false);
|
||||
|
||||
|
16
build.gradle
16
build.gradle
@ -10,7 +10,7 @@ base {
|
||||
}
|
||||
|
||||
configurations {
|
||||
jij
|
||||
jij // jar in jar configuration
|
||||
}
|
||||
|
||||
repositories {
|
||||
@ -42,12 +42,14 @@ loom {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Minecraft/Fabric
|
||||
// Minecraft/Fabric and mods
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
|
||||
|
||||
modCompileOnly "com.terraformersmc:modmenu:${project.mod_menu_version}"
|
||||
|
||||
// ViaVersion Libraries
|
||||
jij "com.viaversion:viaversion-common:${project.viaversion_version}"
|
||||
jij ("com.viaversion:viabackwards-common:${project.viabackwards_version}") {
|
||||
@ -75,18 +77,18 @@ dependencies {
|
||||
exclude group: "com.google.code.gson", module: "gson"
|
||||
exclude group: "org.slf4j", module: "slf4j-api"
|
||||
}
|
||||
jij("org.cloudburstmc.netty:netty-transport-raknet:${project.raknet_transport_version}") {
|
||||
exclude group: "io.netty"
|
||||
}
|
||||
|
||||
// Lenni0451 Libraries
|
||||
jij "net.lenni0451:Reflect:${project.reflect_version}"
|
||||
|
||||
// Misc Libraries
|
||||
modCompileOnly "com.terraformersmc:modmenu:${project.mod_menu_version}"
|
||||
jij(annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-fabric:${project.mixin_extras_version}"))
|
||||
jij("org.cloudburstmc.netty:netty-transport-raknet:${project.raknet_transport_version}") {
|
||||
exclude group: "io.netty"
|
||||
}
|
||||
jij "de.florianmichael:Classic4J:${project.classic4j_version}"
|
||||
jij(annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-fabric:${project.mixin_extras_version}"))
|
||||
|
||||
// Fabric's jar in jar system doesn't support transitive dependencies, so we have to manually add them
|
||||
afterEvaluate {
|
||||
configurations.jij.incoming.resolutionResult.allDependencies {
|
||||
dependencies.include(dependencies.implementation(requested.toString()))
|
||||
|
@ -21,14 +21,13 @@ package de.florianmichael.viafabricplus;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
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.fixes.ClientsideFixes;
|
||||
import de.florianmichael.viafabricplus.fixes.account.BedrockAccountHandler;
|
||||
import de.florianmichael.viafabricplus.fixes.account.ClassiCubeAccountHandler;
|
||||
import de.florianmichael.viafabricplus.fixes.classic.CustomClassicProtocolExtensions;
|
||||
import de.florianmichael.viafabricplus.fixes.classic.screen.ClassicItemSelectionScreen;
|
||||
import de.florianmichael.viafabricplus.event.PostGameLoadCallback;
|
||||
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;
|
||||
@ -61,27 +60,24 @@ import java.io.File;
|
||||
*
|
||||
* TODO | Migration v3
|
||||
* - 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
|
||||
* - Remove information package / system
|
||||
* - Re-add Debug Hud information list
|
||||
* - Recode config save base to support singleton Jsons
|
||||
* - Rebase fixes package / change all packages
|
||||
* - Fix auto detect to not be a huge mess
|
||||
*/
|
||||
public class ViaFabricPlus {
|
||||
|
||||
public final static Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
public final static Logger LOGGER = LogManager.getLogger("ViaFabricPlus");
|
||||
public final static File RUN_DIRECTORY = new File("ViaFabricPlus");
|
||||
public static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
public static final Logger LOGGER = LogManager.getLogger("ViaFabricPlus");
|
||||
public static final File RUN_DIRECTORY = new File("ViaFabricPlus");
|
||||
|
||||
public final static ViaFabricPlus INSTANCE = new ViaFabricPlus();
|
||||
public static final ViaFabricPlus INSTANCE = new ViaFabricPlus();
|
||||
|
||||
private final SettingsSystem settingsSystem = new SettingsSystem();
|
||||
private final InformationSystem informationSystem = new InformationSystem();
|
||||
|
||||
public void init() {
|
||||
public void bootstrap() {
|
||||
if (!RUN_DIRECTORY.exists()) {
|
||||
RUN_DIRECTORY.mkdir();
|
||||
}
|
||||
@ -108,13 +104,12 @@ public class ViaFabricPlus {
|
||||
ProtocolHack.init();
|
||||
|
||||
// Stuff which requires Minecraft to be initialized
|
||||
FinishMinecraftLoadCallback.EVENT.register(() -> {
|
||||
PostGameLoadCallback.EVENT.register(() -> {
|
||||
// Has to be loaded before the settings system in order to catch the ChangeProtocolVersionCallback call
|
||||
ClassicItemSelectionScreen.create();
|
||||
|
||||
// General settings
|
||||
settingsSystem.init();
|
||||
informationSystem.init();
|
||||
|
||||
// Version related mappings
|
||||
PackFormatsMappings.load();
|
||||
@ -125,8 +120,4 @@ public class ViaFabricPlus {
|
||||
public SettingsSystem getSettingsSystem() {
|
||||
return settingsSystem;
|
||||
}
|
||||
|
||||
public InformationSystem getInformationSystem() {
|
||||
return informationSystem;
|
||||
}
|
||||
}
|
||||
|
@ -25,10 +25,10 @@ import net.fabricmc.fabric.api.event.EventFactory;
|
||||
/**
|
||||
* This event is fired when the user disconnects from a server.
|
||||
*/
|
||||
public interface DisconnectConnectionCallback {
|
||||
public interface DisconnectCallback {
|
||||
|
||||
Event<DisconnectConnectionCallback> EVENT = EventFactory.createArrayBacked(DisconnectConnectionCallback.class, listeners -> () -> {
|
||||
for (DisconnectConnectionCallback listener : listeners) {
|
||||
Event<DisconnectCallback> EVENT = EventFactory.createArrayBacked(DisconnectCallback.class, listeners -> () -> {
|
||||
for (DisconnectCallback listener : listeners) {
|
||||
listener.onDisconnect();
|
||||
}
|
||||
});
|
@ -25,13 +25,13 @@ import net.fabricmc.fabric.api.event.EventFactory;
|
||||
/**
|
||||
* This event is fired when Minecraft's loading tree is finished. This should be at the end of the {@link net.minecraft.client.MinecraftClient} constructor
|
||||
*/
|
||||
public interface FinishMinecraftLoadCallback {
|
||||
public interface PostGameLoadCallback {
|
||||
|
||||
Event<FinishMinecraftLoadCallback> EVENT = EventFactory.createArrayBacked(FinishMinecraftLoadCallback.class, listeners -> () -> {
|
||||
for (FinishMinecraftLoadCallback listener : listeners) {
|
||||
listener.onFinishMinecraftLoad();
|
||||
Event<PostGameLoadCallback> EVENT = EventFactory.createArrayBacked(PostGameLoadCallback.class, listeners -> () -> {
|
||||
for (PostGameLoadCallback listener : listeners) {
|
||||
listener.postGameLoad();
|
||||
}
|
||||
});
|
||||
|
||||
void onFinishMinecraftLoad();
|
||||
void postGameLoad();
|
||||
}
|
@ -17,9 +17,9 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.definition;
|
||||
package de.florianmichael.viafabricplus.fixes;
|
||||
|
||||
import de.florianmichael.viafabricplus.definition.model.BoatModel_1_8;
|
||||
import de.florianmichael.viafabricplus.fixes.model.BoatModel_1_8;
|
||||
import net.minecraft.client.render.OverlayTexture;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
@ -32,7 +32,7 @@ import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RotationAxis;
|
||||
|
||||
public class BoatRenderer_1_8 extends EntityRenderer<BoatEntity> {
|
||||
private final static Identifier TEXTURE = new Identifier("viafabricplus", "textures/boat_1_8.png");
|
||||
private static final Identifier TEXTURE = new Identifier("viafabricplus", "textures/boat_1_8.png");
|
||||
private final BoatModel_1_8 model;
|
||||
|
||||
public BoatRenderer_1_8(EntityRendererFactory.Context ctx) {
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.definition;
|
||||
package de.florianmichael.viafabricplus.fixes;
|
||||
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
@ -37,7 +37,7 @@ import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ClientPlayerInteractionManager1_18_2 {
|
||||
public final static Consumer<PacketByteBuf> OLD_PACKET_HANDLER = data -> {
|
||||
public static final Consumer<PacketByteBuf> OLD_PACKET_HANDLER = data -> {
|
||||
try {
|
||||
final var pos = data.readBlockPos();
|
||||
final var blockState = Block.STATE_IDS.get(BlockStateTranslator.translateBlockState1_18(data.readVarInt()));
|
||||
@ -50,7 +50,7 @@ public class ClientPlayerInteractionManager1_18_2 {
|
||||
}
|
||||
};
|
||||
|
||||
private final static Object2ObjectLinkedOpenHashMap<Pair<BlockPos, PlayerActionC2SPacket.Action>, PositionAndRotation> UN_ACKED_ACTIONS = new Object2ObjectLinkedOpenHashMap<>();
|
||||
private static final Object2ObjectLinkedOpenHashMap<Pair<BlockPos, PlayerActionC2SPacket.Action>, PositionAndRotation> UN_ACKED_ACTIONS = new Object2ObjectLinkedOpenHashMap<>();
|
||||
|
||||
public static void trackBlockAction(final PlayerActionC2SPacket.Action action, final BlockPos blockPos) {
|
||||
final var player = MinecraftClient.getInstance().player;
|
@ -17,13 +17,13 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.definition;
|
||||
package de.florianmichael.viafabricplus.fixes;
|
||||
|
||||
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.PostGameLoadCallback;
|
||||
import de.florianmichael.viafabricplus.event.LoadClassicProtocolExtensionCallback;
|
||||
import de.florianmichael.viafabricplus.injection.MixinPlugin;
|
||||
import de.florianmichael.viafabricplus.injection.VFPMixinPlugin;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
@ -55,22 +55,22 @@ public class ClientsideFixes {
|
||||
/**
|
||||
* Legacy versions do not support SRV records, so we need to resolve them manually
|
||||
*/
|
||||
public final static VersionRange LEGACY_SRV_RESOLVE = VersionRange.andOlder(VersionEnum.r1_2_4tor1_2_5).add(VersionRange.single(VersionEnum.bedrockLatest));
|
||||
public static final VersionRange LEGACY_SRV_RESOLVE = VersionRange.andOlder(VersionEnum.r1_2_4tor1_2_5).add(VersionRange.single(VersionEnum.bedrockLatest));
|
||||
|
||||
/**
|
||||
* Contains the armor points of all armor items in legacy versions (<= 1.8.x)
|
||||
*/
|
||||
private final static Map<Item, Integer> LEGACY_ARMOR_POINTS = new HashMap<>();
|
||||
private static final Map<Item, Integer> LEGACY_ARMOR_POINTS = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Contains all tasks that are waiting for a packet to be received, this system can be used to sync ViaVersion tasks with the correct thread
|
||||
*/
|
||||
private final static Map<String, Consumer<PacketByteBuf>> PENDING_EXECUTION_TASKS = new ConcurrentHashMap<>();
|
||||
private static final Map<String, Consumer<PacketByteBuf>> PENDING_EXECUTION_TASKS = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* This identifier is an internal identifier that is used to identify packets that are sent by ViaFabricPlus
|
||||
*/
|
||||
public final static String PACKET_SYNC_IDENTIFIER = UUID.randomUUID() + ":" + UUID.randomUUID();
|
||||
public static final String PACKET_SYNC_IDENTIFIER = UUID.randomUUID() + ":" + UUID.randomUUID();
|
||||
|
||||
/**
|
||||
* The current chat limit
|
||||
@ -78,7 +78,7 @@ public class ClientsideFixes {
|
||||
private static int currentChatLimit = 256;
|
||||
|
||||
public static void init() {
|
||||
FinishMinecraftLoadCallback.EVENT.register(() -> {
|
||||
PostGameLoadCallback.EVENT.register(() -> {
|
||||
// Loads the armor points of all armor items in legacy versions (<= 1.8.x)
|
||||
for (Item armorItem : Arrays.asList(Items.LEATHER_HELMET, Items.LEATHER_CHESTPLATE, Items.LEATHER_BOOTS,
|
||||
Items.CHAINMAIL_HELMET, Items.CHAINMAIL_CHESTPLATE, Items.CHAINMAIL_LEGGINGS, Items.CHAINMAIL_BOOTS,
|
||||
@ -125,7 +125,7 @@ public class ClientsideFixes {
|
||||
currentChatLimit = 256;
|
||||
}
|
||||
|
||||
if (!MixinPlugin.DASH_LOADER_PRESENT) {
|
||||
if (!VFPMixinPlugin.DASH_LOADER_PRESENT) {
|
||||
// Reloads all font storages to fix the font renderer
|
||||
for (FontStorage storage : MinecraftClient.getInstance().fontManager.fontStorages.values()) {
|
||||
storage.glyphRendererCache.clear();
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.definition;
|
||||
package de.florianmichael.viafabricplus.fixes;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.entity.*;
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.definition;
|
||||
package de.florianmichael.viafabricplus.fixes;
|
||||
|
||||
import net.minecraft.block.ConcretePowderBlock;
|
||||
import net.minecraft.block.GlazedTerracottaBlock;
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.definition;
|
||||
package de.florianmichael.viafabricplus.fixes;
|
||||
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
@ -35,7 +35,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class TripleChestHandler1_13_2 {
|
||||
public final static Consumer<PacketByteBuf> TRIPLE_CHEST_HANDLER = data -> {
|
||||
public static final Consumer<PacketByteBuf> TRIPLE_CHEST_HANDLER = data -> {
|
||||
final var byteBuf = data.asByteBuf();
|
||||
|
||||
try {
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.definition.account;
|
||||
package de.florianmichael.viafabricplus.fixes.account;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
@ -17,11 +17,11 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.definition.account;
|
||||
package de.florianmichael.viafabricplus.fixes.account;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import de.florianmichael.classic4j.model.classicube.account.CCAccount;
|
||||
import de.florianmichael.viafabricplus.event.DisconnectConnectionCallback;
|
||||
import de.florianmichael.viafabricplus.event.DisconnectCallback;
|
||||
import de.florianmichael.viafabricplus.protocolhack.provider.vialegacy.ViaFabricPlusClassicMPPassProvider;
|
||||
import de.florianmichael.viafabricplus.util.FileSaver;
|
||||
|
||||
@ -41,7 +41,7 @@ public class ClassiCubeAccountHandler extends FileSaver {
|
||||
public ClassiCubeAccountHandler() {
|
||||
super("classicube.account");
|
||||
|
||||
DisconnectConnectionCallback.EVENT.register(() -> ViaFabricPlusClassicMPPassProvider.classiCubeMPPass = null);
|
||||
DisconnectCallback.EVENT.register(() -> ViaFabricPlusClassicMPPassProvider.classiCubeMPPass = null);
|
||||
}
|
||||
|
||||
@Override
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.definition.classic;
|
||||
package de.florianmichael.viafabricplus.fixes.classic;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
@ -17,10 +17,10 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.definition.classic;
|
||||
package de.florianmichael.viafabricplus.fixes.classic;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.definition.classic.screen.ClassicItemSelectionScreen;
|
||||
import de.florianmichael.viafabricplus.fixes.classic.screen.ClassicItemSelectionScreen;
|
||||
import de.florianmichael.viafabricplus.event.LoadClassicProtocolExtensionCallback;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import io.netty.buffer.ByteBuf;
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.definition.classic.command;
|
||||
package de.florianmichael.viafabricplus.fixes.classic.command;
|
||||
|
||||
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
||||
import com.viaversion.viaversion.api.command.ViaSubCommand;
|
||||
@ -35,6 +35,6 @@ public abstract class ClassicViaSubCommand extends ViaSubCommand {
|
||||
}
|
||||
|
||||
public UserConnection getUser() {
|
||||
return ProtocolHack.getMainUserConnection();
|
||||
return ProtocolHack.getPlayNetworkUserConnection();
|
||||
}
|
||||
}
|
@ -17,11 +17,11 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.definition.classic.command.impl;
|
||||
package de.florianmichael.viafabricplus.fixes.classic.command.impl;
|
||||
|
||||
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.definition.classic.command.ClassicViaSubCommand;
|
||||
import de.florianmichael.viafabricplus.fixes.classic.command.ClassicViaSubCommand;
|
||||
import de.florianmichael.viafabricplus.injection.access.IExtensionProtocolMetadataStorage;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.storage.ExtensionProtocolMetadataStorage;
|
@ -17,11 +17,11 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.definition.classic.command.impl;
|
||||
package de.florianmichael.viafabricplus.fixes.classic.command.impl;
|
||||
|
||||
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.definition.classic.command.ClassicViaSubCommand;
|
||||
import de.florianmichael.viafabricplus.fixes.classic.command.ClassicViaSubCommand;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialegacy.protocols.alpha.protocola1_0_17_1_0_17_4toa1_0_16_2.storage.TimeLockStorage;
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.definition.classic.screen;
|
||||
package de.florianmichael.viafabricplus.fixes.classic.screen;
|
||||
|
||||
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
|
||||
import de.florianmichael.viafabricplus.screen.VFPScreen;
|
||||
@ -46,10 +46,10 @@ public class ClassicItemSelectionScreen extends VFPScreen {
|
||||
});
|
||||
}
|
||||
|
||||
private final static int MAX_ROW_DIVIDER = 9;
|
||||
private final static int ITEM_XY_BOX_DIMENSION_CLASSIC = 25;
|
||||
private final static int SIDE_OFFSET = 15;
|
||||
private final static int ITEM_XY_BOX_DIMENSION_MODERN = 16;
|
||||
private static final int MAX_ROW_DIVIDER = 9;
|
||||
private static final int ITEM_XY_BOX_DIMENSION_CLASSIC = 25;
|
||||
private static final int SIDE_OFFSET = 15;
|
||||
private static final int ITEM_XY_BOX_DIMENSION_MODERN = 16;
|
||||
|
||||
public Item[][] itemGrid = null;
|
||||
public ItemStack selectedItem = null;
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.definition.model;
|
||||
package de.florianmichael.viafabricplus.fixes.model;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.client.model.*;
|
||||
@ -27,7 +27,7 @@ import net.minecraft.entity.vehicle.BoatEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class BoatModel_1_8 extends CompositeEntityModel<BoatEntity> {
|
||||
public final static EntityModelLayer MODEL_LAYER = new EntityModelLayer(new Identifier("viafabricplus", "boat_1_8"), "main");
|
||||
public static final EntityModelLayer MODEL_LAYER = new EntityModelLayer(new Identifier("viafabricplus", "boat_1_8"), "main");
|
||||
private final ImmutableList<ModelPart> parts;
|
||||
|
||||
public BoatModel_1_8(ModelPart root) {
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.definition.model;
|
||||
package de.florianmichael.viafabricplus.fixes.model;
|
||||
|
||||
import net.minecraft.client.font.Glyph;
|
||||
import net.minecraft.client.font.GlyphRenderer;
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.definition.model;
|
||||
package de.florianmichael.viafabricplus.fixes.model;
|
||||
|
||||
import com.mojang.authlib.yggdrasil.response.KeyPairResponse;
|
||||
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.definition.tracker;
|
||||
package de.florianmichael.viafabricplus.fixes.tracker;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.definition.tracker;
|
||||
package de.florianmichael.viafabricplus.fixes.tracker;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.definition.tracker;
|
||||
package de.florianmichael.viafabricplus.fixes.tracker;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
@ -39,7 +39,7 @@ public class WolfHealthTracker extends StoredObject {
|
||||
}
|
||||
|
||||
public static WolfHealthTracker get() {
|
||||
final var connection = ProtocolHack.getMainUserConnection();
|
||||
final var connection = ProtocolHack.getPlayNetworkUserConnection();
|
||||
if (connection == null) return null;
|
||||
|
||||
if (!connection.has(WolfHealthTracker.class)) {
|
@ -1,56 +0,0 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD
|
||||
* Copyright (C) 2023 RK_01/RaphiMC 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.information;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import net.raphimc.vialoader.util.VersionRange;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AbstractInformationGroup {
|
||||
private final VersionRange versionRange;
|
||||
|
||||
public AbstractInformationGroup(final VersionRange versionRange) {
|
||||
this.versionRange = versionRange;
|
||||
}
|
||||
|
||||
public abstract void applyInformation(final UserConnection userConnection, final List<String> output);
|
||||
|
||||
public String format(double a) {
|
||||
return String.format("%.2f", a);
|
||||
}
|
||||
|
||||
public String formatBytes(long value) {
|
||||
if (value < 1024L)
|
||||
return value + " B";
|
||||
else if (value < 1024L * 1024L)
|
||||
return format(((double) value / 1024.0)) + " Kb";
|
||||
else if (value < 1024L * 1024L * 1024L)
|
||||
return format(((double) value / 1024.0 / 1024.0)) + " Mb";
|
||||
else if (value < 1024L * 1024L * 1024L * 1024L)
|
||||
return format(((double) value / 1024.0 / 1024.0 / 1024.0)) + " Gb";
|
||||
else
|
||||
return format(((double) value / 1024.0 / 1024.0 / 1024.0 / 1024.0)) + " Tb";
|
||||
}
|
||||
|
||||
public VersionRange getVersionRange() {
|
||||
return versionRange;
|
||||
}
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD
|
||||
* Copyright (C) 2023 RK_01/RaphiMC 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.information;
|
||||
|
||||
import de.florianmichael.viafabricplus.information.impl.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class InformationSystem {
|
||||
private final List<AbstractInformationGroup> groups = new ArrayList<>();
|
||||
|
||||
public void init() {
|
||||
addGroup(
|
||||
new GeneralInformation(),
|
||||
|
||||
new BedrockInformation(),
|
||||
|
||||
new V1_7_10Information(),
|
||||
new V1_5_2Information(),
|
||||
new V1_2_4_5Information(),
|
||||
new V1_1Information(),
|
||||
|
||||
new C0_30CPEInformation()
|
||||
);
|
||||
}
|
||||
|
||||
public void addGroup(final AbstractInformationGroup... groups) {
|
||||
Collections.addAll(this.groups, groups);
|
||||
}
|
||||
|
||||
public List<AbstractInformationGroup> getGroups() {
|
||||
return groups;
|
||||
}
|
||||
}
|
@ -1,112 +0,0 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD
|
||||
* Copyright (C) 2023 RK_01/RaphiMC 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.information.impl;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.definition.tracker.JoinGameTracker;
|
||||
import de.florianmichael.viafabricplus.information.AbstractInformationGroup;
|
||||
import de.florianmichael.viafabricplus.protocolhack.provider.viabedrock.ViaFabricPlusBlobCacheProvider;
|
||||
import net.lenni0451.reflect.stream.RStream;
|
||||
import net.lenni0451.reflect.stream.field.FieldStream;
|
||||
import net.raphimc.viabedrock.api.chunk.BedrockChunk;
|
||||
import net.raphimc.viabedrock.api.model.entity.Entity;
|
||||
import net.raphimc.viabedrock.protocol.data.enums.bedrock.ServerMovementModes;
|
||||
import net.raphimc.viabedrock.protocol.providers.BlobCacheProvider;
|
||||
import net.raphimc.viabedrock.protocol.storage.BlobCache;
|
||||
import net.raphimc.viabedrock.protocol.storage.ChunkTracker;
|
||||
import net.raphimc.viabedrock.protocol.storage.GameSessionStorage;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialoader.util.VersionRange;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class BedrockInformation extends AbstractInformationGroup {
|
||||
|
||||
public BedrockInformation() {
|
||||
super(VersionRange.single(VersionEnum.bedrockLatest));
|
||||
}
|
||||
|
||||
public String formatMovementMode(final int movementMode) {
|
||||
if (movementMode == ServerMovementModes.CLIENT) return "Client";
|
||||
if (movementMode == ServerMovementModes.SERVER) return "Server";
|
||||
|
||||
return "Server with rewind";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyInformation(UserConnection userConnection, List<String> output) {
|
||||
final ViaFabricPlusBlobCacheProvider blobCache = (ViaFabricPlusBlobCacheProvider) Via.getManager().getProviders().get(BlobCacheProvider.class);
|
||||
if (blobCache != null) {
|
||||
final long totalSize = blobCache.getSize();
|
||||
final int blobCount = blobCache.getBlobs().size();
|
||||
final int pendingCount = RStream.of(userConnection.get(BlobCache.class)).fields().by("pending").<Map<Long, CompletableFuture<byte[]>>>get().size();
|
||||
|
||||
if (totalSize != 0 || blobCount != 0 || pendingCount != 0) {
|
||||
output.add("Blob Cache:");
|
||||
}
|
||||
|
||||
if (totalSize != 0) output.add("Total size: " + formatBytes(totalSize));
|
||||
if (blobCount != 0) output.add("Blob count: " + blobCount);
|
||||
if (pendingCount != 0) output.add("Pending count: " + pendingCount);
|
||||
}
|
||||
final ChunkTracker chunkTracker = userConnection.get(ChunkTracker.class);
|
||||
if (chunkTracker != null) {
|
||||
final FieldStream fields = RStream.of(chunkTracker).fields();
|
||||
final int subChunkRequests = fields.by("subChunkRequests").<Set<Object>>get().size();
|
||||
final int pendingSubChunks = fields.by("pendingSubChunks").<Set<Object>>get().size();
|
||||
final int chunks = fields.by("chunks").<Map<Long, BedrockChunk>>get().size();
|
||||
|
||||
if (subChunkRequests != 0 || pendingSubChunks != 0 || chunks != 0) {
|
||||
if (!output.isEmpty()) output.add("");
|
||||
output.add("Chunk Tracker:");
|
||||
}
|
||||
|
||||
if (subChunkRequests != 0) output.add("Sub-chunk requests: " + subChunkRequests);
|
||||
if (pendingSubChunks != 0) output.add("Pending Sub-chunks: " + pendingSubChunks);
|
||||
if (chunks != 0) output.add("Chunks: " + chunks);
|
||||
}
|
||||
final net.raphimc.viabedrock.protocol.storage.EntityTracker entityTracker = userConnection.get(net.raphimc.viabedrock.protocol.storage.EntityTracker.class);
|
||||
if (entityTracker != null) {
|
||||
if (!output.isEmpty()) output.add("");
|
||||
final int entities = RStream.of(entityTracker).fields().by("entities").<Map<Long, Entity>>get().size();
|
||||
|
||||
if (entities != 0) {
|
||||
output.add("Entity Tracker: " + entities);
|
||||
}
|
||||
}
|
||||
final JoinGameTracker joinGameTracker = userConnection.get(JoinGameTracker.class);
|
||||
if (!joinGameTracker.getLevelId().isEmpty() || joinGameTracker.getSeed() != 0 || joinGameTracker.getEnchantmentSeed() != 0) {
|
||||
if (!output.isEmpty()) output.add("");
|
||||
output.add("Join Game:");
|
||||
}
|
||||
if (joinGameTracker.getSeed() != 0) output.add("World Seed: " + joinGameTracker.getSeed());
|
||||
if (!joinGameTracker.getLevelId().isEmpty()) output.add("Level Id: " + joinGameTracker.getLevelId());
|
||||
if (joinGameTracker.getEnchantmentSeed() != 0) output.add("Enchantment Seed: " + joinGameTracker.getEnchantmentSeed());
|
||||
|
||||
final GameSessionStorage gameSessionStorage = userConnection.get(GameSessionStorage.class);
|
||||
if (gameSessionStorage != null) {
|
||||
output.add("Movement mode: " + formatMovementMode(gameSessionStorage.getMovementMode()));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD
|
||||
* Copyright (C) 2023 RK_01/RaphiMC 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.information.impl;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.information.AbstractInformationGroup;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.storage.ExtensionProtocolMetadataStorage;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialoader.util.VersionRange;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class C0_30CPEInformation extends AbstractInformationGroup {
|
||||
|
||||
public C0_30CPEInformation() {
|
||||
super(VersionRange.single(VersionEnum.c0_30cpe));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyInformation(UserConnection userConnection, List<String> output) {
|
||||
if (userConnection.has(ExtensionProtocolMetadataStorage.class)) output.add("Classic extensions: " + userConnection.get(ExtensionProtocolMetadataStorage.class).getExtensionCount());
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD
|
||||
* Copyright (C) 2023 RK_01/RaphiMC 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.information.impl;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.information.AbstractInformationGroup;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GeneralInformation extends AbstractInformationGroup {
|
||||
|
||||
public GeneralInformation() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@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.getTargetVersion().getName() + " (" + ProtocolHack.getTargetVersion().getVersion() + ")");
|
||||
output.add("Connected version: " + ProtocolHack.getTargetVersion().getName() + " (" + ProtocolHack.getTargetVersion().getVersion() + ")");
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD
|
||||
* Copyright (C) 2023 RK_01/RaphiMC 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.information.impl;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.information.AbstractInformationGroup;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_2_1_3to1_1.storage.SeedStorage;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialoader.util.VersionRange;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class V1_1Information extends AbstractInformationGroup {
|
||||
|
||||
public V1_1Information() {
|
||||
super(VersionRange.andOlder(VersionEnum.r1_1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyInformation(UserConnection userConnection, List<String> output) {
|
||||
if (userConnection.has(SeedStorage.class)) {
|
||||
final long seed = userConnection.get(SeedStorage.class).seed;
|
||||
if (seed != 0) output.add("World Seed: " + seed);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD
|
||||
* Copyright (C) 2023 RK_01/RaphiMC 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.information.impl;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.information.AbstractInformationGroup;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.storage.EntityTracker;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialoader.util.VersionRange;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class V1_2_4_5Information extends AbstractInformationGroup {
|
||||
|
||||
public V1_2_4_5Information() {
|
||||
super(VersionRange.andOlder(VersionEnum.r1_2_4tor1_2_5));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyInformation(UserConnection userConnection, List<String> output) {
|
||||
if (userConnection.has(EntityTracker.class)) {
|
||||
final int entities = userConnection.get(EntityTracker.class).getTrackedEntities().size();
|
||||
if (entities != 0) output.add("Entity Tracker: " + entities);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD
|
||||
* Copyright (C) 2023 RK_01/RaphiMC 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.information.impl;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.information.AbstractInformationGroup;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_6_1to1_5_2.storage.EntityTracker;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialoader.util.VersionRange;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class V1_5_2Information extends AbstractInformationGroup {
|
||||
|
||||
public V1_5_2Information() {
|
||||
super(VersionRange.andOlder(VersionEnum.r1_5_2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyInformation(UserConnection userConnection, List<String> output) {
|
||||
if (userConnection.has(EntityTracker.class)) {
|
||||
final int entities = userConnection.get(EntityTracker.class).getTrackedEntities().size();
|
||||
if (entities != 0) output.add("Entity Tracker: " + entities);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD
|
||||
* Copyright (C) 2023 RK_01/RaphiMC 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.information.impl;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.information.AbstractInformationGroup;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.storage.EntityTracker;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialoader.util.VersionRange;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class V1_7_10Information extends AbstractInformationGroup {
|
||||
|
||||
public V1_7_10Information() {
|
||||
super(VersionRange.andOlder(VersionEnum.r1_7_6tor1_7_10));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyInformation(UserConnection userConnection, List<String> output) {
|
||||
if (userConnection.has(EntityTracker.class)) {
|
||||
final int entities = userConnection.get(EntityTracker.class).getTrackedEntities().size();
|
||||
if (entities != 0) output.add("Entity Tracker: " + entities);
|
||||
}
|
||||
}
|
||||
}
|
@ -27,19 +27,23 @@ import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class MixinPlugin implements IMixinConfigPlugin {
|
||||
public final static String INJECTOR_PACKAGE = "de.florianmichael.viafabricplus.injection.mixin";
|
||||
private final static String MC_FIXES_PACKAGE = ".fixes.minecraft";
|
||||
public class VFPMixinPlugin implements IMixinConfigPlugin {
|
||||
public static final String INJECTOR_PACKAGE = "de.florianmichael.viafabricplus.injection.mixin.";
|
||||
|
||||
private static final String MC_FIXES_PACKAGE = "fixes.minecraft.";
|
||||
private static final String COMPAT_PACKAGE = "compat.";
|
||||
|
||||
public static boolean DASH_LOADER_PRESENT;
|
||||
public static boolean ARMOR_SKIN_PRESENT;
|
||||
public static boolean IPNEXT_PRESENT;
|
||||
|
||||
@Override
|
||||
public void onLoad(String mixinPackage) {
|
||||
final var loader = FabricLoader.getInstance();
|
||||
final FabricLoader loader = FabricLoader.getInstance();
|
||||
|
||||
DASH_LOADER_PRESENT = loader.isModLoaded("dashloader");
|
||||
ARMOR_SKIN_PRESENT = loader.isModLoaded("armorskin");
|
||||
IPNEXT_PRESENT = loader.isModLoaded("inventoryprofilesnext");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -49,12 +53,15 @@ public class MixinPlugin implements IMixinConfigPlugin {
|
||||
|
||||
@Override
|
||||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
|
||||
if (mixinClassName.equals(INJECTOR_PACKAGE + MC_FIXES_PACKAGE + ".MixinFontStorage")) {
|
||||
if (mixinClassName.equals(INJECTOR_PACKAGE + MC_FIXES_PACKAGE + "MixinFontStorage")) {
|
||||
return !DASH_LOADER_PRESENT;
|
||||
}
|
||||
if (mixinClassName.equals(INJECTOR_PACKAGE + MC_FIXES_PACKAGE + ".MixinInGameHud")) {
|
||||
if (mixinClassName.equals(INJECTOR_PACKAGE + MC_FIXES_PACKAGE + "MixinInGameHud")) {
|
||||
return !ARMOR_SKIN_PRESENT;
|
||||
}
|
||||
if (mixinClassName.equals(INJECTOR_PACKAGE + COMPAT_PACKAGE + "ipnext.MixinAutoRefillHandler_ItemSlotMonitor")) {
|
||||
return IPNEXT_PRESENT;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
@ -26,8 +26,8 @@ public interface IClientConnection {
|
||||
|
||||
void viaFabricPlus$setupPreNettyDecryption();
|
||||
|
||||
VersionEnum viaFabricPlus$getServerVersion();
|
||||
void viaFabricPlus$setServerVersion(final VersionEnum serverVersion);
|
||||
VersionEnum viaFabricPlus$getTargetVersion();
|
||||
void viaFabricPlus$setTargetVersion(final VersionEnum serverVersion);
|
||||
|
||||
UserConnection viaFabricPlus$getUserConnection();
|
||||
void viaFabricPlus$setUserConnection(final UserConnection userConnection);
|
||||
|
@ -1,29 +0,0 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD
|
||||
* Copyright (C) 2023 RK_01/RaphiMC 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.nio.ByteBuffer;
|
||||
|
||||
public interface IKeyPairResponse {
|
||||
|
||||
ByteBuffer viafabricplus$getLegacyPublicKeySignature();
|
||||
|
||||
void viafabricplus$setLegacyPublicKeySignature(final ByteBuffer signature);
|
||||
}
|
@ -19,10 +19,9 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.access;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
public interface ILegacyKeySignatureStorage {
|
||||
|
||||
public interface IPublicKeyData {
|
||||
byte[] viafabricplus$getLegacyPublicKeySignature();
|
||||
|
||||
ByteBuffer viaFabricPlus$getV1Key();
|
||||
void viaFabricPlus$setV1Key(final ByteBuffer oldKey);
|
||||
void viafabricplus$setLegacyPublicKeySignature(final byte[] signature);
|
||||
}
|
@ -27,10 +27,11 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(Main.class)
|
||||
public class MixinMain {
|
||||
public abstract class MixinMain {
|
||||
|
||||
@Inject(method = "main", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/crash/CrashReport;initCrashReport()V"))
|
||||
private static void preLoad(CallbackInfo ci) {
|
||||
ViaFabricPlus.INSTANCE.init();
|
||||
private static void bootstrap(CallbackInfo ci) {
|
||||
ViaFabricPlus.INSTANCE.bootstrap();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,11 +17,11 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.connect;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.event.DisconnectConnectionCallback;
|
||||
import de.florianmichael.viafabricplus.event.DisconnectCallback;
|
||||
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
|
||||
import de.florianmichael.viafabricplus.injection.access.IPerformanceLog;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
@ -86,7 +86,7 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
|
||||
}
|
||||
|
||||
@Inject(method = "setupEncryption", at = @At("HEAD"), cancellable = true)
|
||||
private void storeEncryptionCiphers(Cipher decryptionCipher, Cipher encryptionCipher, CallbackInfo ci) {
|
||||
private void storeDecryptionCipher(Cipher decryptionCipher, Cipher encryptionCipher, CallbackInfo ci) {
|
||||
if (this.viaFabricPlus$serverVersion.isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
ci.cancel();
|
||||
this.viaFabricPlus$decryptionCipher = decryptionCipher;
|
||||
@ -110,9 +110,9 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
|
||||
}
|
||||
|
||||
@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) {
|
||||
private static void setTargetVersion(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());
|
||||
((IClientConnection) clientConnection).viaFabricPlus$setTargetVersion(mixinPerformanceLog.viaFabricPlus$getForcedVersion());
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,44 +126,54 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
|
||||
}
|
||||
|
||||
@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());
|
||||
private static void setTargetVersion(InetSocketAddress address, boolean useEpoll, ClientConnection connection, CallbackInfoReturnable<ChannelFuture> cir) {
|
||||
if (((IClientConnection) connection).viaFabricPlus$getTargetVersion() == null) {
|
||||
((IClientConnection) connection).viaFabricPlus$setTargetVersion(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));
|
||||
private static AbstractBootstrap<?, ?> useRakNetChannelFactory(Bootstrap instance, Class<? extends Channel> channelTypeClass, @Local(argsOnly = true) ClientConnection clientConnection) {
|
||||
if (VersionEnum.bedrockLatest.equals(((IClientConnection) clientConnection).viaFabricPlus$getTargetVersion())) {
|
||||
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");
|
||||
}
|
||||
});
|
||||
private static ChannelFuture useRakNetPingHandlers(Bootstrap instance, InetAddress inetHost, int inetPort, @Local(argsOnly = true) ClientConnection clientConnection, @Local(argsOnly = true) boolean isConnecting) {
|
||||
if (VersionEnum.bedrockLatest.equals(((IClientConnection) clientConnection).viaFabricPlus$getTargetVersion()) && !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"))
|
||||
private void resetStorages(Text disconnectReason, CallbackInfo ci) {
|
||||
DisconnectConnectionCallback.EVENT.invoker().onDisconnect();
|
||||
private void callDisconnectCallback(Text disconnectReason, CallbackInfo ci) {
|
||||
DisconnectCallback.EVENT.invoker().onDisconnect();
|
||||
}
|
||||
|
||||
@Unique
|
||||
public void viaFabricPlus$setupPreNettyEncryption(final Cipher encryptionCipher) {
|
||||
if (encryptionCipher == null) throw new IllegalStateException("Encryption cipher is null");
|
||||
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));
|
||||
@ -171,7 +181,9 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
|
||||
|
||||
@Override
|
||||
public void viaFabricPlus$setupPreNettyDecryption() {
|
||||
if (this.viaFabricPlus$decryptionCipher == null) throw new IllegalStateException("Decryption cipher is null");
|
||||
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));
|
||||
@ -188,12 +200,12 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionEnum viaFabricPlus$getServerVersion() {
|
||||
public VersionEnum viaFabricPlus$getTargetVersion() {
|
||||
return this.viaFabricPlus$serverVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaFabricPlus$setServerVersion(final VersionEnum serverVersion) {
|
||||
public void viaFabricPlus$setTargetVersion(final VersionEnum serverVersion) {
|
||||
this.viaFabricPlus$serverVersion = serverVersion;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.connect;
|
||||
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import io.netty.channel.Channel;
|
||||
@ -30,7 +30,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(targets = "net.minecraft.network.ClientConnection$1")
|
||||
public class MixinClientConnection_1 {
|
||||
public abstract class MixinClientConnection_1 {
|
||||
|
||||
@Final
|
||||
@Shadow
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.connect;
|
||||
|
||||
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
|
||||
import net.minecraft.client.network.ClientLoginNetworkHandler;
|
||||
@ -34,16 +34,16 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@SuppressWarnings("DataFlowIssue")
|
||||
@Mixin(ClientLoginNetworkHandler.class)
|
||||
public class MixinClientLoginNetworkHandler {
|
||||
public abstract class MixinClientLoginNetworkHandler {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private ClientConnection connection;
|
||||
|
||||
@Inject(method = "joinServerSession", at = @At("HEAD"), cancellable = true)
|
||||
public void dontVerifySessionIfCracked(String serverId, CallbackInfoReturnable<Text> cir) {
|
||||
public void onlyVerifySessionInOnlineMode(String serverId, CallbackInfoReturnable<Text> cir) {
|
||||
final IClientConnection mixinClientConnection = (IClientConnection) connection;
|
||||
if (mixinClientConnection.viaFabricPlus$getServerVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
if (mixinClientConnection.viaFabricPlus$getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||
if (!mixinClientConnection.viaFabricPlus$getUserConnection().get(ProtocolMetadataStorage.class).authenticate) {
|
||||
cir.setReturnValue(null);
|
||||
}
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.integration;
|
||||
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import de.florianmichael.viafabricplus.screen.common.ForceVersionScreen;
|
||||
@ -38,7 +38,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(AddServerScreen.class)
|
||||
public class MixinAddServerScreen extends Screen {
|
||||
public abstract class MixinAddServerScreen extends Screen {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
@ -61,9 +61,10 @@ public class MixinAddServerScreen extends Screen {
|
||||
}
|
||||
|
||||
@Inject(method = "init", at = @At("RETURN"))
|
||||
private void injectButton(CallbackInfo ci) {
|
||||
private void addVersionSetterButton(CallbackInfo ci) {
|
||||
final VersionEnum forcedVersion = ((IServerInfo) server).viaFabricPlus$forcedVersion();
|
||||
|
||||
// Restore input if the user cancels the version selection screen (or if the user is editing an existing server)
|
||||
if (viaFabricPlus$nameField != null && viaFabricPlus$addressField != null) {
|
||||
this.serverNameField.setText(viaFabricPlus$nameField);
|
||||
this.addressField.setText(viaFabricPlus$addressField);
|
||||
@ -72,21 +73,20 @@ public class MixinAddServerScreen extends Screen {
|
||||
viaFabricPlus$addressField = null;
|
||||
}
|
||||
|
||||
var builder = ButtonWidget.builder(forcedVersion == null ? Text.translatable("misc.viafabricplus.addserverscreenbuttontitle") : Text.literal(forcedVersion.getName()), button -> {
|
||||
// Create the button
|
||||
ButtonWidget.Builder buttonBuilder = ButtonWidget.builder(forcedVersion == null ? Text.translatable("misc.viafabricplus.addserverscreenbuttontitle") : Text.literal(forcedVersion.getName()), button -> {
|
||||
// Store current input in case the user cancels the version selection
|
||||
viaFabricPlus$nameField = serverNameField.getText();
|
||||
viaFabricPlus$addressField = addressField.getText();
|
||||
|
||||
client.setScreen(new ForceVersionScreen(this, version -> ((IServerInfo) server).viaFabricPlus$forceVersion(version)));
|
||||
});
|
||||
}).size(98, 20);
|
||||
|
||||
final int orientation = GeneralSettings.INSTANCE.addServerScreenButtonOrientation.getIndex();
|
||||
switch (orientation) {
|
||||
case 0 -> builder = builder.position(5, 5);
|
||||
case 1 -> builder = builder.position(width - (forcedVersion == null ? 150 : 98) - 5, 5);
|
||||
case 2 -> builder = builder.position(5, height - 20 - 5);
|
||||
case 3 -> builder = builder.position(width - (forcedVersion == null ? 150 : 98) - 5, height - 20 - 5);
|
||||
}
|
||||
// Set the button's position according to the configured orientation
|
||||
buttonBuilder = GeneralSettings.withOrientation(buttonBuilder, GeneralSettings.INSTANCE.addServerScreenButtonOrientation.getIndex(), width, height);
|
||||
|
||||
this.addDrawableChild(builder.size(forcedVersion == null ? 150 : 98, 20).build());
|
||||
// Add the button to the screen
|
||||
this.addDrawableChild(buttonBuilder.build());
|
||||
}
|
||||
|
||||
}
|
@ -17,14 +17,9 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.integration;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.information.AbstractInformationGroup;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.settings.impl.GeneralSettings;
|
||||
import de.florianmichael.viafabricplus.util.ChatUtil;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.hud.DebugHud;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@ -36,33 +31,14 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(DebugHud.class)
|
||||
public class MixinDebugHud {
|
||||
public abstract class MixinDebugHud {
|
||||
|
||||
@Inject(method = "getLeftText", at = @At("RETURN"))
|
||||
public void addViaFabricPlusInformation(CallbackInfoReturnable<List<String>> cir) {
|
||||
if (MinecraftClient.getInstance().isInSingleplayer() || !GeneralSettings.INSTANCE.showExtraInformationInDebugHud.getValue()) return;
|
||||
|
||||
final List<String> information = new ArrayList<>();
|
||||
if (MinecraftClient.getInstance().getNetworkHandler() != null) {
|
||||
final UserConnection userConnection = ProtocolHack.getMainUserConnection();
|
||||
|
||||
information.add("");
|
||||
information.add(ChatUtil.PREFIX);
|
||||
|
||||
for (AbstractInformationGroup group : ViaFabricPlus.INSTANCE.getInformationSystem().getGroups()) {
|
||||
if (group.getVersionRange() != null && !group.getVersionRange().contains(ProtocolHack.getTargetVersion())) continue;
|
||||
|
||||
final List<String> groupInformation = new ArrayList<>();
|
||||
try {
|
||||
group.applyInformation(userConnection, groupInformation);
|
||||
} catch (Exception ignored) {}
|
||||
if (groupInformation.isEmpty()) continue;
|
||||
|
||||
information.add(group.getVersionRange() == null ? "General" : group.getVersionRange().toString());
|
||||
information.addAll(groupInformation);
|
||||
information.add("");
|
||||
}
|
||||
}
|
||||
cir.getReturnValue().addAll(information);
|
||||
}
|
||||
}
|
@ -17,8 +17,9 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.integration;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.settings.impl.GeneralSettings;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.util.ChatUtil;
|
||||
@ -33,24 +34,36 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@SuppressWarnings("DataFlowIssue")
|
||||
@Mixin(targets = { "net.minecraft.client.gui.screen.DownloadingTerrainScreen", "net.minecraft.client.gui.screen.ConnectScreen" })
|
||||
public class MixinDownloadingTerrainScreenAndConnectScreen extends Screen {
|
||||
public abstract class MixinDownloadingTerrainScreenAndConnectScreen extends Screen {
|
||||
|
||||
public MixinDownloadingTerrainScreenAndConnectScreen(Text title) {
|
||||
super(title);
|
||||
}
|
||||
|
||||
@Inject(method = "render", at = @At("RETURN"))
|
||||
public void renderClassicProgress(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
||||
private void renderClassicProgress(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
||||
if (GeneralSettings.INSTANCE.showClassicLoadingProgressInConnectScreen.getValue()) {
|
||||
if (client.getNetworkHandler() == null) return;
|
||||
// Check if ViaVersion is translating
|
||||
final UserConnection connection = ProtocolHack.getPlayNetworkUserConnection();
|
||||
if (connection == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final var connection = ProtocolHack.getMainUserConnection();
|
||||
if (connection == null) return;
|
||||
// Check if the client is connecting to a classic server
|
||||
final ClassicProgressStorage classicProgressStorage = connection.get(ClassicProgressStorage.class);
|
||||
if (classicProgressStorage == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final var classicProgressStorage = connection.get(ClassicProgressStorage.class);
|
||||
if (classicProgressStorage == null) return;
|
||||
|
||||
context.drawCenteredTextWithShadow(client.textRenderer, ChatUtil.prefixText(classicProgressStorage.status), width / 2, height / 2 - 30, -1);
|
||||
// Draw the classic loading progress
|
||||
context.drawCenteredTextWithShadow(
|
||||
client.textRenderer,
|
||||
ChatUtil.prefixText(classicProgressStorage.status),
|
||||
width / 2,
|
||||
height / 2 - 30,
|
||||
-1
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -17,9 +17,9 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.integration;
|
||||
|
||||
import de.florianmichael.viafabricplus.event.FinishMinecraftLoadCallback;
|
||||
import de.florianmichael.viafabricplus.event.PostGameLoadCallback;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.RunArgs;
|
||||
@ -32,12 +32,14 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
public abstract class MixinMinecraftClient {
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
public void postLoad(RunArgs args, CallbackInfo ci) {
|
||||
FinishMinecraftLoadCallback.EVENT.invoker().onFinishMinecraftLoad();
|
||||
private void callPostGameLoadEvent(RunArgs args, CallbackInfo ci) {
|
||||
PostGameLoadCallback.EVENT.invoker().postGameLoad();
|
||||
}
|
||||
|
||||
@Inject(method = "startIntegratedServer", at = @At("HEAD"))
|
||||
private void disableProtocolHack(CallbackInfo ci) {
|
||||
// Set the target version to the native version when starting a singleplayer world
|
||||
// This will automatically reload all the mappings and reset the target version to the forced version
|
||||
ProtocolHack.setTargetVersion(ProtocolHack.NATIVE_VERSION);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.integration;
|
||||
|
||||
import de.florianmichael.viafabricplus.screen.common.ProtocolSelectionScreen;
|
||||
import de.florianmichael.viafabricplus.settings.impl.GeneralSettings;
|
||||
@ -31,24 +31,23 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(MultiplayerScreen.class)
|
||||
public class MixinMultiplayerScreen extends Screen {
|
||||
public abstract class MixinMultiplayerScreen extends Screen {
|
||||
|
||||
public MixinMultiplayerScreen(Text title) {
|
||||
super(title);
|
||||
}
|
||||
|
||||
@Inject(method = "init", at = @At("RETURN"))
|
||||
public void addProtocolSelectionButton(CallbackInfo ci) {
|
||||
ButtonWidget.Builder builder = ButtonWidget.builder(Text.literal("ViaFabricPlus"), button -> ProtocolSelectionScreen.INSTANCE.open(this));
|
||||
private void addProtocolSelectionButton(CallbackInfo ci) {
|
||||
// Create the button
|
||||
var builder = ButtonWidget.builder(Text.literal("ViaFabricPlus"), button ->
|
||||
ProtocolSelectionScreen.INSTANCE.open(this)).size(98, 20);
|
||||
|
||||
final int orientation = GeneralSettings.INSTANCE.multiplayerScreenButtonOrientation.getIndex();
|
||||
switch (orientation) {
|
||||
case 0 -> builder = builder.position(5, 5);
|
||||
case 1 -> builder = builder.position(width - 98 - 5, 5);
|
||||
case 2 -> builder = builder.position(5, height - 20 - 5);
|
||||
case 3 -> builder = builder.position(width - 98 - 5, height - 20 - 5);
|
||||
}
|
||||
// Set the button's position according to the configured orientation
|
||||
builder = GeneralSettings.withOrientation(builder, GeneralSettings.INSTANCE.multiplayerScreenButtonOrientation.getIndex(), width, height);
|
||||
|
||||
this.addDrawableChild(builder.size(98, 20).build());
|
||||
// Add the button to the screen
|
||||
this.addDrawableChild(builder.build());
|
||||
}
|
||||
|
||||
}
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.integration;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
|
||||
@ -50,8 +50,11 @@ public abstract class MixinMultiplayerServerListPinger_1 implements ClientQueryP
|
||||
ClientConnection field_3774;
|
||||
|
||||
@Inject(method = "onResponse(Lnet/minecraft/network/packet/s2c/query/QueryResponseS2CPacket;)V", at = @At("HEAD"))
|
||||
public void trackTranslatingState(QueryResponseS2CPacket packet, CallbackInfo ci) {
|
||||
private void trackTranslatingState(QueryResponseS2CPacket packet, CallbackInfo ci) {
|
||||
final UserConnection userConnection = ((IClientConnection) field_3774).viaFabricPlus$getUserConnection();
|
||||
|
||||
// If ViaVersion is translating the current connection, we track the target version, and it's state in the server info
|
||||
// So we can later draw this information when hovering over the ping bar in the server list
|
||||
if (userConnection != null) {
|
||||
((IServerInfo) field_3776).viaFabricPlus$enable();
|
||||
((IServerInfo) field_3776).viaFabricPlus$setTranslatingVersion(userConnection.getProtocolInfo().getServerProtocolVersion());
|
||||
@ -62,13 +65,20 @@ public abstract class MixinMultiplayerServerListPinger_1 implements ClientQueryP
|
||||
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;
|
||||
// Because of ViaVersion not supporting legacy minecraft versions where protocol ids are overlapping, ViaLegacy
|
||||
// has its own protocol id offset, where realVersion = -(ViaLegacyVersion >> 2). Normally ViaVersion sends the client
|
||||
// version to the client so its detection doesn't break when checking for serverVersion == clientVersion, but since
|
||||
// ViaLegacy doesn't do that, we have to do it ourselves
|
||||
isCompatible = LegacyProtocolVersion.getRealProtocolVersion(((IClientConnection) this.field_3774).viaFabricPlus$getTargetVersion().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;
|
||||
// Bedrock edition doesn't have a protocol id like the Java edition, ViaBedrock also has its own protocol id offset
|
||||
// Which we need to remove to get the real protocol id
|
||||
isCompatible = ((IClientConnection) this.field_3774).viaFabricPlus$getTargetVersion().getVersion() - BedrockProtocolVersion.PROTOCOL_ID_OVERLAP_PREVENTION_OFFSET == this.field_3776.protocolVersion;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the server is compatible with the client, we set the protocol version to the client version
|
||||
if (isCompatible) {
|
||||
this.field_3776.protocolVersion = SharedConstants.getProtocolVersion();
|
||||
}
|
@ -17,8 +17,10 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.integration;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import de.florianmichael.viafabricplus.settings.impl.GeneralSettings;
|
||||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
|
||||
@ -36,25 +38,26 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(MultiplayerServerListWidget.ServerEntry.class)
|
||||
public class MixinMultiplayerServerListWidget_ServerEntry {
|
||||
public abstract class MixinMultiplayerServerListWidget_ServerEntry {
|
||||
|
||||
@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);
|
||||
@WrapOperation(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;setMultiplayerScreenTooltip(Ljava/util/List;)V", ordinal = 0))
|
||||
private void drawTranslatingState(MultiplayerScreen instance, List<Text> tooltip, Operation<Void> original) {
|
||||
if (GeneralSettings.INSTANCE.showAdvertisedServerVersion.getValue()) {
|
||||
final IServerInfo accessor = ((IServerInfo) server);
|
||||
if (accessor.viaFabricPlus$enabled()) {
|
||||
final var versionEnum = VersionEnum.fromProtocolId(accessor.viaFabricPlus$translatingVersion());
|
||||
final IServerInfo mixinServerInfo = ((IServerInfo) server);
|
||||
|
||||
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 + ")"));
|
||||
if (mixinServerInfo.viaFabricPlus$enabled()) {
|
||||
final var versionEnum = VersionEnum.fromProtocolId(mixinServerInfo.viaFabricPlus$translatingVersion());
|
||||
|
||||
tooltip.add(Text.translatable("misc.viafabricplus.translate", versionEnum != VersionEnum.UNKNOWN ? versionEnum.getName() + " (" + versionEnum.getVersion() + ")" : mixinServerInfo.viaFabricPlus$translatingVersion()));
|
||||
tooltip.add(Text.translatable("misc.viafabricplus.serverversion", server.version.getString() + " (" + server.protocolVersion + ")"));
|
||||
}
|
||||
}
|
||||
instance.setMultiplayerScreenTooltip(tooltipOverwrite);
|
||||
|
||||
original.call(instance, tooltip);
|
||||
}
|
||||
|
||||
}
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.per_server_version;
|
||||
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
@ -30,15 +30,16 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(targets = "net.minecraft.client.gui.screen.ConnectScreen$1")
|
||||
public class MixinConnectScreen_1 {
|
||||
public abstract class MixinConnectScreen_1 {
|
||||
|
||||
@Final
|
||||
@Shadow
|
||||
ServerInfo field_40415;
|
||||
|
||||
@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) {
|
||||
private void setForcedTargetVersion(CallbackInfo ci) {
|
||||
if (field_40415 != null) {
|
||||
// Set the target version to the forced version when connecting to a server
|
||||
ProtocolHack.setTargetVersion(((IServerInfo) field_40415).viaFabricPlus$forcedVersion());
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.per_server_version;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import de.florianmichael.viafabricplus.injection.access.IPerformanceLog;
|
||||
@ -40,10 +40,14 @@ public abstract class MixinMultiplayerServerListPinger {
|
||||
private ClientConnection setForcedVersion(InetSocketAddress address, boolean useEpoll, PerformanceLog packetSizeLog, @Local ServerInfo serverInfo) {
|
||||
final VersionEnum forcedVersion = ((IServerInfo) serverInfo).viaFabricPlus$forcedVersion();
|
||||
if (forcedVersion != null) {
|
||||
// We use the PerformanceLog field to store the forced version since it's always null when pinging a server
|
||||
// So we can create a dummy instance, store the forced version in it and later destroy the instance again
|
||||
// To avoid any side effects, we also support cases where a mod is also creating a PerformanceLog instance
|
||||
if (packetSizeLog == null) {
|
||||
packetSizeLog = new PerformanceLog();
|
||||
}
|
||||
|
||||
// Attach the forced version to the PerformanceLog instance
|
||||
((IPerformanceLog) packetSizeLog).viaFabricPlus$setForcedVersion(forcedVersion);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.per_server_version;
|
||||
|
||||
import de.florianmichael.viafabricplus.injection.access.IPerformanceLog;
|
||||
import net.minecraft.util.profiler.PerformanceLog;
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.per_server_version;
|
||||
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
@ -33,7 +33,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
@Mixin(ServerInfo.class)
|
||||
public class MixinServerInfo implements IServerInfo {
|
||||
public abstract class MixinServerInfo implements IServerInfo {
|
||||
|
||||
@Shadow
|
||||
public String name;
|
||||
@ -52,8 +52,10 @@ public class MixinServerInfo implements IServerInfo {
|
||||
}
|
||||
|
||||
@Inject(method = "toNbt", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
public void saveForcedVersion(CallbackInfoReturnable<NbtCompound> cir, NbtCompound nbtCompound) {
|
||||
if (viaFabricPlus$forcedVersion == null) return;
|
||||
private void saveForcedVersion(CallbackInfoReturnable<NbtCompound> cir, NbtCompound nbtCompound) {
|
||||
if (viaFabricPlus$forcedVersion == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
nbtCompound.putInt("viafabricplus_forcedversion", viaFabricPlus$forcedVersion.getOriginalVersion());
|
||||
}
|
||||
@ -71,7 +73,7 @@ public class MixinServerInfo implements IServerInfo {
|
||||
}
|
||||
|
||||
@Inject(method = "copyFrom", at = @At("RETURN"))
|
||||
public void trackForcedVersion(ServerInfo serverInfo, CallbackInfo ci) {
|
||||
private void syncForcedVersion(ServerInfo serverInfo, CallbackInfo ci) {
|
||||
viaFabricPlus$forceVersion(((IServerInfo) serverInfo).viaFabricPlus$forcedVersion());
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.classic4j;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.compat.classic4j;
|
||||
|
||||
import de.florianmichael.classic4j.model.classicube.CCAuthenticationResponse;
|
||||
import de.florianmichael.classic4j.model.classicube.CCError;
|
||||
@ -27,10 +27,11 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(value = CCAuthenticationResponse.class, remap = false)
|
||||
public class MixinCCAuthenticationResponse {
|
||||
public abstract class MixinCCAuthenticationResponse {
|
||||
|
||||
// Classic4J doesn't support translations, so we have to map them manually
|
||||
@Redirect(method = "getErrorDisplay", at = @At(value = "FIELD", target = "Lde/florianmichael/classic4j/model/classicube/CCError;description:Ljava/lang/String;"))
|
||||
public String mapTranslations(CCError instance) {
|
||||
private String mapTranslations(CCError instance) {
|
||||
switch (instance) {
|
||||
case TOKEN -> Text.translatable("classicube.viafabricplus.error.token").getString();
|
||||
case USERNAME -> Text.translatable("classicube.viafabricplus.error.username").getString();
|
||||
@ -41,4 +42,5 @@ public class MixinCCAuthenticationResponse {
|
||||
|
||||
return instance.description;
|
||||
}
|
||||
|
||||
}
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.compat.classic4j;
|
||||
|
||||
import de.florianmichael.viafabricplus.injection.access.ITextFieldWidget;
|
||||
import net.minecraft.SharedConstants;
|
||||
@ -27,25 +27,31 @@ import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
/**
|
||||
* ClassicCube allows to use forbidden characters which the game doesn't allow in passwords, so we have to bypass this check
|
||||
* in order to allow the user to enter their password.
|
||||
*/
|
||||
@Mixin(TextFieldWidget.class)
|
||||
public class MixinTextFieldWidget implements ITextFieldWidget {
|
||||
public abstract class MixinTextFieldWidget implements ITextFieldWidget {
|
||||
|
||||
@Unique
|
||||
private boolean viaFabricPlus$forbiddenCharactersUnlocked = false;
|
||||
|
||||
@Redirect(method = "charTyped", at = @At(value = "INVOKE", target = "Lnet/minecraft/SharedConstants;isValidChar(C)Z"))
|
||||
public boolean allowForbiddenCharacters(char c) {
|
||||
private boolean allowForbiddenCharacters(char c) {
|
||||
if (this.viaFabricPlus$forbiddenCharactersUnlocked) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return SharedConstants.isValidChar(c);
|
||||
}
|
||||
|
||||
@Redirect(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/SharedConstants;stripInvalidChars(Ljava/lang/String;)Ljava/lang/String;"))
|
||||
public String allowForbiddenCharacters(String string) {
|
||||
private String allowForbiddenCharacters(String string) {
|
||||
if (this.viaFabricPlus$forbiddenCharactersUnlocked) {
|
||||
return string;
|
||||
}
|
||||
|
||||
return SharedConstants.stripInvalidChars(string);
|
||||
}
|
||||
|
||||
@ -53,4 +59,5 @@ public class MixinTextFieldWidget implements ITextFieldWidget {
|
||||
public void viaFabricPlus$unlockForbiddenCharacters() {
|
||||
this.viaFabricPlus$forbiddenCharactersUnlocked = true;
|
||||
}
|
||||
|
||||
}
|
@ -36,7 +36,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
*/
|
||||
@Pseudo
|
||||
@Mixin(targets = "org.anti_ad.mc.ipnext.event.AutoRefillHandler$ItemSlotMonitor", remap = false)
|
||||
public class MixinAutoRefillHandler_ItemSlotMonitor {
|
||||
public abstract class MixinAutoRefillHandler_ItemSlotMonitor {
|
||||
|
||||
@Shadow
|
||||
public int currentSlotId;
|
||||
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.jsonwebtoken;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.compat.jsonwebtoken;
|
||||
|
||||
import io.jsonwebtoken.lang.Classes;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@ -30,7 +30,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
* So we have to change all services usages by using the normal Java API
|
||||
*/
|
||||
@Mixin(value = Classes.class, remap = false)
|
||||
public class MixinClasses {
|
||||
public abstract class MixinClasses {
|
||||
|
||||
@Inject(method = "forName", at = @At("HEAD"), cancellable = true)
|
||||
private static void removeServicesSupport(String fqcn, CallbackInfoReturnable<Class<Object>> cir) throws ClassNotFoundException {
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.jsonwebtoken;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.compat.jsonwebtoken;
|
||||
|
||||
import io.jsonwebtoken.gson.io.GsonDeserializer;
|
||||
import io.jsonwebtoken.impl.DefaultJwtParserBuilder;
|
||||
@ -30,7 +30,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
* So we have to change all services usages by using the normal Java API
|
||||
*/
|
||||
@Mixin(value = DefaultJwtParserBuilder.class, remap = false)
|
||||
public class MixinDefaultJwtParserBuilder {
|
||||
public abstract class MixinDefaultJwtParserBuilder {
|
||||
|
||||
@Redirect(method = "build()Lio/jsonwebtoken/JwtParser;", at = @At(value = "INVOKE", target = "Lio/jsonwebtoken/impl/lang/Services;loadFirst(Ljava/lang/Class;)Ljava/lang/Object;"))
|
||||
public Object removeServicesSupport(Class<Object> result) {
|
@ -20,25 +20,23 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.authlib;
|
||||
|
||||
import com.mojang.authlib.yggdrasil.response.KeyPairResponse;
|
||||
import de.florianmichael.viafabricplus.injection.access.IKeyPairResponse;
|
||||
import de.florianmichael.viafabricplus.injection.access.ILegacyKeySignatureStorage;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
@Mixin(value = KeyPairResponse.class, remap = false)
|
||||
public class MixinKeyPairResponse implements IKeyPairResponse {
|
||||
public abstract class MixinKeyPairResponse implements ILegacyKeySignatureStorage {
|
||||
|
||||
@Unique
|
||||
private ByteBuffer viaFabricPlus$legacyKeySignature;
|
||||
private byte[] viaFabricPlus$legacyKeySignature;
|
||||
|
||||
@Override
|
||||
public ByteBuffer viafabricplus$getLegacyPublicKeySignature() {
|
||||
public byte[] viafabricplus$getLegacyPublicKeySignature() {
|
||||
return this.viaFabricPlus$legacyKeySignature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viafabricplus$setLegacyPublicKeySignature(ByteBuffer signature) {
|
||||
public void viafabricplus$setLegacyPublicKeySignature(byte[] signature) {
|
||||
this.viaFabricPlus$legacyKeySignature = signature;
|
||||
}
|
||||
}
|
||||
|
@ -22,8 +22,8 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.authlib;
|
||||
import com.mojang.authlib.minecraft.client.MinecraftClient;
|
||||
import com.mojang.authlib.yggdrasil.YggdrasilUserApiService;
|
||||
import com.mojang.authlib.yggdrasil.response.KeyPairResponse;
|
||||
import de.florianmichael.viafabricplus.definition.model.KeyPairResponse1_19_0;
|
||||
import de.florianmichael.viafabricplus.injection.access.IKeyPairResponse;
|
||||
import de.florianmichael.viafabricplus.fixes.model.KeyPairResponse1_19_0;
|
||||
import de.florianmichael.viafabricplus.injection.access.ILegacyKeySignatureStorage;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -34,23 +34,34 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import java.net.URL;
|
||||
|
||||
@Mixin(value = YggdrasilUserApiService.class, remap = false)
|
||||
public class MixinYggdrasilUserApiService {
|
||||
public abstract class MixinYggdrasilUserApiService {
|
||||
|
||||
@Shadow @Final private MinecraftClient minecraftClient;
|
||||
|
||||
@Shadow @Final private URL routeKeyPair;
|
||||
|
||||
@Inject(method = "getKeyPair", at = @At("HEAD"), cancellable = true)
|
||||
public void storeLegacyPublicKeySignature(CallbackInfoReturnable<KeyPairResponse> cir) {
|
||||
final var response = minecraftClient.post(routeKeyPair, KeyPairResponse1_19_0.class);
|
||||
if (response == null) { // the response can't be null for us since we are constructing a new object with it.
|
||||
private void storeLegacyPublicKeySignature(CallbackInfoReturnable<KeyPairResponse> cir) {
|
||||
final KeyPairResponse1_19_0 response = minecraftClient.post(routeKeyPair, KeyPairResponse1_19_0.class);
|
||||
|
||||
// the response can't be null for us since we are constructing a new object with it.
|
||||
if (response == null) {
|
||||
cir.setReturnValue(null);
|
||||
return;
|
||||
}
|
||||
|
||||
final var keyPairResponse = new KeyPairResponse(response.keyPair(), response.publicKeySignatureV2(), response.expiresAt(), response.refreshedAfter());
|
||||
((IKeyPairResponse) (Object) keyPairResponse).viafabricplus$setLegacyPublicKeySignature(response.publicKeySignature());
|
||||
// create the original KeyPairResponse object with the data
|
||||
final KeyPairResponse keyPairResponse = new KeyPairResponse(
|
||||
response.keyPair(),
|
||||
response.publicKeySignatureV2(),
|
||||
response.expiresAt(),
|
||||
response.refreshedAfter()
|
||||
);
|
||||
|
||||
// set the legacy public key signature in the object
|
||||
((ILegacyKeySignatureStorage) (Object) keyPairResponse).viafabricplus$setLegacyPublicKeySignature(response.publicKeySignature().array());
|
||||
|
||||
cir.setReturnValue(keyPairResponse);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2;
|
||||
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.fixes.ClientPlayerInteractionManager1_18_2;
|
||||
import de.florianmichael.viafabricplus.injection.access.IClientConnection;
|
||||
import de.florianmichael.viafabricplus.injection.access.IScreenHandler;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
@ -84,7 +84,7 @@ public abstract class MixinClientPlayerInteractionManager {
|
||||
private List<ItemStack> viaFabricPlus$oldItems;
|
||||
|
||||
@Inject(method = "breakBlock", at = @At("TAIL"))
|
||||
public void resetBlockBreaking(BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
|
||||
private void resetBlockBreaking(BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_3)) {
|
||||
this.currentBreakingPos = new BlockPos(this.currentBreakingPos.getX(), -1, this.currentBreakingPos.getZ());
|
||||
}
|
||||
@ -152,12 +152,12 @@ public abstract class MixinClientPlayerInteractionManager {
|
||||
}
|
||||
|
||||
@Inject(method = "interactItem", at = @At("HEAD"))
|
||||
public void trackLastUsedItem(PlayerEntity player, Hand hand, CallbackInfoReturnable<ActionResult> cir) {
|
||||
private void trackLastUsedItem(PlayerEntity player, Hand hand, CallbackInfoReturnable<ActionResult> cir) {
|
||||
ViaFabricPlusHandItemProvider.lastUsedItem = player.getStackInHand(hand).copy();
|
||||
}
|
||||
|
||||
@Inject(method = "interactBlock", at = @At("HEAD"))
|
||||
public void trackLastUsedBlock(ClientPlayerEntity player, Hand hand, BlockHitResult hitResult, CallbackInfoReturnable<ActionResult> cir) {
|
||||
private void trackLastUsedBlock(ClientPlayerEntity player, Hand hand, BlockHitResult hitResult, CallbackInfoReturnable<ActionResult> cir) {
|
||||
ViaFabricPlusHandItemProvider.lastUsedItem = player.getStackInHand(hand).copy();
|
||||
}
|
||||
|
||||
@ -165,7 +165,7 @@ public abstract class MixinClientPlayerInteractionManager {
|
||||
private ActionResult viaFabricPlus$actionResult;
|
||||
|
||||
@Inject(method = "interactBlock", at = @At("HEAD"), cancellable = true)
|
||||
public void cacheActionResult(ClientPlayerEntity player, Hand hand, BlockHitResult hitResult, CallbackInfoReturnable<ActionResult> cir) {
|
||||
private 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);
|
||||
|
||||
@ -176,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) {
|
||||
private ActionResult provideCachedResult(ClientPlayerInteractionManager instance, ClientPlayerEntity player, Hand hand, BlockHitResult hitResult) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
return this.viaFabricPlus$actionResult;
|
||||
}
|
||||
@ -184,16 +184,17 @@ public abstract class MixinClientPlayerInteractionManager {
|
||||
}
|
||||
|
||||
@Inject(method = "sendSequencedPacket", at = @At("HEAD"))
|
||||
public void handleBlockAcknowledgements(ClientWorld world, SequencedPacketCreator packetCreator, CallbackInfo ci) {
|
||||
private void handleBlockAcknowledgements(ClientWorld world, SequencedPacketCreator packetCreator, CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isBetweenInclusive(VersionEnum.r1_14_4, VersionEnum.r1_18_2) && packetCreator instanceof PlayerActionC2SPacket playerActionC2SPacket) {
|
||||
ClientPlayerInteractionManager1_18_2.trackBlockAction(playerActionC2SPacket.getAction(), playerActionC2SPacket.getPos());
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getBlockBreakingProgress", at = @At("HEAD"), cancellable = true)
|
||||
public void changeCalculation(CallbackInfoReturnable<Integer> cir) {
|
||||
private void changeCalculation(CallbackInfoReturnable<Integer> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_4)) {
|
||||
cir.setReturnValue((int)(this.currentBreakingProgress * 10.0F) - 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,15 +28,16 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(DrawContext.class)
|
||||
public class MixinDrawContext {
|
||||
public abstract class MixinDrawContext {
|
||||
|
||||
@Redirect(method = "drawItemInSlot(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/item/ItemStack;IILjava/lang/String;)V",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawText(Lnet/minecraft/client/font/TextRenderer;Ljava/lang/String;IIIZ)I"))
|
||||
public int recolor(DrawContext instance, TextRenderer textRenderer, String text, int x, int y, int color, boolean shadow) {
|
||||
private int recolor(DrawContext instance, TextRenderer textRenderer, String text, int x, int y, int color, boolean shadow) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_10) && text.startsWith("-")) {
|
||||
color = -43213; // red
|
||||
}
|
||||
|
||||
return instance.drawText(textRenderer, text, x, y, color, shadow);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import de.florianmichael.viafabricplus.definition.model.BuiltinEmptyGlyph1_12_2;
|
||||
import de.florianmichael.viafabricplus.fixes.model.BuiltinEmptyGlyph1_12_2;
|
||||
import de.florianmichael.viafabricplus.mappings.CharacterMappings;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.settings.impl.VisualSettings;
|
||||
@ -60,7 +60,7 @@ public abstract class MixinFontStorage {
|
||||
private boolean viaFabricPlus$obfuscation;
|
||||
|
||||
@Inject(method = "setFonts", at = @At("HEAD"))
|
||||
public void trackForbiddenCharacters(List<Font> fonts, CallbackInfo ci) {
|
||||
private void trackForbiddenCharacters(List<Font> fonts, CallbackInfo ci) {
|
||||
viaFabricPlus$forbiddenCharacters = CharacterMappings.getForbiddenCharactersForID(this.id);
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ public abstract class MixinFontStorage {
|
||||
}
|
||||
|
||||
@Inject(method = "findGlyph", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/Font;getGlyph(I)Lnet/minecraft/client/font/Glyph;"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
|
||||
public void injectFindGlyph(int codePoint, CallbackInfoReturnable<FontStorage.GlyphPair> cir, Glyph glyph, Iterator var3, Font font) {
|
||||
private void injectFindGlyph(int codePoint, CallbackInfoReturnable<FontStorage.GlyphPair> cir, Glyph glyph, Iterator var3, Font font) {
|
||||
if (!this.id.getNamespace().equals("minecraft")) return;
|
||||
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_4)) {
|
||||
@ -96,7 +96,7 @@ public abstract class MixinFontStorage {
|
||||
}
|
||||
|
||||
@Inject(method = "findGlyphRenderer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/Font;getGlyph(I)Lnet/minecraft/client/font/Glyph;"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
|
||||
public void injectFindGlyphRenderer(int codePoint, CallbackInfoReturnable<GlyphRenderer> cir, Iterator var2, Font font) {
|
||||
private 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)) {
|
||||
@ -114,12 +114,12 @@ public abstract class MixinFontStorage {
|
||||
*/
|
||||
|
||||
@Inject(method = "getObfuscatedGlyphRenderer", at = @At("HEAD"))
|
||||
public void trackObfuscationState(Glyph glyph, CallbackInfoReturnable<GlyphRenderer> cir) {
|
||||
private void trackObfuscationState(Glyph glyph, CallbackInfoReturnable<GlyphRenderer> cir) {
|
||||
viaFabricPlus$obfuscation = true;
|
||||
}
|
||||
|
||||
@Inject(method = "getGlyphRenderer(I)Lnet/minecraft/client/font/GlyphRenderer;", at = @At("RETURN"))
|
||||
public void revertObfuscationState(int codePoint, CallbackInfoReturnable<GlyphRenderer> cir) {
|
||||
private void revertObfuscationState(int codePoint, CallbackInfoReturnable<GlyphRenderer> cir) {
|
||||
viaFabricPlus$obfuscation = false;
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ public abstract class MixinMinecraftClient {
|
||||
@WrapWithCondition(method = "doItemUse",
|
||||
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;interactItem(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;")),
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;resetEquipProgress(Lnet/minecraft/util/Hand;)V", ordinal = 0))
|
||||
public boolean removeEquipProgressReset(HeldItemRenderer instance, Hand hand) {
|
||||
private boolean removeEquipProgressReset(HeldItemRenderer instance, Hand hand) {
|
||||
return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_8) || !(player.getStackInHand(hand).getItem() instanceof SwordItem);
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ public abstract class MixinMinecraftClient {
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(method = "handleBlockBreaking", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isUsingItem()Z"))
|
||||
public boolean allowBlockBreakAndItemUsageAtTheSameTime(boolean original) {
|
||||
private boolean allowBlockBreakAndItemUsageAtTheSameTime(boolean original) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10)) {
|
||||
return false;
|
||||
}
|
||||
@ -87,7 +87,7 @@ public abstract class MixinMinecraftClient {
|
||||
}
|
||||
|
||||
@Redirect(method = "tick", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;attackCooldown:I", ordinal = 1))
|
||||
public int unwrapOperation(MinecraftClient instance) {
|
||||
private int unwrapOperation(MinecraftClient instance) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
return 0;
|
||||
}
|
||||
@ -95,7 +95,7 @@ public abstract class MixinMinecraftClient {
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;handleInputEvents()V", shift = At.Shift.BEFORE))
|
||||
public void updateCooldown(CallbackInfo ci) {
|
||||
private void updateCooldown(CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
if (this.attackCooldown > 0) {
|
||||
--this.attackCooldown;
|
||||
@ -112,7 +112,7 @@ public abstract class MixinMinecraftClient {
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Inject(method = "tick", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;",
|
||||
ordinal = 4, shift = At.Shift.BEFORE))
|
||||
public void injectTick(CallbackInfo ci) {
|
||||
private void injectTick(CallbackInfo ci) {
|
||||
if (!DebugSettings.INSTANCE.executeInputsInSync.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
@ -128,7 +128,7 @@ public abstract class MixinMinecraftClient {
|
||||
@Inject(method = "handleInputEvents", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;hasRidingInventory()Z"))
|
||||
private void onInventoryKeyPressed(CallbackInfo ci) {
|
||||
if (getNetworkHandler() != null && DebugSettings.INSTANCE.sendOpenInventoryPacket.isEnabled()) {
|
||||
final UserConnection userConnection = ProtocolHack.getMainUserConnection();
|
||||
final UserConnection userConnection = ProtocolHack.getPlayNetworkUserConnection();
|
||||
|
||||
if (userConnection != null && userConnection.getProtocolInfo().getPipeline().contains(Protocol1_12To1_11_1.class)) {
|
||||
final PacketWrapper clientStatus = PacketWrapper.create(ServerboundPackets1_9_3.CLIENT_STATUS, userConnection);
|
||||
|
@ -27,12 +27,13 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(PendingUpdateManager.class)
|
||||
public class MixinPendingUpdateManager {
|
||||
public abstract class MixinPendingUpdateManager {
|
||||
|
||||
@Inject(method = "incrementSequence", at = @At(value = "FIELD", target = "Lnet/minecraft/client/network/PendingUpdateManager;pendingSequence:Z", shift = At.Shift.BEFORE), cancellable = true)
|
||||
public void injectIncrementSequence(CallbackInfoReturnable<PendingUpdateManager> cir) {
|
||||
private void injectIncrementSequence(CallbackInfoReturnable<PendingUpdateManager> cir) {
|
||||
if (DebugSettings.INSTANCE.disableSequencing.isEnabled()) {
|
||||
cir.setReturnValue((PendingUpdateManager) (Object) this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(PlayerEntityRenderer.class)
|
||||
public class MixinPlayerEntityRenderer {
|
||||
public abstract class MixinPlayerEntityRenderer {
|
||||
|
||||
@Inject(method = "getPositionOffset*", at = @At("RETURN"), cancellable = true)
|
||||
private void injectGetPositionOffset(AbstractClientPlayerEntity player, float delta, CallbackInfoReturnable<Vec3d> ci) {
|
||||
@ -49,4 +49,5 @@ public class MixinPlayerEntityRenderer {
|
||||
private boolean redirectGetPositionOffset(AbstractClientPlayerEntity player) {
|
||||
return (ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_11_1to1_11_2)) && player.isInSneakingPose();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,26 +19,25 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import de.florianmichael.viafabricplus.injection.access.IPublicKeyData;
|
||||
import de.florianmichael.viafabricplus.injection.access.ILegacyKeySignatureStorage;
|
||||
import net.minecraft.network.encryption.PlayerPublicKey;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
@Mixin(PlayerPublicKey.PublicKeyData.class)
|
||||
public class MixinPlayerPublicKey_PublicKeyData implements IPublicKeyData {
|
||||
public abstract class MixinPlayerPublicKey_PublicKeyData implements ILegacyKeySignatureStorage {
|
||||
|
||||
@Unique
|
||||
private ByteBuffer viaFabricPlus$v1_key;
|
||||
private byte[] viaFabricPlus$legacyKeySignature;
|
||||
|
||||
@Override
|
||||
public ByteBuffer viaFabricPlus$getV1Key() {
|
||||
return viaFabricPlus$v1_key;
|
||||
public byte[] viafabricplus$getLegacyPublicKeySignature() {
|
||||
return this.viaFabricPlus$legacyKeySignature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaFabricPlus$setV1Key(ByteBuffer byteBuffer) {
|
||||
this.viaFabricPlus$v1_key = byteBuffer;
|
||||
public void viafabricplus$setLegacyPublicKeySignature(byte[] signature) {
|
||||
this.viaFabricPlus$legacyKeySignature = signature;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,8 +20,7 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import com.mojang.authlib.yggdrasil.response.KeyPairResponse;
|
||||
import de.florianmichael.viafabricplus.injection.access.IKeyPairResponse;
|
||||
import de.florianmichael.viafabricplus.injection.access.IPublicKeyData;
|
||||
import de.florianmichael.viafabricplus.injection.access.ILegacyKeySignatureStorage;
|
||||
import net.minecraft.client.session.ProfileKeysImpl;
|
||||
import net.minecraft.network.encryption.PlayerPublicKey;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@ -30,10 +29,11 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(ProfileKeysImpl.class)
|
||||
public class MixinProfileKeysImpl {
|
||||
public abstract 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());
|
||||
((ILegacyKeySignatureStorage) (Object) cir.getReturnValue()).viafabricplus$setLegacyPublicKeySignature(((ILegacyKeySignatureStorage) (Object) keyPairResponse).viafabricplus$getLegacyPublicKeySignature());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
@Mixin(ServerResourcePackProvider.class)
|
||||
public class MixinServerResourcePackProvider {
|
||||
public abstract class MixinServerResourcePackProvider {
|
||||
|
||||
@Unique
|
||||
private File viaFabricPlus$trackedFile;
|
||||
@ -68,12 +68,12 @@ public class MixinServerResourcePackProvider {
|
||||
}
|
||||
|
||||
@Inject(method = "verifyFile", at = @At("HEAD"))
|
||||
public void keepFile(String expectedSha1, File file, CallbackInfoReturnable<Boolean> cir) {
|
||||
private void keepFile(String expectedSha1, File file, CallbackInfoReturnable<Boolean> cir) {
|
||||
viaFabricPlus$trackedFile = file;
|
||||
}
|
||||
|
||||
@Redirect(method = "verifyFile", at = @At(value = "INVOKE", target = "Lcom/google/common/hash/HashCode;toString()Ljava/lang/String;", remap = false))
|
||||
public String revertHashAlgorithm(HashCode instance) {
|
||||
private String revertHashAlgorithm(HashCode instance) {
|
||||
try {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
//noinspection deprecation
|
||||
@ -87,10 +87,11 @@ public class MixinServerResourcePackProvider {
|
||||
}
|
||||
|
||||
@Redirect(method = "verifyFile", at = @At(value = "INVOKE", target = "Ljava/lang/String;toLowerCase(Ljava/util/Locale;)Ljava/lang/String;"))
|
||||
public String disableIgnoreCase(String instance, Locale locale) {
|
||||
private String disableIgnoreCase(String instance, Locale locale) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
return instance;
|
||||
}
|
||||
return instance.toLowerCase(locale);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import de.florianmichael.viafabricplus.definition.ClientsideFixes;
|
||||
import de.florianmichael.viafabricplus.fixes.ClientsideFixes;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.util.StringHelper;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@ -27,7 +27,7 @@ import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
|
||||
@Mixin(StringHelper.class)
|
||||
public class MixinStringHelper {
|
||||
public abstract class MixinStringHelper {
|
||||
|
||||
@ModifyConstant(method = "truncateChat", constant = @Constant(intValue = 256))
|
||||
private static int expandChatLength(int constant) {
|
||||
@ -37,4 +37,5 @@ public class MixinStringHelper {
|
||||
|
||||
return ClientsideFixes.getCurrentChatLimit();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public abstract class MixinTextRenderer {
|
||||
@Shadow public abstract int getWidth(OrderedText text);
|
||||
|
||||
@Inject(method = "draw(Ljava/lang/String;FFIZLorg/joml/Matrix4f;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/font/TextRenderer$TextLayerType;IIZ)I", at = @At("HEAD"), cancellable = true)
|
||||
public void allowNewLines_String(String text, float x, float y, int color, boolean shadow, Matrix4f matrix, VertexConsumerProvider vertexConsumers, TextRenderer.TextLayerType layerType, int backgroundColor, int light, boolean rightToLeft, CallbackInfoReturnable<Integer> cir) {
|
||||
private void allowNewLines_String(String text, float x, float y, int color, boolean shadow, Matrix4f matrix, VertexConsumerProvider vertexConsumers, TextRenderer.TextLayerType layerType, int backgroundColor, int light, boolean rightToLeft, CallbackInfoReturnable<Integer> cir) {
|
||||
if (ProtocolHack.getTargetVersion() == VersionEnum.bedrockLatest) {
|
||||
final List<OrderedText> lines = wrapLines(StringVisitable.plain(rightToLeft ? this.mirror(text) : text), Integer.MAX_VALUE);
|
||||
if (lines.size() > 1) {
|
||||
@ -68,7 +68,7 @@ public abstract class MixinTextRenderer {
|
||||
}
|
||||
|
||||
@Inject(method = "draw(Lnet/minecraft/text/Text;FFIZLorg/joml/Matrix4f;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/font/TextRenderer$TextLayerType;II)I", at = @At("HEAD"), cancellable = true)
|
||||
public void allowNewLines_Text(Text text, float x, float y, int color, boolean shadow, Matrix4f matrix, VertexConsumerProvider vertexConsumers, TextRenderer.TextLayerType layerType, int backgroundColor, int light, CallbackInfoReturnable<Integer> cir) {
|
||||
private void allowNewLines_Text(Text text, float x, float y, int color, boolean shadow, Matrix4f matrix, VertexConsumerProvider vertexConsumers, TextRenderer.TextLayerType layerType, int backgroundColor, int light, CallbackInfoReturnable<Integer> cir) {
|
||||
if (ProtocolHack.getTargetVersion() == VersionEnum.bedrockLatest) {
|
||||
final List<OrderedText> lines = wrapLines(text, Integer.MAX_VALUE);
|
||||
if (lines.size() > 1) {
|
||||
@ -82,7 +82,7 @@ public abstract class MixinTextRenderer {
|
||||
}
|
||||
|
||||
@Inject(method = "getWidth(Lnet/minecraft/text/StringVisitable;)I", at = @At("HEAD"), cancellable = true)
|
||||
public void allowNewLines_getWidth(StringVisitable text, CallbackInfoReturnable<Integer> cir) {
|
||||
private void allowNewLines_getWidth(StringVisitable text, CallbackInfoReturnable<Integer> cir) {
|
||||
if (MinecraftClient.getInstance().world != null && ProtocolHack.getTargetVersion() == VersionEnum.bedrockLatest) {
|
||||
int i = 0;
|
||||
for (OrderedText wrapLine : this.wrapLines(text, Integer.MAX_VALUE)) {
|
||||
@ -91,4 +91,5 @@ public abstract class MixinTextRenderer {
|
||||
cir.setReturnValue(MathHelper.ceil(i));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,10 +31,10 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(AbstractBlock.class)
|
||||
public class MixinAbstractBlock {
|
||||
public abstract class MixinAbstractBlock {
|
||||
|
||||
@Inject(method = "calcBlockBreakingDelta", at = @At("HEAD"), cancellable = true)
|
||||
public void fixLegacyMiningSpeed(BlockState state, PlayerEntity player, BlockView world, BlockPos pos, CallbackInfoReturnable<Float> cir) {
|
||||
private void changeMiningSpeedCalculation(BlockState state, PlayerEntity player, BlockView world, BlockPos pos, CallbackInfoReturnable<Float> cir) {
|
||||
if (DebugSettings.INSTANCE.legacyMiningSpeeds.isEnabled()) {
|
||||
final float hardness = state.getHardness(world, pos);
|
||||
if (hardness == -1.0F) {
|
||||
@ -48,4 +48,5 @@ public class MixinAbstractBlock {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public abstract class MixinAbstractBlock_AbstractBlockState {
|
||||
}
|
||||
|
||||
@Inject(method = "getHardness", at = @At("RETURN"), cancellable = true)
|
||||
public void changeHardness(BlockView world, BlockPos pos, CallbackInfoReturnable<Float> cir) {
|
||||
private void changeHardness(BlockView world, BlockPos pos, CallbackInfoReturnable<Float> cir) {
|
||||
final Block block = this.getBlock();
|
||||
if (block.equals(Blocks.OBSIDIAN)) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
||||
@ -79,4 +79,5 @@ public abstract class MixinAbstractBlock_AbstractBlockState {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -42,15 +42,23 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
public abstract class MixinAbstractSignBlock {
|
||||
|
||||
@Inject(method = "onUse", at = @At("HEAD"), cancellable = true)
|
||||
private void alwaysReturnSuccess(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ActionResult> cir) {
|
||||
if (!world.isClient) return;
|
||||
private void changeInteractionCalculation(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ActionResult> cir) {
|
||||
if (!world.isClient) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
||||
// <= 1.14.4 doesn't have any sign interactions.
|
||||
|
||||
cir.setReturnValue(ActionResult.SUCCESS);
|
||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_4)) {
|
||||
// Removes the isWaxed() condition and reverts the interaction changes from 1.19.4 -> 1.20 when signs
|
||||
// got a front and back side.
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -36,13 +36,13 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(AnvilBlock.class)
|
||||
public class MixinAnvilBlock extends FallingBlock {
|
||||
public abstract class MixinAnvilBlock extends FallingBlock {
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape viaFabricPlus$x_axis_shape_r1_12_2 = Block.createCuboidShape(0, 0, 2, 16, 16, 14);
|
||||
private static final VoxelShape viaFabricPlus$x_axis_shape_r1_12_2 = Block.createCuboidShape(0.0D, 0.0D, 2.0D, 16.0D, 16.0D, 14.0D);
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape viaFabricPlus$z_axis_shape_r1_12_2 = Block.createCuboidShape(2, 0, 0, 14, 16, 16);
|
||||
private static final VoxelShape viaFabricPlus$z_axis_shape_r1_12_2 = Block.createCuboidShape(2.0D, 0.0D, 0.0D, 14.0D, 16.0D, 16.0D);
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
@ -56,11 +56,12 @@ public class MixinAnvilBlock extends FallingBlock {
|
||||
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) {
|
||||
public void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
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_r1_12_2 : viaFabricPlus$z_axis_shape_r1_12_2);
|
||||
}
|
||||
@ -68,7 +69,10 @@ public class MixinAnvilBlock extends FallingBlock {
|
||||
|
||||
@Override
|
||||
public VoxelShape getCullingShape(BlockState state, BlockView world, BlockPos pos) {
|
||||
// Workaround for https://github.com/ViaVersion/ViaFabricPlus/issues/246
|
||||
// MoreCulling is caching the culling shape and doesn't reload it, so we have to force vanilla's shape here.
|
||||
viaFabricPlus$requireOriginalShape = true;
|
||||
return super.getCullingShape(state, world, pos);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,12 +32,13 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(BambooBlock.class)
|
||||
public class MixinBambooBlock {
|
||||
public abstract class MixinBambooBlock {
|
||||
|
||||
@Inject(method = "isShapeFullCube", at = @At("HEAD"), cancellable = true)
|
||||
public void changeFullCube(BlockState state, BlockView world, BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
|
||||
private void changeBlockBoundingBox(BlockState state, BlockView world, BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_17)) {
|
||||
cir.setReturnValue(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,22 +37,23 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(BedBlock.class)
|
||||
public class MixinBedBlock {
|
||||
public abstract class MixinBedBlock {
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape viaFabricPlus$shape_r1_13_2 = Block.createCuboidShape(0, 0, 0, 16, 9, 16);
|
||||
private static final VoxelShape viaFabricPlus$shape_r1_13_2 = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 9.0D, 16.0D);
|
||||
|
||||
@Inject(method = "bounceEntity", at = @At("HEAD"), cancellable = true)
|
||||
public void injectBounceEntity(Entity entity, CallbackInfo ci) {
|
||||
private void cancelEntityBounce(Entity entity, CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_11_1to1_11_2)) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
|
||||
cir.setReturnValue(viaFabricPlus$shape_r1_13_2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,18 +36,19 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(BrewingStandBlock.class)
|
||||
public class MixinBrewingStandBlock {
|
||||
public abstract class MixinBrewingStandBlock {
|
||||
|
||||
@Unique
|
||||
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 */
|
||||
private static final VoxelShape viaFabricPlus$shape_r1_12_2 = VoxelShapes.union(
|
||||
Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D) /* Base */,
|
||||
Block.createCuboidShape(7.0D, 0.0D, 7.0D, 9.0D, 14.0D, 9.0D) /* Stick */
|
||||
);
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
cir.setReturnValue(viaFabricPlus$shape_r1_12_2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ import org.spongepowered.asm.mixin.Unique;
|
||||
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);
|
||||
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);
|
||||
|
@ -38,7 +38,7 @@ import java.util.Map;
|
||||
public abstract class MixinCauldronBlock extends AbstractCauldronBlock {
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape viaFabricPlus$shape_r1_12_2 = VoxelShapes.combineAndSimplify(
|
||||
private static final 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
|
||||
@ -55,4 +55,5 @@ public abstract class MixinCauldronBlock extends AbstractCauldronBlock {
|
||||
}
|
||||
return super.getOutlineShape(state, world, pos, context);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ public abstract class MixinChestBlock extends AbstractChestBlock<ChestBlockEntit
|
||||
}
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_4_2)) {
|
||||
cir.setReturnValue(VoxelShapes.fullCube());
|
||||
}
|
||||
@ -85,8 +85,7 @@ public abstract class MixinChestBlock extends AbstractChestBlock<ChestBlockEntit
|
||||
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");
|
||||
default -> DOUBLE_EAST_SHAPE;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -31,15 +31,16 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(CropBlock.class)
|
||||
public class MixinCropBlock {
|
||||
public abstract class MixinCropBlock {
|
||||
|
||||
@Unique
|
||||
private final VoxelShape viaFabricPlus$shape_r1_8_x = Block.createCuboidShape(0.0, 0.0, 0.0, 16.0, 4.0, 16.0);
|
||||
private static final VoxelShape viaFabricPlus$shape_r1_8_x = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 4.0D, 16.0D);
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetOutlineShape(CallbackInfoReturnable<VoxelShape> cir) {
|
||||
private void changeOutlineShape(CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
cir.setReturnValue(viaFabricPlus$shape_r1_8_x);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,17 +35,17 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
public abstract class MixinEndPortalBlock extends BlockWithEntity {
|
||||
|
||||
@Unique
|
||||
private final VoxelShape viaFabricPlus$shape_r1_8_x = Block.createCuboidShape(0.0, 0.0, 0.0, 16.0, 1.0, 16.0);
|
||||
private static final VoxelShape viaFabricPlus$shape_r1_8_x = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D);
|
||||
|
||||
@Unique
|
||||
private final VoxelShape viaFabricPlus$shape_r1_16_5 = Block.createCuboidShape(0.0, 0.0, 0.0, 16.0, 12.0, 16.0);
|
||||
private static final VoxelShape viaFabricPlus$shape_r1_16_5 = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 12.0D, 16.0D);
|
||||
|
||||
protected MixinEndPortalBlock(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
cir.setReturnValue(viaFabricPlus$shape_r1_8_x);
|
||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
|
||||
|
@ -39,7 +39,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(EndPortalFrameBlock.class)
|
||||
public class MixinEndPortalFrameBlock extends Block {
|
||||
public abstract class MixinEndPortalFrameBlock extends Block {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
@ -50,7 +50,7 @@ public class MixinEndPortalFrameBlock extends Block {
|
||||
public static BooleanProperty EYE;
|
||||
|
||||
@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);
|
||||
private static final VoxelShape viaFabricPlus$eye_shape_r1_12_2 = Block.createCuboidShape(5.0D, 13.0D, 5.0D, 11.0D, 16.0D, 11.0D);
|
||||
|
||||
@Unique
|
||||
private static final VoxelShape viaFabricPlus$frame_with_eye_shape_r1_12_2 = VoxelShapes.union(FRAME_SHAPE, viaFabricPlus$eye_shape_r1_12_2);
|
||||
@ -60,7 +60,7 @@ public class MixinEndPortalFrameBlock extends Block {
|
||||
}
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At(value = "HEAD"), cancellable = true)
|
||||
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
private 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);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public abstract class MixinEnderChestBlock extends BlockWithEntity {
|
||||
}
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
private void changeShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_4_2)) {
|
||||
cir.setReturnValue(VoxelShapes.fullCube());
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(FarmlandBlock.class)
|
||||
public class MixinFarmlandBlock extends Block {
|
||||
public abstract class MixinFarmlandBlock extends Block {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
@ -48,7 +48,7 @@ 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) {
|
||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_9_3tor1_9_4)) {
|
||||
cir.setReturnValue(VoxelShapes.fullCube());
|
||||
}
|
||||
|
@ -38,40 +38,37 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
public abstract class MixinFenceBlock extends HorizontalConnectingBlock {
|
||||
|
||||
@Unique
|
||||
private VoxelShape[] collisionShapes1_4_7;
|
||||
private static final VoxelShape viaFabricPlus$shape_b1_8_1 = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 24.0D, 16.0D);
|
||||
|
||||
@Unique
|
||||
private VoxelShape[] boundingShapes1_4_7;
|
||||
private VoxelShape[] viaFabricPlus$collision_shape_r1_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);
|
||||
private VoxelShape[] viaFabricPlus$outline_shape_r1_4_7;
|
||||
|
||||
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 modifyOnUse(CallbackInfoReturnable<ActionResult> cir) {
|
||||
private void alwaysSuccess(CallbackInfoReturnable<ActionResult> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_10)) {
|
||||
cir.setReturnValue(ActionResult.SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
private void init1_4_7Shapes(Settings settings, CallbackInfo ci) {
|
||||
this.viaFabricPlus$collision_shape_r1_4_7 = this.createShapes1_4_7(24.0F);
|
||||
this.viaFabricPlus$outline_shape_r1_4_7 = this.createShapes1_4_7(16.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
||||
return _b1_8_1_OUTLINE_SHAPE;
|
||||
return VoxelShapes.fullCube();
|
||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_4_6tor1_4_7)) {
|
||||
return this.boundingShapes1_4_7[this.getShapeIndex(state)];
|
||||
return this.viaFabricPlus$outline_shape_r1_4_7[this.getShapeIndex(state)];
|
||||
}
|
||||
|
||||
return super.getOutlineShape(state, world, pos, context);
|
||||
@ -80,42 +77,44 @@ public abstract class MixinFenceBlock extends HorizontalConnectingBlock {
|
||||
@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;
|
||||
return viaFabricPlus$shape_b1_8_1;
|
||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_4_6tor1_4_7)) {
|
||||
return this.collisionShapes1_4_7[this.getShapeIndex(state)];
|
||||
return this.viaFabricPlus$collision_shape_r1_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[]{
|
||||
private VoxelShape[] createShapes1_4_7(final float height) {
|
||||
final float f = 6.0F;
|
||||
final float g = 10.0F;
|
||||
final float h = 6.0F;
|
||||
final float i = 10.0F;
|
||||
final VoxelShape baseShape = Block.createCuboidShape(f, 0.0, f, g, height, g);
|
||||
final VoxelShape northShape = Block.createCuboidShape(h, (float) 0.0, 0.0, i, height, i);
|
||||
final VoxelShape southShape = Block.createCuboidShape(h, (float) 0.0, h, i, height, 16.0);
|
||||
final VoxelShape westShape = Block.createCuboidShape(0.0, (float) 0.0, h, i, height, i);
|
||||
final VoxelShape eastShape = Block.createCuboidShape(h, (float) 0.0, h, 16.0, height, 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),
|
||||
Block.createCuboidShape(f, (float) 0.0, h, g, height, 16.0D),
|
||||
Block.createCuboidShape(0.0D, (float) 0.0, f, i, height, g),
|
||||
Block.createCuboidShape(f - 6, (float) 0.0, h, g, height, 16.0D),
|
||||
Block.createCuboidShape(f, (float) 0.0, 0.0D, g, height, 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),
|
||||
Block.createCuboidShape(f - 6, (float) 0.0, 0.0D, g, height, i),
|
||||
Block.createCuboidShape(f - 6, (float) 0.0, h - 5, g, height, 16.0D),
|
||||
Block.createCuboidShape(h, (float) 0.0, f, 16.0D, height, g),
|
||||
Block.createCuboidShape(h, (float) 0.0, f, 16.0D, height, 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)
|
||||
Block.createCuboidShape(h - 5, (float) 0.0, f, 16.0D, height, g + 6),
|
||||
Block.createCuboidShape(f, (float) 0.0, 0.0D, g + 6, height, i),
|
||||
Block.createCuboidShape(f, (float) 0.0, 0.0D, g + 6, height, i + 5),
|
||||
Block.createCuboidShape(h - 5, (float) 0.0, f - 6, 16.0D, height, g),
|
||||
Block.createCuboidShape(0, (float) 0.0, 0, 16.0D, height, 16.0D)
|
||||
};
|
||||
|
||||
for (int j = 0; j < 16; ++j) {
|
||||
|
@ -37,16 +37,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
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);
|
||||
private static final VoxelShape viaFabricPlus$x_and_z_axis_collision_shape_b1_8_1 = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 24.0D, 16.0D);
|
||||
|
||||
protected MixinFenceGateBlock(Settings settings) {
|
||||
super(settings);
|
||||
@ -55,14 +46,14 @@ public abstract class MixinFenceGateBlock extends HorizontalFacingBlock {
|
||||
@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);
|
||||
cir.setReturnValue(VoxelShapes.fullCube());
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
cir.setReturnValue(viaFabricPlus$x_and_z_axis_collision_shape_b1_8_1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,12 +35,13 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(FireBlock.class)
|
||||
public class MixinFireBlock {
|
||||
public abstract class MixinFireBlock {
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
|
||||
cir.setReturnValue(VoxelShapes.empty());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,16 +34,17 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(FlowerPotBlock.class)
|
||||
public class MixinFlowerPotBlock {
|
||||
public abstract class MixinFlowerPotBlock {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private Block content;
|
||||
|
||||
@Inject(method = "onUse", at = @At(value = "FIELD", target = "Lnet/minecraft/block/FlowerPotBlock;content:Lnet/minecraft/block/Block;", ordinal = 0), cancellable = true)
|
||||
private void injectOnUse(CallbackInfoReturnable<ActionResult> ci) {
|
||||
private void alwaysConsume(CallbackInfoReturnable<ActionResult> ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_10) && content != Blocks.AIR) {
|
||||
ci.setReturnValue(ActionResult.CONSUME);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,15 +35,16 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(FlowerbedBlock.class)
|
||||
public class MixinFlowerbedBlock {
|
||||
public abstract class MixinFlowerbedBlock {
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape viaFabricPlus$shape_r1_20_1 = Block.createCuboidShape(0.0, 0.0, 0.0, 16.0, 3.0, 16.0);
|
||||
private static final VoxelShape viaFabricPlus$shape_r1_20_1 = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 3.0D, 16.0D);
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
public void replaceShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) {
|
||||
cir.setReturnValue(viaFabricPlus$shape_r1_20_1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,10 +37,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
public abstract class MixinHopperBlock extends BlockWithEntity {
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape viaFabricPlus$inside_shape_r1_12_2 = Block.createCuboidShape(2, 10, 2, 14, 16, 14);
|
||||
private static final VoxelShape viaFabricPlus$inside_shape_r1_12_2 = Block.createCuboidShape(2.0D, 10.0D, 2.0D, 14.0D, 16.0D, 14.0D);
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape viaFabricPlus$hopper_shape_r1_12_2 = VoxelShapes.combineAndSimplify(VoxelShapes.fullCube(), viaFabricPlus$inside_shape_r1_12_2, BooleanBiFunction.ONLY_FIRST);
|
||||
private static final 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;
|
||||
@ -50,7 +50,7 @@ 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) {
|
||||
public void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (viaFabricPlus$requireOriginalShape) {
|
||||
viaFabricPlus$requireOriginalShape = false;
|
||||
return;
|
||||
@ -61,7 +61,7 @@ public abstract class MixinHopperBlock extends BlockWithEntity {
|
||||
}
|
||||
|
||||
@Inject(method = "getRaycastShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetRaycastShape(BlockState state, BlockView world, BlockPos pos, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
public void changeRaycastShape(BlockState state, BlockView world, BlockPos pos, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
cir.setReturnValue(viaFabricPlus$inside_shape_r1_12_2);
|
||||
}
|
||||
@ -69,7 +69,9 @@ public abstract class MixinHopperBlock extends BlockWithEntity {
|
||||
|
||||
@Override
|
||||
public VoxelShape getCullingShape(BlockState state, BlockView world, BlockPos pos) {
|
||||
// Workaround for https://github.com/ViaVersion/ViaFabricPlus/issues/45
|
||||
viaFabricPlus$requireOriginalShape = true;
|
||||
return super.getCullingShape(state, world, pos);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,22 +35,22 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(LadderBlock.class)
|
||||
public class MixinLadderBlock {
|
||||
public abstract class MixinLadderBlock {
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape viaFabricPlus$east_shape_r1_8_x = Block.createCuboidShape(0, 0, 0, 2, 16, 16);
|
||||
private static final VoxelShape viaFabricPlus$east_shape_r1_8_x = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 2.0D, 16.0D, 16.0D);
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape viaFabricPlus$west_shape_r1_8_x = Block.createCuboidShape(14, 0, 0, 16, 16, 16);
|
||||
private static final VoxelShape viaFabricPlus$west_shape_r1_8_x = Block.createCuboidShape(14.0D, 0.0D, 0.0D, 16.0D, 16.0D, 16.0D);
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape viaFabricPlus$south_shape_r1_8_x = Block.createCuboidShape(0, 0, 0, 16, 16, 2);
|
||||
private static final VoxelShape viaFabricPlus$south_shape_r1_8_x = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 16.0D, 2.0D);
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape viaFabricPlus$north_shape_r1_8_x = Block.createCuboidShape(0, 0, 14, 16, 16, 16);
|
||||
private static final VoxelShape viaFabricPlus$north_shape_r1_8_x = Block.createCuboidShape(0.0D, 0.0D, 14.0D, 16.0D, 16.0D, 16.0D);
|
||||
|
||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||
private void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> ci) {
|
||||
private void changeOutlineShape(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_r1_8_x);
|
||||
@ -60,4 +60,5 @@ public class MixinLadderBlock {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,15 +35,16 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(LilyPadBlock.class)
|
||||
public class MixinLilyPadBlock {
|
||||
public abstract class MixinLilyPadBlock {
|
||||
|
||||
@Unique
|
||||
private final static VoxelShape viaFabricPlus$shape_r1_8_x = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 0.25D, 16.0D);
|
||||
private static final 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) {
|
||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
cir.setReturnValue(viaFabricPlus$shape_r1_8_x);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,62 +36,38 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
public abstract class MixinPaneBlock extends HorizontalConnectingBlock {
|
||||
|
||||
@Unique
|
||||
private VoxelShape[] collisionShapes1_8;
|
||||
|
||||
@Unique
|
||||
private VoxelShape[] boundingShapes1_8;
|
||||
private VoxelShape[] viaFabricPlus$shape_r1_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);
|
||||
}
|
||||
private void initShapes1_8(Settings settings, CallbackInfo ci) {
|
||||
final float f = 7.0F;
|
||||
final float g = 9.0F;
|
||||
final float h = 7.0F;
|
||||
final float i = 9.0F;
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
return this.boundingShapes1_8[this.getShapeIndex(state)];
|
||||
}
|
||||
final VoxelShape baseShape = Block.createCuboidShape(f, 0.0, f, g, (float) 16.0, g);
|
||||
final VoxelShape northShape = Block.createCuboidShape(h, (float) 0.0, 0.0, i, (float) 16.0, i);
|
||||
final VoxelShape southShape = Block.createCuboidShape(h, (float) 0.0, h, i, (float) 16.0, 16.0);
|
||||
final VoxelShape westShape = Block.createCuboidShape(0.0, (float) 0.0, h, i, (float) 16.0, i);
|
||||
final VoxelShape eastShape = Block.createCuboidShape(h, (float) 0.0, h, 16.0, (float) 16.0, i);
|
||||
|
||||
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 this.collisionShapes1_8[this.getShapeIndex(state)];
|
||||
}
|
||||
|
||||
return super.getCollisionShape(state, world, pos, context);
|
||||
}
|
||||
|
||||
@Unique
|
||||
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[]{
|
||||
|
||||
viaFabricPlus$shape_r1_8 = 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
|
||||
Block.createCuboidShape(h, (float) 0.0, h + 1, i, (float) 16.0, 16.0D), // south
|
||||
Block.createCuboidShape(0.0D, (float) 0.0, h, i - 1, (float) 16.0, i), // west
|
||||
southWestCornerShape,
|
||||
Block.createCuboidShape(h, offset2, 0.0D, i, height2, i - 1), // north
|
||||
Block.createCuboidShape(h, (float) 0.0, 0.0D, i, (float) 16.0, 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
|
||||
Block.createCuboidShape(h + 1, (float) 0.0, h, 16.0D, (float) 16.0, i), // east
|
||||
VoxelShapes.union(southShape, eastShape),
|
||||
VoxelShapes.union(westShape, eastShape),
|
||||
VoxelShapes.union(southWestCornerShape, eastShape),
|
||||
@ -103,10 +79,26 @@ public abstract class MixinPaneBlock extends HorizontalConnectingBlock {
|
||||
|
||||
for (int j = 0; j < 16; ++j) {
|
||||
if (j == 1 || j == 2 || j == 4 || j == 8) continue;
|
||||
voxelShapes[j] = VoxelShapes.union(baseShape, voxelShapes[j]);
|
||||
viaFabricPlus$shape_r1_8[j] = VoxelShapes.union(baseShape, viaFabricPlus$shape_r1_8[j]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
return this.viaFabricPlus$shape_r1_8[this.getShapeIndex(state)];
|
||||
}
|
||||
|
||||
return voxelShapes;
|
||||
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 this.viaFabricPlus$shape_r1_8[this.getShapeIndex(state)];
|
||||
}
|
||||
|
||||
return super.getCollisionShape(state, world, pos, context);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -64,17 +64,14 @@ public abstract class MixinPistonBlock extends FacingBlock {
|
||||
@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) {
|
||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_1)) {
|
||||
cir.setReturnValue(_1_1_SHAPE);
|
||||
cir.setReturnValue(VoxelShapes.fullCube());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,29 +62,29 @@ public abstract class MixinPistonHeadBlock extends FacingBlock {
|
||||
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);
|
||||
private static final VoxelShape viaFabricPlus$up_arm_shape_r1_8_x = 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);
|
||||
private static final VoxelShape viaFabricPlus$down_arm_shape_r1_8_x = 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);
|
||||
private static final VoxelShape viaFabricPlus$south_arm_shape_r1_8_x = 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);
|
||||
private static final VoxelShape viaFabricPlus$north_arm_shape_r1_8_x = 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);
|
||||
private static final VoxelShape viaFabricPlus$east_arm_shape_r1_8_x = 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);
|
||||
private static final VoxelShape viaFabricPlus$west_arm_shape_r1_8_x = Block.createCuboidShape(6.0, 4.0, 4.0, 10.0, 12.0, 16.0);
|
||||
|
||||
protected MixinPistonHeadBlock(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) {
|
||||
private void changeOutlineShape(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;
|
||||
@ -101,12 +101,12 @@ public abstract class MixinPistonHeadBlock extends FacingBlock {
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||
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);
|
||||
case DOWN -> VoxelShapes.union(DOWN_HEAD_SHAPE, viaFabricPlus$down_arm_shape_r1_8_x);
|
||||
case UP -> VoxelShapes.union(UP_HEAD_SHAPE, viaFabricPlus$up_arm_shape_r1_8_x);
|
||||
case NORTH -> VoxelShapes.union(NORTH_HEAD_SHAPE, viaFabricPlus$north_arm_shape_r1_8_x);
|
||||
case SOUTH -> VoxelShapes.union(SOUTH_HEAD_SHAPE, viaFabricPlus$south_arm_shape_r1_8_x);
|
||||
case WEST -> VoxelShapes.union(WEST_HEAD_SHAPE, viaFabricPlus$west_arm_shape_r1_8_x);
|
||||
case EAST -> VoxelShapes.union(EAST_HEAD_SHAPE, viaFabricPlus$east_arm_shape_r1_8_x);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -38,28 +38,30 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(SnowBlock.class)
|
||||
public class MixinSnowBlock {
|
||||
public abstract class MixinSnowBlock {
|
||||
|
||||
@Unique
|
||||
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),
|
||||
Block.createCuboidShape(0, 0, 0, 16, 8, 16),
|
||||
Block.createCuboidShape(0, 0, 0, 16, 10, 16),
|
||||
Block.createCuboidShape(0, 0, 0, 16, 12, 16),
|
||||
Block.createCuboidShape(0, 0, 0, 16, 14, 16),
|
||||
Block.createCuboidShape(0, 0, 0, 16, 16, 16)
|
||||
private static final VoxelShape[] viaFabricPlus$layers_to_shape_r1_12_2 = new VoxelShape[]{
|
||||
Block.createCuboidShape(0.0D, -0.00001 /* 0.0D */, 0.0D, 16.0D, 0.0D, 16.0D),
|
||||
Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D),
|
||||
Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 4.0D, 16.0D),
|
||||
Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 6.0D, 16.0D),
|
||||
Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D),
|
||||
Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 10.0D, 16.0D),
|
||||
Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 12.0D, 16.0D),
|
||||
Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 14.0D, 16.0D),
|
||||
Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 16.0D, 16.0D)
|
||||
};
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
public static IntProperty LAYERS;
|
||||
|
||||
@Inject(method = "getCollisionShape", at = @At("HEAD"), cancellable = true)
|
||||
public void injectGetOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||
private void changeCollisionShape(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_r1_12_2[state.get(LAYERS) - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -52,22 +52,22 @@ public abstract class MixinWallBlock extends Block {
|
||||
private Map<BlockState, VoxelShape> shapeMap;
|
||||
|
||||
@Unique
|
||||
private VoxelShape[] collisionShapes1_12_2;
|
||||
private final Object2IntMap<BlockState> viaFabricPlus$shape_index_cache_r1_12_2 = new Object2IntOpenHashMap<>();
|
||||
|
||||
@Unique
|
||||
private VoxelShape[] boundingShapes1_12_2;
|
||||
private VoxelShape[] viaFabricPlus$collision_shape_r1_12_2;
|
||||
|
||||
@Unique
|
||||
private final Object2IntMap<BlockState> SHAPE_INDEX_CACHE1_12_2 = new Object2IntOpenHashMap<>();
|
||||
private VoxelShape[] viaFabricPlus$outline_shape_r1_12_2;
|
||||
|
||||
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);
|
||||
private void initShapes1_12_2(Settings settings, CallbackInfo ci) {
|
||||
this.viaFabricPlus$collision_shape_r1_12_2 = this.createShapes1_12_2(24.0F);
|
||||
this.viaFabricPlus$outline_shape_r1_12_2 = this.createShapes1_12_2(16.0F);
|
||||
}
|
||||
|
||||
@Inject(method = "getPlacementState", at = @At("RETURN"), cancellable = true)
|
||||
@ -112,14 +112,14 @@ public abstract class MixinWallBlock extends Block {
|
||||
@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)]);
|
||||
cir.setReturnValue(this.viaFabricPlus$outline_shape_r1_12_2[this.getShapeIndex(state)]);
|
||||
}
|
||||
}
|
||||
|
||||
@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(WallBlock.UP) && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||
cir.setReturnValue(this.collisionShapes1_12_2[this.getShapeIndex(state)]);
|
||||
cir.setReturnValue(this.viaFabricPlus$collision_shape_r1_12_2[this.getShapeIndex(state)]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,33 +133,34 @@ public abstract class MixinWallBlock extends Block {
|
||||
}
|
||||
|
||||
@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);
|
||||
private VoxelShape[] createShapes1_12_2(final float height) {
|
||||
final float f = 4.0F;
|
||||
final float g = 12.0F;
|
||||
final float h = 5.0F;
|
||||
final float i = 11.0F;
|
||||
|
||||
final VoxelShape baseShape = Block.createCuboidShape(f, 0.0D, f, g, height, g);
|
||||
final VoxelShape northShape = Block.createCuboidShape(h, (float) 0.0, 0.0D, i, height, i);
|
||||
final VoxelShape southShape = Block.createCuboidShape(h, (float) 0.0, h, i, height, 16.0D);
|
||||
final VoxelShape westShape = Block.createCuboidShape(0.0D, (float) 0.0, h, i, height, i);
|
||||
final VoxelShape eastShape = Block.createCuboidShape(h, (float) 0.0, h, 16.0D, height, 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),
|
||||
Block.createCuboidShape(f, (float) 0.0, h, g, height, 16.0D),
|
||||
Block.createCuboidShape(0.0D, (float) 0.0, f, i, height, g),
|
||||
Block.createCuboidShape(f - 4, (float) 0.0, h - 1, g, height, 16.0D),
|
||||
Block.createCuboidShape(f, (float) 0.0, 0.0D, g, height, 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),
|
||||
Block.createCuboidShape(f - 4, (float) 0.0, 0.0D, g, height, i + 1),
|
||||
Block.createCuboidShape(f - 4, (float) 0.0, h - 5, g, height, 16.0D),
|
||||
Block.createCuboidShape(h, (float) 0.0, f, 16.0D, height, g),
|
||||
Block.createCuboidShape(h - 1, (float) 0.0, f, 16.0D, height, 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)
|
||||
Block.createCuboidShape(h - 5, (float) 0.0, f, 16.0D, height, g + 4),
|
||||
Block.createCuboidShape(f, (float) 0.0, 0.0D, g + 4, height, i + 1),
|
||||
Block.createCuboidShape(f, (float) 0.0, 0.0D, g + 4, height, i + 5),
|
||||
Block.createCuboidShape(h - 5, (float) 0.0, f - 4, 16.0D, height, g),
|
||||
Block.createCuboidShape(0, (float) 0.0, 0, 16.0D, height, 16.0D)
|
||||
};
|
||||
|
||||
for (int j = 0; j < 16; ++j) {
|
||||
@ -176,7 +177,7 @@ public abstract class MixinWallBlock extends Block {
|
||||
|
||||
@Unique
|
||||
private int getShapeIndex(BlockState state) {
|
||||
return this.SHAPE_INDEX_CACHE1_12_2.computeIntIfAbsent(state, statex -> {
|
||||
return this.viaFabricPlus$shape_index_cache_r1_12_2.computeIntIfAbsent(state, statex -> {
|
||||
int i = 0;
|
||||
if (!WallShape.NONE.equals(statex.get(WallBlock.NORTH_SHAPE))) {
|
||||
i |= getDirectionMask(Direction.NORTH);
|
||||
|
@ -29,10 +29,11 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(AnimalEntity.class)
|
||||
public class MixinAnimalEntity {
|
||||
public abstract class MixinAnimalEntity {
|
||||
|
||||
@Redirect(method = "interactMob", at = @At(value = "FIELD", target = "Lnet/minecraft/world/World;isClient:Z"))
|
||||
public boolean redirectInteractMob(World instance) {
|
||||
private boolean redirectInteractMob(World instance) {
|
||||
return instance.isClient && ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_15);
|
||||
}
|
||||
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user