mirror of
https://github.com/GeyserMC/Geyser.git
synced 2025-12-19 14:59:27 +00:00
Resolve client-side visual bug when removing flowers from flower pots
Fixes https://github.com/GeyserMC/Geyser/issues/5295
This commit is contained in:
@@ -27,7 +27,6 @@ package org.geysermc.geyser.translator.protocol.bedrock;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
|
||||
import java.util.List;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.math.vector.Vector3i;
|
||||
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
|
||||
@@ -64,6 +63,7 @@ import org.geysermc.geyser.level.block.type.Block;
|
||||
import org.geysermc.geyser.level.block.type.BlockState;
|
||||
import org.geysermc.geyser.level.block.type.ButtonBlock;
|
||||
import org.geysermc.geyser.level.block.type.CauldronBlock;
|
||||
import org.geysermc.geyser.level.block.type.FlowerPotBlock;
|
||||
import org.geysermc.geyser.registry.BlockRegistries;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.skin.FakeHeadProvider;
|
||||
@@ -90,6 +90,8 @@ import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.player.Serv
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.player.ServerboundSwingPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.player.ServerboundUseItemOnPacket;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* BedrockInventoryTransactionTranslator handles most interactions between the client and the world,
|
||||
* or the client and their inventory.
|
||||
@@ -325,6 +327,24 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
||||
session.setPlacedBucket(true);
|
||||
}
|
||||
}
|
||||
|
||||
// Fix https://github.com/GeyserMC/Geyser/issues/5295
|
||||
// This is not an issue on 1.21.8, as there the Java server matches the client prediction
|
||||
// However, plugins might change that, so, let's always stop Bedrock shenanigans
|
||||
if (blockState.block() instanceof FlowerPotBlock flowerPotBlock && flowerPotBlock.flower() != Blocks.AIR) {
|
||||
Item mightStackHere = flowerPotBlock.flower().asItem();
|
||||
for (int i = 0; i < 36; i++) {
|
||||
int slot = i;
|
||||
if (i < 9) {
|
||||
slot = session.getPlayerInventory().getOffsetForHotbar(slot);
|
||||
}
|
||||
GeyserItemStack stack = session.getPlayerInventory().getItem(slot);
|
||||
if (stack.isEmpty() || stack.getJavaId() == mightStackHere.javaId()) {
|
||||
session.getPlayerInventoryHolder().updateSlot(slot);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (packet.getActions().isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user