Skip to content

Commit

Permalink
Work
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Dec 25, 2024
1 parent 90c1832 commit 396f2c8
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<

@Inject(method = "setCompressionThreshold", at = @At("RETURN"))
private void reorderCompression(int compressionThreshold, boolean rejectBad, CallbackInfo ci) {
// Compression enabled and elements put into pipeline, move via handlers
channel.pipeline().fireUserEventTriggered(CompressionReorderEvent.INSTANCE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.viaversion.viafabricplus.injection.mixin.base.ui;
package com.viaversion.viafabricplus.injection.mixin.base.integration.bedrock;

import com.viaversion.viafabricplus.injection.access.base.bedrock.IConfirmScreen;
import net.minecraft.client.gui.screen.ConfirmScreen;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.viaversion.viafabricplus.injection.mixin.base.integration;
package com.viaversion.viafabricplus.injection.mixin.base.integration.bedrock;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.viaversion.viafabricplus.injection.mixin.base.integration;
package com.viaversion.viafabricplus.injection.mixin.base.integration.event;

import com.viaversion.viafabricplus.api.events.LoadingCycleCallback;
import com.viaversion.viafabricplus.base.Events;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ public abstract class MixinEntityPacketRewriter1_17 {

@Redirect(method = "registerPackets", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/protocols/v1_16_4to1_17/Protocol1_16_4To1_17;registerClientbound(Lcom/viaversion/viaversion/api/protocol/packet/ClientboundPacketType;Lcom/viaversion/viaversion/api/protocol/remapper/PacketHandler;)V"))
private void handleClassicWorldHeight(Protocol1_16_4To1_17 instance, ClientboundPacketType packetType, PacketHandler packetHandler) {
if (packetType == ClientboundPackets1_16_2.LOGIN) packetHandler = WorldHeightSupport.handleJoinGame(packetHandler);
if (packetType == ClientboundPackets1_16_2.RESPAWN) packetHandler = WorldHeightSupport.handleRespawn(packetHandler);
if (packetType == ClientboundPackets1_16_2.LOGIN) {
packetHandler = WorldHeightSupport.handleJoinGame(packetHandler);
}
if (packetType == ClientboundPackets1_16_2.RESPAWN) {
packetHandler = WorldHeightSupport.handleRespawn(packetHandler);
}

((Protocol) instance).registerClientbound(packetType, packetHandler);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ public abstract class MixinWorldPacketRewriter1_17 {

@Redirect(method = "register", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/protocols/v1_16_4to1_17/Protocol1_16_4To1_17;registerClientbound(Lcom/viaversion/viaversion/api/protocol/packet/ClientboundPacketType;Lcom/viaversion/viaversion/api/protocol/remapper/PacketHandler;)V"))
private static void handleClassicWorldHeight(Protocol1_16_4To1_17 instance, ClientboundPacketType packetType, PacketHandler packetHandler) {
if (packetType == ClientboundPackets1_16_2.LEVEL_CHUNK) packetHandler = WorldHeightSupport.handleChunkData(packetHandler);
if (packetType == ClientboundPackets1_16_2.LIGHT_UPDATE) packetHandler = WorldHeightSupport.handleUpdateLight(packetHandler);
if (packetType == ClientboundPackets1_16_2.LEVEL_CHUNK) {
packetHandler = WorldHeightSupport.handleChunkData(packetHandler);
}
if (packetType == ClientboundPackets1_16_2.LIGHT_UPDATE) {
packetHandler = WorldHeightSupport.handleUpdateLight(packetHandler);
}

((Protocol) instance).registerClientbound(packetType, packetHandler);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus
* Copyright (C) 2021-2024 the original authors
* - FlorianMichael/EnZaXD <[email protected]>
* - RK_01/RaphiMC
* Copyright (C) 2023-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.viaversion.viafabricplus.injection.mixin.features.entity.interactions;

import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.vehicle.AbstractBoatEntity;
import net.minecraft.entity.vehicle.BoatEntity;
import net.minecraft.entity.vehicle.VehicleEntity;
import net.minecraft.item.Item;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

import java.util.function.Supplier;

@Mixin(AbstractBoatEntity.class)
public abstract class MixinAbstractBoatEntity extends VehicleEntity {

public MixinAbstractBoatEntity(EntityType<?> entityType, World world) {
super(entityType, world);
}

@Redirect(method = "interact", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/vehicle/VehicleEntity;interact(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;"))
private ActionResult makeNotLeashable(VehicleEntity instance, PlayerEntity player, Hand hand) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20_5)) {
return ActionResult.PASS;
} else {
return super.interact(player, hand);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus
* Copyright (C) 2021-2024 the original authors
* - FlorianMichael/EnZaXD <[email protected]>
* - RK_01/RaphiMC
* Copyright (C) 2023-2024 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.viaversion.viafabricplus.injection.mixin.features.entity.riding_offsets;

import com.viaversion.viafabricplus.features.entity.riding_offsets.EntityRidingOffsetsPre1_20_2;
import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.vehicle.AbstractBoatEntity;
import net.minecraft.entity.vehicle.VehicleEntity;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(AbstractBoatEntity.class)
public abstract class MixinAbstractBoatEntity extends VehicleEntity {

public MixinAbstractBoatEntity(EntityType<?> entityType, World world) {
super(entityType, world);
}

@Inject(method = "updatePassengerPosition", at = @At(value = "HEAD"), cancellable = true)
private void updatePassengerPosition1_8(Entity passenger, Entity.PositionUpdater positionUpdater, CallbackInfo ci) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
final Vec3d newPosition = EntityRidingOffsetsPre1_20_2.getMountedHeightOffset(this, passenger).add(this.getPos());
positionUpdater.accept(passenger, newPosition.x, newPosition.y + EntityRidingOffsetsPre1_20_2.getHeightOffset(passenger), newPosition.z);
ci.cancel();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.viaversion.viafabricplus.injection.mixin.features.entity.v1_8_boat;
package com.viaversion.viafabricplus.injection.mixin.features.movement.entity;

import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viafabricplus.features.entity.riding_offsets.EntityRidingOffsetsPre1_20_2;
import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
Expand All @@ -31,14 +30,11 @@
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.MovementType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.vehicle.AbstractBoatEntity;
import net.minecraft.entity.vehicle.BoatEntity;
import net.minecraft.entity.vehicle.VehicleEntity;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.registry.tag.FluidTags;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.MathHelper;
Expand Down Expand Up @@ -88,15 +84,6 @@ public MixinAbstractBoatEntity(EntityType<?> entityType, World world) {
super(entityType, world);
}

@Redirect(method = "interact", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/vehicle/VehicleEntity;interact(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;"))
private ActionResult makeNotLeashable(VehicleEntity instance, PlayerEntity player, Hand hand) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20_5)) {
return ActionResult.PASS;
} else {
return super.interact(player, hand);
}
}

@Redirect(method = "updateVelocity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;isSpaceEmpty(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/math/Box;)Z"))
private boolean alwaysUpdatePosition(World instance, Entity entity, Box box) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20_5)) {
Expand Down Expand Up @@ -310,15 +297,6 @@ private void tick1_8(CallbackInfo ci) {
}
}

@Inject(method = "updatePassengerPosition", at = @At(value = "HEAD"), cancellable = true)
private void updatePassengerPosition1_8(Entity passenger, PositionUpdater positionUpdater, CallbackInfo ci) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
final Vec3d newPosition = EntityRidingOffsetsPre1_20_2.getMountedHeightOffset(this, passenger).add(this.getPos());
positionUpdater.accept(passenger, newPosition.x, newPosition.y + EntityRidingOffsetsPre1_20_2.getHeightOffset(passenger), newPosition.z);
ci.cancel();
}
}

@Inject(method = "onPassengerLookAround", at = @At("HEAD"), cancellable = true)
private void onPassengerLookAround1_8(Entity passenger, CallbackInfo ci) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
Expand Down
28 changes: 16 additions & 12 deletions src/main/resources/viafabricplus.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
"base.connection.MixinMultiplayerServerListPinger",
"base.integration.MixinClientConnection",
"base.integration.MixinDebugHud",
"base.integration.MixinMinecraftClient",
"base.integration.MixinMultiplayerServerListPinger",
"base.integration.MixinMultiplayerServerListPinger_1",
"base.integration.MixinServerInfo",
"base.integration.MixinUserConnectionImpl",
"base.integration.bedrock.MixinConfirmScreen",
"base.integration.bedrock.MixinConnectScreen_1",
"base.integration.bedrock.MixinMultiplayerServerListPinger",
"base.integration.event.MixinMinecraftClient",
"base.integration.sync_tasks.MixinClientCommonNetworkHandler",
"base.ui.MixinAddServerScreen",
"base.ui.MixinConfirmScreen",
"base.ui.MixinConnectScreen_1",
"base.ui.MixinDirectConnectScreen",
"base.ui.MixinDownloadingTerrainScreen",
Expand Down Expand Up @@ -107,7 +107,7 @@
"features.entity.metadata_handling.MixinEntityTracker1_9",
"features.entity.pose.MixinOtherClientPlayerEntity",
"features.entity.riding_offsets.MixinCamelEntity",
"features.entity.v1_8_boat.MixinAbstractBoatEntity",
"features.movement.entity.MixinAbstractBoatEntity",
"features.entity.v1_8_boat.MixinEntityModels",
"features.entity.v1_8_boat.MixinEntityRenderDispatcher",
"features.execute_inputs_sync.MixinKeyboard",
Expand Down Expand Up @@ -167,6 +167,11 @@
"features.movement.block.MixinHoneyBlock",
"features.movement.block.MixinSoulSandBlock",
"features.movement.elytra.MixinFireworkRocketItem",
"features.movement.entity.MixinClientPlayerEntity",
"features.movement.entity.MixinEntity",
"features.movement.entity.MixinLivingEntity",
"features.movement.entity.MixinPlayerEntity",
"features.movement.entity.MixinPlayerEntityRenderer",
"features.movement.entity.MixinSkeletonHorseEntity",
"features.movement.item.MixinEnderEyeItem",
"features.movement.levitation_value.MixinStatusEffectInstance",
Expand Down Expand Up @@ -200,6 +205,7 @@
"features.networking.srv_resolving.MixinRedirectResolver",
"features.networking.srv_resolving.MixinServerAddress",
"features.networking.warn_feature_updates.MixinClientConfigurationNetworkHandler",
"features.open_inventory_packet.MixinMinecraftClient",
"features.player_abilities.MixinUpdatePlayerAbilitiesC2SPacket",
"features.recipe_emulation.MixinCraftingScreenHandler",
"features.recipe_emulation.MixinEntityPacketRewriter1_12",
Expand All @@ -217,18 +223,16 @@
"features.world.item_picking.MixinMinecraftClient",
"features.world.remove_server_view_distance.MixinGameOptions",
"integration.viabedrock.MixinJoinPackets",
"integration.vialegacy.MixinViaLegacyConfig",
"features.open_inventory_packet.MixinMinecraftClient",
"features.movement.entity.MixinClientPlayerEntity",
"features.movement.entity.MixinEntity",
"features.movement.entity.MixinLivingEntity",
"features.movement.entity.MixinPlayerEntity",
"features.movement.entity.MixinPlayerEntityRenderer"
"integration.vialegacy.MixinViaLegacyConfig"
],
"injectors": {
"defaultRequire": 1
},
"overwrites": {
"requireAnnotations": true
}
},
"mixins": [
"features.entity.interactions.MixinAbstractBoatEntity",
"features.entity.riding_offsets.MixinAbstractBoatEntity"
]
}

0 comments on commit 396f2c8

Please sign in to comment.