mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Implement globe banner pattern translation
Co-Authored-By: Konicai <71294714+Konicai@users.noreply.github.com>
This commit is contained in:
parent
31fd57a58d
commit
252348ebd8
3 changed files with 15 additions and 17 deletions
|
@ -224,8 +224,14 @@ public class ItemRegistryPopulator {
|
|||
// This items has a mapping specifically for this version of the game
|
||||
mappingItem = entry.getValue();
|
||||
}
|
||||
|
||||
String bedrockIdentifier;
|
||||
if (javaIdentifier.equals("minecraft:music_disc_otherside") && palette.getValue().protocolVersion() <= Bedrock_v471.V471_CODEC.getProtocolVersion()) {
|
||||
mappingItem.setBedrockIdentifier("minecraft:music_disc_pigstep");
|
||||
bedrockIdentifier = "minecraft:music_disc_pigstep";
|
||||
} else if (javaIdentifier.equals("minecraft:globe_banner_pattern") && palette.getValue().protocolVersion() < Bedrock_v486.V486_CODEC.getProtocolVersion()) {
|
||||
bedrockIdentifier = "minecraft:banner_pattern";
|
||||
} else {
|
||||
bedrockIdentifier = mappingItem.getBedrockIdentifier();
|
||||
}
|
||||
|
||||
if (usingFurnaceMinecart && javaIdentifier.equals("minecraft:furnace_minecart")) {
|
||||
|
@ -233,7 +239,7 @@ public class ItemRegistryPopulator {
|
|||
itemIndex++;
|
||||
continue;
|
||||
}
|
||||
String bedrockIdentifier = mappingItem.getBedrockIdentifier().intern();
|
||||
|
||||
int bedrockId = bedrockIdentifierToId.getInt(bedrockIdentifier);
|
||||
if (bedrockId == Short.MIN_VALUE) {
|
||||
throw new RuntimeException("Missing Bedrock ID in mappings: " + bedrockIdentifier);
|
||||
|
@ -358,7 +364,7 @@ public class ItemRegistryPopulator {
|
|||
ItemMapping.ItemMappingBuilder mappingBuilder = ItemMapping.builder()
|
||||
.javaIdentifier(javaIdentifier)
|
||||
.javaId(itemIndex)
|
||||
.bedrockIdentifier(bedrockIdentifier)
|
||||
.bedrockIdentifier(bedrockIdentifier.intern())
|
||||
.bedrockId(bedrockId)
|
||||
.bedrockData(mappingItem.getBedrockData())
|
||||
.bedrockBlockId(bedrockBlockId)
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.geysermc.geyser.registry.Registries;
|
|||
import org.geysermc.geyser.registry.type.ItemMapping;
|
||||
import org.geysermc.geyser.registry.type.ItemMappings;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -96,10 +97,7 @@ public class BannerTranslator extends ItemTranslator {
|
|||
public static NbtList<NbtMap> convertBannerPattern(ListTag patterns) {
|
||||
List<NbtMap> tagsList = new ArrayList<>();
|
||||
for (Tag patternTag : patterns.getValue()) {
|
||||
NbtMap newPatternTag = getBedrockBannerPattern((CompoundTag) patternTag);
|
||||
if (newPatternTag != null) {
|
||||
tagsList.add(newPatternTag);
|
||||
}
|
||||
tagsList.add(getBedrockBannerPattern((CompoundTag) patternTag));
|
||||
}
|
||||
|
||||
return new NbtList<>(NbtType.COMPOUND, tagsList);
|
||||
|
@ -111,17 +109,11 @@ public class BannerTranslator extends ItemTranslator {
|
|||
* @param pattern Java edition pattern nbt
|
||||
* @return The Bedrock edition format pattern nbt
|
||||
*/
|
||||
public static NbtMap getBedrockBannerPattern(CompoundTag pattern) {
|
||||
String patternName = (String) pattern.get("Pattern").getValue();
|
||||
|
||||
// Return null if its the globe pattern as it doesn't exist on bedrock
|
||||
if (patternName.equals("glb")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private static NbtMap getBedrockBannerPattern(CompoundTag pattern) {
|
||||
return NbtMap.builder()
|
||||
.putInt("Color", 15 - (int) pattern.get("Color").getValue())
|
||||
.putString("Pattern", patternName)
|
||||
.putString("Pattern", (String) pattern.get("Pattern").getValue())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit b60cfcdd40cd58a93143b489fc9153a347e48c41
|
||||
Subproject commit 8620c9c4603c16b74cbe1d6630695d243679896b
|
Loading…
Reference in a new issue