Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-20 06:50:09 +01:00
1.16.220 support (#2105)
This update does not break compatibility with any other currently supported version of Bedrock. Co-authored-by: Redned <redned235@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
8f6785e48f
Commit
86b2901f02
@ -18,7 +18,7 @@ The ultimate goal of this project is to allow Minecraft: Bedrock Edition users t
|
||||
|
||||
Special thanks to the DragonProxy project for being a trailblazer in protocol translation and for all the team members who have now joined us here!
|
||||
|
||||
### Currently supporting Minecraft Bedrock v1.16.100 - v1.16.210 and Minecraft Java v1.16.4 - v1.16.5.
|
||||
### Currently supporting Minecraft Bedrock v1.16.100 - v1.16.220 and Minecraft Java v1.16.4 - v1.16.5.
|
||||
|
||||
## Setting Up
|
||||
Take a look [here](https://github.com/GeyserMC/Geyser/wiki#Setup) for how to set up Geyser.
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>bootstrap-parent</artifactId>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>bootstrap-bungeecord</artifactId>
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>connector</artifactId>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>geyser-parent</artifactId>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>bootstrap-parent</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>bootstrap-parent</artifactId>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>bootstrap-spigot</artifactId>
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>connector</artifactId>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>bootstrap-parent</artifactId>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>bootstrap-sponge</artifactId>
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>connector</artifactId>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>bootstrap-parent</artifactId>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>bootstrap-standalone</artifactId>
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>connector</artifactId>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>bootstrap-parent</artifactId>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>bootstrap-velocity</artifactId>
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>connector</artifactId>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>geyser-parent</artifactId>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>common</artifactId>
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>geyser-parent</artifactId>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>connector</artifactId>
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -31,8 +31,8 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.CloudburstMC.Protocol</groupId>
|
||||
<artifactId>bedrock-v428</artifactId>
|
||||
<version>42da92f</version>
|
||||
<artifactId>bedrock-v431</artifactId>
|
||||
<version>f8ecf54</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
|
@ -107,7 +107,7 @@ public class ItemFrameEntity extends Entity {
|
||||
if (itemData.getTag() != null) {
|
||||
builder.put("tag", itemData.getTag().toBuilder().build());
|
||||
}
|
||||
builder.putShort("Damage", itemData.getDamage());
|
||||
builder.putShort("Damage", (short) itemData.getDamage());
|
||||
builder.putString("Name", itemEntry.getBedrockIdentifier());
|
||||
NbtMapBuilder tag = getDefaultTag().toBuilder();
|
||||
tag.put("Item", builder.build());
|
||||
|
@ -56,9 +56,12 @@ public class LlamaEntity extends ChestedHorseEntity {
|
||||
// -1 means no armor
|
||||
if ((int) entityMetadata.getValue() != -1) {
|
||||
// The damage value is the dye color that Java sends us
|
||||
// Always going to be a carpet so we can hardcode 171 in BlockTranslator
|
||||
// The int then short conversion is required or we get a ClassCastException
|
||||
equipmentPacket.setChestplate(ItemData.of(BlockTranslator.CARPET, (short) ((int) entityMetadata.getValue()), 1));
|
||||
// The item is always going to be a carpet
|
||||
equipmentPacket.setChestplate(ItemData.builder()
|
||||
.id(BlockTranslator.CARPET)
|
||||
.damage((int) entityMetadata.getValue())
|
||||
.count(1)
|
||||
.build());
|
||||
} else {
|
||||
equipmentPacket.setChestplate(ItemData.AIR);
|
||||
}
|
||||
|
@ -101,6 +101,7 @@ public class GeyserItemStack {
|
||||
public ItemData getItemData(GeyserSession session) {
|
||||
ItemData itemData = ItemTranslator.translateToBedrock(session, getItemStack());
|
||||
itemData.setNetId(getNetId());
|
||||
itemData.setUsingNetId(true); // Seems silly - this should probably be on the protocol level
|
||||
return itemData;
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ import com.nukkitx.protocol.bedrock.BedrockPacketCodec;
|
||||
import com.nukkitx.protocol.bedrock.v419.Bedrock_v419;
|
||||
import com.nukkitx.protocol.bedrock.v422.Bedrock_v422;
|
||||
import com.nukkitx.protocol.bedrock.v428.Bedrock_v428;
|
||||
import com.nukkitx.protocol.bedrock.v431.Bedrock_v431;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -55,6 +56,7 @@ public class BedrockProtocol {
|
||||
.minecraftVersion("1.16.200/1.16.201")
|
||||
.build());
|
||||
SUPPORTED_BEDROCK_CODECS.add(DEFAULT_BEDROCK_CODEC);
|
||||
SUPPORTED_BEDROCK_CODECS.add(Bedrock_v431.V431_CODEC);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,23 +28,32 @@ package org.geysermc.connector.network.translators.item;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
import org.geysermc.connector.network.translators.world.block.BlockTranslator1_16_210;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class ItemEntry {
|
||||
|
||||
public static ItemEntry AIR = new ItemEntry("minecraft:air", "minecraft:air", 0, 0, 0, false, 64);
|
||||
public static ItemEntry AIR = new ItemEntry("minecraft:air", "minecraft:air", 0, 0, 0,
|
||||
BlockTranslator1_16_210.INSTANCE.getBedrockAirId(), 64);
|
||||
|
||||
private final String javaIdentifier;
|
||||
private final String bedrockIdentifier;
|
||||
private final int javaId;
|
||||
private final int bedrockId;
|
||||
private final int bedrockData;
|
||||
|
||||
private final boolean block;
|
||||
/**
|
||||
* The Bedrock block runtime ID to render this item with. The specific state *does* matter in how this item is rendered.
|
||||
* Required since 1.16.220.
|
||||
*/
|
||||
private final int bedrockBlockId;
|
||||
private final int stackSize;
|
||||
|
||||
public boolean isBlock() {
|
||||
return bedrockBlockId != -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj == this || (obj instanceof ItemEntry && ((ItemEntry) obj).getBedrockId() == this.getBedrockId() && ((ItemEntry) obj).getJavaIdentifier().equals(this.getJavaIdentifier()));
|
||||
|
@ -42,6 +42,7 @@ import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.network.translators.world.block.BlockTranslator1_16_210;
|
||||
import org.geysermc.connector.utils.FileUtils;
|
||||
import org.geysermc.connector.utils.LanguageUtils;
|
||||
|
||||
@ -176,54 +177,64 @@ public class ItemRegistry {
|
||||
}
|
||||
JsonNode stackSizeNode = entry.getValue().get("stack_size");
|
||||
int stackSize = stackSizeNode == null ? 64 : stackSizeNode.intValue();
|
||||
|
||||
int bedrockBlockId = -1;
|
||||
JsonNode blockRuntimeIdNode = entry.getValue().get("blockRuntimeId");
|
||||
if (blockRuntimeIdNode != null) {
|
||||
bedrockBlockId = BlockTranslator1_16_210.INSTANCE.getBedrockBlockId(blockRuntimeIdNode.intValue());
|
||||
}
|
||||
|
||||
ItemEntry itemEntry;
|
||||
if (entry.getValue().has("tool_type")) {
|
||||
if (entry.getValue().has("tool_tier")) {
|
||||
ITEM_ENTRIES.put(itemIndex, new ToolItemEntry(
|
||||
itemEntry = new ToolItemEntry(
|
||||
entry.getKey(), bedrockIdentifier, itemIndex, bedrockId,
|
||||
entry.getValue().get("bedrock_data").intValue(),
|
||||
entry.getValue().get("tool_type").textValue(),
|
||||
entry.getValue().get("tool_tier").textValue(),
|
||||
entry.getValue().get("is_block").booleanValue(),
|
||||
stackSize));
|
||||
bedrockBlockId,
|
||||
stackSize);
|
||||
} else {
|
||||
ITEM_ENTRIES.put(itemIndex, new ToolItemEntry(
|
||||
itemEntry = new ToolItemEntry(
|
||||
entry.getKey(), bedrockIdentifier, itemIndex, bedrockId,
|
||||
entry.getValue().get("bedrock_data").intValue(),
|
||||
entry.getValue().get("tool_type").textValue(),
|
||||
"", entry.getValue().get("is_block").booleanValue(),
|
||||
stackSize));
|
||||
"", bedrockBlockId,
|
||||
stackSize);
|
||||
}
|
||||
} else {
|
||||
ITEM_ENTRIES.put(itemIndex, new ItemEntry(
|
||||
itemEntry = new ItemEntry(
|
||||
entry.getKey(), bedrockIdentifier, itemIndex, bedrockId,
|
||||
entry.getValue().get("bedrock_data").intValue(),
|
||||
entry.getValue().get("is_block").booleanValue(),
|
||||
stackSize));
|
||||
bedrockBlockId,
|
||||
stackSize);
|
||||
}
|
||||
ITEM_ENTRIES.put(itemIndex, itemEntry);
|
||||
|
||||
switch (entry.getKey()) {
|
||||
case "minecraft:barrier":
|
||||
BARRIER_INDEX = itemIndex;
|
||||
break;
|
||||
case "minecraft:bamboo":
|
||||
BAMBOO = ITEM_ENTRIES.get(itemIndex);
|
||||
BAMBOO = itemEntry;
|
||||
break;
|
||||
case "minecraft:egg":
|
||||
EGG = ITEM_ENTRIES.get(itemIndex);
|
||||
EGG = itemEntry;
|
||||
break;
|
||||
case "minecraft:gold_ingot":
|
||||
GOLD = ITEM_ENTRIES.get(itemIndex);
|
||||
GOLD = itemEntry;
|
||||
break;
|
||||
case "minecraft:shield":
|
||||
SHIELD = ITEM_ENTRIES.get(itemIndex);
|
||||
SHIELD = itemEntry;
|
||||
break;
|
||||
case "minecraft:milk_bucket":
|
||||
MILK_BUCKET = ITEM_ENTRIES.get(itemIndex);
|
||||
MILK_BUCKET = itemEntry;
|
||||
break;
|
||||
case "minecraft:wheat":
|
||||
WHEAT = ITEM_ENTRIES.get(itemIndex);
|
||||
WHEAT = itemEntry;
|
||||
break;
|
||||
case "minecraft:writable_book":
|
||||
WRITABLE_BOOK = ITEM_ENTRIES.get(itemIndex);
|
||||
WRITABLE_BOOK = itemEntry;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -249,7 +260,7 @@ public class ItemRegistry {
|
||||
|
||||
// Add the loadstone compass since it doesn't exist on java but we need it for item conversion
|
||||
ITEM_ENTRIES.put(itemIndex, new ItemEntry("minecraft:lodestone_compass", "minecraft:lodestone_compass", itemIndex,
|
||||
lodestoneCompassId, 0, false, 1));
|
||||
lodestoneCompassId, 0, -1, 1));
|
||||
|
||||
/* Load creative items */
|
||||
stream = FileUtils.getResource("bedrock/creative_items.json");
|
||||
@ -261,11 +272,24 @@ public class ItemRegistry {
|
||||
throw new AssertionError(LanguageUtils.getLocaleStringLog("geyser.toolbox.fail.creative"), e);
|
||||
}
|
||||
|
||||
Set<String> javaOnlyItems = new ObjectOpenHashSet<>();
|
||||
Collections.addAll(javaOnlyItems, "minecraft:spectral_arrow", "minecraft:debug_stick",
|
||||
"minecraft:knowledge_book", "minecraft:tipped_arrow");
|
||||
if (!usingFurnaceMinecart) {
|
||||
javaOnlyItems.add("minecraft:furnace_minecart");
|
||||
}
|
||||
JAVA_ONLY_ITEMS = ImmutableSet.copyOf(javaOnlyItems);
|
||||
|
||||
int netId = 1;
|
||||
List<ItemData> creativeItems = new ArrayList<>();
|
||||
for (JsonNode itemNode : creativeItemEntries) {
|
||||
ItemData item = getBedrockItemFromJson(itemNode);
|
||||
creativeItems.add(ItemData.fromNet(netId++, item.getId(), item.getDamage(), item.getCount(), item.getTag()));
|
||||
ItemData.Builder item = getBedrockItemFromJson(itemNode);
|
||||
int bedrockRuntimeId = 0;
|
||||
ItemEntry itemEntry = getItem(item.build()); // please
|
||||
if (itemEntry.isBlock()) {
|
||||
bedrockRuntimeId = itemEntry.getBedrockBlockId();
|
||||
}
|
||||
creativeItems.add(item.netId(netId++).blockRuntimeId(bedrockRuntimeId).build());
|
||||
}
|
||||
|
||||
if (usingFurnaceMinecart) {
|
||||
@ -274,8 +298,11 @@ public class ItemRegistry {
|
||||
|
||||
ITEMS.add(new StartGamePacket.ItemEntry("geysermc:furnace_minecart", (short) furnaceMinecartId, true));
|
||||
ITEM_ENTRIES.put(javaFurnaceMinecartId, new ItemEntry("minecraft:furnace_minecart", "geysermc:furnace_minecart", javaFurnaceMinecartId,
|
||||
furnaceMinecartId, 0, false, 1));
|
||||
creativeItems.add(ItemData.fromNet(netId, furnaceMinecartId, (short) 0, 1, null));
|
||||
furnaceMinecartId, 0, -1, 1));
|
||||
creativeItems.add(ItemData.builder()
|
||||
.netId(netId)
|
||||
.id(furnaceMinecartId)
|
||||
.count(1).build());
|
||||
|
||||
NbtMapBuilder builder = NbtMap.builder();
|
||||
builder.putString("name", "geysermc:furnace_minecart")
|
||||
@ -312,14 +339,6 @@ public class ItemRegistry {
|
||||
CREATIVE_ITEMS = creativeItems.toArray(new ItemData[0]);
|
||||
|
||||
ITEM_NAMES = itemNames.toArray(new String[0]);
|
||||
|
||||
Set<String> javaOnlyItems = new ObjectOpenHashSet<>();
|
||||
Collections.addAll(javaOnlyItems, "minecraft:spectral_arrow", "minecraft:debug_stick",
|
||||
"minecraft:knowledge_book", "minecraft:tipped_arrow");
|
||||
if (!usingFurnaceMinecart) {
|
||||
javaOnlyItems.add("minecraft:furnace_minecart");
|
||||
}
|
||||
JAVA_ONLY_ITEMS = ImmutableSet.copyOf(javaOnlyItems);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -376,11 +395,11 @@ public class ItemRegistry {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Bedrock {@link ItemData} from a {@link JsonNode}
|
||||
* Gets a Bedrock {@link com.nukkitx.protocol.bedrock.data.inventory.ItemData.Builder} from a {@link JsonNode}
|
||||
* @param itemNode the JSON node that contains ProxyPass-compatible Bedrock item data
|
||||
* @return
|
||||
*/
|
||||
public static ItemData getBedrockItemFromJson(JsonNode itemNode) {
|
||||
public static ItemData.Builder getBedrockItemFromJson(JsonNode itemNode) {
|
||||
int count = 1;
|
||||
short damage = 0;
|
||||
NbtMap tag = null;
|
||||
@ -399,6 +418,10 @@ public class ItemRegistry {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return ItemData.of(itemNode.get("id").asInt(), damage, count, tag);
|
||||
return ItemData.builder()
|
||||
.id(itemNode.get("id").asInt())
|
||||
.damage(damage)
|
||||
.count(count)
|
||||
.tag(tag);
|
||||
}
|
||||
}
|
||||
|
@ -149,12 +149,15 @@ public abstract class ItemTranslator {
|
||||
|
||||
translateDisplayProperties(session, nbt);
|
||||
|
||||
ItemData itemData;
|
||||
ItemData.Builder builder;
|
||||
ItemTranslator itemStackTranslator = ITEM_STACK_TRANSLATORS.get(bedrockItem.getJavaId());
|
||||
if (itemStackTranslator != null) {
|
||||
itemData = itemStackTranslator.translateToBedrock(itemStack, bedrockItem);
|
||||
builder = itemStackTranslator.translateToBedrock(itemStack, bedrockItem);
|
||||
} else {
|
||||
itemData = DEFAULT_TRANSLATOR.translateToBedrock(itemStack, bedrockItem);
|
||||
builder = DEFAULT_TRANSLATOR.translateToBedrock(itemStack, bedrockItem);
|
||||
}
|
||||
if (bedrockItem.isBlock()) {
|
||||
builder.blockRuntimeId(bedrockItem.getBedrockBlockId());
|
||||
}
|
||||
|
||||
if (nbt != null) {
|
||||
@ -165,10 +168,11 @@ public abstract class ItemTranslator {
|
||||
String[] canPlace = new String[0];
|
||||
canBreak = getCanModify(session, canDestroy, canBreak);
|
||||
canPlace = getCanModify(session, canPlaceOn, canPlace);
|
||||
itemData = ItemData.of(itemData.getId(), itemData.getDamage(), itemData.getCount(), itemData.getTag(), canPlace, canBreak);
|
||||
builder.canBreak(canBreak);
|
||||
builder.canPlace(canPlace);
|
||||
}
|
||||
|
||||
return itemData;
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -202,14 +206,19 @@ public abstract class ItemTranslator {
|
||||
}
|
||||
};
|
||||
|
||||
public ItemData translateToBedrock(ItemStack itemStack, ItemEntry itemEntry) {
|
||||
public ItemData.Builder translateToBedrock(ItemStack itemStack, ItemEntry itemEntry) {
|
||||
if (itemStack == null) {
|
||||
return ItemData.AIR;
|
||||
// Return, essentially, air
|
||||
return ItemData.builder();
|
||||
}
|
||||
if (itemStack.getNbt() == null) {
|
||||
return ItemData.of(itemEntry.getBedrockId(), (short) itemEntry.getBedrockData(), itemStack.getAmount());
|
||||
ItemData.Builder builder = ItemData.builder()
|
||||
.id(itemEntry.getBedrockId())
|
||||
.damage(itemEntry.getBedrockData())
|
||||
.count(itemStack.getAmount());
|
||||
if (itemStack.getNbt() != null) {
|
||||
builder.tag(this.translateNbtToBedrock(itemStack.getNbt()));
|
||||
}
|
||||
return ItemData.of(itemEntry.getBedrockId(), (short) itemEntry.getBedrockData(), itemStack.getAmount(), this.translateNbtToBedrock(itemStack.getNbt()));
|
||||
return builder;
|
||||
}
|
||||
|
||||
public ItemStack translateToJava(ItemData itemData, ItemEntry itemEntry) {
|
||||
|
@ -91,7 +91,7 @@ public enum Potion {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Potion getByBedrockId(short bedrockId) {
|
||||
public static Potion getByBedrockId(int bedrockId) {
|
||||
for (Potion potion : Potion.values()) {
|
||||
if (potion.bedrockId == bedrockId) {
|
||||
return potion;
|
||||
|
@ -272,7 +272,11 @@ public class RecipeRegistry {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return ItemData.of(itemEntry.getBedrockId(), damage, count, tag);
|
||||
return ItemData.builder()
|
||||
.id(itemEntry.getBedrockId())
|
||||
.damage(damage)
|
||||
.count(count)
|
||||
.tag(tag).build();
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
|
@ -100,7 +100,7 @@ public enum TippedArrowPotion {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static TippedArrowPotion getByBedrockId(short bedrockId) {
|
||||
public static TippedArrowPotion getByBedrockId(int bedrockId) {
|
||||
for (TippedArrowPotion potion : TippedArrowPotion.values()) {
|
||||
if (potion.bedrockId == bedrockId) {
|
||||
return potion;
|
||||
|
@ -32,8 +32,9 @@ public class ToolItemEntry extends ItemEntry {
|
||||
private final String toolType;
|
||||
private final String toolTier;
|
||||
|
||||
public ToolItemEntry(String javaIdentifier, String bedrockIdentifier, int javaId, int bedrockId, int bedrockData, String toolType, String toolTier, boolean isBlock, int stackSize) {
|
||||
super(javaIdentifier, bedrockIdentifier, javaId, bedrockId, bedrockData, isBlock, stackSize);
|
||||
public ToolItemEntry(String javaIdentifier, String bedrockIdentifier, int javaId, int bedrockId, int bedrockData,
|
||||
String toolType, String toolTier, int bedrockBlockId, int stackSize) {
|
||||
super(javaIdentifier, bedrockIdentifier, javaId, bedrockId, bedrockData, bedrockBlockId, stackSize);
|
||||
this.toolType = toolType;
|
||||
this.toolTier = toolTier;
|
||||
}
|
||||
|
@ -153,30 +153,30 @@ public class BannerTranslator extends ItemTranslator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemData translateToBedrock(ItemStack itemStack, ItemEntry itemEntry) {
|
||||
public ItemData.Builder translateToBedrock(ItemStack itemStack, ItemEntry itemEntry) {
|
||||
if (itemStack.getNbt() == null) {
|
||||
return super.translateToBedrock(itemStack, itemEntry);
|
||||
}
|
||||
|
||||
ItemData itemData = super.translateToBedrock(itemStack, itemEntry);
|
||||
ItemData.Builder builder = super.translateToBedrock(itemStack, itemEntry);
|
||||
|
||||
CompoundTag blockEntityTag = itemStack.getNbt().get("BlockEntityTag");
|
||||
if (blockEntityTag != null && blockEntityTag.contains("Patterns")) {
|
||||
ListTag patterns = blockEntityTag.get("Patterns");
|
||||
|
||||
NbtMapBuilder builder = itemData.getTag().toBuilder();
|
||||
NbtMapBuilder nbtBuilder = builder.build().getTag().toBuilder(); //TODO fix ugly hack
|
||||
if (patterns.equals(OMINOUS_BANNER_PATTERN)) {
|
||||
// Remove the current patterns and set the ominous banner type
|
||||
builder.remove("Patterns");
|
||||
builder.putInt("Type", 1);
|
||||
nbtBuilder.remove("Patterns");
|
||||
nbtBuilder.putInt("Type", 1);
|
||||
} else {
|
||||
builder.put("Patterns", convertBannerPattern(patterns));
|
||||
nbtBuilder.put("Patterns", convertBannerPattern(patterns));
|
||||
}
|
||||
|
||||
itemData = ItemData.of(itemData.getId(), itemData.getDamage(), itemData.getCount(), builder.build());
|
||||
builder.tag(nbtBuilder.build());
|
||||
}
|
||||
|
||||
return itemData;
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -47,7 +47,7 @@ public class CompassTranslator extends ItemTranslator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemData translateToBedrock(ItemStack itemStack, ItemEntry itemEntry) {
|
||||
public ItemData.Builder translateToBedrock(ItemStack itemStack, ItemEntry itemEntry) {
|
||||
if (itemStack.getNbt() == null) return super.translateToBedrock(itemStack, itemEntry);
|
||||
|
||||
Tag lodestoneTag = itemStack.getNbt().get("LodestoneTracked");
|
||||
@ -75,9 +75,7 @@ public class CompassTranslator extends ItemTranslator {
|
||||
}
|
||||
}
|
||||
|
||||
ItemData itemData = super.translateToBedrock(itemStack, itemEntry);
|
||||
|
||||
return itemData;
|
||||
return super.translateToBedrock(itemStack, itemEntry);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -49,13 +49,17 @@ public class PotionTranslator extends ItemTranslator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemData translateToBedrock(ItemStack itemStack, ItemEntry itemEntry) {
|
||||
public ItemData.Builder translateToBedrock(ItemStack itemStack, ItemEntry itemEntry) {
|
||||
if (itemStack.getNbt() == null) return super.translateToBedrock(itemStack, itemEntry);
|
||||
Tag potionTag = itemStack.getNbt().get("Potion");
|
||||
if (potionTag instanceof StringTag) {
|
||||
Potion potion = Potion.getByJavaIdentifier(((StringTag) potionTag).getValue());
|
||||
if (potion != null) {
|
||||
return ItemData.of(itemEntry.getBedrockId(), potion.getBedrockId(), itemStack.getAmount(), translateNbtToBedrock(itemStack.getNbt()));
|
||||
return ItemData.builder()
|
||||
.id(itemEntry.getBedrockId())
|
||||
.damage(potion.getBedrockId())
|
||||
.count(itemStack.getAmount())
|
||||
.tag(translateNbtToBedrock(itemStack.getNbt()));
|
||||
}
|
||||
GeyserConnector.getInstance().getLogger().debug("Unknown Java potion: " + potionTag.getValue());
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public class TippedArrowTranslator extends ItemTranslator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemData translateToBedrock(ItemStack itemStack, ItemEntry itemEntry) {
|
||||
public ItemData.Builder translateToBedrock(ItemStack itemStack, ItemEntry itemEntry) {
|
||||
if (!itemEntry.getJavaIdentifier().equals("minecraft:tipped_arrow") || itemStack.getNbt() == null) {
|
||||
// We're only concerned about minecraft:arrow when translating Bedrock -> Java
|
||||
return super.translateToBedrock(itemStack, itemEntry);
|
||||
@ -61,7 +61,11 @@ public class TippedArrowTranslator extends ItemTranslator {
|
||||
if (potionTag instanceof StringTag) {
|
||||
TippedArrowPotion tippedArrowPotion = TippedArrowPotion.getByJavaIdentifier(((StringTag) potionTag).getValue());
|
||||
if (tippedArrowPotion != null) {
|
||||
return ItemData.of(itemEntry.getBedrockId(), tippedArrowPotion.getBedrockId(), itemStack.getAmount(), translateNbtToBedrock(itemStack.getNbt()));
|
||||
return ItemData.builder()
|
||||
.id(itemEntry.getBedrockId())
|
||||
.damage(tippedArrowPotion.getBedrockId())
|
||||
.count(itemStack.getAmount())
|
||||
.tag(translateNbtToBedrock(itemStack.getNbt()));
|
||||
}
|
||||
GeyserConnector.getInstance().getLogger().debug("Unknown Java potion (tipped arrow): " + potionTag.getValue());
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class CrossbowTranslator extends NbtItemStackTranslator {
|
||||
newProjectile.put(new ByteTag("Count", (byte) itemData.getCount()));
|
||||
newProjectile.put(new StringTag("Name", projectileEntry.getBedrockIdentifier()));
|
||||
|
||||
newProjectile.put(new ShortTag("Damage", itemData.getDamage()));
|
||||
newProjectile.put(new ShortTag("Damage", (short) itemData.getDamage()));
|
||||
|
||||
itemTag.put(newProjectile);
|
||||
}
|
||||
|
@ -30,8 +30,8 @@ import com.github.steveice10.mc.protocol.data.game.command.CommandParser;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerDeclareCommandsPacket;
|
||||
import com.nukkitx.protocol.bedrock.data.command.CommandData;
|
||||
import com.nukkitx.protocol.bedrock.data.command.CommandEnumData;
|
||||
import com.nukkitx.protocol.bedrock.data.command.CommandParam;
|
||||
import com.nukkitx.protocol.bedrock.data.command.CommandParamData;
|
||||
import com.nukkitx.protocol.bedrock.data.command.CommandParamType;
|
||||
import com.nukkitx.protocol.bedrock.packet.AvailableCommandsPacket;
|
||||
import it.unimi.dsi.fastutil.Hash;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
@ -200,47 +200,47 @@ public class JavaDeclareCommandsTranslator extends PacketTranslator<ServerDeclar
|
||||
*/
|
||||
private static Object mapCommandType(CommandParser parser) {
|
||||
if (parser == null) {
|
||||
return CommandParamType.STRING;
|
||||
return CommandParam.STRING;
|
||||
}
|
||||
|
||||
switch (parser) {
|
||||
case FLOAT:
|
||||
case ROTATION:
|
||||
case DOUBLE:
|
||||
return CommandParamType.FLOAT;
|
||||
return CommandParam.FLOAT;
|
||||
|
||||
case INTEGER:
|
||||
return CommandParamType.INT;
|
||||
return CommandParam.INT;
|
||||
|
||||
case ENTITY:
|
||||
case GAME_PROFILE:
|
||||
return CommandParamType.TARGET;
|
||||
return CommandParam.TARGET;
|
||||
|
||||
case BLOCK_POS:
|
||||
return CommandParamType.BLOCK_POSITION;
|
||||
return CommandParam.BLOCK_POSITION;
|
||||
|
||||
case COLUMN_POS:
|
||||
case VEC3:
|
||||
return CommandParamType.POSITION;
|
||||
return CommandParam.POSITION;
|
||||
|
||||
case MESSAGE:
|
||||
return CommandParamType.MESSAGE;
|
||||
return CommandParam.MESSAGE;
|
||||
|
||||
case NBT:
|
||||
case NBT_COMPOUND_TAG:
|
||||
case NBT_TAG:
|
||||
case NBT_PATH:
|
||||
return CommandParamType.JSON;
|
||||
return CommandParam.JSON;
|
||||
|
||||
case RESOURCE_LOCATION:
|
||||
case FUNCTION:
|
||||
return CommandParamType.FILE_PATH;
|
||||
return CommandParam.FILE_PATH;
|
||||
|
||||
case BOOL:
|
||||
return ENUM_BOOLEAN;
|
||||
|
||||
case OPERATION: // ">=", "==", etc
|
||||
return CommandParamType.OPERATOR;
|
||||
return CommandParam.OPERATOR;
|
||||
|
||||
case BLOCK_STATE:
|
||||
return BlockTranslator.getAllBlockIdentifiers();
|
||||
@ -261,7 +261,7 @@ public class JavaDeclareCommandsTranslator extends PacketTranslator<ServerDeclar
|
||||
return VALID_SCOREBOARD_SLOTS;
|
||||
|
||||
default:
|
||||
return CommandParamType.STRING;
|
||||
return CommandParam.STRING;
|
||||
}
|
||||
}
|
||||
|
||||
@ -324,11 +324,11 @@ public class JavaDeclareCommandsTranslator extends PacketTranslator<ServerDeclar
|
||||
// Put the non-enum param into the list
|
||||
Object mappedType = mapCommandType(paramNode.getParser());
|
||||
CommandEnumData enumData = null;
|
||||
CommandParamType type = null;
|
||||
CommandParam type = null;
|
||||
if (mappedType instanceof String[]) {
|
||||
enumData = new CommandEnumData(paramNode.getParser().name().toLowerCase(), (String[]) mappedType, false);
|
||||
} else {
|
||||
type = (CommandParamType) mappedType;
|
||||
type = (CommandParam) mappedType;
|
||||
}
|
||||
// IF enumData != null:
|
||||
// In game, this will show up like <paramNode.getName(): enumData.getName()>
|
||||
|
@ -69,7 +69,7 @@ public class JavaDeclareRecipesTranslator extends PacketTranslator<ServerDeclare
|
||||
ShapelessRecipeData shapelessRecipeData = (ShapelessRecipeData) recipe.getData();
|
||||
ItemData output = ItemTranslator.translateToBedrock(session, shapelessRecipeData.getResult());
|
||||
// Strip NBT - tools won't appear in the recipe book otherwise
|
||||
output = ItemData.of(output.getId(), output.getDamage(), output.getCount());
|
||||
output = output.toBuilder().tag(null).build();
|
||||
ItemData[][] inputCombinations = combinations(session, shapelessRecipeData.getIngredients());
|
||||
for (ItemData[] inputs : inputCombinations) {
|
||||
UUID uuid = UUID.randomUUID();
|
||||
@ -83,7 +83,7 @@ public class JavaDeclareRecipesTranslator extends PacketTranslator<ServerDeclare
|
||||
ShapedRecipeData shapedRecipeData = (ShapedRecipeData) recipe.getData();
|
||||
ItemData output = ItemTranslator.translateToBedrock(session, shapedRecipeData.getResult());
|
||||
// See above
|
||||
output = ItemData.of(output.getId(), output.getDamage(), output.getCount());
|
||||
output = output.toBuilder().tag(null).build();
|
||||
ItemData[][] inputCombinations = combinations(session, shapedRecipeData.getIngredients());
|
||||
for (ItemData[] inputs : inputCombinations) {
|
||||
UUID uuid = UUID.randomUUID();
|
||||
@ -230,7 +230,11 @@ public class JavaDeclareRecipesTranslator extends PacketTranslator<ServerDeclare
|
||||
if (entry.getValue().size() < idCount) {
|
||||
optionSet.addAll(entry.getValue());
|
||||
} else {
|
||||
optionSet.add(ItemData.of(groupedItem.id, Short.MAX_VALUE, groupedItem.count, groupedItem.tag));
|
||||
optionSet.add(ItemData.builder()
|
||||
.id(groupedItem.id)
|
||||
.damage(Short.MAX_VALUE)
|
||||
.count(groupedItem.count)
|
||||
.tag(groupedItem.tag).build());
|
||||
}
|
||||
} else {
|
||||
ItemData item = entry.getValue().get(0);
|
||||
|
@ -68,7 +68,7 @@ public class JavaSpawnParticleTranslator extends PacketTranslator<ServerSpawnPar
|
||||
ItemStack javaItem = ((ItemParticleData)packet.getParticle().getData()).getItemStack();
|
||||
ItemData bedrockItem = ItemTranslator.translateToBedrock(session, javaItem);
|
||||
int id = bedrockItem.getId();
|
||||
short damage = bedrockItem.getDamage();
|
||||
int damage = bedrockItem.getDamage();
|
||||
particle.setType(LevelEventType.PARTICLE_ITEM_BREAK);
|
||||
particle.setData(id << 16 | damage);
|
||||
particle.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ()));
|
||||
|
@ -140,7 +140,7 @@ public class JavaTradeListTranslator extends PacketTranslator<ServerTradeListPac
|
||||
|
||||
NbtMapBuilder builder = NbtMap.builder();
|
||||
builder.putByte("Count", (byte) (Math.max(itemData.getCount() + specialPrice, 1)));
|
||||
builder.putShort("Damage", itemData.getDamage());
|
||||
builder.putShort("Damage", (short) itemData.getDamage());
|
||||
builder.putString("Name", itemEntry.getBedrockIdentifier());
|
||||
if (itemData.getTag() != null) {
|
||||
NbtMap tag = itemData.getTag().toBuilder().build();
|
||||
|
@ -164,7 +164,10 @@ public class InventoryUtils {
|
||||
display.putList("Lore", NbtType.STRING, Collections.singletonList(ChatColor.RESET + ChatColor.DARK_PURPLE + description));
|
||||
|
||||
root.put("display", display.build());
|
||||
return ItemData.of(ItemRegistry.ITEM_ENTRIES.get(ItemRegistry.BARRIER_INDEX).getBedrockId(), (short) 0, 1, root.build());
|
||||
return ItemData.builder()
|
||||
.id(ItemRegistry.ITEM_ENTRIES.get(ItemRegistry.BARRIER_INDEX).getBedrockId())
|
||||
.count(1)
|
||||
.tag(root.build()).build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 2ce794e21a0212865059e7551db893c28843620a
|
||||
Subproject commit c846b8200eb8ebb37207666f7eddb83f2b636c37
|
2
pom.xml
2
pom.xml
@ -5,7 +5,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>geyser-parent</artifactId>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>Geyser</name>
|
||||
<description>Allows for players from Minecraft Bedrock Edition to join Minecraft Java Edition servers.</description>
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren