Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-05 07:40:11 +01:00
Fix: Sticky pistons not retracting on Geyser-Spigot/turning visually into normal pistons on all other platforms (#4891)
Dieser Commit ist enthalten in:
Ursprung
b113a6b185
Commit
b664395684
@ -43,7 +43,15 @@ import org.geysermc.geyser.translator.level.block.entity.BlockEntityTranslator;
|
||||
import org.geysermc.geyser.translator.level.block.entity.PistonBlockEntity;
|
||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||
import org.geysermc.geyser.translator.protocol.Translator;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.level.block.value.*;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.level.block.value.BellValue;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.level.block.value.BlockValue;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.level.block.value.ChestValue;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.level.block.value.DecoratedPotValue;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.level.block.value.EndGatewayValue;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.level.block.value.MobSpawnerValue;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.level.block.value.NoteBlockValue;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.level.block.value.PistonValue;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.level.block.value.PistonValueType;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.ClientboundBlockEventPacket;
|
||||
|
||||
@Translator(packet = ClientboundBlockEventPacket.class)
|
||||
@ -80,7 +88,7 @@ public class JavaBlockEventTranslator extends PacketTranslator<ClientboundBlockE
|
||||
// See https://github.com/PaperMC/Paper/blob/6fa1983e9ce177a4a412d5b950fd978620174777/patches/server/0304-Fire-BlockPistonRetractEvent-for-all-empty-pistons.patch
|
||||
if (action == PistonValueType.PULLING || action == PistonValueType.CANCELLED_MID_PUSH) {
|
||||
BlockState pistonBlock = session.getGeyser().getWorldManager().blockAt(session, position);
|
||||
if (!pistonBlock.is(Blocks.STICKY_PISTON)) {
|
||||
if (!isSticky(pistonBlock)) {
|
||||
return;
|
||||
}
|
||||
if (action != PistonValueType.CANCELLED_MID_PUSH) {
|
||||
@ -99,7 +107,7 @@ public class JavaBlockEventTranslator extends PacketTranslator<ClientboundBlockE
|
||||
} else {
|
||||
PistonBlockEntity blockEntity = pistonCache.getPistons().computeIfAbsent(position, pos -> {
|
||||
BlockState state = session.getGeyser().getWorldManager().blockAt(session, position);
|
||||
boolean sticky = state.is(Blocks.STICKY_PISTON);
|
||||
boolean sticky = isSticky(state);
|
||||
boolean extended = action != PistonValueType.PUSHING;
|
||||
return new PistonBlockEntity(session, pos, direction, sticky, extended);
|
||||
});
|
||||
@ -149,4 +157,8 @@ public class JavaBlockEventTranslator extends PacketTranslator<ClientboundBlockE
|
||||
session.getGeyser().getLogger().debug("Unhandled block event packet: " + packet);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isSticky(BlockState state) {
|
||||
return state.is(Blocks.STICKY_PISTON) || (state.is(Blocks.MOVING_PISTON) && "sticky".equals(state.getValue(Properties.PISTON_TYPE)));
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren