Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-20 06:50:09 +01:00
Implement multi-block chunk updates
Dieser Commit ist enthalten in:
Ursprung
c606119c1d
Commit
21ddc83da8
@ -176,6 +176,7 @@ public class TranslatorsInit {
|
|||||||
Registry.registerJava(ServerDisplayScoreboardPacket.class, new JavaDisplayScoreboardTranslator());
|
Registry.registerJava(ServerDisplayScoreboardPacket.class, new JavaDisplayScoreboardTranslator());
|
||||||
Registry.registerJava(ServerUpdateScorePacket.class, new JavaUpdateScoreTranslator());
|
Registry.registerJava(ServerUpdateScorePacket.class, new JavaUpdateScoreTranslator());
|
||||||
Registry.registerJava(ServerBlockChangePacket.class, new JavaBlockChangeTranslator());
|
Registry.registerJava(ServerBlockChangePacket.class, new JavaBlockChangeTranslator());
|
||||||
|
Registry.registerJava(ServerMultiBlockChangePacket.class, new JavaMultiBlockChangeTranslator());
|
||||||
|
|
||||||
Registry.registerBedrock(AnimatePacket.class, new BedrockAnimateTranslator());
|
Registry.registerBedrock(AnimatePacket.class, new BedrockAnimateTranslator());
|
||||||
Registry.registerBedrock(CommandRequestPacket.class, new BedrockCommandRequestTranslator());
|
Registry.registerBedrock(CommandRequestPacket.class, new BedrockCommandRequestTranslator());
|
||||||
|
@ -4,29 +4,26 @@ import com.flowpowered.math.vector.Vector3i;
|
|||||||
import com.github.steveice10.mc.protocol.data.game.world.block.BlockChangeRecord;
|
import com.github.steveice10.mc.protocol.data.game.world.block.BlockChangeRecord;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerBlockChangePacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerBlockChangePacket;
|
||||||
import com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket;
|
import com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket;
|
||||||
import org.geysermc.api.Geyser;
|
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||||
|
import org.geysermc.connector.network.translators.TranslatorsInit;
|
||||||
import org.geysermc.connector.network.translators.item.BedrockItem;
|
import org.geysermc.connector.network.translators.item.BedrockItem;
|
||||||
import org.geysermc.connector.network.translators.item.ItemTranslator;
|
|
||||||
import org.geysermc.connector.world.GlobalBlockPalette;
|
import org.geysermc.connector.world.GlobalBlockPalette;
|
||||||
|
|
||||||
public class JavaBlockChangeTranslator extends PacketTranslator<ServerBlockChangePacket> {
|
public class JavaBlockChangeTranslator extends PacketTranslator<ServerBlockChangePacket> {
|
||||||
@Override
|
@Override
|
||||||
public void translate(ServerBlockChangePacket packet, GeyserSession session) {
|
public void translate(ServerBlockChangePacket packet, GeyserSession session) {
|
||||||
UpdateBlockPacket pack = new UpdateBlockPacket();
|
UpdateBlockPacket updateBlockPacket = new UpdateBlockPacket();
|
||||||
|
|
||||||
BlockChangeRecord record = packet.getRecord();
|
BlockChangeRecord record = packet.getRecord();
|
||||||
|
updateBlockPacket.setDataLayer(0);
|
||||||
|
updateBlockPacket.setBlockPosition(new Vector3i(
|
||||||
|
record.getPosition().getX(),
|
||||||
|
record.getPosition().getY(),
|
||||||
|
record.getPosition().getZ()));
|
||||||
|
|
||||||
BedrockItem i = new ItemTranslator().getBedrockBlock(record.getBlock());
|
BedrockItem bedrockItem = TranslatorsInit.getItemTranslator().getBedrockBlock(record.getBlock());
|
||||||
|
updateBlockPacket.setRuntimeId(GlobalBlockPalette.getOrCreateRuntimeId(bedrockItem.hashCode()));
|
||||||
|
|
||||||
pack.setDataLayer(0);
|
session.getUpstream().sendPacket(updateBlockPacket);
|
||||||
pack.setRuntimeId(GlobalBlockPalette.getOrCreateRuntimeId(i.hashCode()));
|
|
||||||
pack.setBlockPosition(new Vector3i(
|
|
||||||
record.getPosition().getX()
|
|
||||||
, record.getPosition().getY()
|
|
||||||
, record.getPosition().getZ()));
|
|
||||||
|
|
||||||
session.getUpstream().sendPacket(pack);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019 GeyserMC. http://geysermc.org
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @author GeyserMC
|
||||||
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.geysermc.connector.network.translators.java.world;
|
||||||
|
|
||||||
|
import com.flowpowered.math.vector.Vector3i;
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.world.block.BlockChangeRecord;
|
||||||
|
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerMultiBlockChangePacket;
|
||||||
|
import com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket;
|
||||||
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
|
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||||
|
import org.geysermc.connector.network.translators.TranslatorsInit;
|
||||||
|
import org.geysermc.connector.network.translators.item.BedrockItem;
|
||||||
|
import org.geysermc.connector.world.GlobalBlockPalette;
|
||||||
|
|
||||||
|
public class JavaMultiBlockChangeTranslator extends PacketTranslator<ServerMultiBlockChangePacket> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void translate(ServerMultiBlockChangePacket packet, GeyserSession session) {
|
||||||
|
for (BlockChangeRecord record : packet.getRecords()) {
|
||||||
|
UpdateBlockPacket updateBlockPacket = new UpdateBlockPacket();
|
||||||
|
updateBlockPacket.setDataLayer(0);
|
||||||
|
updateBlockPacket.setBlockPosition(new Vector3i(
|
||||||
|
record.getPosition().getX(),
|
||||||
|
record.getPosition().getY(),
|
||||||
|
record.getPosition().getZ()));
|
||||||
|
|
||||||
|
BedrockItem bedrockItem = TranslatorsInit.getItemTranslator().getBedrockBlock(record.getBlock());
|
||||||
|
updateBlockPacket.setRuntimeId(GlobalBlockPalette.getOrCreateRuntimeId(bedrockItem.hashCode()));
|
||||||
|
|
||||||
|
session.getUpstream().sendPacket(updateBlockPacket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren