Merge branch 'master' into feature/sounds

This commit is contained in:
RednedEpic 2020-04-26 00:26:14 -05:00
commit c22eb170ec
7 changed files with 39 additions and 15 deletions

View File

@ -0,0 +1,6 @@
<component name="CopyrightManager">
<copyright>
<option name="notice" value="Copyright (c) 2019-&amp;#36;today.year GeyserMC. http://geysermc.org&#10; &#10; Permission is hereby granted, free of charge, to any person obtaining a copy&#10; of this software and associated documentation files (the &quot;Software&quot;), to deal&#10; in the Software without restriction, including without limitation the rights&#10; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell&#10; copies of the Software, and to permit persons to whom the Software is&#10; furnished to do so, subject to the following conditions:&#10; &#10; The above copyright notice and this permission notice shall be included in&#10; all copies or substantial portions of the Software.&#10; &#10; THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR&#10; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,&#10; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE&#10; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER&#10; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,&#10; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN&#10; THE SOFTWARE.&#10; &#10; @author GeyserMC&#10; @link https://github.com/GeyserMC/Geyser&#10; " />
<option name="myName" value="Geyser" />
</copyright>
</component>

View File

@ -0,0 +1,7 @@
<component name="CopyrightManager">
<settings>
<module2copyright>
<element module="All" copyright="Geyser" />
</module2copyright>
</settings>
</component>

View File

@ -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();

View File

@ -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) {

View File

@ -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()));
}

View File

@ -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);
}
}
/**