mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Prevent 2x placement due to extended collision box
Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com>
This commit is contained in:
parent
4e88a7fb9a
commit
41d7d8e3a3
1 changed files with 22 additions and 0 deletions
|
@ -173,6 +173,27 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
|||
}
|
||||
}
|
||||
|
||||
// Check if this is a double placement due to an extended collision block
|
||||
if (!session.getBlockMappings().getExtendedCollisionBoxes().isEmpty()) {
|
||||
Vector3i belowBlockPos = null;
|
||||
switch (packet.getBlockFace()) {
|
||||
case 1 -> belowBlockPos = blockPos.add(0, -2, 0);
|
||||
case 2 -> belowBlockPos = blockPos.add(0, -1, 1);
|
||||
case 3 -> belowBlockPos = blockPos.add(0, -1, -1);
|
||||
case 4 -> belowBlockPos = blockPos.add(1, -1, 0);
|
||||
case 5 -> belowBlockPos = blockPos.add(-1, -1, 0);
|
||||
}
|
||||
|
||||
if (belowBlockPos != null) {
|
||||
int belowBlock = session.getGeyser().getWorldManager().getBlockAt(session, belowBlockPos);
|
||||
BlockDefinition extendedCollisionDefinition = session.getBlockMappings().getExtendedCollisionBoxes().get(belowBlock);
|
||||
if (extendedCollisionDefinition != null && (System.currentTimeMillis() - session.getLastInteractionTime()) < 200) {
|
||||
restoreCorrectBlock(session, blockPos, packet);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check to make sure the client isn't spamming interaction
|
||||
// Based on Nukkit 1.0, with changes to ensure holding down still works
|
||||
boolean hasAlreadyClicked = System.currentTimeMillis() - session.getLastInteractionTime() < 110.0 &&
|
||||
|
@ -257,6 +278,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
|||
restoreCorrectBlock(session, blockPos, packet);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
Block place checks end - client is good to go
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue