Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-20 06:50:09 +01:00
Finish block state changes
Dieser Commit ist enthalten in:
Ursprung
ad4c1ff0c7
Commit
65f61ec703
@ -114,7 +114,7 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
|
|||||||
case CONTINUE_BREAK:
|
case CONTINUE_BREAK:
|
||||||
LevelEventPacket continueBreakPacket = new LevelEventPacket();
|
LevelEventPacket continueBreakPacket = new LevelEventPacket();
|
||||||
continueBreakPacket.setType(LevelEventType.PUNCH_BLOCK);
|
continueBreakPacket.setType(LevelEventType.PUNCH_BLOCK);
|
||||||
continueBreakPacket.setData(BlockTranslator.getBedrockBlockId(session.getBreakingBlock() == null ? BlockTranslator.AIR : session.getBreakingBlock()));
|
continueBreakPacket.setData(BlockTranslator.getBedrockBlockId(session.getBreakingBlock()));
|
||||||
continueBreakPacket.setPosition(packet.getBlockPosition().toFloat());
|
continueBreakPacket.setPosition(packet.getBlockPosition().toFloat());
|
||||||
session.sendUpstreamPacket(continueBreakPacket);
|
session.sendUpstreamPacket(continueBreakPacket);
|
||||||
break;
|
break;
|
||||||
|
@ -50,13 +50,13 @@ public class JavaPlayerActionAckTranslator extends PacketTranslator<ServerPlayer
|
|||||||
LevelEventPacket levelEvent = new LevelEventPacket();
|
LevelEventPacket levelEvent = new LevelEventPacket();
|
||||||
switch (packet.getAction()) {
|
switch (packet.getAction()) {
|
||||||
case FINISH_DIGGING:
|
case FINISH_DIGGING:
|
||||||
double blockHardness = BlockTranslator.JAVA_RUNTIME_ID_TO_HARDNESS.get(session.getBreakingBlock() == null ? 0 : session.getBreakingBlock().getId());
|
double blockHardness = BlockTranslator.JAVA_RUNTIME_ID_TO_HARDNESS.get(session.getBreakingBlock());
|
||||||
if (session.getGameMode() != GameMode.CREATIVE && blockHardness != 0) {
|
if (session.getGameMode() != GameMode.CREATIVE && blockHardness != 0) {
|
||||||
levelEvent.setType(LevelEventType.DESTROY);
|
levelEvent.setType(LevelEventType.DESTROY);
|
||||||
levelEvent.setPosition(Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()));
|
levelEvent.setPosition(Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()));
|
||||||
levelEvent.setData(BlockTranslator.getBedrockBlockId(session.getBreakingBlock()));
|
levelEvent.setData(BlockTranslator.getBedrockBlockId(session.getBreakingBlock()));
|
||||||
session.sendUpstreamPacket(levelEvent);
|
session.sendUpstreamPacket(levelEvent);
|
||||||
session.setBreakingBlock(null);
|
session.setBreakingBlock(0);
|
||||||
}
|
}
|
||||||
ChunkUtils.updateBlock(session, packet.getNewState(), packet.getPosition());
|
ChunkUtils.updateBlock(session, packet.getNewState(), packet.getPosition());
|
||||||
break;
|
break;
|
||||||
@ -64,7 +64,7 @@ public class JavaPlayerActionAckTranslator extends PacketTranslator<ServerPlayer
|
|||||||
if (session.getGameMode() == GameMode.CREATIVE) {
|
if (session.getGameMode() == GameMode.CREATIVE) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
blockHardness = BlockTranslator.JAVA_RUNTIME_ID_TO_HARDNESS.get(packet.getNewState().getId());
|
blockHardness = BlockTranslator.JAVA_RUNTIME_ID_TO_HARDNESS.get(packet.getNewState());
|
||||||
levelEvent.setType(LevelEventType.BLOCK_START_BREAK);
|
levelEvent.setType(LevelEventType.BLOCK_START_BREAK);
|
||||||
levelEvent.setPosition(Vector3f.from(
|
levelEvent.setPosition(Vector3f.from(
|
||||||
packet.getPosition().getX(),
|
packet.getPosition().getX(),
|
||||||
@ -79,7 +79,7 @@ public class JavaPlayerActionAckTranslator extends PacketTranslator<ServerPlayer
|
|||||||
itemEntry = ItemRegistry.getItem(item);
|
itemEntry = ItemRegistry.getItem(item);
|
||||||
nbtData = item.getNbt();
|
nbtData = item.getNbt();
|
||||||
}
|
}
|
||||||
double breakTime = Math.ceil(BlockUtils.getBreakTime(blockHardness, packet.getNewState().getId(), itemEntry, nbtData, session) * 20);
|
double breakTime = Math.ceil(BlockUtils.getBreakTime(blockHardness, packet.getNewState(), itemEntry, nbtData, session) * 20);
|
||||||
levelEvent.setData((int) (65535 / breakTime));
|
levelEvent.setData((int) (65535 / breakTime));
|
||||||
session.setBreakingBlock(packet.getNewState());
|
session.setBreakingBlock(packet.getNewState());
|
||||||
session.sendUpstreamPacket(levelEvent);
|
session.sendUpstreamPacket(levelEvent);
|
||||||
@ -92,7 +92,7 @@ public class JavaPlayerActionAckTranslator extends PacketTranslator<ServerPlayer
|
|||||||
packet.getPosition().getZ()
|
packet.getPosition().getZ()
|
||||||
));
|
));
|
||||||
levelEvent.setData(0);
|
levelEvent.setData(0);
|
||||||
session.setBreakingBlock(null);
|
session.setBreakingBlock(0);
|
||||||
session.sendUpstreamPacket(levelEvent);
|
session.sendUpstreamPacket(levelEvent);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ public class JavaBlockChangeTranslator extends PacketTranslator<ServerBlockChang
|
|||||||
@Override
|
@Override
|
||||||
public void translate(ServerBlockChangePacket packet, GeyserSession session) {
|
public void translate(ServerBlockChangePacket packet, GeyserSession session) {
|
||||||
Position pos = packet.getRecord().getPosition();
|
Position pos = packet.getRecord().getPosition();
|
||||||
boolean updatePlacement = !(session.getConnector().getConfig().isCacheChunks() && session.getConnector().getWorldManager().getBlockAt(session, pos.getX(), pos.getY(), pos.getZ()).getId() == packet.getRecord().getBlock().getId());
|
boolean updatePlacement = !(session.getConnector().getConfig().isCacheChunks() && session.getConnector().getWorldManager().getBlockAt(session, pos.getX(), pos.getY(), pos.getZ()) == packet.getRecord().getBlock());
|
||||||
ChunkUtils.updateBlock(session, packet.getRecord().getBlock(), packet.getRecord().getPosition());
|
ChunkUtils.updateBlock(session, packet.getRecord().getBlock(), packet.getRecord().getPosition());
|
||||||
if (updatePlacement && session.getConnector().getPlatformType() != PlatformType.BUKKIT) {
|
if (updatePlacement && session.getConnector().getPlatformType() != PlatformType.BUKKIT) {
|
||||||
this.checkPlace(session, packet);
|
this.checkPlace(session, packet);
|
||||||
|
@ -47,7 +47,7 @@ public class JavaUpdateTileEntityTranslator extends PacketTranslator<ServerUpdat
|
|||||||
ChunkUtils.CACHED_BLOCK_ENTITIES.get(packet.getPosition())), packet.getPosition());
|
ChunkUtils.CACHED_BLOCK_ENTITIES.get(packet.getPosition())), packet.getPosition());
|
||||||
ChunkUtils.CACHED_BLOCK_ENTITIES.remove(packet.getPosition());
|
ChunkUtils.CACHED_BLOCK_ENTITIES.remove(packet.getPosition());
|
||||||
} else {
|
} else {
|
||||||
BlockEntityUtils.updateBlockEntity(session, translator.getBlockEntityTag(id, packet.getNbt(), null), packet.getPosition());
|
BlockEntityUtils.updateBlockEntity(session, translator.getBlockEntityTag(id, packet.getNbt(), 0), packet.getPosition());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren