3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-03 14:50:19 +01:00

Fix llama carpet decoration (#2125)

Dieser Commit ist enthalten in:
Camotoy 2021-04-16 11:30:17 -04:00 committet von GitHub
Ursprung 6a88a46b51
Commit beb7e54b7a
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
3 geänderte Dateien mit 17 neuen und 12 gelöschten Zeilen

Datei anzeigen

@ -32,7 +32,7 @@ import com.nukkitx.protocol.bedrock.data.inventory.ItemData;
import com.nukkitx.protocol.bedrock.packet.MobArmorEquipmentPacket; import com.nukkitx.protocol.bedrock.packet.MobArmorEquipmentPacket;
import org.geysermc.connector.entity.type.EntityType; import org.geysermc.connector.entity.type.EntityType;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.world.block.BlockTranslator; import org.geysermc.connector.network.translators.item.ItemRegistry;
public class LlamaEntity extends ChestedHorseEntity { public class LlamaEntity extends ChestedHorseEntity {
@ -52,16 +52,13 @@ public class LlamaEntity extends ChestedHorseEntity {
if (entityMetadata.getId() == 20) { if (entityMetadata.getId() == 20) {
// Bedrock treats llama decoration as armor // Bedrock treats llama decoration as armor
MobArmorEquipmentPacket equipmentPacket = new MobArmorEquipmentPacket(); MobArmorEquipmentPacket equipmentPacket = new MobArmorEquipmentPacket();
equipmentPacket.setRuntimeEntityId(getGeyserId()); equipmentPacket.setRuntimeEntityId(geyserId);
// -1 means no armor // -1 means no armor
if ((int) entityMetadata.getValue() != -1) { int carpetIndex = (int) entityMetadata.getValue();
// The damage value is the dye color that Java sends us if (carpetIndex > -1 && carpetIndex <= 15) {
// The damage value is the dye color that Java sends us, for pre-1.16.220
// The item is always going to be a carpet // The item is always going to be a carpet
equipmentPacket.setChestplate(ItemData.builder() equipmentPacket.setChestplate(ItemRegistry.CARPETS.get(carpetIndex));
.id(BlockTranslator.CARPET)
.damage((int) entityMetadata.getValue())
.count(1)
.build());
} else { } else {
equipmentPacket.setChestplate(ItemData.AIR); equipmentPacket.setChestplate(ItemData.AIR);
} }

Datei anzeigen

@ -92,6 +92,10 @@ public class ItemRegistry {
* Bucket item entries (excluding the milk bucket), used in BedrockInventoryTransactionTranslator.java * Bucket item entries (excluding the milk bucket), used in BedrockInventoryTransactionTranslator.java
*/ */
public static final IntSet BUCKETS = new IntArraySet(); public static final IntSet BUCKETS = new IntArraySet();
/**
* Carpet item data, used in LlamaEntity.java
*/
public static final List<ItemData> CARPETS = new ArrayList<>(16);
/** /**
* Crossbow item entry, used in PillagerEntity.java * Crossbow item entry, used in PillagerEntity.java
*/ */
@ -452,6 +456,13 @@ public class ItemRegistry {
BOATS.add(entry.getValue().get("bedrock_id").intValue()); BOATS.add(entry.getValue().get("bedrock_id").intValue());
} else if (entry.getKey().contains("bucket") && !entry.getKey().contains("milk")) { } else if (entry.getKey().contains("bucket") && !entry.getKey().contains("milk")) {
BUCKETS.add(entry.getValue().get("bedrock_id").intValue()); BUCKETS.add(entry.getValue().get("bedrock_id").intValue());
} else if (entry.getKey().contains("_carpet")) {
// This should be the numerical order Java sends as an integer value for llamas
CARPETS.add(ItemData.builder()
.id(itemEntry.getBedrockId())
.damage(itemEntry.getBedrockData())
.count(1)
.blockRuntimeId(itemEntry.getBedrockBlockId()).build());
} }
itemNames.add(entry.getKey()); itemNames.add(entry.getKey());

Datei anzeigen

@ -74,9 +74,6 @@ public abstract class BlockTranslator {
private final Object2IntMap<NbtMap> itemFrames = new Object2IntOpenHashMap<>(); private final Object2IntMap<NbtMap> itemFrames = new Object2IntOpenHashMap<>();
private final Map<String, NbtMap> flowerPotBlocks = new HashMap<>(); private final Map<String, NbtMap> flowerPotBlocks = new HashMap<>();
// Bedrock carpet ID, used in LlamaEntity.java for decoration
public static final int CARPET = 171;
public static final Int2DoubleMap JAVA_RUNTIME_ID_TO_HARDNESS = new Int2DoubleOpenHashMap(); public static final Int2DoubleMap JAVA_RUNTIME_ID_TO_HARDNESS = new Int2DoubleOpenHashMap();
public static final Int2BooleanMap JAVA_RUNTIME_ID_TO_CAN_HARVEST_WITH_HAND = new Int2BooleanOpenHashMap(); public static final Int2BooleanMap JAVA_RUNTIME_ID_TO_CAN_HARVEST_WITH_HAND = new Int2BooleanOpenHashMap();
public static final Int2ObjectMap<String> JAVA_RUNTIME_ID_TO_TOOL_TYPE = new Int2ObjectOpenHashMap<>(); public static final Int2ObjectMap<String> JAVA_RUNTIME_ID_TO_TOOL_TYPE = new Int2ObjectOpenHashMap<>();