From 7cb8e9c859f62c9461e1f85b2e9a5980b8d2b7f2 Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 1 Feb 2024 23:17:46 +0000 Subject: [PATCH] Fixed cloud block placement desync when on multiplayer --- .../com/minelittlepony/unicopia/InteractionManager.java | 4 ++++ .../unicopia/ability/AbilityDispatcher.java | 1 + .../unicopia/client/ClientInteractionManager.java | 9 +++++++++ .../unicopia/item/cloud/CloudBlockItem.java | 4 +++- .../resources/data/unicopia/tags/items/falls_slowly.json | 3 ++- 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/InteractionManager.java b/src/main/java/com/minelittlepony/unicopia/InteractionManager.java index 736cf4a3..7c60d0d5 100644 --- a/src/main/java/com/minelittlepony/unicopia/InteractionManager.java +++ b/src/main/java/com/minelittlepony/unicopia/InteractionManager.java @@ -86,4 +86,8 @@ public class InteractionManager { public PlayerEntity createPlayer(World world, GameProfile profile) { return new DummyPlayerEntity(world, profile); } + + public void sendPlayerLookAngles(PlayerEntity player) { + + } } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/AbilityDispatcher.java b/src/main/java/com/minelittlepony/unicopia/ability/AbilityDispatcher.java index d9a977b4..8a291d0a 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/AbilityDispatcher.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/AbilityDispatcher.java @@ -209,6 +209,7 @@ public class AbilityDispatcher implements Tickable, NbtSerialisable { warmup = 0; if (data.isPresent()) { + InteractionManager.instance().sendPlayerLookAngles(player.asEntity()); Channel.CLIENT_PLAYER_ABILITY.sendToServer(new MsgPlayerAbility<>(ability, data, ActivationType.NONE)); } else { player.asEntity().playSound(USounds.GUI_ABILITY_FAIL, 1, 1); diff --git a/src/main/java/com/minelittlepony/unicopia/client/ClientInteractionManager.java b/src/main/java/com/minelittlepony/unicopia/client/ClientInteractionManager.java index 3a4105b9..837b65fd 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/ClientInteractionManager.java +++ b/src/main/java/com/minelittlepony/unicopia/client/ClientInteractionManager.java @@ -26,6 +26,7 @@ import com.mojang.authlib.GameProfile; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.sound.AggressiveBeeSoundInstance; import net.minecraft.client.sound.MovingMinecartSoundInstance; import net.minecraft.client.sound.PassiveBeeSoundInstance; @@ -37,6 +38,7 @@ import net.minecraft.entity.passive.BeeEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.vehicle.AbstractMinecartEntity; import net.minecraft.network.PacketByteBuf; +import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import net.minecraft.sound.SoundCategory; import net.minecraft.util.Identifier; import net.minecraft.util.math.random.Random; @@ -152,4 +154,11 @@ public class ClientInteractionManager extends InteractionManager { public ParticleSpawner createBoundParticle(UUID id) { return new ClientBoundParticleSpawner(id); } + + @Override + public void sendPlayerLookAngles(PlayerEntity player) { + if (player instanceof ClientPlayerEntity c) { + c.networkHandler.sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(player.getYaw(), player.getPitch(), player.isOnGround())); + } + } } diff --git a/src/main/java/com/minelittlepony/unicopia/item/cloud/CloudBlockItem.java b/src/main/java/com/minelittlepony/unicopia/item/cloud/CloudBlockItem.java index 4652d8e9..f208e723 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/cloud/CloudBlockItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/cloud/CloudBlockItem.java @@ -1,5 +1,7 @@ package com.minelittlepony.unicopia.item.cloud; +import com.minelittlepony.unicopia.InteractionManager; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; @@ -30,7 +32,7 @@ extends BlockItem { @Override public TypedActionResult use(World world, PlayerEntity user, Hand hand) { - + InteractionManager.instance().sendPlayerLookAngles(user); Vec3d targetPos = user.getEyePos().add(user.getRotationVec(1).multiply(1, 1.5, 1).normalize().multiply(2)); ItemPlacementContext context = new ItemPlacementContext(user, hand, user.getStackInHand(hand), new BlockHitResult( targetPos, diff --git a/src/main/resources/data/unicopia/tags/items/falls_slowly.json b/src/main/resources/data/unicopia/tags/items/falls_slowly.json index d413b877..49ac7cee 100644 --- a/src/main/resources/data/unicopia/tags/items/falls_slowly.json +++ b/src/main/resources/data/unicopia/tags/items/falls_slowly.json @@ -2,6 +2,7 @@ "replace": false, "values": [ "minecraft:feather", - "#unicopia:magic_feathers" + "#unicopia:magic_feathers", + "unicopia:cloud_lump" ] }