-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Support of Geyser Palette Reordering
Squashed commit of the following: commit 337bd75388d1b1cf58246f1906591519cd4940bd Author: bundabrg <brendan@grieve.com.au> Date: Sun Sep 13 22:40:56 2020 +0800 Bump to V1.0.10 Reversion commit bba505b Author: bundabrg <brendan@grieve.com.au> Date: Sun Sep 13 17:34:30 2020 +0800 Fix Geyser Remapper commit 4c7bff9 Author: bundabrg <brendan@grieve.com.au> Date: Sun Sep 13 11:22:34 2020 +0800 Working palette Mapper commit 409406c Author: bundabrg <brendan@grieve.com.au> Date: Fri Sep 11 23:40:33 2020 +0800 Work commit ff9c719 Author: bundabrg <brendan@grieve.com.au> Date: Wed Sep 9 18:42:32 2020 +0800 Add Translator to geyser to handle Geyser specific stuff commit 23d74ab Author: bundabrg <bundabrg@grieve.com.au> Date: Wed Sep 9 17:39:51 2020 +0800 Start work on geyser palette ordering
- Loading branch information
Showing
6 changed files
with
167 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...ain/java/au/com/grieve/geyser/reversion/translators/geyser/v408/Register_Geyser_v408.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* EduSupport - Minecraft Protocol Support for MultiVersion in Geyser | ||
* Copyright (C) 2020 GeyserReversion Developers | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package au.com.grieve.geyser.reversion.translators.geyser.v408; | ||
|
||
import au.com.grieve.geyser.reversion.translators.geyser.v408.handlers.StartGameHandler_Geyser_v408; | ||
import au.com.grieve.reversion.editions.bedrock.BedrockRegisteredTranslator; | ||
import au.com.grieve.reversion.editions.bedrock.BedrockTranslator; | ||
import au.com.grieve.reversion.editions.bedrock.handlers.LevelChunkHandler_Bedrock; | ||
import au.com.grieve.reversion.editions.bedrock.handlers.UpdateBlockHandler_Bedrock; | ||
import au.com.grieve.reversion.editions.bedrock.mappers.BlockMapper; | ||
import au.com.grieve.reversion.editions.bedrock.mappers.EntityMapper; | ||
import au.com.grieve.reversion.editions.bedrock.mappers.ItemMapper; | ||
import com.nukkitx.protocol.bedrock.packet.LevelChunkPacket; | ||
import com.nukkitx.protocol.bedrock.packet.StartGamePacket; | ||
import com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket; | ||
import com.nukkitx.protocol.bedrock.v408.Bedrock_v408; | ||
|
||
public class Register_Geyser_v408 { | ||
public static BedrockRegisteredTranslator TRANSLATOR = BedrockRegisteredTranslator.builder() | ||
.fromEdition("bedrock") | ||
.fromProtocolVersion(408) | ||
.toEdition("geyser-bedrock") | ||
.toProtocolVersion(408) | ||
.codec(Bedrock_v408.V408_CODEC) | ||
.translator(BedrockTranslator.class) | ||
.blockMapper(BlockMapper.builder() | ||
.palette(() -> Register_Geyser_v408.class.getResourceAsStream("/protocol/bedrock-v408/blockpalette.nbt")) | ||
.build() | ||
) | ||
.itemMapper(ItemMapper.DEFAULT) | ||
.entityMapper(EntityMapper.DEFAULT) | ||
.registerPacketHandler(LevelChunkPacket.class, LevelChunkHandler_Bedrock.class) | ||
.registerPacketHandler(StartGamePacket.class, StartGameHandler_Geyser_v408.class) | ||
.registerPacketHandler(UpdateBlockPacket.class, UpdateBlockHandler_Bedrock.class) | ||
.build(); | ||
} |
83 changes: 83 additions & 0 deletions
83
...rieve/geyser/reversion/translators/geyser/v408/handlers/StartGameHandler_Geyser_v408.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* EduSupport - Minecraft Protocol Support for MultiVersion in Geyser | ||
* Copyright (C) 2020 GeyserReversion Developers | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package au.com.grieve.geyser.reversion.translators.geyser.v408.handlers; | ||
|
||
import au.com.grieve.geyser.reversion.GeyserReversionExtension; | ||
import au.com.grieve.reversion.editions.bedrock.BedrockTranslator; | ||
import au.com.grieve.reversion.editions.bedrock.handlers.StartGameHandler_Bedrock; | ||
import com.nukkitx.nbt.NbtList; | ||
import com.nukkitx.nbt.NbtMap; | ||
import com.nukkitx.protocol.bedrock.packet.StartGamePacket; | ||
|
||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.IntStream; | ||
|
||
/* | ||
Geyser re-arranged the block palette which will cause issues with the new baked in palette format. | ||
What we do here is to re-arrange it back based upon the supported bedrock palette in Geyser and keep a record | ||
of the mapping so we translate it in other packets | ||
*/ | ||
public class StartGameHandler_Geyser_v408 extends StartGameHandler_Bedrock { | ||
protected boolean initialized = false; | ||
|
||
public StartGameHandler_Geyser_v408(BedrockTranslator translator) { | ||
super(translator); | ||
} | ||
|
||
@Override | ||
public boolean fromDownstream(StartGamePacket packet) { | ||
// Only grab runtime ID's for the first player | ||
if (!initialized) { | ||
initialized = true; | ||
|
||
NbtList<NbtMap> geyserTags = packet.getBlockPalette(); | ||
|
||
Map<Integer, NbtMap> translatedTags = IntStream.range(0, getTranslator().getRegisteredTranslator().getBlockMapper().getUpstreamPalette().size()) | ||
.boxed() | ||
.collect(Collectors.toMap(i -> i, i -> getTranslator().getRegisteredTranslator().getBlockMapper().getUpstreamPalette().get(i).getCompound("block"))); | ||
|
||
for (int geyserId = 0; geyserId < geyserTags.size(); geyserId++) { | ||
NbtMap geyserTag = geyserTags.get(geyserId).getCompound("block"); | ||
boolean found = false; | ||
for (Map.Entry<Integer, NbtMap> entry : translatedTags.entrySet()) { | ||
if (geyserTag.equals(entry.getValue())) { | ||
getTranslator().getRegisteredTranslator().getBlockMapper().registerRuntimeIdMapping(geyserId, entry.getKey()); | ||
found = true; | ||
translatedTags.remove(entry.getKey()); | ||
break; | ||
} | ||
} | ||
if (!found) { | ||
GeyserReversionExtension.getInstance().getLogger().error("Unable to find upstream palette entry: " + geyserTag); | ||
getTranslator().getRegisteredTranslator().getBlockMapper().registerRuntimeIdMapping(geyserId, 0); // Set to 0 for now | ||
} | ||
if (translatedTags.size() == 0) { | ||
break; | ||
} | ||
} | ||
|
||
if (translatedTags.size() > 0) { | ||
GeyserReversionExtension.getInstance().getLogger().error("Extra upstream unmatched palette entries: \n" + translatedTags); | ||
} | ||
} | ||
|
||
return super.fromDownstream(packet); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters