All 1.8 EntityMetaData, all 1.8 mobs and objects

This commit is contained in:
Bixilon 2020-06-23 20:24:28 +02:00
parent 9a57571b3c
commit c15dd9d252
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
40 changed files with 565 additions and 22 deletions

View File

@ -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 <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.game.datatypes;
public class EntityRotation {
final float yaw;
final float pitch;
final float roll;
public EntityRotation(float yaw, float pitch, float roll) {
this.yaw = yaw;
this.pitch = pitch;
this.roll = roll;
}
public float getYaw() {
return yaw;
}
public float getPitch() {
return pitch;
}
public float getRoll() {
return roll;
}
@Override
public String toString() {
return String.format("%s %s %s", getYaw(), getPitch(), getRoll());
}
}

View File

@ -35,6 +35,7 @@ public enum Mobs {
WITHER(new Identifier("wither"), 64, Wither.class), WITHER(new Identifier("wither"), 64, Wither.class),
BAT(new Identifier("bat"), 65, Bat.class), BAT(new Identifier("bat"), 65, Bat.class),
WITCH(new Identifier("witch"), 66, Witch.class), WITCH(new Identifier("witch"), 66, Witch.class),
GUARDIAN(new Identifier("witch"), 68, Guardian.class),
PIG(new Identifier("pig"), 90, Pig.class), PIG(new Identifier("pig"), 90, Pig.class),
SHEEP(new Identifier("sheep"), 91, Sheep.class), SHEEP(new Identifier("sheep"), 91, Sheep.class),
COW(new Identifier("cow"), 92, Cow.class), COW(new Identifier("cow"), 92, Cow.class),
@ -46,6 +47,7 @@ public enum Mobs {
OCELOT(new Identifier("ocelot"), 98, Ocelot.class), OCELOT(new Identifier("ocelot"), 98, Ocelot.class),
IRON_GOLEM(new Identifier("iron_golem"), 99, IronGolem.class), IRON_GOLEM(new Identifier("iron_golem"), 99, IronGolem.class),
HORSE(new Identifier("horse"), 100, Horse.class), HORSE(new Identifier("horse"), 100, Horse.class),
RABBIT(new Identifier("rabbit"), 101, Rabbit.class),
VILLAGER(new Identifier("villager"), 120, Villager.class); VILLAGER(new Identifier("villager"), 120, Villager.class);
final Identifier identifier; final Identifier identifier;

View File

@ -37,6 +37,7 @@ public enum Objects implements EntityEnumInterface {
THROWN_EXP_BOTTLE(null, 75, ThrownExpBottle.class), THROWN_EXP_BOTTLE(null, 75, ThrownExpBottle.class),
FIREWORK(new Identifier("firework"), 76, Firework.class), FIREWORK(new Identifier("firework"), 76, Firework.class),
LEASH_KNOT(new Identifier("firework"), 77, LeashKnot.class), LEASH_KNOT(new Identifier("firework"), 77, LeashKnot.class),
ARMOR_STAND(new Identifier("armor_stand"), 78, ArmorStand.class),
FISHING_FLOAT(null, 90, FishingFloat.class); FISHING_FLOAT(null, 90, FishingFloat.class);
//ToDo: identifier //ToDo: identifier

View File

@ -26,6 +26,7 @@ public class AgeableMetaData extends MobMetaData {
public int getAge() { public int getAge() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (int) sets.get(12).getData(); return (int) sets.get(12).getData();
} }
return 0; return 0;

View File

@ -0,0 +1,117 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*
* 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.EntityRotation;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import de.bixilon.minosoft.util.BitByte;
public class ArmorStandMetaData extends MobMetaData {
public ArmorStandMetaData(InByteBuffer buffer, ProtocolVersion v) {
super(buffer, v);
}
public boolean isSmall() {
switch (version) {
case VERSION_1_8:
return BitByte.isBitSet((byte) sets.get(10).getData(), 0);
}
return false;
}
public boolean hasGravity() {
switch (version) {
case VERSION_1_8:
return BitByte.isBitSet((byte) sets.get(10).getData(), 1);
}
return false;
}
public boolean hasArms() {
switch (version) {
case VERSION_1_8:
return BitByte.isBitSet((byte) sets.get(10).getData(), 2);
}
return false;
}
public boolean removeBasePlate() {
switch (version) {
case VERSION_1_8:
return BitByte.isBitSet((byte) sets.get(10).getData(), 3);
}
return false;
}
public boolean hasMarker() {
switch (version) {
case VERSION_1_8:
return BitByte.isBitSet((byte) sets.get(10).getData(), 4);
}
return false;
}
public EntityRotation getHeadPosition() {
switch (version) {
case VERSION_1_8:
return (EntityRotation) sets.get(11).getData();
}
return null;
}
public EntityRotation getBodyPosition() {
switch (version) {
case VERSION_1_8:
return (EntityRotation) sets.get(12).getData();
}
return null;
}
public EntityRotation getLeftArmPosition() {
switch (version) {
case VERSION_1_8:
return (EntityRotation) sets.get(13).getData();
}
return null;
}
public EntityRotation getRightArmPosition() {
switch (version) {
case VERSION_1_8:
return (EntityRotation) sets.get(14).getData();
}
return null;
}
public EntityRotation getLeftLegPosition() {
switch (version) {
case VERSION_1_8:
return (EntityRotation) sets.get(15).getData();
}
return null;
}
public EntityRotation getRightLegPosition() {
switch (version) {
case VERSION_1_8:
return (EntityRotation) sets.get(16).getData();
}
return null;
}
}

View File

@ -25,7 +25,8 @@ public class ArrowMetaData extends EntityMetaData {
public boolean isCritical() { public boolean isCritical() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
return (int) sets.get(16).getData() == 0x01; case VERSION_1_8:
return (byte) sets.get(16).getData() == 0x01;
} }
return false; return false;
} }

View File

@ -26,6 +26,7 @@ public class BatMetaData extends MobMetaData {
public boolean isHanging() { public boolean isHanging() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (byte) sets.get(16).getData() == 0x01; return (byte) sets.get(16).getData() == 0x01;
} }
return false; return false;

View File

@ -26,6 +26,7 @@ public class BlazeMetaData extends MobMetaData {
public boolean isOnFire() { public boolean isOnFire() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (byte) sets.get(16).getData() == 0x01; return (byte) sets.get(16).getData() == 0x01;
} }
return false; return false;

View File

@ -25,6 +25,7 @@ public class BoatMetaData extends EntityMetaData {
public int getTimeSinceHit() { public int getTimeSinceHit() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (int) sets.get(17).getData(); return (int) sets.get(17).getData();
} }
return 0; return 0;
@ -33,6 +34,7 @@ public class BoatMetaData extends EntityMetaData {
public int getForwardDirection() { public int getForwardDirection() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (int) sets.get(18).getData(); return (int) sets.get(18).getData();
} }
return 0; return 0;
@ -41,6 +43,7 @@ public class BoatMetaData extends EntityMetaData {
public float getDamageTaken() { public float getDamageTaken() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (float) sets.get(19).getData(); return (float) sets.get(19).getData();
} }
return 0; return 0;

View File

@ -26,6 +26,7 @@ public class CreeperMetaData extends MobMetaData {
public byte getState() { public byte getState() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (byte) sets.get(16).getData(); return (byte) sets.get(16).getData();
} }
return -1; return -1;
@ -35,6 +36,7 @@ public class CreeperMetaData extends MobMetaData {
public boolean isPowered() { public boolean isPowered() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (byte) sets.get(17).getData() == 0x01; return (byte) sets.get(17).getData() == 0x01;
} }
return false; return false;

View File

@ -25,6 +25,7 @@ public class EnderCrystalMetaData extends EntityMetaData {
public int getHealth() { public int getHealth() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (int) sets.get(8).getData(); return (int) sets.get(8).getData();
} }
return 0; return 0;

View File

@ -27,6 +27,7 @@ public class EndermanMetaData extends MobMetaData {
public Blocks getCarriedBlock() { public Blocks getCarriedBlock() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return Blocks.byLegacy((short) sets.get(16).getData(), (byte) sets.get(17).getData()); return Blocks.byLegacy((short) sets.get(16).getData(), (byte) sets.get(17).getData());
} }
return Blocks.AIR; return Blocks.AIR;
@ -35,7 +36,8 @@ public class EndermanMetaData extends MobMetaData {
public boolean isScreaming() { public boolean isScreaming() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
return (byte) sets.get(17).getData() == 0x01; case VERSION_1_8:
return (byte) sets.get(18).getData() == 0x01;
} }
return false; return false;
} }

View File

@ -13,6 +13,7 @@
package de.bixilon.minosoft.game.datatypes.entities.meta; package de.bixilon.minosoft.game.datatypes.entities.meta;
import de.bixilon.minosoft.game.datatypes.EntityRotation;
import de.bixilon.minosoft.game.datatypes.Vector; import de.bixilon.minosoft.game.datatypes.Vector;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer; import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
@ -24,15 +25,20 @@ public class EntityMetaData {
final HashMap<Integer, MetaDataSet> sets = new HashMap<>(); final HashMap<Integer, MetaDataSet> sets = new HashMap<>();
final ProtocolVersion version; final ProtocolVersion version;
/*
1.7.10: https://wiki.vg/index.php?title=Entity_metadata&oldid=5991
1.8: https://wiki.vg/index.php?title=Entity_metadata&oldid=6611
*/
public EntityMetaData(InByteBuffer buffer, ProtocolVersion v) { public EntityMetaData(InByteBuffer buffer, ProtocolVersion v) {
version = v; version = v;
switch (v) { switch (v) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
byte item = buffer.readByte(); byte item = buffer.readByte();
while (item != 0x7F) { while (item != 0x7F) {
byte index = (byte) (item & 0x1F); byte index = (byte) (item & 0x1F);
Object data; Object data;
Type_1_7_10 type = Type_1_7_10.byId((item & 0xFF) >>> 5); TypeLegacy type = TypeLegacy.byId((item & 0xFF) >>> 5);
switch (type) { switch (type) {
case BYTE: case BYTE:
data = buffer.readByte(); data = buffer.readByte();
@ -55,6 +61,9 @@ public class EntityMetaData {
case SLOT: case SLOT:
data = buffer.readSlot(v); data = buffer.readSlot(v);
break; break;
case POSITION:
data = new EntityRotation(buffer.readFloat(), buffer.readFloat(), buffer.readFloat());
break;
default: default:
throw new IllegalStateException("Unexpected value: " + type); throw new IllegalStateException("Unexpected value: " + type);
} }
@ -152,6 +161,7 @@ public class EntityMetaData {
public boolean onFire() { public boolean onFire() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return BitByte.isBitSet((byte) sets.get(0).getData(), 0); return BitByte.isBitSet((byte) sets.get(0).getData(), 0);
} }
return false; return false;
@ -160,6 +170,7 @@ public class EntityMetaData {
public boolean isSneaking() { public boolean isSneaking() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return BitByte.isBitSet((byte) sets.get(0).getData(), 1); return BitByte.isBitSet((byte) sets.get(0).getData(), 1);
} }
return false; return false;
@ -168,6 +179,7 @@ public class EntityMetaData {
public boolean isSprinting() { public boolean isSprinting() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return BitByte.isBitSet((byte) sets.get(0).getData(), 2); return BitByte.isBitSet((byte) sets.get(0).getData(), 2);
} }
return false; return false;
@ -176,6 +188,7 @@ public class EntityMetaData {
public boolean isEating() { public boolean isEating() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return BitByte.isBitSet((byte) sets.get(0).getData(), 3); return BitByte.isBitSet((byte) sets.get(0).getData(), 3);
} }
return false; return false;
@ -192,6 +205,7 @@ public class EntityMetaData {
public boolean isInvisible() { public boolean isInvisible() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return BitByte.isBitSet((byte) sets.get(0).getData(), 4); return BitByte.isBitSet((byte) sets.get(0).getData(), 4);
} }
return false; return false;
@ -240,24 +254,25 @@ public class EntityMetaData {
} }
} }
enum Type_1_7_10 implements Types { enum TypeLegacy implements Types {
BYTE(0), BYTE(0),
SHORT(1), SHORT(1),
INT(2), INT(2),
FLOAT(3), FLOAT(3),
STRING(4), STRING(4),
SLOT(5), SLOT(5),
VECTOR(6); VECTOR(6),
POSITION(7);
final int id; final int id;
Type_1_7_10(int id) { TypeLegacy(int id) {
this.id = id; this.id = id;
} }
public static Type_1_7_10 byId(int id) { public static TypeLegacy byId(int id) {
for (Type_1_7_10 s : values()) { for (TypeLegacy s : values()) {
if (s.getId() == id) { if (s.getId() == id) {
return s; return s;
} }

View File

@ -26,6 +26,7 @@ public class FireworkMetaData extends EntityMetaData {
public Slot getInfo() { public Slot getInfo() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (Slot) sets.get(8).getData(); return (Slot) sets.get(8).getData();
} }
return null; return null;

View File

@ -16,15 +16,16 @@ package de.bixilon.minosoft.game.datatypes.entities.meta;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer; import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class FurnaceMetaData extends EntityMetaData { public class FurnaceMinecartMetaData extends EntityMetaData {
public FurnaceMetaData(InByteBuffer buffer, ProtocolVersion v) { public FurnaceMinecartMetaData(InByteBuffer buffer, ProtocolVersion v) {
super(buffer, v); super(buffer, v);
} }
public boolean getPowered() { public boolean getPowered() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (int) sets.get(16).getData() == 0x01; return (int) sets.get(16).getData() == 0x01;
} }
return false; return false;

View File

@ -25,6 +25,7 @@ public class GhastMetaData extends MobMetaData {
public boolean isAttacking() { public boolean isAttacking() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (byte) sets.get(16).getData() == 0x01; return (byte) sets.get(16).getData() == 0x01;
} }
return false; return false;

View File

@ -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 <https://www.gnu.org/licenses/>.
*
* 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 GuardianMetaData extends MobMetaData {
public GuardianMetaData(InByteBuffer buffer, ProtocolVersion v) {
super(buffer, v);
}
public boolean isElderly() {
switch (version) {
case VERSION_1_8:
return BitByte.isBitSet((byte) sets.get(16).getData(), 1);
}
return false;
}
public boolean isRetractingSpikes() {
switch (version) {
case VERSION_1_8:
return BitByte.isBitSet((byte) sets.get(16).getData(), 2);
}
return false;
}
public int getTargetId() {
switch (version) {
case VERSION_1_8:
return (int) sets.get(17).getData();
}
return 0;
}
}

View File

@ -27,6 +27,7 @@ public class HorseMetaData extends AgeableMetaData {
public boolean isTame() { public boolean isTame() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return BitByte.isBitSet((int) sets.get(16).getData(), 1); return BitByte.isBitSet((int) sets.get(16).getData(), 1);
} }
return false; return false;
@ -35,6 +36,7 @@ public class HorseMetaData extends AgeableMetaData {
public boolean hasSaddle() { public boolean hasSaddle() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return BitByte.isBitSet((int) sets.get(16).getData(), 2); return BitByte.isBitSet((int) sets.get(16).getData(), 2);
} }
return false; return false;
@ -43,6 +45,7 @@ public class HorseMetaData extends AgeableMetaData {
public boolean hasChest() { public boolean hasChest() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return BitByte.isBitSet((int) sets.get(16).getData(), 3); return BitByte.isBitSet((int) sets.get(16).getData(), 3);
} }
return false; return false;
@ -51,6 +54,7 @@ public class HorseMetaData extends AgeableMetaData {
public boolean isBred() { public boolean isBred() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return BitByte.isBitSet((int) sets.get(16).getData(), 4); return BitByte.isBitSet((int) sets.get(16).getData(), 4);
} }
return false; return false;
@ -59,6 +63,7 @@ public class HorseMetaData extends AgeableMetaData {
public boolean isEating() { public boolean isEating() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return BitByte.isBitSet((int) sets.get(16).getData(), 5); return BitByte.isBitSet((int) sets.get(16).getData(), 5);
} }
return false; return false;
@ -67,6 +72,7 @@ public class HorseMetaData extends AgeableMetaData {
public boolean isRearing() { public boolean isRearing() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return BitByte.isBitSet((int) sets.get(16).getData(), 6); return BitByte.isBitSet((int) sets.get(16).getData(), 6);
} }
return false; return false;
@ -75,6 +81,7 @@ public class HorseMetaData extends AgeableMetaData {
public boolean isMouthOpen() { public boolean isMouthOpen() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return BitByte.isBitSet((int) sets.get(16).getData(), 7); return BitByte.isBitSet((int) sets.get(16).getData(), 7);
} }
return false; return false;
@ -83,6 +90,7 @@ public class HorseMetaData extends AgeableMetaData {
public HorseType getType() { public HorseType getType() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return HorseType.byId((Integer) sets.get(19).getData()); return HorseType.byId((Integer) sets.get(19).getData());
} }
return null; return null;
@ -91,6 +99,7 @@ public class HorseMetaData extends AgeableMetaData {
public HorseColor getColor() { public HorseColor getColor() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return HorseColor.byId((int) sets.get(20).getData() & 0xFF); return HorseColor.byId((int) sets.get(20).getData() & 0xFF);
} }
return null; return null;
@ -99,6 +108,7 @@ public class HorseMetaData extends AgeableMetaData {
public HorseDots getDots() { public HorseDots getDots() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return HorseDots.byId((int) sets.get(20).getData() & 0xFF00); return HorseDots.byId((int) sets.get(20).getData() & 0xFF00);
} }
return null; return null;
@ -108,6 +118,7 @@ public class HorseMetaData extends AgeableMetaData {
public String getOwnerName() { public String getOwnerName() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (String) sets.get(21).getData(); return (String) sets.get(21).getData();
} }
return null; return null;
@ -116,6 +127,7 @@ public class HorseMetaData extends AgeableMetaData {
public HorseArmor getArmor() { public HorseArmor getArmor() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return HorseArmor.byId((int) sets.get(21).getData()); return HorseArmor.byId((int) sets.get(21).getData());
} }
return null; return null;

View File

@ -27,6 +27,7 @@ public class HumanMetaData extends MobMetaData {
public boolean hideCape() { public boolean hideCape() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return BitByte.isBitSet((byte) sets.get(16).getData(), 1); return BitByte.isBitSet((byte) sets.get(16).getData(), 1);
} }
return false; return false;
@ -35,6 +36,7 @@ public class HumanMetaData extends MobMetaData {
public float getAbsorptionHearts() { public float getAbsorptionHearts() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (float) sets.get(17).getData(); return (float) sets.get(17).getData();
} }
return 0.0F; return 0.0F;
@ -43,6 +45,7 @@ public class HumanMetaData extends MobMetaData {
public int getScore() { public int getScore() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (int) sets.get(18).getData(); return (int) sets.get(18).getData();
} }
return 0; return 0;

View File

@ -25,6 +25,7 @@ public class IronGolemMetaData extends MobMetaData {
public boolean isCreatedByPlayer() { public boolean isCreatedByPlayer() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (byte) sets.get(16).getData() == 0x01; return (byte) sets.get(16).getData() == 0x01;
} }
return false; return false;

View File

@ -27,6 +27,8 @@ public class ItemFrameMetaData extends EntityMetaData {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
return (Slot) sets.get(2).getData(); return (Slot) sets.get(2).getData();
case VERSION_1_8:
return (Slot) sets.get(8).getData();
} }
return null; return null;
} }
@ -35,6 +37,8 @@ public class ItemFrameMetaData extends EntityMetaData {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
return (byte) sets.get(3).getData(); return (byte) sets.get(3).getData();
case VERSION_1_8:
return (byte) sets.get(9).getData();
} }
return 0; return 0;
} }

View File

@ -26,6 +26,7 @@ public class ItemMetaData extends EntityMetaData {
public Slot getSlot() { public Slot getSlot() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (Slot) sets.get(10).getData(); return (Slot) sets.get(10).getData();
} }
return null; return null;

View File

@ -26,6 +26,7 @@ public class MinecartMetaData extends EntityMetaData {
public int getShakingPower() { public int getShakingPower() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (int) sets.get(17).getData(); return (int) sets.get(17).getData();
} }
return 0; return 0;
@ -34,6 +35,7 @@ public class MinecartMetaData extends EntityMetaData {
public int getShakingDirection() { public int getShakingDirection() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (int) sets.get(18).getData(); return (int) sets.get(18).getData();
} }
return 0; return 0;
@ -42,6 +44,7 @@ public class MinecartMetaData extends EntityMetaData {
public float getDamageTaken() { public float getDamageTaken() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (float) sets.get(19).getData(); return (float) sets.get(19).getData();
} }
return 0; return 0;
@ -50,9 +53,26 @@ public class MinecartMetaData extends EntityMetaData {
public Blocks getBlock() { public Blocks getBlock() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
return Blocks.byLegacy((int) sets.get(20).getData() & 0xFF, (int) sets.get(20).getData() & 0xFF00); case VERSION_1_8:
return Blocks.byLegacy((int) sets.get(20).getData() & 0xFF, (int) sets.get(20).getData() >>> 4);
} }
return Blocks.AIR; return Blocks.AIR;
} }
public int getBlockYPosition() {
switch (version) {
case VERSION_1_8:
return (int) sets.get(21).getData();
}
return 0;
}
public boolean isShowingBlock() {
switch (version) {
case VERSION_1_8:
return (int) sets.get(22).getData() == 0x01;
}
return false;
}
} }

View File

@ -27,6 +27,7 @@ public class MobMetaData extends EntityMetaData {
public float getHealth() { public float getHealth() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (float) sets.get(6).getData(); return (float) sets.get(6).getData();
} }
return 0.0F; return 0.0F;
@ -35,6 +36,7 @@ public class MobMetaData extends EntityMetaData {
public StatusEffects getPotionEffectColor() { public StatusEffects getPotionEffectColor() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return StatusEffects.byId((int) sets.get(7).getData()); return StatusEffects.byId((int) sets.get(7).getData());
} }
return null; return null;
@ -44,6 +46,7 @@ public class MobMetaData extends EntityMetaData {
public byte getPotionEffectAmbient() { public byte getPotionEffectAmbient() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (byte) sets.get(8).getData(); return (byte) sets.get(8).getData();
} }
return 0; return 0;
@ -52,6 +55,7 @@ public class MobMetaData extends EntityMetaData {
public byte getNumberOfArrowsInEntity() { public byte getNumberOfArrowsInEntity() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (byte) sets.get(9).getData(); return (byte) sets.get(9).getData();
} }
return 0; return 0;
@ -61,6 +65,8 @@ public class MobMetaData extends EntityMetaData {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
return (String) sets.get(10).getData(); return (String) sets.get(10).getData();
case VERSION_1_8:
return (String) sets.get(2).getData();
} }
return null; return null;
} }
@ -69,9 +75,19 @@ public class MobMetaData extends EntityMetaData {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
return (byte) sets.get(11).getData(); return (byte) sets.get(11).getData();
case VERSION_1_8:
return (byte) sets.get(3).getData();
} }
return 0; return 0;
} }
public boolean hasAI() {
switch (version) {
case VERSION_1_8:
return (byte) sets.get(15).getData() == 0x01;
}
return false;
}
} }

View File

@ -26,6 +26,7 @@ public class OcelotMetaData extends TameableMetaData {
public byte getType() { public byte getType() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (byte) sets.get(18).getData(); return (byte) sets.get(18).getData();
} }
return 0x00; return 0x00;

View File

@ -26,6 +26,7 @@ public class PigMetaData extends AgeableMetaData {
public boolean hasSaddle() { public boolean hasSaddle() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (byte) sets.get(16).getData() == 0x01; return (byte) sets.get(16).getData() == 0x01;
} }
return false; return false;

View File

@ -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 <https://www.gnu.org/licenses/>.
*
* 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 RabbitMetaData extends TameableMetaData {
public RabbitMetaData(InByteBuffer buffer, ProtocolVersion v) {
super(buffer, v);
}
public byte getType() {
switch (version) {
case VERSION_1_8:
return (byte) sets.get(18).getData();
}
return 0;
}
}

View File

@ -28,6 +28,7 @@ public class SheepMetaData extends AgeableMetaData {
public Color getColor() { public Color getColor() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return Color.byId((byte) sets.get(16).getData() & 0xF); return Color.byId((byte) sets.get(16).getData() & 0xF);
} }
return Color.WHITE; return Color.WHITE;
@ -36,6 +37,7 @@ public class SheepMetaData extends AgeableMetaData {
public boolean isSheared() { public boolean isSheared() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return BitByte.isBitSet((byte) sets.get(16).getData(), 5); return BitByte.isBitSet((byte) sets.get(16).getData(), 5);
} }
return false; return false;

View File

@ -25,6 +25,7 @@ public class SkeletonMetaData extends MobMetaData {
public boolean isWitherSkeleton() { public boolean isWitherSkeleton() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (byte) sets.get(13).getData() == 0x01; return (byte) sets.get(13).getData() == 0x01;
} }
return false; return false;

View File

@ -25,6 +25,7 @@ public class SlimeMetaData extends MobMetaData {
public byte getSize() { public byte getSize() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (byte) sets.get(16).getData(); return (byte) sets.get(16).getData();
} }
return 0; return 0;

View File

@ -26,6 +26,7 @@ public class SpiderMetaData extends MobMetaData {
public boolean isClimbing() { public boolean isClimbing() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (byte) sets.get(16).getData() == 0x01; return (byte) sets.get(16).getData() == 0x01;
} }
return false; return false;

View File

@ -27,6 +27,7 @@ public class TameableMetaData extends AgeableMetaData {
public boolean isSitting() { public boolean isSitting() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return BitByte.isBitSet((int) sets.get(16).getData(), 0); return BitByte.isBitSet((int) sets.get(16).getData(), 0);
} }
return false; return false;
@ -35,6 +36,7 @@ public class TameableMetaData extends AgeableMetaData {
public boolean isTame() { public boolean isTame() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return BitByte.isBitSet((int) sets.get(16).getData(), 2); return BitByte.isBitSet((int) sets.get(16).getData(), 2);
} }
return false; return false;
@ -43,6 +45,7 @@ public class TameableMetaData extends AgeableMetaData {
public String getOwnerName() { public String getOwnerName() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (String) sets.get(17).getData(); return (String) sets.get(17).getData();
} }
return null; return null;

View File

@ -26,7 +26,8 @@ public class VillagerMetaData extends AgeableMetaData {
public VillagerType getVillagerType() { public VillagerType getVillagerType() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
return VillagerType.byId((int) sets.get(17).getData()); case VERSION_1_8:
return VillagerType.byId((int) sets.get(16).getData());
} }
return VillagerType.FARMER; return VillagerType.FARMER;
} }

View File

@ -25,7 +25,8 @@ public class WitchMetaData extends MobMetaData {
public boolean isAggressive() { public boolean isAggressive() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
return (byte) sets.get(13).getData() == 0x01; case VERSION_1_8:
return (byte) sets.get(21).getData() == 0x01;
} }
return false; return false;
} }

View File

@ -25,6 +25,7 @@ public class WitherMetaData extends MobMetaData {
public int getWatchedTarget1() { public int getWatchedTarget1() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (int) sets.get(17).getData(); return (int) sets.get(17).getData();
} }
return 0; return 0;
@ -33,6 +34,7 @@ public class WitherMetaData extends MobMetaData {
public int getWatchedTarget2() { public int getWatchedTarget2() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (int) sets.get(18).getData(); return (int) sets.get(18).getData();
} }
return 0; return 0;
@ -41,6 +43,7 @@ public class WitherMetaData extends MobMetaData {
public int getWatchedTarget3() { public int getWatchedTarget3() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (int) sets.get(19).getData(); return (int) sets.get(19).getData();
} }
return 0; return 0;
@ -49,6 +52,7 @@ public class WitherMetaData extends MobMetaData {
public int getInvulnerableTime() { public int getInvulnerableTime() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return (int) sets.get(20).getData(); return (int) sets.get(20).getData();
} }
return 0; return 0;

View File

@ -25,17 +25,10 @@ public class WolfMetaData extends TameableMetaData {
} }
public byte getType() {
switch (version) {
case VERSION_1_7_10:
return (byte) sets.get(18).getData();
}
return 0x00;
}
public boolean isAngry() { public boolean isAngry() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return BitByte.isBitSet((int) sets.get(16).getData(), 1); return BitByte.isBitSet((int) sets.get(16).getData(), 1);
} }
return false; return false;
@ -44,15 +37,26 @@ public class WolfMetaData extends TameableMetaData {
public float getHealth() { public float getHealth() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
return (float) sets.get(19).getData(); case VERSION_1_8:
return (float) sets.get(18).getData();
} }
return 0.00F; return 0.00F;
} }
public boolean isBegging() {
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
return ((byte) sets.get(19).getData()) == 0x01;
}
return false;
}
public Color getColor() { public Color getColor() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return Color.byId((byte) sets.get(20).getData()); return Color.byId((byte) sets.get(20).getData());
} }
return Color.WHITE; return Color.WHITE;

View File

@ -26,6 +26,7 @@ public class ZombieMetaData extends MobMetaData {
public boolean isChild() { public boolean isChild() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return ((byte) sets.get(12).getData()) == 0x01; return ((byte) sets.get(12).getData()) == 0x01;
} }
return false; return false;
@ -34,6 +35,7 @@ public class ZombieMetaData extends MobMetaData {
public boolean isVillager() { public boolean isVillager() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return ((byte) sets.get(13).getData()) == 0x01; return ((byte) sets.get(13).getData()) == 0x01;
} }
return false; return false;
@ -42,6 +44,7 @@ public class ZombieMetaData extends MobMetaData {
public boolean isConverting() { public boolean isConverting() {
switch (version) { switch (version) {
case VERSION_1_7_10: case VERSION_1_7_10:
case VERSION_1_8:
return ((byte) sets.get(14).getData()) == 0x01; return ((byte) sets.get(14).getData()) == 0x01;
} }
return false; return false;

View File

@ -0,0 +1,64 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*
* 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.GuardianMetaData;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Guardian extends Mob implements MobInterface {
GuardianMetaData metaData;
public Guardian(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity);
this.metaData = new GuardianMetaData(buffer, v);
}
@Override
public Mobs getEntityType() {
return Mobs.GUARDIAN;
}
@Override
public GuardianMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
this.metaData = (GuardianMetaData) metaData;
}
@Override
public float getWidth() {
return 0.85F;
}
@Override
public float getHeight() {
return 0.85F;
}
@Override
public int getMaxHealth() {
return 30;
}
@Override
public Class<? extends EntityMetaData> getMetaDataClass() {
return GuardianMetaData.class;
}
}

View File

@ -0,0 +1,64 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*
* 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.RabbitMetaData;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Rabbit extends Mob implements MobInterface {
RabbitMetaData metaData;
public Rabbit(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity);
this.metaData = new RabbitMetaData(buffer, v);
}
@Override
public Mobs getEntityType() {
return Mobs.RABBIT;
}
@Override
public RabbitMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
this.metaData = (RabbitMetaData) metaData;
}
@Override
public float getWidth() {
return 0.6F;
}
@Override
public float getHeight() {
return 0.7F;
}
@Override
public int getMaxHealth() {
return 3;
}
@Override
public Class<? extends EntityMetaData> getMetaDataClass() {
return RabbitMetaData.class;
}
}

View File

@ -0,0 +1,56 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*
* 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.ArmorStandMetaData;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
public class ArmorStand extends EntityObject implements ObjectInterface {
ArmorStandMetaData metaData;
public ArmorStand(int id, Location location, short yaw, short pitch, int additionalInt) {
super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int
}
public ArmorStand(int id, Location location, short yaw, short pitch, int additionalInt, Velocity velocity) {
super(id, location, yaw, pitch, velocity);
}
@Override
public Objects getEntityType() {
return Objects.ARMOR_STAND;
}
@Override
public ArmorStandMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
this.metaData = (ArmorStandMetaData) metaData;
}
@Override
public float getWidth() {
return 0.5F;
}
@Override
public float getHeight() {
return 2.0F;
}
}