From 392d2ca6f701bd31db62dc93a673e4e9f800f78d Mon Sep 17 00:00:00 2001 From: DoctorMacc Date: Fri, 10 Apr 2020 12:39:52 -0400 Subject: [PATCH 01/20] Begin work on ender crystal support --- .../connector/entity/EnderCrystalEntity.java | 19 +++++++++++++++++++ .../connector/entity/type/EntityType.java | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 connector/src/main/java/org/geysermc/connector/entity/EnderCrystalEntity.java diff --git a/connector/src/main/java/org/geysermc/connector/entity/EnderCrystalEntity.java b/connector/src/main/java/org/geysermc/connector/entity/EnderCrystalEntity.java new file mode 100644 index 000000000..483592489 --- /dev/null +++ b/connector/src/main/java/org/geysermc/connector/entity/EnderCrystalEntity.java @@ -0,0 +1,19 @@ +package org.geysermc.connector.entity; + +import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata; +import com.nukkitx.math.vector.Vector3f; +import org.geysermc.connector.entity.type.EntityType; +import org.geysermc.connector.network.session.GeyserSession; + +public class EnderCrystalEntity extends Entity { + + public EnderCrystalEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) { + super(entityId, geyserId, entityType, position, motion, rotation); + + } + + @Override + public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) { + super.updateBedrockMetadata(entityMetadata, session); + } +} diff --git a/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java b/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java index 500aa1a2e..b1452dd88 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java +++ b/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java @@ -105,7 +105,7 @@ public enum EntityType { EXPERIENCE_BOTTLE(ThrowableEntity.class, 68, 0.25f, 0.25f), EXPERIENCE_ORB(ExpOrbEntity.class, 69, 0f), EYE_OF_ENDER(Entity.class, 70, 0f), - END_CRYSTAL(Entity.class, 71, 0f), + END_CRYSTAL(EnderCrystalEntity.class, 71, 0f), FIREWORK_ROCKET(Entity.class, 72, 0f), TRIDENT(ArrowEntity.class, 73, 0f), TURTLE(AnimalEntity.class, 74, 0.4f, 1.2f), From fd5333b77ba06200653559c28752f14c910f0f03 Mon Sep 17 00:00:00 2001 From: DoctorMacc Date: Sat, 11 Apr 2020 13:06:50 -0400 Subject: [PATCH 02/20] Merge latest master --- .../connector/entity/EnderCrystalEntity.java | 22 +++++++++++++++++++ .../living/monster/EnderDragonEntity.java | 12 ++++++++++ .../connector/entity/type/EntityType.java | 2 +- 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java diff --git a/connector/src/main/java/org/geysermc/connector/entity/EnderCrystalEntity.java b/connector/src/main/java/org/geysermc/connector/entity/EnderCrystalEntity.java index 483592489..1f7664788 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/EnderCrystalEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/EnderCrystalEntity.java @@ -2,6 +2,8 @@ package org.geysermc.connector.entity; import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata; import com.nukkitx.math.vector.Vector3f; +import com.nukkitx.protocol.bedrock.data.EntityData; +import com.nukkitx.protocol.bedrock.packet.AddEntityPacket; import org.geysermc.connector.entity.type.EntityType; import org.geysermc.connector.network.session.GeyserSession; @@ -14,6 +16,26 @@ public class EnderCrystalEntity extends Entity { @Override public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) { + System.out.println("ID: " + entityMetadata.getId() + ", " + entityMetadata.getValue()); super.updateBedrockMetadata(entityMetadata, session); } + + @Override + public void spawnEntity(GeyserSession session) { + AddEntityPacket addEntityPacket = new AddEntityPacket(); + // Not end crystal but ender crystal + addEntityPacket.setIdentifier("minecraft:ender_crystal"); + addEntityPacket.setRuntimeEntityId(geyserId); + addEntityPacket.setUniqueEntityId(geyserId); + addEntityPacket.setPosition(position); + addEntityPacket.setMotion(motion); + addEntityPacket.setRotation(getBedrockRotation()); + addEntityPacket.setEntityType(entityType.getType()); + addEntityPacket.getMetadata().putAll(metadata); + + valid = true; + session.getUpstream().sendPacket(addEntityPacket); + + session.getConnector().getLogger().debug("Spawned entity " + entityType + " at location " + position + " with id " + geyserId + " (java id " + entityId + ")"); + } } diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java new file mode 100644 index 000000000..cf493e26c --- /dev/null +++ b/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java @@ -0,0 +1,12 @@ +package org.geysermc.connector.entity.living.monster; + +import com.nukkitx.math.vector.Vector3f; +import org.geysermc.connector.entity.living.InsentientEntity; +import org.geysermc.connector.entity.type.EntityType; + +public class EnderDragonEntity extends InsentientEntity { + + public EnderDragonEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) { + super(entityId, geyserId, entityType, position, motion, rotation); + } +} diff --git a/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java b/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java index b1452dd88..9fbb60f45 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java +++ b/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java @@ -85,7 +85,7 @@ public enum EntityType { ELDER_GUARDIAN(GuardianEntity.class, 50, 1.9975f), NPC(PlayerEntity.class, 51, 1.8f, 0.6f, 0.6f, 1.62f), WITHER(MonsterEntity.class, 52, 3.5f, 0.9f), - ENDER_DRAGON(InsentientEntity.class, 53, 4f, 13f), + ENDER_DRAGON(EnderDragonEntity.class, 53, 4f, 13f), SHULKER(GolemEntity.class, 54, 1f, 1f), ENDERMITE(MonsterEntity.class, 55, 0.3f, 0.4f), AGENT(Entity.class, 56, 0f), From 13bee6ca6a0b2a6db75957cb9e4aabb9bba73112 Mon Sep 17 00:00:00 2001 From: DoctorMacc Date: Sat, 11 Apr 2020 13:10:35 -0400 Subject: [PATCH 03/20] Debug stuff --- .../entity/living/monster/EnderDragonEntity.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java index cf493e26c..12870bd7c 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java @@ -1,12 +1,20 @@ package org.geysermc.connector.entity.living.monster; +import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata; import com.nukkitx.math.vector.Vector3f; import org.geysermc.connector.entity.living.InsentientEntity; import org.geysermc.connector.entity.type.EntityType; +import org.geysermc.connector.network.session.GeyserSession; public class EnderDragonEntity extends InsentientEntity { public EnderDragonEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) { super(entityId, geyserId, entityType, position, motion, rotation); } + + @Override + public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) { + System.out.println("Ender Dragon ID: " + entityMetadata.getId() + " Value: " + entityMetadata.getValue()); + super.updateBedrockMetadata(entityMetadata, session); + } } From 76e29af6b8f91974684cf36ab679bce9f3735b0f Mon Sep 17 00:00:00 2001 From: rtm516 Date: Sun, 12 Apr 2020 01:45:31 +0100 Subject: [PATCH 04/20] Fixed map name --- .../connector/network/translators/item/ItemTranslator.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemTranslator.java index 0da776dcf..68f88bb21 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemTranslator.java @@ -77,8 +77,10 @@ public class ItemTranslator { CompoundTag tag = stack.getNbt(); IntTag mapId = tag.get("map"); - if (mapId != null) + if (mapId != null) { tag.put(new StringTag("map_uuid", mapId.getValue().toString())); + tag.put(new IntTag("map_name_index", mapId.getValue())); + } return ItemData.of(bedrockItem.getBedrockId(), (short) bedrockItem.getBedrockData(), stack.getAmount(), translateToBedrockNBT(tag)); From d613835f9253dbfbcfb924ba882d4e721e41dc1e Mon Sep 17 00:00:00 2001 From: rtm516 Date: Sun, 12 Apr 2020 10:37:31 +0100 Subject: [PATCH 05/20] Added debug packet logging for unhandled packets --- .../org/geysermc/connector/network/translators/Registry.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/Registry.java b/connector/src/main/java/org/geysermc/connector/network/translators/Registry.java index cf80cdbfe..70201ba88 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/Registry.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/Registry.java @@ -55,6 +55,8 @@ public class Registry { if (MAP.containsKey(clazz)) { ((PacketTranslator

) MAP.get(clazz)).translate(packet, session); return true; + } else { + GeyserConnector.getInstance().getLogger().debug("Could not find packet for " + (packet.toString().length() > 25 ? packet.getClass().getSimpleName() : packet)); } } catch (Throwable ex) { GeyserConnector.getInstance().getLogger().error("Could not translate packet " + packet.getClass().getSimpleName(), ex); From 746cd29a6d3be32ff40f18d240dd443df1c63113 Mon Sep 17 00:00:00 2001 From: DoctorMacc Date: Sun, 12 Apr 2020 21:13:51 -0400 Subject: [PATCH 06/20] Add doDaylightCycle gamerule support --- connector/pom.xml | 6 ++++ .../java/world/JavaUpdateTimeTranslator.java | 33 ++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/connector/pom.xml b/connector/pom.xml index 25ef50730..190cd4e3b 100644 --- a/connector/pom.xml +++ b/connector/pom.xml @@ -66,6 +66,12 @@ 8.3.1 compile + + com.nukkitx.fastutil + fastutil-long-boolean-maps + 8.3.1 + compile + com.nukkitx.fastutil fastutil-object-long-maps diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java index ccb69856c..314814f8c 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java @@ -25,6 +25,10 @@ package org.geysermc.connector.network.translators.java.world; +import com.nukkitx.protocol.bedrock.data.GameRuleData; +import com.nukkitx.protocol.bedrock.packet.GameRulesChangedPacket; +import it.unimi.dsi.fastutil.longs.Long2BooleanMap; +import it.unimi.dsi.fastutil.longs.Long2BooleanOpenHashMap; import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.translators.PacketTranslator; import org.geysermc.connector.network.translators.Translator; @@ -35,11 +39,38 @@ import com.nukkitx.protocol.bedrock.packet.SetTimePacket; @Translator(packet = ServerUpdateTimePacket.class) public class JavaUpdateTimeTranslator extends PacketTranslator { + // doDaylightCycle per-player for multi-world support + static Long2BooleanMap daylightCycles = new Long2BooleanOpenHashMap(); + @Override public void translate(ServerUpdateTimePacket packet, GeyserSession session) { + + boolean doDayLightCycle = daylightCycles.getOrDefault(session.getPlayerEntity().getEntityId(), true); + long time = packet.getTime(); + + if ((!doDayLightCycle && time > 0) || (doDayLightCycle && time < 0)) { + // doDaylightCycle is different than the client and we don't know + // Time is set either way as a reference point for the current time + setTime(time, session); + setDoDayLightGamerule(session, !doDayLightCycle); + } else if (time > 0) { + // doDaylightCycle is true and we know + setTime(time, session); + } + } + + private void setTime(long time, GeyserSession session) { // https://minecraft.gamepedia.com/Day-night_cycle#24-hour_Minecraft_day SetTimePacket setTimePacket = new SetTimePacket(); - setTimePacket.setTime((int) Math.abs(packet.getTime()) % 24000); + setTimePacket.setTime((int) Math.abs(time) % 24000); session.getUpstream().sendPacket(setTimePacket); } + + private void setDoDayLightGamerule(GeyserSession session, boolean doCycle) { + GameRulesChangedPacket gameRulesChangedPacket = new GameRulesChangedPacket(); + gameRulesChangedPacket.getGameRules().add(new GameRuleData<>("dodaylightcycle", doCycle)); + session.getUpstream().sendPacket(gameRulesChangedPacket); + daylightCycles.put(session.getPlayerEntity().getEntityId(), doCycle); + } + } From daa1888c0959b2a94ae8542f4f26555483d4f413 Mon Sep 17 00:00:00 2001 From: DoctorMacc Date: Sun, 12 Apr 2020 21:33:51 -0400 Subject: [PATCH 07/20] Add some code in case of a rogue plugin --- .../java/world/JavaUpdateTimeTranslator.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java index 314814f8c..2db849dd8 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java @@ -29,6 +29,8 @@ import com.nukkitx.protocol.bedrock.data.GameRuleData; import com.nukkitx.protocol.bedrock.packet.GameRulesChangedPacket; import it.unimi.dsi.fastutil.longs.Long2BooleanMap; import it.unimi.dsi.fastutil.longs.Long2BooleanOpenHashMap; +import it.unimi.dsi.fastutil.longs.Long2LongMap; +import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap; import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.translators.PacketTranslator; import org.geysermc.connector.network.translators.Translator; @@ -41,14 +43,17 @@ public class JavaUpdateTimeTranslator extends PacketTranslator 0) || (doDayLightCycle && time < 0)) { + if ((!doDayLightCycle && time > 0 && lastTime != time) || (doDayLightCycle && time < 0)) { // doDaylightCycle is different than the client and we don't know // Time is set either way as a reference point for the current time setTime(time, session); @@ -56,6 +61,10 @@ public class JavaUpdateTimeTranslator extends PacketTranslator 0) { // doDaylightCycle is true and we know setTime(time, session); + } else if (time < 0) { + setTime(time, session); + // Only written to if negative to ease performance + lastRecordedTimes.put(session.getPlayerEntity().getEntityId(), time); } } From 5c62b47175aa156dce2b35590c53c0798cfe6ed4 Mon Sep 17 00:00:00 2001 From: DoctorMacc Date: Mon, 13 Apr 2020 10:46:13 -0400 Subject: [PATCH 08/20] Simplify logic --- connector/pom.xml | 6 --- .../java/world/JavaUpdateTimeTranslator.java | 37 ++++++++----------- 2 files changed, 16 insertions(+), 27 deletions(-) diff --git a/connector/pom.xml b/connector/pom.xml index 190cd4e3b..25ef50730 100644 --- a/connector/pom.xml +++ b/connector/pom.xml @@ -66,12 +66,6 @@ 8.3.1 compile - - com.nukkitx.fastutil - fastutil-long-boolean-maps - 8.3.1 - compile - com.nukkitx.fastutil fastutil-object-long-maps diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java index 2db849dd8..f6f9c892a 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java @@ -42,44 +42,39 @@ import com.nukkitx.protocol.bedrock.packet.SetTimePacket; public class JavaUpdateTimeTranslator extends PacketTranslator { // doDaylightCycle per-player for multi-world support - static Long2BooleanMap daylightCycles = new Long2BooleanOpenHashMap(); + //static Long2BooleanMap daylightCycles = new Long2BooleanOpenHashMap(); // If negative, the last time is stored so we know it's not some plugin behavior doing weird things. + // Per-player for multi-world support static Long2LongMap lastRecordedTimes = new Long2LongOpenHashMap(); @Override public void translate(ServerUpdateTimePacket packet, GeyserSession session) { - boolean doDayLightCycle = daylightCycles.getOrDefault(session.getPlayerEntity().getEntityId(), true); + // Bedrock sends a GameRulesChangedPacket if there is no daylight cycle + // Java just sends a negative long if there is no daylight cycle + //boolean doDayLightCycle = daylightCycles.getOrDefault(session.getPlayerEntity().getEntityId(), true); long lastTime = lastRecordedTimes.getOrDefault(session.getPlayerEntity().getEntityId(), 0); long time = packet.getTime(); - if ((!doDayLightCycle && time > 0 && lastTime != time) || (doDayLightCycle && time < 0)) { - // doDaylightCycle is different than the client and we don't know - // Time is set either way as a reference point for the current time - setTime(time, session); - setDoDayLightGamerule(session, !doDayLightCycle); - } else if (time > 0) { - // doDaylightCycle is true and we know - setTime(time, session); - } else if (time < 0) { - setTime(time, session); - // Only written to if negative to ease performance + if (lastTime != time) { + // https://minecraft.gamepedia.com/Day-night_cycle#24-hour_Minecraft_day + SetTimePacket setTimePacket = new SetTimePacket(); + setTimePacket.setTime((int) Math.abs(time) % 24000); + session.getUpstream().sendPacket(setTimePacket); + // TODO: Performance efficient to always do this? lastRecordedTimes.put(session.getPlayerEntity().getEntityId(), time); } - } - - private void setTime(long time, GeyserSession session) { - // https://minecraft.gamepedia.com/Day-night_cycle#24-hour_Minecraft_day - SetTimePacket setTimePacket = new SetTimePacket(); - setTimePacket.setTime((int) Math.abs(time) % 24000); - session.getUpstream().sendPacket(setTimePacket); + if (lastTime < 0 && time > 0) { + setDoDayLightGamerule(session, true); + } else if (lastTime != time && time < 0) { + setDoDayLightGamerule(session, false); + } } private void setDoDayLightGamerule(GeyserSession session, boolean doCycle) { GameRulesChangedPacket gameRulesChangedPacket = new GameRulesChangedPacket(); gameRulesChangedPacket.getGameRules().add(new GameRuleData<>("dodaylightcycle", doCycle)); session.getUpstream().sendPacket(gameRulesChangedPacket); - daylightCycles.put(session.getPlayerEntity().getEntityId(), doCycle); } } From d08c13a7e37c0949fdf6985cbd14e6a552590ec9 Mon Sep 17 00:00:00 2001 From: DoctorMacc Date: Mon, 13 Apr 2020 10:47:30 -0400 Subject: [PATCH 09/20] Remove old lines of code --- .../translators/java/world/JavaUpdateTimeTranslator.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java index f6f9c892a..9646e3297 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java @@ -40,9 +40,7 @@ import com.nukkitx.protocol.bedrock.packet.SetTimePacket; @Translator(packet = ServerUpdateTimePacket.class) public class JavaUpdateTimeTranslator extends PacketTranslator { - - // doDaylightCycle per-player for multi-world support - //static Long2BooleanMap daylightCycles = new Long2BooleanOpenHashMap(); + // If negative, the last time is stored so we know it's not some plugin behavior doing weird things. // Per-player for multi-world support static Long2LongMap lastRecordedTimes = new Long2LongOpenHashMap(); @@ -52,7 +50,6 @@ public class JavaUpdateTimeTranslator extends PacketTranslator Date: Mon, 13 Apr 2020 10:55:52 -0400 Subject: [PATCH 10/20] Remove unused imports --- .../translators/java/world/JavaUpdateTimeTranslator.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java index 9646e3297..2a9726645 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java @@ -27,8 +27,6 @@ package org.geysermc.connector.network.translators.java.world; import com.nukkitx.protocol.bedrock.data.GameRuleData; import com.nukkitx.protocol.bedrock.packet.GameRulesChangedPacket; -import it.unimi.dsi.fastutil.longs.Long2BooleanMap; -import it.unimi.dsi.fastutil.longs.Long2BooleanOpenHashMap; import it.unimi.dsi.fastutil.longs.Long2LongMap; import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap; import org.geysermc.connector.network.session.GeyserSession; @@ -40,7 +38,7 @@ import com.nukkitx.protocol.bedrock.packet.SetTimePacket; @Translator(packet = ServerUpdateTimePacket.class) public class JavaUpdateTimeTranslator extends PacketTranslator { - + // If negative, the last time is stored so we know it's not some plugin behavior doing weird things. // Per-player for multi-world support static Long2LongMap lastRecordedTimes = new Long2LongOpenHashMap(); From 35a16996b5b88d87ab794a6ee52b40241518b9e1 Mon Sep 17 00:00:00 2001 From: DoctorMacc Date: Mon, 13 Apr 2020 10:58:10 -0400 Subject: [PATCH 11/20] Small change --- .../translators/java/world/JavaUpdateTimeTranslator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java index 2a9726645..ab7ed8ae7 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java @@ -59,7 +59,7 @@ public class JavaUpdateTimeTranslator extends PacketTranslator 0) { + if (lastTime < 0 && time >= 0) { setDoDayLightGamerule(session, true); } else if (lastTime != time && time < 0) { setDoDayLightGamerule(session, false); From 3616aa07fe22cbc1be17ad0eb5ca69b72601c72e Mon Sep 17 00:00:00 2001 From: rtm516 Date: Mon, 13 Apr 2020 22:29:22 +0100 Subject: [PATCH 12/20] Fixed colour and style formatting for some messages --- .../org/geysermc/connector/utils/MessageUtils.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/utils/MessageUtils.java b/connector/src/main/java/org/geysermc/connector/utils/MessageUtils.java index a28d6a7a1..b47e86ee9 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/MessageUtils.java +++ b/connector/src/main/java/org/geysermc/connector/utils/MessageUtils.java @@ -58,7 +58,7 @@ public class MessageUtils { strings.add(" - no permission or invalid command!"); } - List furtherParams = getTranslationParams(translation.getTranslationParams()); + List furtherParams = getTranslationParams(translation.getTranslationParams(), locale); if (locale != null) { strings.add(insertParams(LocaleUtils.getLocaleString(translation.getTranslationKey(), locale), furtherParams)); }else{ @@ -96,7 +96,11 @@ public class MessageUtils { messageText = LocaleUtils.getLocaleString(messageText, locale); } - StringBuilder builder = new StringBuilder(messageText); + StringBuilder builder = new StringBuilder(); + builder.append(getFormat(message.getStyle().getFormats())); + builder.append(getColorOrParent(message.getStyle())); + builder.append(messageText); + for (Message msg : message.getExtra()) { builder.append(getFormat(msg.getStyle().getFormats())); builder.append(getColorOrParent(msg.getStyle())); @@ -139,8 +143,8 @@ public class MessageUtils { private static String getColorOrParent(MessageStyle style) { ChatColor chatColor = style.getColor(); - if (chatColor == ChatColor.NONE) { - return getColor(style.getParent().getColor()); + if (chatColor == ChatColor.NONE && style.getParent() != null) { + return getColorOrParent(style.getParent()); } return getColor(chatColor); From 821f164b23c3973c73ca96ccb5b500e90028398b Mon Sep 17 00:00:00 2001 From: DoctorMacc Date: Mon, 13 Apr 2020 18:01:30 -0400 Subject: [PATCH 13/20] Fix requested changes --- .../java/world/JavaUpdateTimeTranslator.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java index ab7ed8ae7..365338443 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java @@ -41,14 +41,14 @@ public class JavaUpdateTimeTranslator extends PacketTranslator= 0) { - setDoDayLightGamerule(session, true); + setDoDaylightCycleGamerule(session, true); } else if (lastTime != time && time < 0) { - setDoDayLightGamerule(session, false); + setDoDaylightCycleGamerule(session, false); } } - private void setDoDayLightGamerule(GeyserSession session, boolean doCycle) { + private void setDoDaylightCycleGamerule(GeyserSession session, boolean doCycle) { GameRulesChangedPacket gameRulesChangedPacket = new GameRulesChangedPacket(); gameRulesChangedPacket.getGameRules().add(new GameRuleData<>("dodaylightcycle", doCycle)); session.getUpstream().sendPacket(gameRulesChangedPacket); From d92b83afdbbc76b9d8bd7ecf6a01e49857e2070f Mon Sep 17 00:00:00 2001 From: DoctorMacc Date: Tue, 14 Apr 2020 16:58:41 -0400 Subject: [PATCH 14/20] Fix ender dragon; add enderman --- .../living/monster/EnderDragonEntity.java | 43 +++++++++++++++++++ .../entity/living/monster/EndermanEntity.java | 34 +++++++++++++++ .../connector/entity/type/EntityType.java | 2 +- 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 connector/src/main/java/org/geysermc/connector/entity/living/monster/EndermanEntity.java diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java index 12870bd7c..db8e8589e 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java @@ -2,6 +2,12 @@ package org.geysermc.connector.entity.living.monster; import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata; import com.nukkitx.math.vector.Vector3f; +import com.nukkitx.protocol.bedrock.data.Attribute; +import com.nukkitx.protocol.bedrock.data.EntityData; +import com.nukkitx.protocol.bedrock.data.EntityEventType; +import com.nukkitx.protocol.bedrock.data.EntityFlag; +import com.nukkitx.protocol.bedrock.packet.AddEntityPacket; +import com.nukkitx.protocol.bedrock.packet.EntityEventPacket; import org.geysermc.connector.entity.living.InsentientEntity; import org.geysermc.connector.entity.type.EntityType; import org.geysermc.connector.network.session.GeyserSession; @@ -15,6 +21,43 @@ public class EnderDragonEntity extends InsentientEntity { @Override public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) { System.out.println("Ender Dragon ID: " + entityMetadata.getId() + " Value: " + entityMetadata.getValue()); + if (entityMetadata.getId() == 15) { + metadata.getFlags().setFlag(EntityFlag.FIRE_IMMUNE, true); + switch ((int) entityMetadata.getValue()) { + // Performing breath attack + case 5: + EntityEventPacket entityEventPacket = new EntityEventPacket(); + entityEventPacket.setType(EntityEventType.DRAGON_FLAMING); + entityEventPacket.setRuntimeEntityId(geyserId); + entityEventPacket.setData(0); + session.getUpstream().sendPacket(entityEventPacket); + case 6: + case 7: + metadata.getFlags().setFlag(EntityFlag.SITTING, true); + break; + } + } super.updateBedrockMetadata(entityMetadata, session); } + + @Override + public void spawnEntity(GeyserSession session) { + AddEntityPacket addEntityPacket = new AddEntityPacket(); + addEntityPacket.setIdentifier("minecraft:" + entityType.name().toLowerCase()); + addEntityPacket.setRuntimeEntityId(geyserId); + addEntityPacket.setUniqueEntityId(geyserId); + addEntityPacket.setPosition(position); + addEntityPacket.setMotion(motion); + addEntityPacket.setRotation(getBedrockRotation()); + addEntityPacket.setEntityType(entityType.getType()); + addEntityPacket.getMetadata().putAll(metadata); + + // Otherwise dragon is always 'dying' + addEntityPacket.getAttributes().add(new Attribute("minecraft:health", 0.0f, 200f, 200f, 200f)); + + valid = true; + session.getUpstream().sendPacket(addEntityPacket); + + session.getConnector().getLogger().debug("Spawned entity " + entityType + " at location " + position + " with id " + geyserId + " (java id " + entityId + ")"); + } } diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/monster/EndermanEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/monster/EndermanEntity.java new file mode 100644 index 000000000..40573df6b --- /dev/null +++ b/connector/src/main/java/org/geysermc/connector/entity/living/monster/EndermanEntity.java @@ -0,0 +1,34 @@ +package org.geysermc.connector.entity.living.monster; + +import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata; +import com.github.steveice10.mc.protocol.data.game.world.block.BlockState; +import com.github.steveice10.mc.protocol.data.game.world.block.value.PistonValueType; +import com.nukkitx.math.vector.Vector3f; +import com.nukkitx.protocol.bedrock.data.EntityData; +import com.nukkitx.protocol.bedrock.data.EntityFlag; +import org.geysermc.connector.entity.type.EntityType; +import org.geysermc.connector.network.session.GeyserSession; +import org.geysermc.connector.network.translators.block.BlockTranslator; + +public class EndermanEntity extends MonsterEntity { + + public EndermanEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) { + super(entityId, geyserId, entityType, position, motion, rotation); + } + + @Override + public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) { + if (entityMetadata.getId() == 15) { + System.out.println("Block: " + entityMetadata.getValue()); + metadata.put(EntityData.ENDERMAN_HELD_ITEM_ID, BlockTranslator.getBedrockBlockId((BlockState) entityMetadata.getValue())); + } + if (entityMetadata.getId() == 16) { + System.out.println("Is screaming? " + (boolean) entityMetadata.getValue()); + metadata.getFlags().setFlag(EntityFlag.ANGRY, (boolean) entityMetadata.getValue()); + } + if (entityMetadata.getId() == 17) { + System.out.println("Is stared at? " + (boolean) entityMetadata.getValue()); + } + super.updateBedrockMetadata(entityMetadata, session); + } +} diff --git a/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java b/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java index e2c61699f..c50f05db4 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java +++ b/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java @@ -69,7 +69,7 @@ public enum EntityType { SPIDER(SpiderEntity.class, 35, 0.9f, 1.4f, 1.4f, 1f), ZOMBIE_PIGMAN(MonsterEntity.class, 36, 1.8f, 0.6f, 0.6f, 1.62f), SLIME(InsentientEntity.class, 37, 0.51f), - ENDERMAN(MonsterEntity.class, 38, 2.9f, 0.6f), + ENDERMAN(EndermanEntity.class, 38, 2.9f, 0.6f), SILVERFISH(MonsterEntity.class, 39, 0.3f, 0.4f), CAVE_SPIDER(MonsterEntity.class, 40, 0.5f, 0.7f), GHAST(FlyingEntity.class, 41, 4.0f), From ee453502e27261b0097677d48f49921ef4317035 Mon Sep 17 00:00:00 2001 From: DoctorMacc Date: Tue, 14 Apr 2020 21:46:05 -0400 Subject: [PATCH 15/20] Final touches --- .../connector/entity/EnderCrystalEntity.java | 18 +++++++++++++++++- .../living/monster/EnderDragonEntity.java | 1 - .../entity/living/monster/EndermanEntity.java | 9 +++------ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/entity/EnderCrystalEntity.java b/connector/src/main/java/org/geysermc/connector/entity/EnderCrystalEntity.java index 1f7664788..1adc1871c 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/EnderCrystalEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/EnderCrystalEntity.java @@ -1,8 +1,11 @@ package org.geysermc.connector.entity; import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata; +import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position; import com.nukkitx.math.vector.Vector3f; +import com.nukkitx.math.vector.Vector3i; import com.nukkitx.protocol.bedrock.data.EntityData; +import com.nukkitx.protocol.bedrock.data.EntityFlag; import com.nukkitx.protocol.bedrock.packet.AddEntityPacket; import org.geysermc.connector.entity.type.EntityType; import org.geysermc.connector.network.session.GeyserSession; @@ -16,7 +19,20 @@ public class EnderCrystalEntity extends Entity { @Override public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) { - System.out.println("ID: " + entityMetadata.getId() + ", " + entityMetadata.getValue()); + // Show beam + // Usually performed client-side on Bedrock except for Ender Dragon respawn event + if (entityMetadata.getId() == 7) { + if (entityMetadata.getValue() instanceof Position) { + Position pos = (Position) entityMetadata.getValue(); + metadata.put(EntityData.BLOCK_TARGET, Vector3i.from(pos.getX(), pos.getY(), pos.getZ())); + } else { + metadata.put(EntityData.BLOCK_TARGET, Vector3i.ZERO); + } + } + // There is a base located on the ender crystal + if (entityMetadata.getId() == 8) { + metadata.getFlags().setFlag(EntityFlag.SHOW_BOTTOM, (boolean) entityMetadata.getValue()); + } super.updateBedrockMetadata(entityMetadata, session); } diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java index db8e8589e..309eef149 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java @@ -3,7 +3,6 @@ package org.geysermc.connector.entity.living.monster; import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata; import com.nukkitx.math.vector.Vector3f; import com.nukkitx.protocol.bedrock.data.Attribute; -import com.nukkitx.protocol.bedrock.data.EntityData; import com.nukkitx.protocol.bedrock.data.EntityEventType; import com.nukkitx.protocol.bedrock.data.EntityFlag; import com.nukkitx.protocol.bedrock.packet.AddEntityPacket; diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/monster/EndermanEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/monster/EndermanEntity.java index 40573df6b..a2970ff2b 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/living/monster/EndermanEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/living/monster/EndermanEntity.java @@ -2,7 +2,6 @@ package org.geysermc.connector.entity.living.monster; import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata; import com.github.steveice10.mc.protocol.data.game.world.block.BlockState; -import com.github.steveice10.mc.protocol.data.game.world.block.value.PistonValueType; import com.nukkitx.math.vector.Vector3f; import com.nukkitx.protocol.bedrock.data.EntityData; import com.nukkitx.protocol.bedrock.data.EntityFlag; @@ -18,17 +17,15 @@ public class EndermanEntity extends MonsterEntity { @Override public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) { + // Held block if (entityMetadata.getId() == 15) { - System.out.println("Block: " + entityMetadata.getValue()); metadata.put(EntityData.ENDERMAN_HELD_ITEM_ID, BlockTranslator.getBedrockBlockId((BlockState) entityMetadata.getValue())); } + // 'Angry' - mouth open if (entityMetadata.getId() == 16) { - System.out.println("Is screaming? " + (boolean) entityMetadata.getValue()); metadata.getFlags().setFlag(EntityFlag.ANGRY, (boolean) entityMetadata.getValue()); } - if (entityMetadata.getId() == 17) { - System.out.println("Is stared at? " + (boolean) entityMetadata.getValue()); - } + // TODO: ID 17 is stared at but I don't believe it's used - maybe only for the sound effect. Check after particle merge super.updateBedrockMetadata(entityMetadata, session); } } From 52783804ac1be4bb13cc92591c30bbcf276e30f5 Mon Sep 17 00:00:00 2001 From: DoctorMacc Date: Tue, 14 Apr 2020 21:50:43 -0400 Subject: [PATCH 16/20] Remove debug code --- .../connector/entity/living/monster/EnderDragonEntity.java | 1 - 1 file changed, 1 deletion(-) diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java index 309eef149..7232023ea 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java @@ -19,7 +19,6 @@ public class EnderDragonEntity extends InsentientEntity { @Override public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) { - System.out.println("Ender Dragon ID: " + entityMetadata.getId() + " Value: " + entityMetadata.getValue()); if (entityMetadata.getId() == 15) { metadata.getFlags().setFlag(EntityFlag.FIRE_IMMUNE, true); switch ((int) entityMetadata.getValue()) { From 9e93ea4c8d727dcc2e4a35c172b73e45adba72b4 Mon Sep 17 00:00:00 2001 From: DoctorMacc Date: Tue, 14 Apr 2020 21:52:25 -0400 Subject: [PATCH 17/20] Add licenses --- .../connector/entity/EnderCrystalEntity.java | 25 +++++++++++++++++++ .../living/monster/EnderDragonEntity.java | 25 +++++++++++++++++++ .../entity/living/monster/EndermanEntity.java | 25 +++++++++++++++++++ 3 files changed, 75 insertions(+) diff --git a/connector/src/main/java/org/geysermc/connector/entity/EnderCrystalEntity.java b/connector/src/main/java/org/geysermc/connector/entity/EnderCrystalEntity.java index 1adc1871c..b3ce22783 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/EnderCrystalEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/EnderCrystalEntity.java @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @author GeyserMC + * @link https://github.com/GeyserMC/Geyser + */ + package org.geysermc.connector.entity; import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata; diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java index 7232023ea..b07377389 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @author GeyserMC + * @link https://github.com/GeyserMC/Geyser + */ + package org.geysermc.connector.entity.living.monster; import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata; diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/monster/EndermanEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/monster/EndermanEntity.java index a2970ff2b..a423013cb 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/living/monster/EndermanEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/living/monster/EndermanEntity.java @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @author GeyserMC + * @link https://github.com/GeyserMC/Geyser + */ + package org.geysermc.connector.entity.living.monster; import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata; From 95e1eb2a63e095491a6d7dbd217a850c2807d2f9 Mon Sep 17 00:00:00 2001 From: theminecoder Date: Wed, 15 Apr 2020 14:02:57 +1000 Subject: [PATCH 18/20] Fix bedrock clients not able to connect when the client thinks the server is full --- .../connector/network/ConnectorServerEventHandler.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/connector/src/main/java/org/geysermc/connector/network/ConnectorServerEventHandler.java b/connector/src/main/java/org/geysermc/connector/network/ConnectorServerEventHandler.java index f0ae14a5c..60ad28d47 100644 --- a/connector/src/main/java/org/geysermc/connector/network/ConnectorServerEventHandler.java +++ b/connector/src/main/java/org/geysermc/connector/network/ConnectorServerEventHandler.java @@ -80,6 +80,13 @@ public class ConnectorServerEventHandler implements BedrockServerEventHandler { pong.setMotd(config.getBedrock().getMotd1()); pong.setMotd(config.getBedrock().getMotd2()); } + + //Bedrock will not even attempt a connection if the client thinks the server is full + //so we have to fake it not being full + if (pong.getPlayerCount() >= pong.getMaximumPlayerCount()) { + pong.setMaximumPlayerCount(pong.getPlayerCount() + 1); + } + return pong; } From b15d37a4c55d00c07c5c8453c37d98702a2b32af Mon Sep 17 00:00:00 2001 From: RednedEpic Date: Tue, 14 Apr 2020 23:27:16 -0500 Subject: [PATCH 19/20] Print throwable for disconnection if present --- .../org/geysermc/connector/network/session/GeyserSession.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java index d5b2e75d5..af7c4e585 100644 --- a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java +++ b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java @@ -274,6 +274,9 @@ public class GeyserSession implements CommandSender { loggingIn = false; loggedIn = false; connector.getLogger().info(authData.getName() + " has disconnected from remote java server on address " + remoteServer.getAddress() + " because of " + event.getReason()); + if (event.getCause() != null) { + event.getCause().printStackTrace(); + } upstream.disconnect(event.getReason()); } From dbe2a9b3b0df9c06d7fa194854ac8bb52e83ebb0 Mon Sep 17 00:00:00 2001 From: RednedEpic Date: Tue, 14 Apr 2020 23:35:59 -0500 Subject: [PATCH 20/20] Return COLOR_0 for null values in MapColor Might be better to eventually figure out why this is null to begin with, but for the time being considering maps are not working, we'd have to get to that step first. This just prevents the console from spamming errors, and will do until maps are fully implemented/fixed. --- .../src/main/java/org/geysermc/connector/utils/MapColor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connector/src/main/java/org/geysermc/connector/utils/MapColor.java b/connector/src/main/java/org/geysermc/connector/utils/MapColor.java index 2c4a13b9f..2db144648 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/MapColor.java +++ b/connector/src/main/java/org/geysermc/connector/utils/MapColor.java @@ -227,7 +227,7 @@ public enum MapColor { } public static MapColor fromId(int id) { - return Arrays.stream(values()).filter(color -> color.getId() == id).findFirst().get(); + return Arrays.stream(values()).filter(color -> color.getId() == id).findFirst().orElse(COLOR_0); } public int toARGB() {