From 0b74cea68d08dfa4932934fd7ee29a95cbe581ab Mon Sep 17 00:00:00 2001 From: Bixilon Date: Fri, 10 Jul 2020 19:10:25 +0200 Subject: [PATCH] All 1.13.2 metadata and entities/objects --- .../game/datatypes/entities/Entities.java | 11 ++- ...hMetaData.java => PufferfishMetaData.java} | 36 ++++++-- .../entities/meta/RabbitMetaData.java | 47 +---------- .../entities/meta/TurtleMetaData.java | 74 +++++++++++++++++ .../game/datatypes/entities/mob/Cod.java | 66 +++++++++++++++ .../game/datatypes/entities/mob/Dolphin.java | 66 +++++++++++++++ .../game/datatypes/entities/mob/Drowned.java | 72 ++++++++++++++++ .../datatypes/entities/mob/Endermite.java | 61 ++++++++++++++ .../datatypes/entities/mob/FishingBobber.java | 60 ++++++++++++++ .../datatypes/entities/mob/LightningBolt.java | 60 ++++++++++++++ .../game/datatypes/entities/mob/Phantom.java | 65 +++++++++++++++ .../datatypes/entities/mob/Pufferfish.java | 82 +++++++++++++++++++ .../game/datatypes/entities/mob/Rabbit.java | 12 +-- .../game/datatypes/entities/mob/Salmon.java | 66 +++++++++++++++ .../datatypes/entities/mob/TropicalFish.java | 66 +++++++++++++++ .../game/datatypes/entities/mob/Turtle.java | 72 ++++++++++++++++ .../objects/MinecartCommandBlock.java | 6 +- .../entities/objects/MinecartFurnace.java | 74 +++++++++++++++++ .../entities/objects/MinecartHopper.java | 43 ++++++++++ .../entities/objects/MinecartSpawner.java | 43 ++++++++++ .../entities/objects/MinecartTNT.java | 43 ++++++++++ .../play/PacketEntityMetadata.java | 1 + .../clientbound/play/PacketSpawnMob.java | 6 +- .../protocol/protocol/InByteBuffer.java | 3 +- 24 files changed, 1069 insertions(+), 66 deletions(-) rename src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/{PufferFishMetaData.java => PufferfishMetaData.java} (58%) create mode 100644 src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/TurtleMetaData.java create mode 100644 src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Cod.java create mode 100644 src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Dolphin.java create mode 100644 src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Drowned.java create mode 100644 src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Endermite.java create mode 100644 src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/FishingBobber.java create mode 100644 src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/LightningBolt.java create mode 100644 src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Phantom.java create mode 100644 src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Pufferfish.java create mode 100644 src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Salmon.java create mode 100644 src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/TropicalFish.java create mode 100644 src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Turtle.java create mode 100644 src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/MinecartFurnace.java create mode 100644 src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/MinecartHopper.java create mode 100644 src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/MinecartSpawner.java create mode 100644 src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/MinecartTNT.java diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/Entities.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/Entities.java index 2dae1cb21..bad7ac24a 100644 --- a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/Entities.java +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/Entities.java @@ -102,10 +102,10 @@ public enum Entities { COD(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 8)}, Cod.class), DOLPHIN(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 12)}, Dolphin.class), DROWNED(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 14)}, Drowned.class), - ENDERMITE(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 19)}, Endermite.class), + ENDERMITE(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_8, 67), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 19)}, Endermite.class), MINECART_FURNACE(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 42)}, MinecartFurnace.class), MINECART_HOPPER(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 43)}, MinecartHopper.class), - MINECART_SPAWNER(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 44)}, MinecarSpawner.class), + MINECART_SPAWNER(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 44)}, MinecartSpawner.class), MINECART_TNT(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 45)}, MinecartTNT.class), PUFFERFISH(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 52)}, Pufferfish.class), SALMON(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 57)}, Salmon.class), @@ -132,16 +132,15 @@ public enum Entities { public static Entities byId(int id, ProtocolVersion version) { for (Entities entity : values()) { - if (entity.getType() == id) { + if (entity.getValueMap().get(version) == id) { return entity; } } return null; } - - public int getType() { - return type; + public VersionValueMap getValueMap() { + return valueMap; } public Class getClazz() { diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/PufferFishMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/PufferfishMetaData.java similarity index 58% rename from src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/PufferFishMetaData.java rename to src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/PufferfishMetaData.java index 8e5d91b62..4e33c9f40 100644 --- a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/PufferFishMetaData.java +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/PufferfishMetaData.java @@ -16,17 +16,43 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; import java.util.HashMap; -public class PufferFishMetaData extends FishMetaData { +public class PufferfishMetaData extends FishMetaData { - public PufferFishMetaData(HashMap sets, ProtocolVersion version) { + public PufferfishMetaData(HashMap sets, ProtocolVersion version) { super(sets, version); } - public int getPuffState() { + public PufferStates getPufferState() { switch (version) { case VERSION_1_13_2: - return (int) sets.get(13).getData(); + return PufferStates.byId((int) sets.get(13).getData()); + } + return PufferStates.UN_PUFFED; + } + + public enum PufferStates { + UN_PUFFED(0), + SEMI_PUFFED(1), + FULLY_PUFFED(2); + + + final int id; + + PufferStates(int id) { + this.id = id; + } + + public static PufferStates byId(int id) { + for (PufferStates state : values()) { + if (state.getId() == id) { + return state; + } + } + return null; + } + + public int getId() { + return id; } - return 0; } } diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/RabbitMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/RabbitMetaData.java index 4a93178f5..594c871ab 100644 --- a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/RabbitMetaData.java +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/RabbitMetaData.java @@ -12,7 +12,6 @@ */ package de.bixilon.minosoft.game.datatypes.entities.meta; -import de.bixilon.minosoft.game.datatypes.world.BlockPosition; import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; import java.util.HashMap; @@ -24,51 +23,11 @@ public class RabbitMetaData extends TameableMetaData { } - public BlockPosition getHomePosition() { + public int getType() { switch (version) { case VERSION_1_13_2: - return (BlockPosition) sets.get(13).getData(); + return (int) sets.get(13).getData(); } - return new BlockPosition(0, (short) 0, 0); - } - - public boolean hasEgg() { - switch (version) { - case VERSION_1_13_2: - return (boolean) sets.get(14).getData(); - } - return false; - } - - public boolean isLayingEgg() { - switch (version) { - case VERSION_1_13_2: - return (boolean) sets.get(15).getData(); - } - return false; - } - - public BlockPosition getTravelPosition() { - switch (version) { - case VERSION_1_13_2: - return (BlockPosition) sets.get(16).getData(); - } - return new BlockPosition(0, (short) 0, 0); - } - - public boolean isGoingHome() { - switch (version) { - case VERSION_1_13_2: - return (boolean) sets.get(17).getData(); - } - return false; - } - - public boolean isTraveling() { - switch (version) { - case VERSION_1_13_2: - return (boolean) sets.get(18).getData(); - } - return false; + return 0; } } diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/TurtleMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/TurtleMetaData.java new file mode 100644 index 000000000..39f89d233 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/TurtleMetaData.java @@ -0,0 +1,74 @@ +/* + * Codename Minosoft + * Copyright (C) 2020 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ +package de.bixilon.minosoft.game.datatypes.entities.meta; + +import de.bixilon.minosoft.game.datatypes.world.BlockPosition; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +import java.util.HashMap; + +public class TurtleMetaData extends AgeableMetaData { + + public TurtleMetaData(HashMap sets, ProtocolVersion version) { + super(sets, version); + } + + + public BlockPosition getHomePosition() { + switch (version) { + case VERSION_1_13_2: + return (BlockPosition) sets.get(13).getData(); + } + return new BlockPosition(0, (short) 0, 0); + } + + public boolean hasEgg() { + switch (version) { + case VERSION_1_13_2: + return (boolean) sets.get(14).getData(); + } + return false; + } + + public boolean isLayingEgg() { + switch (version) { + case VERSION_1_13_2: + return (boolean) sets.get(15).getData(); + } + return false; + } + + public BlockPosition getTravelPosition() { + switch (version) { + case VERSION_1_13_2: + return (BlockPosition) sets.get(16).getData(); + } + return new BlockPosition(0, (short) 0, 0); + } + + public boolean isGoingHome() { + switch (version) { + case VERSION_1_13_2: + return (boolean) sets.get(17).getData(); + } + return false; + } + + public boolean isTraveling() { + switch (version) { + case VERSION_1_13_2: + return (boolean) sets.get(18).getData(); + } + return false; + } +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Cod.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Cod.java new file mode 100644 index 000000000..94d174732 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Cod.java @@ -0,0 +1,66 @@ +/* + * Codename Minosoft + * Copyright (C) 2020 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.game.datatypes.entities.mob; + +import de.bixilon.minosoft.game.datatypes.entities.*; +import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData; +import de.bixilon.minosoft.game.datatypes.entities.meta.FishMetaData; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +import java.util.HashMap; + +public class Cod extends Mob implements MobInterface { + FishMetaData metaData; + + public Cod(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap sets, ProtocolVersion version) { + super(entityId, location, yaw, pitch, velocity); + this.metaData = new FishMetaData(sets, version); + } + + + @Override + public Entities getEntityType() { + return Entities.COD; + } + + @Override + public FishMetaData getMetaData() { + return metaData; + } + + @Override + public void setMetaData(EntityMetaData metaData) { + this.metaData = (FishMetaData) metaData; + } + + @Override + public float getWidth() { + return 0.5F; + } + + @Override + public float getHeight() { + return 0.3F; + } + + @Override + public int getMaxHealth() { + return 3; + } + + @Override + public Class getMetaDataClass() { + return FishMetaData.class; + } +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Dolphin.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Dolphin.java new file mode 100644 index 000000000..13b07476a --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Dolphin.java @@ -0,0 +1,66 @@ +/* + * Codename Minosoft + * Copyright (C) 2020 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.game.datatypes.entities.mob; + +import de.bixilon.minosoft.game.datatypes.entities.*; +import de.bixilon.minosoft.game.datatypes.entities.meta.DolphinMetaData; +import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +import java.util.HashMap; + +public class Dolphin extends Mob implements MobInterface { + DolphinMetaData metaData; + + public Dolphin(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap sets, ProtocolVersion version) { + super(entityId, location, yaw, pitch, velocity); + this.metaData = new DolphinMetaData(sets, version); + } + + + @Override + public Entities getEntityType() { + return Entities.DOLPHIN; + } + + @Override + public DolphinMetaData getMetaData() { + return metaData; + } + + @Override + public void setMetaData(EntityMetaData metaData) { + this.metaData = (DolphinMetaData) metaData; + } + + @Override + public float getWidth() { + return 0.9F; + } + + @Override + public float getHeight() { + return 0.6F; + } + + @Override + public int getMaxHealth() { + return 10; + } + + @Override + public Class getMetaDataClass() { + return DolphinMetaData.class; + } +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Drowned.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Drowned.java new file mode 100644 index 000000000..2945f71bb --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Drowned.java @@ -0,0 +1,72 @@ +/* + * Codename Minosoft + * Copyright (C) 2020 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.game.datatypes.entities.mob; + +import de.bixilon.minosoft.game.datatypes.entities.*; +import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData; +import de.bixilon.minosoft.game.datatypes.entities.meta.ZombieMetaData; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +import java.util.HashMap; + +public class Drowned extends Mob implements MobInterface { + ZombieMetaData metaData; + + public Drowned(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap sets, ProtocolVersion version) { + super(entityId, location, yaw, pitch, velocity); + this.metaData = new ZombieMetaData(sets, version); + } + + + @Override + public Entities getEntityType() { + return Entities.DROWNED; + } + + @Override + public ZombieMetaData getMetaData() { + return metaData; + } + + @Override + public void setMetaData(EntityMetaData metaData) { + this.metaData = (ZombieMetaData) metaData; + } + + @Override + public float getWidth() { + if (metaData.isChild()) { + return 0.3F; + } + return 0.6F; + } + + @Override + public float getHeight() { + if (metaData.isChild()) { + return 0.975F; + } + return 1.95F; + } + + @Override + public int getMaxHealth() { + return 20; + } + + @Override + public Class getMetaDataClass() { + return ZombieMetaData.class; + } +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Endermite.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Endermite.java new file mode 100644 index 000000000..2129bb7fe --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Endermite.java @@ -0,0 +1,61 @@ +/* + * Codename Minosoft + * Copyright (C) 2020 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.game.datatypes.entities.mob; + +import de.bixilon.minosoft.game.datatypes.entities.*; +import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +import java.util.HashMap; + +public class Endermite extends Mob implements MobInterface { + EntityMetaData metaData; + + public Endermite(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap sets, ProtocolVersion version) { + super(entityId, location, yaw, pitch, velocity); + this.metaData = new EntityMetaData(sets, version); + } + + + @Override + public Entities getEntityType() { + return Entities.ENDERMITE; + } + + @Override + public EntityMetaData getMetaData() { + return metaData; + } + + @Override + public void setMetaData(EntityMetaData metaData) { + this.metaData = metaData; + } + + @Override + public float getWidth() { + return 0.4F; + } + + @Override + public float getHeight() { + return 0.3F; + } + + @Override + public int getMaxHealth() { + return 8; + } + +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/FishingBobber.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/FishingBobber.java new file mode 100644 index 000000000..c41f43357 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/FishingBobber.java @@ -0,0 +1,60 @@ +/* + * Codename Minosoft + * Copyright (C) 2020 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.game.datatypes.entities.mob; + +import de.bixilon.minosoft.game.datatypes.entities.*; +import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +import java.util.HashMap; + +public class FishingBobber extends Mob implements MobInterface { + EntityMetaData metaData; + + public FishingBobber(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap sets, ProtocolVersion version) { + super(entityId, location, yaw, pitch, velocity); + this.metaData = new EntityMetaData(sets, version); + } + + + @Override + public Entities getEntityType() { + return Entities.FISHING_BOBBER; + } + + @Override + public EntityMetaData getMetaData() { + return metaData; + } + + @Override + public void setMetaData(EntityMetaData metaData) { + this.metaData = metaData; + } + + @Override + public float getWidth() { + return 0.0F; + } + + @Override + public float getHeight() { + return 0.0F; + } + + @Override + public int getMaxHealth() { + return 1; + } +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/LightningBolt.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/LightningBolt.java new file mode 100644 index 000000000..5757e01c5 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/LightningBolt.java @@ -0,0 +1,60 @@ +/* + * Codename Minosoft + * Copyright (C) 2020 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.game.datatypes.entities.mob; + +import de.bixilon.minosoft.game.datatypes.entities.*; +import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +import java.util.HashMap; + +public class LightningBolt extends Mob implements MobInterface { + EntityMetaData metaData; + + public LightningBolt(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap sets, ProtocolVersion version) { + super(entityId, location, yaw, pitch, velocity); + this.metaData = new EntityMetaData(sets, version); + } + + + @Override + public Entities getEntityType() { + return Entities.LIGHTNING_BOLT; + } + + @Override + public EntityMetaData getMetaData() { + return metaData; + } + + @Override + public void setMetaData(EntityMetaData metaData) { + this.metaData = metaData; + } + + @Override + public float getWidth() { + return 0.0F; + } + + @Override + public float getHeight() { + return 0.0F; + } + + @Override + public int getMaxHealth() { + return 1; + } +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Phantom.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Phantom.java new file mode 100644 index 000000000..2f7b119af --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Phantom.java @@ -0,0 +1,65 @@ +/* + * Codename Minosoft + * Copyright (C) 2020 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.game.datatypes.entities.mob; + +import de.bixilon.minosoft.game.datatypes.entities.*; +import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData; +import de.bixilon.minosoft.game.datatypes.entities.meta.PhantomMetaData; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +import java.util.HashMap; + +public class Phantom extends Mob implements MobInterface { + PhantomMetaData metaData; + + public Phantom(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap sets, ProtocolVersion version) { + super(entityId, location, yaw, pitch, velocity); + this.metaData = new PhantomMetaData(sets, version); + } + + @Override + public Entities getEntityType() { + return Entities.PHANTOM; + } + + @Override + public PhantomMetaData getMetaData() { + return metaData; + } + + @Override + public void setMetaData(EntityMetaData metaData) { + this.metaData = (PhantomMetaData) metaData; + } + + @Override + public float getWidth() { + return 0.9F; + } + + @Override + public float getHeight() { + return 0.5F; + } + + @Override + public int getMaxHealth() { + return 20; + } + + @Override + public Class getMetaDataClass() { + return PhantomMetaData.class; + } +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Pufferfish.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Pufferfish.java new file mode 100644 index 000000000..7eef558ca --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Pufferfish.java @@ -0,0 +1,82 @@ +/* + * Codename Minosoft + * Copyright (C) 2020 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.game.datatypes.entities.mob; + +import de.bixilon.minosoft.game.datatypes.entities.*; +import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData; +import de.bixilon.minosoft.game.datatypes.entities.meta.PufferfishMetaData; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +import java.util.HashMap; + +public class Pufferfish extends Mob implements MobInterface { + PufferfishMetaData metaData; + + public Pufferfish(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap sets, ProtocolVersion version) { + super(entityId, location, yaw, pitch, velocity); + this.metaData = new PufferfishMetaData(sets, version); + } + + + @Override + public Entities getEntityType() { + return Entities.PUFFERFISH; + } + + @Override + public PufferfishMetaData getMetaData() { + return metaData; + } + + @Override + public void setMetaData(EntityMetaData metaData) { + this.metaData = (PufferfishMetaData) metaData; + } + + @Override + public float getWidth() { + switch (metaData.getPufferState()) { + case UN_PUFFED: + return 0.35F; + case SEMI_PUFFED: + return 0.5F; + case FULLY_PUFFED: + return 0.7F; + } + return 0.35F; + } + + @Override + public float getHeight() { + switch (metaData.getPufferState()) { + case UN_PUFFED: + return 0.35F; + case SEMI_PUFFED: + return 0.5F; + case FULLY_PUFFED: + return 0.7F; + } + return 0.35F; + } + + @Override + public int getMaxHealth() { + return 3; + } + + @Override + public Class getMetaDataClass() { + return PufferfishMetaData.class; + } +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Rabbit.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Rabbit.java index 090b2acc9..1370e410e 100644 --- a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Rabbit.java +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Rabbit.java @@ -15,17 +15,17 @@ package de.bixilon.minosoft.game.datatypes.entities.mob; import de.bixilon.minosoft.game.datatypes.entities.*; import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData; -import de.bixilon.minosoft.game.datatypes.entities.meta.RabbitMetaData; +import de.bixilon.minosoft.game.datatypes.entities.meta.TurtleMetaData; import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; import java.util.HashMap; public class Rabbit extends Mob implements MobInterface { - RabbitMetaData metaData; + TurtleMetaData metaData; public Rabbit(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap sets, ProtocolVersion version) { super(entityId, location, yaw, pitch, velocity); - this.metaData = new RabbitMetaData(sets, version); + this.metaData = new TurtleMetaData(sets, version); } @Override @@ -34,13 +34,13 @@ public class Rabbit extends Mob implements MobInterface { } @Override - public RabbitMetaData getMetaData() { + public TurtleMetaData getMetaData() { return metaData; } @Override public void setMetaData(EntityMetaData metaData) { - this.metaData = (RabbitMetaData) metaData; + this.metaData = (TurtleMetaData) metaData; } @Override @@ -60,6 +60,6 @@ public class Rabbit extends Mob implements MobInterface { @Override public Class getMetaDataClass() { - return RabbitMetaData.class; + return TurtleMetaData.class; } } diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Salmon.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Salmon.java new file mode 100644 index 000000000..3686a8be1 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Salmon.java @@ -0,0 +1,66 @@ +/* + * Codename Minosoft + * Copyright (C) 2020 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.game.datatypes.entities.mob; + +import de.bixilon.minosoft.game.datatypes.entities.*; +import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData; +import de.bixilon.minosoft.game.datatypes.entities.meta.FishMetaData; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +import java.util.HashMap; + +public class Salmon extends Mob implements MobInterface { + FishMetaData metaData; + + public Salmon(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap sets, ProtocolVersion version) { + super(entityId, location, yaw, pitch, velocity); + this.metaData = new FishMetaData(sets, version); + } + + + @Override + public Entities getEntityType() { + return Entities.SALMON; + } + + @Override + public FishMetaData getMetaData() { + return metaData; + } + + @Override + public void setMetaData(EntityMetaData metaData) { + this.metaData = (FishMetaData) metaData; + } + + @Override + public float getWidth() { + return 0.7F; + } + + @Override + public float getHeight() { + return 0.4F; + } + + @Override + public int getMaxHealth() { + return 3; + } + + @Override + public Class getMetaDataClass() { + return FishMetaData.class; + } +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/TropicalFish.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/TropicalFish.java new file mode 100644 index 000000000..50dd4019a --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/TropicalFish.java @@ -0,0 +1,66 @@ +/* + * Codename Minosoft + * Copyright (C) 2020 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.game.datatypes.entities.mob; + +import de.bixilon.minosoft.game.datatypes.entities.*; +import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData; +import de.bixilon.minosoft.game.datatypes.entities.meta.FishMetaData; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +import java.util.HashMap; + +public class TropicalFish extends Mob implements MobInterface { + FishMetaData metaData; + + public TropicalFish(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap sets, ProtocolVersion version) { + super(entityId, location, yaw, pitch, velocity); + this.metaData = new FishMetaData(sets, version); + } + + + @Override + public Entities getEntityType() { + return Entities.SALMON; + } + + @Override + public FishMetaData getMetaData() { + return metaData; + } + + @Override + public void setMetaData(EntityMetaData metaData) { + this.metaData = (FishMetaData) metaData; + } + + @Override + public float getWidth() { + return 0.5F; + } + + @Override + public float getHeight() { + return 0.4F; + } + + @Override + public int getMaxHealth() { + return 3; + } + + @Override + public Class getMetaDataClass() { + return FishMetaData.class; + } +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Turtle.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Turtle.java new file mode 100644 index 000000000..f939aeac1 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Turtle.java @@ -0,0 +1,72 @@ +/* + * Codename Minosoft + * Copyright (C) 2020 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.game.datatypes.entities.mob; + +import de.bixilon.minosoft.game.datatypes.entities.*; +import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData; +import de.bixilon.minosoft.game.datatypes.entities.meta.TurtleMetaData; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +import java.util.HashMap; + +public class Turtle extends Mob implements MobInterface { + TurtleMetaData metaData; + + public Turtle(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap sets, ProtocolVersion version) { + super(entityId, location, yaw, pitch, velocity); + this.metaData = new TurtleMetaData(sets, version); + } + + + @Override + public Entities getEntityType() { + return Entities.TURTLE; + } + + @Override + public TurtleMetaData getMetaData() { + return metaData; + } + + @Override + public void setMetaData(EntityMetaData metaData) { + this.metaData = (TurtleMetaData) metaData; + } + + @Override + public float getWidth() { + if (metaData.isAdult()) { + return 1.2F; + } + return 0.36F; + } + + @Override + public float getHeight() { + if (metaData.isAdult()) { + return 0.4F; + } + return 0.12F; + } + + @Override + public int getMaxHealth() { + return 30; + } + + @Override + public Class getMetaDataClass() { + return TurtleMetaData.class; + } +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/MinecartCommandBlock.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/MinecartCommandBlock.java index 6d417765e..0c0cffc36 100644 --- a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/MinecartCommandBlock.java +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/MinecartCommandBlock.java @@ -39,7 +39,7 @@ public class MinecartCommandBlock extends EntityObject implements ObjectInterfac @Override public Entities getEntityType() { - return Entities.MINECART_RIDE_ABLE; + return Entities.MINECART_COMMAND_BLOCK; } @Override @@ -67,4 +67,8 @@ public class MinecartCommandBlock extends EntityObject implements ObjectInterfac return CommandBlockMinecartMetaData.class; } + public Minecart.MinecartType getType() { + return Minecart.MinecartType.COMMAND_BLOCK; + } + } diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/MinecartFurnace.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/MinecartFurnace.java new file mode 100644 index 000000000..d45736a5b --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/MinecartFurnace.java @@ -0,0 +1,74 @@ +/* + * Codename Minosoft + * Copyright (C) 2020 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.game.datatypes.entities.objects; + +import de.bixilon.minosoft.game.datatypes.entities.*; +import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData; +import de.bixilon.minosoft.game.datatypes.entities.meta.FurnaceMinecartMetaData; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +import java.util.HashMap; + +public class MinecartFurnace extends EntityObject implements ObjectInterface { + FurnaceMinecartMetaData metaData; + + public MinecartFurnace(int entityId, Location location, short yaw, short pitch, int additionalInt) { + super(entityId, location, yaw, pitch, null); + } + + public MinecartFurnace(int entityId, Location location, short yaw, short pitch, int additionalInt, Velocity velocity) { + super(entityId, location, yaw, pitch, velocity); + } + + public MinecartFurnace(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap sets, ProtocolVersion version) { + super(entityId, location, yaw, pitch, velocity); + this.metaData = new FurnaceMinecartMetaData(sets, version); + } + + + @Override + public Entities getEntityType() { + return Entities.MINECART_FURNACE; + } + + @Override + public FurnaceMinecartMetaData getMetaData() { + return metaData; + } + + @Override + public void setMetaData(EntityMetaData metaData) { + this.metaData = (FurnaceMinecartMetaData) metaData; + } + + @Override + public float getWidth() { + return 0.98F; + } + + @Override + public float getHeight() { + return 0.7F; + } + + @Override + public Class getMetaDataClass() { + return FurnaceMinecartMetaData.class; + } + + public Minecart.MinecartType getType() { + return Minecart.MinecartType.FURNACE; + } + +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/MinecartHopper.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/MinecartHopper.java new file mode 100644 index 000000000..a02dadec8 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/MinecartHopper.java @@ -0,0 +1,43 @@ +/* + * Codename Minosoft + * Copyright (C) 2020 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.game.datatypes.entities.objects; + +import de.bixilon.minosoft.game.datatypes.entities.Location; +import de.bixilon.minosoft.game.datatypes.entities.ObjectInterface; +import de.bixilon.minosoft.game.datatypes.entities.Velocity; +import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +import java.util.HashMap; + +public class MinecartHopper extends Minecart implements ObjectInterface { + + public MinecartHopper(int entityId, Location location, short yaw, short pitch, int additionalInt) { + super(entityId, location, yaw, pitch, additionalInt, null); + } + + public MinecartHopper(int entityId, Location location, short yaw, short pitch, int additionalInt, Velocity velocity) { + super(entityId, location, yaw, pitch, additionalInt, velocity); + } + + public MinecartHopper(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap sets, ProtocolVersion version) { + super(entityId, location, yaw, pitch, 0, velocity); + } + + @Override + public Minecart.MinecartType getType() { + return MinecartType.HOPPER; + } + +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/MinecartSpawner.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/MinecartSpawner.java new file mode 100644 index 000000000..5a796db74 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/MinecartSpawner.java @@ -0,0 +1,43 @@ +/* + * Codename Minosoft + * Copyright (C) 2020 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.game.datatypes.entities.objects; + +import de.bixilon.minosoft.game.datatypes.entities.Location; +import de.bixilon.minosoft.game.datatypes.entities.ObjectInterface; +import de.bixilon.minosoft.game.datatypes.entities.Velocity; +import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +import java.util.HashMap; + +public class MinecartSpawner extends Minecart implements ObjectInterface { + + public MinecartSpawner(int entityId, Location location, short yaw, short pitch, int additionalInt) { + super(entityId, location, yaw, pitch, additionalInt, null); + } + + public MinecartSpawner(int entityId, Location location, short yaw, short pitch, int additionalInt, Velocity velocity) { + super(entityId, location, yaw, pitch, additionalInt, velocity); + } + + public MinecartSpawner(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap sets, ProtocolVersion version) { + super(entityId, location, yaw, pitch, 0, velocity); + } + + @Override + public MinecartType getType() { + return MinecartType.SPAWNER; + } + +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/MinecartTNT.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/MinecartTNT.java new file mode 100644 index 000000000..81f9406f4 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/MinecartTNT.java @@ -0,0 +1,43 @@ +/* + * Codename Minosoft + * Copyright (C) 2020 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.game.datatypes.entities.objects; + +import de.bixilon.minosoft.game.datatypes.entities.Location; +import de.bixilon.minosoft.game.datatypes.entities.ObjectInterface; +import de.bixilon.minosoft.game.datatypes.entities.Velocity; +import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +import java.util.HashMap; + +public class MinecartTNT extends Minecart implements ObjectInterface { + + public MinecartTNT(int entityId, Location location, short yaw, short pitch, int additionalInt) { + super(entityId, location, yaw, pitch, additionalInt, null); + } + + public MinecartTNT(int entityId, Location location, short yaw, short pitch, int additionalInt, Velocity velocity) { + super(entityId, location, yaw, pitch, additionalInt, velocity); + } + + public MinecartTNT(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap sets, ProtocolVersion version) { + super(entityId, location, yaw, pitch, 0, velocity); + } + + @Override + public MinecartType getType() { + return MinecartType.TNT; + } + +} diff --git a/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketEntityMetadata.java b/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketEntityMetadata.java index f58942f33..62244011a 100644 --- a/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketEntityMetadata.java +++ b/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketEntityMetadata.java @@ -41,6 +41,7 @@ public class PacketEntityMetadata implements ClientboundPacket { case VERSION_1_10: case VERSION_1_11_2: case VERSION_1_12_2: + case VERSION_1_13_2: entityId = buffer.readVarInt(); break; default: diff --git a/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketSpawnMob.java b/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketSpawnMob.java index ed53db59a..fdc1b4dd9 100644 --- a/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketSpawnMob.java +++ b/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketSpawnMob.java @@ -37,7 +37,7 @@ public class PacketSpawnMob implements ClientboundPacket { case VERSION_1_7_10: case VERSION_1_8: { int entityId = buffer.readVarInt(); - Entities type = Entities.byId(buffer.readByte()); + Entities type = Entities.byId(buffer.readByte(), buffer.getVersion()); Location location = new Location(buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger()); short yaw = buffer.readAngle(); short pitch = buffer.readAngle(); @@ -58,7 +58,7 @@ public class PacketSpawnMob implements ClientboundPacket { case VERSION_1_10: { int entityId = buffer.readVarInt(); UUID uuid = buffer.readUUID(); - Entities type = Entities.byId(buffer.readByte()); + Entities type = Entities.byId(buffer.readByte(), buffer.getVersion()); Location location = new Location(buffer.readDouble(), buffer.readDouble(), buffer.readDouble()); short yaw = buffer.readAngle(); short pitch = buffer.readAngle(); @@ -79,7 +79,7 @@ public class PacketSpawnMob implements ClientboundPacket { case VERSION_1_13_2: { int entityId = buffer.readVarInt(); UUID uuid = buffer.readUUID(); - Entities type = Entities.byId(buffer.readVarInt()); + Entities type = Entities.byId(buffer.readVarInt(), buffer.getVersion()); Location location = new Location(buffer.readDouble(), buffer.readDouble(), buffer.readDouble()); short yaw = buffer.readAngle(); short pitch = buffer.readAngle(); diff --git a/src/main/java/de/bixilon/minosoft/protocol/protocol/InByteBuffer.java b/src/main/java/de/bixilon/minosoft/protocol/protocol/InByteBuffer.java index bcd051326..762ab71e6 100644 --- a/src/main/java/de/bixilon/minosoft/protocol/protocol/InByteBuffer.java +++ b/src/main/java/de/bixilon/minosoft/protocol/protocol/InByteBuffer.java @@ -366,7 +366,8 @@ public class InByteBuffer { } break; } - case VERSION_1_12_2: { + case VERSION_1_12_2: + case VERSION_1_13_2: { byte index = readByte(); while (index != (byte) 0xFF) { EntityMetaData.Types type = EntityMetaData.Types.byId(readVarInt(), version);