mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Fix llama carpet decoration (#2125)
This commit is contained in:
parent
6a88a46b51
commit
beb7e54b7a
3 changed files with 17 additions and 12 deletions
|
@ -32,7 +32,7 @@ import com.nukkitx.protocol.bedrock.data.inventory.ItemData;
|
|||
import com.nukkitx.protocol.bedrock.packet.MobArmorEquipmentPacket;
|
||||
import org.geysermc.connector.entity.type.EntityType;
|
||||
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 {
|
||||
|
||||
|
@ -52,16 +52,13 @@ public class LlamaEntity extends ChestedHorseEntity {
|
|||
if (entityMetadata.getId() == 20) {
|
||||
// Bedrock treats llama decoration as armor
|
||||
MobArmorEquipmentPacket equipmentPacket = new MobArmorEquipmentPacket();
|
||||
equipmentPacket.setRuntimeEntityId(getGeyserId());
|
||||
equipmentPacket.setRuntimeEntityId(geyserId);
|
||||
// -1 means no armor
|
||||
if ((int) entityMetadata.getValue() != -1) {
|
||||
// The damage value is the dye color that Java sends us
|
||||
int carpetIndex = (int) entityMetadata.getValue();
|
||||
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
|
||||
equipmentPacket.setChestplate(ItemData.builder()
|
||||
.id(BlockTranslator.CARPET)
|
||||
.damage((int) entityMetadata.getValue())
|
||||
.count(1)
|
||||
.build());
|
||||
equipmentPacket.setChestplate(ItemRegistry.CARPETS.get(carpetIndex));
|
||||
} else {
|
||||
equipmentPacket.setChestplate(ItemData.AIR);
|
||||
}
|
||||
|
|
|
@ -92,6 +92,10 @@ public class ItemRegistry {
|
|||
* Bucket item entries (excluding the milk bucket), used in BedrockInventoryTransactionTranslator.java
|
||||
*/
|
||||
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
|
||||
*/
|
||||
|
@ -452,6 +456,13 @@ public class ItemRegistry {
|
|||
BOATS.add(entry.getValue().get("bedrock_id").intValue());
|
||||
} else if (entry.getKey().contains("bucket") && !entry.getKey().contains("milk")) {
|
||||
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());
|
||||
|
|
|
@ -74,9 +74,6 @@ public abstract class BlockTranslator {
|
|||
private final Object2IntMap<NbtMap> itemFrames = new Object2IntOpenHashMap<>();
|
||||
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 Int2BooleanMap JAVA_RUNTIME_ID_TO_CAN_HARVEST_WITH_HAND = new Int2BooleanOpenHashMap();
|
||||
public static final Int2ObjectMap<String> JAVA_RUNTIME_ID_TO_TOOL_TYPE = new Int2ObjectOpenHashMap<>();
|
||||
|
|
Loading…
Reference in a new issue