diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/ArrowMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/ArrowMetaData.java new file mode 100644 index 000000000..958313879 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/ArrowMetaData.java @@ -0,0 +1,33 @@ +/* + * 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.protocol.protocol.InByteBuffer; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +public class ArrowMetaData extends EntityMetaData { + + public ArrowMetaData(InByteBuffer buffer, ProtocolVersion v) { + super(buffer, v); + } + + public boolean isCritical() { + switch (version) { + case VERSION_1_7_10: + return (int) sets.get(16).getData() == 0x01; + } + return false; + } + +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/BatMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/BatMetaData.java new file mode 100644 index 000000000..3aff117ed --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/BatMetaData.java @@ -0,0 +1,34 @@ +/* + * 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.protocol.protocol.InByteBuffer; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +public class BatMetaData extends MobMetaData { + + public BatMetaData(InByteBuffer buffer, ProtocolVersion v) { + super(buffer, v); + } + + + public boolean isHanging() { + switch (version) { + case VERSION_1_7_10: + return (byte) sets.get(16).getData() == 0x01; + } + return false; + } + +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/BlazeMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/BlazeMetaData.java new file mode 100644 index 000000000..e01c0e788 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/BlazeMetaData.java @@ -0,0 +1,35 @@ +/* + * 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.protocol.protocol.InByteBuffer; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +public class BlazeMetaData extends MobMetaData { + + public BlazeMetaData(InByteBuffer buffer, ProtocolVersion v) { + super(buffer, v); + } + + + public boolean isOnFire() { + switch (version) { + case VERSION_1_7_10: + return (byte) sets.get(16).getData() == 0x01; + } + return false; + } + + +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/BoatMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/BoatMetaData.java new file mode 100644 index 000000000..8a0510a5f --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/BoatMetaData.java @@ -0,0 +1,49 @@ +/* + * 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.protocol.protocol.InByteBuffer; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +public class BoatMetaData extends EntityMetaData { + + public BoatMetaData(InByteBuffer buffer, ProtocolVersion v) { + super(buffer, v); + } + + public int getTimeSinceHit() { + switch (version) { + case VERSION_1_7_10: + return (int) sets.get(17).getData(); + } + return 0; + } + + public int getForwardDirection() { + switch (version) { + case VERSION_1_7_10: + return (int) sets.get(18).getData(); + } + return 0; + } + + public float getDamageTaken() { + switch (version) { + case VERSION_1_7_10: + return (float) sets.get(19).getData(); + } + return 0; + } + +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/CreeperMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/CreeperMetaData.java new file mode 100644 index 000000000..778d30900 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/CreeperMetaData.java @@ -0,0 +1,44 @@ +/* + * 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.protocol.protocol.InByteBuffer; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +public class CreeperMetaData extends MobMetaData { + + public CreeperMetaData(InByteBuffer buffer, ProtocolVersion v) { + super(buffer, v); + } + + + public byte getState() { + switch (version) { + case VERSION_1_7_10: + return (byte) sets.get(16).getData(); + } + return -1; + } + + + public boolean isPowered() { + switch (version) { + case VERSION_1_7_10: + return (byte) sets.get(17).getData() == 0x01; + } + return false; + } + + +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/EnderCrystalMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/EnderCrystalMetaData.java new file mode 100644 index 000000000..ba9e3e512 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/EnderCrystalMetaData.java @@ -0,0 +1,32 @@ +/* + * 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.protocol.protocol.InByteBuffer; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +public class EnderCrystalMetaData extends EntityMetaData { + + public EnderCrystalMetaData(InByteBuffer buffer, ProtocolVersion v) { + super(buffer, v); + } + + public int getHealth() { + switch (version) { + case VERSION_1_7_10: + return (int) sets.get(8).getData(); + } + return 0; + } +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/EndermanMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/EndermanMetaData.java new file mode 100644 index 000000000..601292d7e --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/EndermanMetaData.java @@ -0,0 +1,44 @@ +/* + * 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.blocks.Block; +import de.bixilon.minosoft.protocol.protocol.InByteBuffer; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +public class EndermanMetaData extends MobMetaData { + + public EndermanMetaData(InByteBuffer buffer, ProtocolVersion v) { + super(buffer, v); + } + + + public Block getCarriedBlock() { + switch (version) { + case VERSION_1_7_10: + return Block.byLegacy((short) sets.get(16).getData(), (byte) sets.get(17).getData()); + } + return Block.AIR; + } + + public boolean isScreaming() { + switch (version) { + case VERSION_1_7_10: + return (byte) sets.get(17).getData() == 0x01; + } + return false; + } + + +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/EntityMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/EntityMetaData.java index 851cd8fce..0c4158eaf 100644 --- a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/EntityMetaData.java +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/EntityMetaData.java @@ -21,7 +21,7 @@ import de.bixilon.minosoft.util.BitByte; import java.util.HashMap; public class EntityMetaData { - HashMap sets = new HashMap<>(); + HashMap sets = new HashMap<>(); ProtocolVersion version; public EntityMetaData(InByteBuffer buffer, ProtocolVersion v) { @@ -55,7 +55,7 @@ public class EntityMetaData { default: throw new IllegalStateException("Unexpected value: " + type); } - sets.put(index, new MetaDataSet(index, data)); + sets.put((int) index, new MetaDataSet(index, data)); item = buffer.readByte(); @@ -142,7 +142,7 @@ public class EntityMetaData { } - public HashMap getSets() { + public HashMap getSets() { return sets; } diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/FireworkMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/FireworkMetaData.java new file mode 100644 index 000000000..f2b4957a2 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/FireworkMetaData.java @@ -0,0 +1,34 @@ +/* + * 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.Slot; +import de.bixilon.minosoft.protocol.protocol.InByteBuffer; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +public class FireworkMetaData extends EntityMetaData { + + public FireworkMetaData(InByteBuffer buffer, ProtocolVersion v) { + super(buffer, v); + } + + public Slot getInfo() { + switch (version) { + case VERSION_1_7_10: + return (Slot) sets.get(8).getData(); + } + return null; + } + +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/FurnaceMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/FurnaceMetaData.java new file mode 100644 index 000000000..e224d204a --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/FurnaceMetaData.java @@ -0,0 +1,33 @@ +/* + * 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.protocol.protocol.InByteBuffer; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +public class FurnaceMetaData extends EntityMetaData { + + public FurnaceMetaData(InByteBuffer buffer, ProtocolVersion v) { + super(buffer, v); + } + + public boolean getPowered() { + switch (version) { + case VERSION_1_7_10: + return (int) sets.get(16).getData() == 0x01; + } + return false; + } + +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/GhastMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/GhastMetaData.java new file mode 100644 index 000000000..02a0c3140 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/GhastMetaData.java @@ -0,0 +1,34 @@ +/* + * 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.protocol.protocol.InByteBuffer; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +public class GhastMetaData extends MobMetaData { + + public GhastMetaData(InByteBuffer buffer, ProtocolVersion v) { + super(buffer, v); + } + + public boolean isAttacking() { + switch (version) { + case VERSION_1_7_10: + return (byte) sets.get(16).getData() == 0x01; + } + return false; + } + + +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/HorseMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/HorseMetaData.java new file mode 100644 index 000000000..ffc852137 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/HorseMetaData.java @@ -0,0 +1,154 @@ +/* + * 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.protocol.protocol.InByteBuffer; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; +import de.bixilon.minosoft.util.BitByte; + +public class HorseMetaData extends AgeableMetaData { + + public HorseMetaData(InByteBuffer buffer, ProtocolVersion v) { + super(buffer, v); + } + + + public boolean isTame() { + switch (version) { + case VERSION_1_7_10: + return BitByte.isBitSet((int) sets.get(16).getData(), 1); + } + return false; + } + + public boolean hasSaddle() { + switch (version) { + case VERSION_1_7_10: + return BitByte.isBitSet((int) sets.get(16).getData(), 2); + } + return false; + } + + public boolean hasChest() { + switch (version) { + case VERSION_1_7_10: + return BitByte.isBitSet((int) sets.get(16).getData(), 3); + } + return false; + } + + public boolean isBred() { + switch (version) { + case VERSION_1_7_10: + return BitByte.isBitSet((int) sets.get(16).getData(), 4); + } + return false; + } + + public boolean isEating() { + switch (version) { + case VERSION_1_7_10: + return BitByte.isBitSet((int) sets.get(16).getData(), 5); + } + return false; + } + + public boolean isRearing() { + switch (version) { + case VERSION_1_7_10: + return BitByte.isBitSet((int) sets.get(16).getData(), 6); + } + return false; + } + + public boolean isMouthOpen() { + switch (version) { + case VERSION_1_7_10: + return BitByte.isBitSet((int) sets.get(16).getData(), 7); + } + return false; + } + + public HorseType getType() { + switch (version) { + case VERSION_1_7_10: + return HorseType.byId((Integer) sets.get(19).getData()); + } + return null; + } + + public String getOwnerName() { + switch (version) { + case VERSION_1_7_10: + return (String) sets.get(21).getData(); + } + return null; + } + + // ToDo: entity color (index 20) + + + enum HorseType { + HORSE(0), + DONKEY(1), + MULE(2), + ZOMBIE(3), + SKELETON(4); + + final int id; + + HorseType(int id) { + this.id = id; + } + + public static HorseType byId(int id) { + for (HorseType h : values()) { + if (h.getId() == id) { + return h; + } + } + return null; + } + + public int getId() { + return id; + } + } + + enum Armor { + NO_ARMOR(0), + IRON_ARMOR(1), + GOLD_ARMOR(2), + DIAMOND_ARMOR(3); + + final int id; + + Armor(int id) { + this.id = id; + } + + public static Armor byId(int id) { + for (Armor a : values()) { + if (a.getId() == id) { + return a; + } + } + return null; + } + + public int getId() { + return id; + } + } +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/IronGolemMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/IronGolemMetaData.java new file mode 100644 index 000000000..b1a5ac812 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/IronGolemMetaData.java @@ -0,0 +1,34 @@ +/* + * 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.protocol.protocol.InByteBuffer; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +public class IronGolemMetaData extends MobMetaData { + + public IronGolemMetaData(InByteBuffer buffer, ProtocolVersion v) { + super(buffer, v); + } + + public boolean isCreatedByPlayer() { + switch (version) { + case VERSION_1_7_10: + return (byte) sets.get(16).getData() == 0x01; + } + return false; + } + + +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/ItemFrameMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/ItemFrameMetaData.java new file mode 100644 index 000000000..cc01779e8 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/ItemFrameMetaData.java @@ -0,0 +1,42 @@ +/* + * 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.Slot; +import de.bixilon.minosoft.protocol.protocol.InByteBuffer; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +public class ItemFrameMetaData extends EntityMetaData { + + public ItemFrameMetaData(InByteBuffer buffer, ProtocolVersion v) { + super(buffer, v); + } + + public Slot getItem() { + switch (version) { + case VERSION_1_7_10: + return (Slot) sets.get(2).getData(); + } + return null; + } + + public byte getRotation() { + switch (version) { + case VERSION_1_7_10: + return (byte) sets.get(3).getData(); + } + return 0; + } + +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/ItemMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/ItemMetaData.java new file mode 100644 index 000000000..c2838c984 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/ItemMetaData.java @@ -0,0 +1,34 @@ +/* + * 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.Slot; +import de.bixilon.minosoft.protocol.protocol.InByteBuffer; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +public class ItemMetaData extends EntityMetaData { + + public ItemMetaData(InByteBuffer buffer, ProtocolVersion v) { + super(buffer, v); + } + + public Slot getSlot() { + switch (version) { + case VERSION_1_7_10: + return (Slot) sets.get(10).getData(); + } + return null; + } + +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/MinecartMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/MinecartMetaData.java new file mode 100644 index 000000000..b3afe1efa --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/MinecartMetaData.java @@ -0,0 +1,58 @@ +/* + * 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.blocks.Block; +import de.bixilon.minosoft.protocol.protocol.InByteBuffer; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +public class MinecartMetaData extends EntityMetaData { + + public MinecartMetaData(InByteBuffer buffer, ProtocolVersion v) { + super(buffer, v); + } + + public int getShakingPower() { + switch (version) { + case VERSION_1_7_10: + return (int) sets.get(17).getData(); + } + return 0; + } + + public int getShakingDirection() { + switch (version) { + case VERSION_1_7_10: + return (int) sets.get(18).getData(); + } + return 0; + } + + public float getDamageTaken() { + switch (version) { + case VERSION_1_7_10: + return (float) sets.get(19).getData(); + } + return 0; + } + + public Block getBlock() { + switch (version) { + case VERSION_1_7_10: + return Block.byLegacy((int) sets.get(20).getData() & 0xFF, (int) sets.get(20).getData() & 0xFF00); + } + return Block.AIR; + } + +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/OcelotMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/OcelotMetaData.java new file mode 100644 index 000000000..70b1c55a6 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/OcelotMetaData.java @@ -0,0 +1,34 @@ +/* + * 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.protocol.protocol.InByteBuffer; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +public class OcelotMetaData extends TamableMetaData { + + public OcelotMetaData(InByteBuffer buffer, ProtocolVersion v) { + super(buffer, v); + } + + + public byte getType() { + switch (version) { + case VERSION_1_7_10: + return (byte) sets.get(18).getData(); + } + return 0x00; + } + +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/PigMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/PigMetaData.java new file mode 100644 index 000000000..1ad2dd721 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/PigMetaData.java @@ -0,0 +1,34 @@ +/* + * 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.protocol.protocol.InByteBuffer; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +public class PigMetaData extends AgeableMetaData { + + public PigMetaData(InByteBuffer buffer, ProtocolVersion v) { + super(buffer, v); + } + + + public boolean hasSaddle() { + switch (version) { + case VERSION_1_7_10: + return (byte) sets.get(16).getData() == 0x01; + } + return false; + } + +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/SheepMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/SheepMetaData.java new file mode 100644 index 000000000..ed940597c --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/SheepMetaData.java @@ -0,0 +1,44 @@ +/* + * 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.Color; +import de.bixilon.minosoft.protocol.protocol.InByteBuffer; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; +import de.bixilon.minosoft.util.BitByte; + +public class SheepMetaData extends AgeableMetaData { + + public SheepMetaData(InByteBuffer buffer, ProtocolVersion v) { + super(buffer, v); + } + + + public Color getColor() { + switch (version) { + case VERSION_1_7_10: + return Color.byId((byte) sets.get(16).getData() & 0xF); + } + return Color.WHITE; + } + + public boolean isSheared() { + switch (version) { + case VERSION_1_7_10: + return BitByte.isBitSet((byte) sets.get(16).getData(), 5); + } + return false; + } + +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/SkeletonMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/SkeletonMetaData.java new file mode 100644 index 000000000..1a0abc9d7 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/SkeletonMetaData.java @@ -0,0 +1,34 @@ +/* + * 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.protocol.protocol.InByteBuffer; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +public class SkeletonMetaData extends MobMetaData { + + public SkeletonMetaData(InByteBuffer buffer, ProtocolVersion v) { + super(buffer, v); + } + + public boolean isWitherSkeleton() { + switch (version) { + case VERSION_1_7_10: + return (byte) sets.get(13).getData() == 0x01; + } + return false; + } + + +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/SlimeMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/SlimeMetaData.java new file mode 100644 index 000000000..ba1de25aa --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/SlimeMetaData.java @@ -0,0 +1,34 @@ +/* + * 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.protocol.protocol.InByteBuffer; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +public class SlimeMetaData extends MobMetaData { + + public SlimeMetaData(InByteBuffer buffer, ProtocolVersion v) { + super(buffer, v); + } + + public byte getSize() { + switch (version) { + case VERSION_1_7_10: + return (byte) sets.get(16).getData(); + } + return 0; + } + + +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/SpiderMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/SpiderMetaData.java new file mode 100644 index 000000000..efeacd1c8 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/SpiderMetaData.java @@ -0,0 +1,35 @@ +/* + * 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.protocol.protocol.InByteBuffer; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +public class SpiderMetaData extends MobMetaData { + + public SpiderMetaData(InByteBuffer buffer, ProtocolVersion v) { + super(buffer, v); + } + + + public boolean isClimbing() { + switch (version) { + case VERSION_1_7_10: + return (byte) sets.get(16).getData() == 0x01; + } + return false; + } + + +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/TamableMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/TamableMetaData.java new file mode 100644 index 000000000..06b1bf16b --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/TamableMetaData.java @@ -0,0 +1,51 @@ +/* + * 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.protocol.protocol.InByteBuffer; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; +import de.bixilon.minosoft.util.BitByte; + +public class TamableMetaData extends MobMetaData { + + public TamableMetaData(InByteBuffer buffer, ProtocolVersion v) { + super(buffer, v); + } + + + public boolean isSitting() { + switch (version) { + case VERSION_1_7_10: + return BitByte.isBitSet((int) sets.get(16).getData(), 0); + } + return false; + } + + public boolean isTame() { + switch (version) { + case VERSION_1_7_10: + return BitByte.isBitSet((int) sets.get(16).getData(), 2); + } + return false; + } + + public String getOwnerName() { + switch (version) { + case VERSION_1_7_10: + return (String) sets.get(17).getData(); + } + return null; + } + +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/VillagerMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/VillagerMetaData.java new file mode 100644 index 000000000..4930b2275 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/VillagerMetaData.java @@ -0,0 +1,63 @@ +/* + * 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.protocol.protocol.InByteBuffer; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +public class VillagerMetaData extends AgeableMetaData { + + public VillagerMetaData(InByteBuffer buffer, ProtocolVersion v) { + super(buffer, v); + } + + + public VillagerType getVillagerType() { + switch (version) { + case VERSION_1_7_10: + return VillagerType.byId((int) sets.get(17).getData()); + } + return VillagerType.FARMER; + } + + public enum VillagerType { + FARMER(0), + LIBRARIAN(1), + PRIEST(2), + BLACKSMITH(3), + BUTCHER(4); + + + final int id; + + VillagerType(int id) { + this.id = id; + } + + public static VillagerType byId(int id) { + for (VillagerType t : values()) { + if (t.getId() == id) { + return t; + } + } + return null; + } + + public int getId() { + return id; + } + } + + +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/WitchMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/WitchMetaData.java new file mode 100644 index 000000000..344a5bba6 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/WitchMetaData.java @@ -0,0 +1,34 @@ +/* + * 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.protocol.protocol.InByteBuffer; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +public class WitchMetaData extends MobMetaData { + + public WitchMetaData(InByteBuffer buffer, ProtocolVersion v) { + super(buffer, v); + } + + public boolean isAggressive() { + switch (version) { + case VERSION_1_7_10: + return (byte) sets.get(13).getData() == 0x01; + } + return false; + } + + +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/WitherMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/WitherMetaData.java new file mode 100644 index 000000000..e54b4c063 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/WitherMetaData.java @@ -0,0 +1,58 @@ +/* + * 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.protocol.protocol.InByteBuffer; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +public class WitherMetaData extends MobMetaData { + + public WitherMetaData(InByteBuffer buffer, ProtocolVersion v) { + super(buffer, v); + } + + public int getWatchedTarget1() { + switch (version) { + case VERSION_1_7_10: + return (int) sets.get(17).getData(); + } + return 0; + } + + public int getWatchedTarget2() { + switch (version) { + case VERSION_1_7_10: + return (int) sets.get(18).getData(); + } + return 0; + } + + public int getWatchedTarget3() { + switch (version) { + case VERSION_1_7_10: + return (int) sets.get(19).getData(); + } + return 0; + } + + public int getInvulnerableTime() { + switch (version) { + case VERSION_1_7_10: + return (int) sets.get(20).getData(); + } + return 0; + } + + +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/WolfMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/WolfMetaData.java new file mode 100644 index 000000000..fbea537db --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/WolfMetaData.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.meta; + +import de.bixilon.minosoft.game.datatypes.Color; +import de.bixilon.minosoft.protocol.protocol.InByteBuffer; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; +import de.bixilon.minosoft.util.BitByte; + +public class WolfMetaData extends TamableMetaData { + + public WolfMetaData(InByteBuffer buffer, ProtocolVersion v) { + super(buffer, v); + } + + + public byte getType() { + switch (version) { + case VERSION_1_7_10: + return (byte) sets.get(18).getData(); + } + return 0x00; + } + + public boolean isAngry() { + switch (version) { + case VERSION_1_7_10: + return BitByte.isBitSet((int) sets.get(16).getData(), 1); + } + return false; + } + + public float getHealth() { + switch (version) { + case VERSION_1_7_10: + return (float) sets.get(19).getData(); + } + return 0.00F; + } + + + public Color getColor() { + switch (version) { + case VERSION_1_7_10: + return Color.byId((byte) sets.get(20).getData()); + } + return Color.WHITE; + } + +}