forked from GeyserMC/Geyser
Merge branch 'master' into feature/sounds
This commit is contained in:
commit
c22eb170ec
7 changed files with 39 additions and 15 deletions
|
@ -43,22 +43,14 @@ import com.nukkitx.math.vector.Vector2f;
|
|||
import com.nukkitx.math.vector.Vector2i;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import com.nukkitx.nbt.tag.CompoundTag;
|
||||
import com.nukkitx.protocol.bedrock.BedrockServerSession;
|
||||
import com.nukkitx.protocol.bedrock.data.ContainerId;
|
||||
import com.nukkitx.protocol.bedrock.data.GamePublishSetting;
|
||||
import com.nukkitx.protocol.bedrock.packet.AvailableEntityIdentifiersPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.BiomeDefinitionListPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.PlayStatusPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.StartGamePacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.TextPacket;
|
||||
import com.nukkitx.protocol.bedrock.data.GameRuleData;
|
||||
import com.nukkitx.protocol.bedrock.data.PlayerPermission;
|
||||
import com.nukkitx.protocol.bedrock.packet.*;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import org.geysermc.common.AuthType;
|
||||
import org.geysermc.common.window.FormWindow;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
|
@ -176,7 +168,7 @@ public class GeyserSession implements CommandSender {
|
|||
upstream.sendPacket(biomeDefinitionListPacket);
|
||||
|
||||
AvailableEntityIdentifiersPacket entityPacket = new AvailableEntityIdentifiersPacket();
|
||||
entityPacket.setTag(CompoundTag.EMPTY);
|
||||
entityPacket.setTag(Toolbox.ENTITY_IDENTIFIERS);
|
||||
upstream.sendPacket(entityPacket);
|
||||
|
||||
InventoryContentPacket creativePacket = new InventoryContentPacket();
|
||||
|
|
|
@ -58,13 +58,19 @@ public class EntityCache {
|
|||
}
|
||||
|
||||
public void spawnEntity(Entity entity) {
|
||||
cacheEntity(entity);
|
||||
entity.spawnEntity(session);
|
||||
if (cacheEntity(entity)) {
|
||||
entity.spawnEntity(session);
|
||||
}
|
||||
}
|
||||
|
||||
public void cacheEntity(Entity entity) {
|
||||
entityIdTranslations.put(entity.getEntityId(), entity.getGeyserId());
|
||||
entities.put(entity.getGeyserId(), entity);
|
||||
public boolean cacheEntity(Entity entity) {
|
||||
// Check to see if the entity exists, otherwise we can end up with duplicated mobs
|
||||
if (!entityIdTranslations.containsKey(entity.getEntityId())) {
|
||||
entityIdTranslations.put(entity.getEntityId(), entity.getGeyserId());
|
||||
entities.put(entity.getGeyserId(), entity);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean removeEntity(Entity entity, boolean force) {
|
||||
|
|
|
@ -54,7 +54,7 @@ public abstract class ItemStackTranslator {
|
|||
public ItemStack translateToJava(ItemData itemData, ItemEntry itemEntry) {
|
||||
if (itemData == null) return null;
|
||||
if (itemData.getTag() == null) {
|
||||
return new ItemStack(itemEntry.getJavaId(), itemData.getCount());
|
||||
return new ItemStack(itemEntry.getJavaId(), itemData.getCount(), new com.github.steveice10.opennbt.tag.builtin.CompoundTag(""));
|
||||
}
|
||||
return new ItemStack(itemEntry.getJavaId(), itemData.getCount(), this.translateToJavaNBT(itemData.getTag()));
|
||||
}
|
||||
|
|
|
@ -55,6 +55,8 @@ public class Toolbox {
|
|||
|
||||
public static final Int2ObjectMap<ItemEntry> ITEM_ENTRIES = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
public static CompoundTag ENTITY_IDENTIFIERS;
|
||||
|
||||
public static int BARRIER_INDEX = 0;
|
||||
|
||||
static {
|
||||
|
@ -143,6 +145,7 @@ public class Toolbox {
|
|||
// Load the locale data
|
||||
LocaleUtils.init();
|
||||
|
||||
/* Load creative items */
|
||||
stream = getResource("bedrock/creative_items.json");
|
||||
|
||||
JsonNode creativeItemEntries;
|
||||
|
@ -172,6 +175,16 @@ public class Toolbox {
|
|||
}
|
||||
}
|
||||
CREATIVE_ITEMS = creativeItems.toArray(new ItemData[0]);
|
||||
|
||||
|
||||
/* Load entity identifiers */
|
||||
stream = Toolbox.getResource("bedrock/entity_identifiers.dat");
|
||||
|
||||
try (NBTInputStream nbtInputStream = NbtUtils.createNetworkReader(stream)) {
|
||||
ENTITY_IDENTIFIERS = (CompoundTag) nbtInputStream.readTag();
|
||||
} catch (Exception e) {
|
||||
throw new AssertionError("Unable to get entities from entity identifiers", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue