diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/Mobs.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/Mobs.java
index a6aad6fe6..383c4f36b 100644
--- a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/Mobs.java
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/Mobs.java
@@ -16,7 +16,7 @@ package de.bixilon.minosoft.game.datatypes.entities;
import de.bixilon.minosoft.game.datatypes.entities.mob.*;
public enum Mobs {
- PLAYER(92, OtherPlayer.class),
+ PLAYER(105, OtherPlayer.class),
CREEPER(50, Creeper.class),
SKELETON(51, Skeleton.class),
SPIDER(52, Spider.class),
@@ -35,6 +35,7 @@ public enum Mobs {
BAT(65, Bat.class),
WITCH(66, Witch.class),
GUARDIAN(68, Guardian.class),
+ SHULKER(69, Shulker.class),
PIG(90, Pig.class),
SHEEP(91, Sheep.class),
COW(92, Cow.class),
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/Objects.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/Objects.java
index be65b17d2..0db7ee104 100644
--- a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/Objects.java
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/Objects.java
@@ -28,6 +28,7 @@ public enum Objects implements EntityEnumInterface {
FIRE_CHARGE(64, FireCharge.class),
ENDER_PEARL(65, Enderpearl.class),
WITHER_SKULL(66, WitherSkull.class),
+ SHULKER_BULLET(67, ShulkerBullet.class),
FALLING_BLOCK(70, FallingBlock.class),
ITEM_FRAME(71, ItemFrame.class),
EYE_OF_ENDER(72, EyeOfEnder.class),
@@ -37,7 +38,11 @@ public enum Objects implements EntityEnumInterface {
FIREWORK(76, Firework.class),
LEASH_KNOT(77, LeashKnot.class),
ARMOR_STAND(78, ArmorStand.class),
- FISHING_FLOAT(90, FishingFloat.class);
+ FISHING_FLOAT(90, FishingFloat.class),
+ SPECTRAL_ARROW(91, SpectralArrow.class),
+ DRAGON_FIREBALL(93, DragonFireball.class);
+
+ //ToDO: size changed between versions, fix it!
final int type;
final Class extends EntityObject> clazz;
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/AgeableMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/AgeableMetaData.java
index a55af846a..88347443e 100644
--- a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/AgeableMetaData.java
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/AgeableMetaData.java
@@ -15,7 +15,7 @@ package de.bixilon.minosoft.game.datatypes.entities.meta;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
-public class AgeableMetaData extends MobMetaData {
+public class AgeableMetaData extends InsentientMetaData {
public AgeableMetaData(InByteBuffer buffer) {
super(buffer);
@@ -32,7 +32,14 @@ public class AgeableMetaData extends MobMetaData {
}
public boolean isAdult() {
- return getAge() >= 0;
+ switch (version) {
+ case VERSION_1_7_10:
+ case VERSION_1_8:
+ return getAge() >= 0;
+ case VERSION_1_9_4:
+ return (boolean) sets.get(11).getData();
+ }
+ return false;
}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/AreaEffectCloudMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/AreaEffectCloudMetaData.java
new file mode 100644
index 000000000..fb11116e1
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/AreaEffectCloudMetaData.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.meta;
+
+import de.bixilon.minosoft.game.datatypes.Color;
+import de.bixilon.minosoft.game.datatypes.particle.Particles;
+import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
+
+public class AreaEffectCloudMetaData extends MobMetaData {
+
+ public AreaEffectCloudMetaData(InByteBuffer buffer) {
+ super(buffer);
+ }
+
+
+ public float getRadius() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return (float) sets.get(5).getData();
+ }
+ return 0;
+ }
+
+ public Color getColor() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return Color.byId((int) sets.get(6).getData());
+ }
+ return Color.WHITE;
+ }
+
+ public boolean ignoreRadius() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return (boolean) sets.get(7).getData();
+ }
+ return false;
+ }
+
+ public Particles getParticle() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return Particles.byType((int) sets.get(8).getData());
+ }
+ return null;
+ }
+
+
+}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/ArmorStandMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/ArmorStandMetaData.java
index 43a1e75c9..7e513c42a 100644
--- a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/ArmorStandMetaData.java
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/ArmorStandMetaData.java
@@ -27,7 +27,7 @@ public class ArmorStandMetaData extends MobMetaData {
public boolean isSmall() {
switch (version) {
case VERSION_1_8:
- return BitByte.isBitSet((byte) sets.get(10).getData(), 0);
+ return BitByte.isBitMask((byte) sets.get(10).getData(), 0x01);
}
return false;
}
@@ -35,7 +35,7 @@ public class ArmorStandMetaData extends MobMetaData {
public boolean hasGravity() {
switch (version) {
case VERSION_1_8:
- return BitByte.isBitSet((byte) sets.get(10).getData(), 1);
+ return BitByte.isBitMask((byte) sets.get(10).getData(), 0x02);
}
return false;
}
@@ -43,7 +43,7 @@ public class ArmorStandMetaData extends MobMetaData {
public boolean hasArms() {
switch (version) {
case VERSION_1_8:
- return BitByte.isBitSet((byte) sets.get(10).getData(), 2);
+ return BitByte.isBitMask((byte) sets.get(10).getData(), 0x04);
}
return false;
}
@@ -51,7 +51,7 @@ public class ArmorStandMetaData extends MobMetaData {
public boolean removeBasePlate() {
switch (version) {
case VERSION_1_8:
- return BitByte.isBitSet((byte) sets.get(10).getData(), 3);
+ return BitByte.isBitMask((byte) sets.get(10).getData(), 0x08);
}
return false;
}
@@ -59,54 +59,60 @@ public class ArmorStandMetaData extends MobMetaData {
public boolean hasMarker() {
switch (version) {
case VERSION_1_8:
- return BitByte.isBitSet((byte) sets.get(10).getData(), 4);
+ return BitByte.isBitMask((byte) sets.get(10).getData(), 0x10);
}
return false;
}
- public EntityRotation getHeadPosition() {
+ public EntityRotation getHeadRotation() {
switch (version) {
case VERSION_1_8:
+ case VERSION_1_9_4:
return (EntityRotation) sets.get(11).getData();
}
return null;
}
- public EntityRotation getBodyPosition() {
+ public EntityRotation getBodyRotation() {
switch (version) {
case VERSION_1_8:
+ case VERSION_1_9_4:
return (EntityRotation) sets.get(12).getData();
}
return null;
}
- public EntityRotation getLeftArmPosition() {
+ public EntityRotation getLeftArmRotation() {
switch (version) {
case VERSION_1_8:
+ case VERSION_1_9_4:
return (EntityRotation) sets.get(13).getData();
}
return null;
}
- public EntityRotation getRightArmPosition() {
+ public EntityRotation getRightArmRotation() {
switch (version) {
case VERSION_1_8:
+ case VERSION_1_9_4:
return (EntityRotation) sets.get(14).getData();
}
return null;
}
- public EntityRotation getLeftLegPosition() {
+ public EntityRotation getLeftLegRotation() {
switch (version) {
case VERSION_1_8:
+ case VERSION_1_9_4:
return (EntityRotation) sets.get(15).getData();
}
return null;
}
- public EntityRotation getRightLegPosition() {
+ public EntityRotation getRightLegRotation() {
switch (version) {
case VERSION_1_8:
+ case VERSION_1_9_4:
return (EntityRotation) sets.get(16).getData();
}
return null;
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
index 1ef2fd7dd..04501d10a 100644
--- 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
@@ -14,6 +14,7 @@
package de.bixilon.minosoft.game.datatypes.entities.meta;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
+import de.bixilon.minosoft.util.BitByte;
public class ArrowMetaData extends EntityMetaData {
@@ -26,6 +27,8 @@ public class ArrowMetaData extends EntityMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return (byte) sets.get(16).getData() == 0x01;
+ case VERSION_1_9_4:
+ return BitByte.isBitMask((byte) sets.get(5).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
index 399029e61..aea33ca26 100644
--- 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
@@ -14,8 +14,9 @@
package de.bixilon.minosoft.game.datatypes.entities.meta;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
+import de.bixilon.minosoft.util.BitByte;
-public class BatMetaData extends MobMetaData {
+public class BatMetaData extends InsentientMetaData {
public BatMetaData(InByteBuffer buffer) {
super(buffer);
@@ -27,6 +28,8 @@ public class BatMetaData extends MobMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return (byte) sets.get(16).getData() == 0x01;
+ case VERSION_1_9_4:
+ return BitByte.isBitMask((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
index a0157d2fa..bc336aee1 100644
--- 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
@@ -14,6 +14,7 @@
package de.bixilon.minosoft.game.datatypes.entities.meta;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
+import de.bixilon.minosoft.util.BitByte;
public class BlazeMetaData extends MobMetaData {
@@ -27,6 +28,8 @@ public class BlazeMetaData extends MobMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return (byte) sets.get(16).getData() == 0x01;
+ case VERSION_1_9_4:
+ return BitByte.isBitMask((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
index df4b58948..837bbe6ff 100644
--- 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
@@ -26,6 +26,8 @@ public class BoatMetaData extends EntityMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return (int) sets.get(17).getData();
+ case VERSION_1_9_4:
+ return (int) sets.get(5).getData();
}
return 0;
}
@@ -35,6 +37,8 @@ public class BoatMetaData extends EntityMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return (int) sets.get(18).getData();
+ case VERSION_1_9_4:
+ return (int) sets.get(6).getData();
}
return 0;
}
@@ -44,8 +48,34 @@ public class BoatMetaData extends EntityMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return (float) sets.get(19).getData();
+ case VERSION_1_9_4:
+ return (float) sets.get(7).getData();
}
return 0;
}
+ public int getType() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return (int) sets.get(8).getData();
+ }
+ return 0;
+ }
+
+ public boolean isRightPaddleTurning() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return (boolean) sets.get(9).getData();
+ }
+ return false;
+ }
+
+ public boolean isLeftPaddleTurning() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return (boolean) sets.get(10).getData();
+ }
+ return false;
+ }
+
}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/CommandBlockMinecartMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/CommandBlockMinecartMetaData.java
new file mode 100644
index 000000000..05ad1dfcf
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/CommandBlockMinecartMetaData.java
@@ -0,0 +1,41 @@
+/*
+ * 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.TextComponent;
+import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
+
+public class CommandBlockMinecartMetaData extends EntityMetaData {
+
+ public CommandBlockMinecartMetaData(InByteBuffer buffer) {
+ super(buffer);
+ }
+
+ public String getCommand() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return (String) sets.get(11).getData();
+ }
+ return "";
+ }
+
+ public TextComponent getLastOutput() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return (TextComponent) sets.get(12).getData();
+ }
+ return null;
+ }
+
+}
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
index f15d9933d..957f0c915 100644
--- 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
@@ -22,21 +22,33 @@ public class CreeperMetaData extends MobMetaData {
}
- public byte getState() {
+ public int getState() {
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
return (byte) sets.get(16).getData();
+ case VERSION_1_9_4:
+ return (int) sets.get(11).getData();
}
return -1;
}
- public boolean isPowered() {
+ public boolean isCharged() {
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
return (byte) sets.get(17).getData() == 0x01;
+ case VERSION_1_9_4:
+ return (boolean) sets.get(12).getData();
+ }
+ return false;
+ }
+
+ public boolean isIgnited() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return (boolean) sets.get(13).getData();
}
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
index d029861e1..f0ef46341 100644
--- 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
@@ -13,6 +13,7 @@
package de.bixilon.minosoft.game.datatypes.entities.meta;
+import de.bixilon.minosoft.game.datatypes.world.BlockPosition;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
public class EnderCrystalMetaData extends EntityMetaData {
@@ -29,4 +30,20 @@ public class EnderCrystalMetaData extends EntityMetaData {
}
return 0;
}
+
+ public BlockPosition getBeamTarget() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return (BlockPosition) sets.get(5).getData();
+ }
+ return null;
+ }
+
+ public boolean showBottom() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return (boolean) sets.get(6).getData();
+ }
+ return true;
+ }
}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/EnderDragonMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/EnderDragonMetaData.java
new file mode 100644
index 000000000..57e361faa
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/EnderDragonMetaData.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;
+
+public class EnderDragonMetaData extends InsentientMetaData {
+
+ public EnderDragonMetaData(InByteBuffer buffer) {
+ super(buffer);
+ }
+
+
+ public int getDragonPhase() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return ((int) sets.get(11).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
index 304164956..7ade45f4e 100644
--- 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
@@ -28,6 +28,8 @@ public class EndermanMetaData extends MobMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return Blocks.byId((short) sets.get(16).getData(), (byte) sets.get(17).getData());
+ case VERSION_1_9_4:
+ return (Blocks) sets.get(11).getData();
}
return Blocks.AIR;
}
@@ -37,6 +39,8 @@ public class EndermanMetaData extends MobMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return (byte) sets.get(18).getData() == 0x01;
+ case VERSION_1_9_4:
+ return (boolean) sets.get(12).getData();
}
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 f7f804cb2..0a7d7fe56 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
@@ -14,141 +14,50 @@
package de.bixilon.minosoft.game.datatypes.entities.meta;
import de.bixilon.minosoft.game.datatypes.EntityRotation;
+import de.bixilon.minosoft.game.datatypes.MapSet;
import de.bixilon.minosoft.game.datatypes.Vector;
+import de.bixilon.minosoft.game.datatypes.VersionValueMap;
+import de.bixilon.minosoft.game.datatypes.blocks.Blocks;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import de.bixilon.minosoft.util.BitByte;
import java.util.HashMap;
+
public class EntityMetaData {
+
final HashMap sets = new HashMap<>();
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
+ 1.9.4; https://wiki.vg/index.php?title=Entity_metadata&oldid=7955
*/
public EntityMetaData(InByteBuffer buffer) {
version = buffer.getVersion();
switch (version) {
case VERSION_1_7_10:
- case VERSION_1_8:
+ case VERSION_1_8: {
byte item = buffer.readByte();
+
while (item != 0x7F) {
byte index = (byte) (item & 0x1F);
- Object data;
- TypeLegacy type = TypeLegacy.byId((item & 0xFF) >>> 5);
- switch (type) {
- case BYTE:
- data = buffer.readByte();
- break;
- case SHORT:
- data = buffer.readShort();
- break;
- case INT:
- data = buffer.readInteger();
- break;
- case FLOAT:
- data = buffer.readFloat();
- break;
- case STRING:
- data = buffer.readString();
- break;
- case VECTOR:
- data = new Vector(buffer.readInteger(), buffer.readInteger(), buffer.readInteger());
- break;
- case SLOT:
- data = buffer.readSlot();
- break;
- case POSITION:
- data = new EntityRotation(buffer.readFloat(), buffer.readFloat(), buffer.readFloat());
- break;
- default:
- throw new IllegalStateException("Unexpected value: " + type);
- }
- sets.put((int) index, new MetaDataSet(index, data));
-
-
+ Types type = Types.byId((item & 0xFF) >> 5, buffer.getVersion());
+ sets.put((int) index, new MetaDataSet(index, getData(type, buffer)));
item = buffer.readByte();
}
break;
- /*
- case VERSION_1_15_2:
- byte index = buffer.readByte();
- while (index != -1) { // 0xFF
- // still data here
- int id = buffer.readVarInt();
- Type type = Type.byId(id);
- Object data;
- switch (type) {
- case BYTE:
- data = buffer.readByte();
- break;
- case VAR_INT:
- case OPT_BLOCK_ID:
- case OPT_VAR_INT:
- data = buffer.readVarInt();
- break;
- case FLOAT:
- data = buffer.readFloat();
- break;
- case STRING:
- data = buffer.readString();
- break;
- case CHAT:
- data = buffer.readChatComponent();
- break;
- case OPT_CHAT:
- if (buffer.readBoolean()) {
- data = buffer.readChatComponent();
- }
- break;
- case SLOT:
- data = buffer.readSlot();
- break;
- case BOOLEAN:
- data = buffer.readBoolean();
- break;
- case ROTATION:
- //ToDo
- buffer.readFloat();
- buffer.readFloat();
- buffer.readFloat();
- break;
- case POSITION:
- data = buffer.readPosition();
- break;
- case OPT_POSITION:
- if (buffer.readBoolean()) {
- data = buffer.readPosition();
- }
- break;
- case DIRECTION:
- data = buffer.readDirection();
- break;
- case OPT_UUID:
- if (buffer.readBoolean()) {
- data = buffer.readUUID();
- }
- break;
- case NBT:
- data = buffer.readNBT();
- break;
- case PARTICLE:
- data = buffer.readParticle();
- break;
- case POSE:
- data = buffer.readPose();
- break;
-
}
-
-
- index = buffer.readByte();
- }
- */
+ case VERSION_1_9_4:
+ byte index = buffer.readByte();
+ while (index != (byte) 0xFF) {
+ Types type = Types.byId(buffer.readByte(), buffer.getVersion());
+ sets.put((int) index, new MetaDataSet(index, getData(type, buffer)));
+ index = buffer.readByte();
+ }
}
@@ -162,7 +71,7 @@ public class EntityMetaData {
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
- return BitByte.isBitSet((byte) sets.get(0).getData(), 0);
+ return BitByte.isBitMask((byte) sets.get(0).getData(), 0x01);
}
return false;
}
@@ -171,7 +80,7 @@ public class EntityMetaData {
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
- return BitByte.isBitSet((byte) sets.get(0).getData(), 1);
+ return BitByte.isBitMask((byte) sets.get(0).getData(), 0x02);
}
return false;
}
@@ -180,7 +89,7 @@ public class EntityMetaData {
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
- return BitByte.isBitSet((byte) sets.get(0).getData(), 2);
+ return BitByte.isBitMask((byte) sets.get(0).getData(), 0x08);
}
return false;
}
@@ -189,7 +98,7 @@ public class EntityMetaData {
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
- return BitByte.isBitSet((byte) sets.get(0).getData(), 3);
+ return BitByte.isBitMask((byte) sets.get(0).getData(), 0x10);
}
return false;
}
@@ -206,89 +115,182 @@ public class EntityMetaData {
switch (version) {
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(), 0x20);
}
return false;
}
- enum Type implements Types {
+ public boolean isGlowing() {
+ switch (version) {
+ case VERSION_1_7_10:
+ case VERSION_1_8:
+ return BitByte.isBitSet((byte) sets.get(0).getData(), 0x40);
+ }
+ return false;
+ }
+
+ public boolean isFlyingWithElytra() {
+ switch (version) {
+ case VERSION_1_7_10:
+ case VERSION_1_8:
+ return BitByte.isBitSet((byte) sets.get(0).getData(), 0x80);
+ }
+ return false;
+ }
+
+ public String getNameTag() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return (String) sets.get(2).getData();
+ }
+ return null;
+ }
+
+ public boolean isCustomNameVisible() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return (boolean) sets.get(3).getData();
+ }
+ return false;
+ }
+
+ public boolean isSilent() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return (boolean) sets.get(4).getData();
+ }
+ return false;
+ }
+
+
+ public Object getData(Types type, InByteBuffer buffer) {
+ Object data = null;
+
+ switch (type) {
+ case BYTE:
+ data = buffer.readByte();
+ break;
+ case VAR_INT:
+ data = buffer.readVarInt();
+ break;
+ case SHORT:
+ data = buffer.readShort();
+ break;
+ case INT:
+ data = buffer.readInteger();
+ break;
+ case FLOAT:
+ data = buffer.readFloat();
+ break;
+ case STRING:
+ data = buffer.readString();
+ break;
+ case CHAT:
+ data = buffer.readTextComponent();
+ break;
+ case BOOLEAN:
+ data = buffer.readBoolean();
+ break;
+ case VECTOR:
+ data = new Vector(buffer.readInteger(), buffer.readInteger(), buffer.readInteger());
+ break;
+ case SLOT:
+ data = buffer.readSlot();
+ break;
+ case ROTATION:
+ data = new EntityRotation(buffer.readFloat(), buffer.readFloat(), buffer.readFloat());
+ break;
+ case POSITION:
+ data = buffer.readPosition();
+ break;
+ case OPT_CHAT:
+ if (buffer.readBoolean()) {
+ data = buffer.readTextComponent();
+ }
+ break;
+ case OPT_POSITION:
+ if (buffer.readBoolean()) {
+ data = buffer.readPosition();
+ }
+ break;
+ case DIRECTION:
+ data = buffer.readDirection();
+ break;
+ case OPT_UUID:
+ if (buffer.readBoolean()) {
+ data = buffer.readUUID();
+ }
+ break;
+ case NBT:
+ data = buffer.readNBT();
+ break;
+ case PARTICLE:
+ data = buffer.readParticle();
+ break;
+ case POSE:
+ data = buffer.readPose();
+ break;
+ case BLOCK_ID:
+ int blockId = buffer.readVarInt();
+ data = Blocks.byId(blockId >> 4, blockId & 0xF);
+ break;
+ default:
+ throw new IllegalStateException("Unexpected value: " + type);
+ }
+ return data;
+ }
+
+ enum Types {
BYTE(0),
- VAR_INT(1),
- FLOAT(2),
- STRING(3),
- CHAT(4),
- OPT_CHAT(5),
- SLOT(6),
- BOOLEAN(7),
- ROTATION(8),
- POSITION(9),
- OPT_POSITION(10),
- DIRECTION(11),
- OPT_UUID(12),
- OPT_BLOCK_ID(13),
- NBT(13),
- PARTICLE(14),
- VILLAGER_DATA(15),
- OPT_VAR_INT(17),
- POSE(18);
+ SHORT(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 1), new MapSet<>(ProtocolVersion.VERSION_1_9_4, 1000)}), // got removed in 1.9
+ INT(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 2), new MapSet<>(ProtocolVersion.VERSION_1_9_4, 1001)}),
+ VAR_INT(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_9_4, 1)}),
+ FLOAT(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 3), new MapSet<>(ProtocolVersion.VERSION_1_9_4, 2)}),
+ STRING(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 4), new MapSet<>(ProtocolVersion.VERSION_1_9_4, 3)}),
+ CHAT(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_9_4, 4)}),
+ OPT_CHAT(-1),
+ SLOT(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 5)}),
+ BOOLEAN(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_9_4, 6)}),
+ VECTOR(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 6), new MapSet<>(ProtocolVersion.VERSION_1_9_4, 1002)}),
+ ROTATION(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 7)}),
+ POSITION(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_9_4, 8)}),
+ OPT_POSITION(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_9_4, 9)}),
+ DIRECTION(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_9_4, 10)}),
+ OPT_UUID(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_9_4, 11)}),
+ BLOCK_ID(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_9_4, 14)}),
+ OPT_BLOCK_ID(-1),
+ NBT(-1),
+ PARTICLE(-1),
+ VILLAGER_DATA(-1),
+ OPT_VAR_INT(-1),
+ POSE(-1);
+ //ToDo: add all types by version
- final int id;
+ final VersionValueMap valueMap;
- Type(int id) {
- this.id = id;
+ Types(MapSet[] values) {
+ valueMap = new VersionValueMap<>(values, true);
}
- public static Type byId(int id) {
- for (Type s : values()) {
- if (s.getId() == id) {
- return s;
+ Types(int id) {
+ valueMap = new VersionValueMap<>(id);
+ }
+
+ public static Types byId(int id, ProtocolVersion version) {
+ for (Types types : values()) {
+ if (types.getId(version) == id) {
+ return types;
}
}
return null;
}
-
- public int getId() {
- return id;
+ public int getId(ProtocolVersion version) {
+ return valueMap.get(version);
}
}
- enum TypeLegacy implements Types {
- BYTE(0),
- SHORT(1),
- INT(2),
- FLOAT(3),
- STRING(4),
- SLOT(5),
- VECTOR(6),
- POSITION(7);
-
-
- final int id;
-
- TypeLegacy(int id) {
- this.id = id;
- }
-
- public static TypeLegacy byId(int id) {
- for (TypeLegacy s : values()) {
- if (s.getId() == id) {
- return s;
- }
- }
- return null;
- }
-
- public int getId() {
- return id;
- }
- }
-
- interface Types {
- int getId();
- }
-
public static class MetaDataSet {
final int index;
final Object data;
@@ -306,6 +308,4 @@ public class EntityMetaData {
return index;
}
}
-
-
}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/FallingBlockMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/FallingBlockMetaData.java
new file mode 100644
index 000000000..1439724cf
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/FallingBlockMetaData.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.game.datatypes.world.BlockPosition;
+import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
+
+public class FallingBlockMetaData extends EntityMetaData {
+
+ public FallingBlockMetaData(InByteBuffer buffer) {
+ super(buffer);
+ }
+
+ public BlockPosition getSpawnPosition() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return (BlockPosition) sets.get(5).getData();
+ }
+ return null;
+ }
+
+}
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
index 943cda3c0..192297bab 100644
--- 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
@@ -27,6 +27,8 @@ public class FireworkMetaData extends EntityMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return (Slot) sets.get(8).getData();
+ case VERSION_1_9_4:
+ return (Slot) sets.get(5).getData();
}
return null;
}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/FishingHookMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/FishingHookMetaData.java
new file mode 100644
index 000000000..083468917
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/FishingHookMetaData.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;
+
+public class FishingHookMetaData extends MobMetaData {
+
+ public FishingHookMetaData(InByteBuffer buffer) {
+ super(buffer);
+ }
+
+
+ public int getHookedEntityId() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return (int) sets.get(5).getData();
+ }
+ return -1;
+ }
+
+
+}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/FurnaceMinecartMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/FurnaceMinecartMetaData.java
index b9e16b172..75f0dd6da 100644
--- a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/FurnaceMinecartMetaData.java
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/FurnaceMinecartMetaData.java
@@ -21,11 +21,13 @@ public class FurnaceMinecartMetaData extends EntityMetaData {
super(buffer);
}
- public boolean getPowered() {
+ public boolean isPowered() {
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
- return (int) sets.get(16).getData() == 0x01;
+ return (byte) sets.get(16).getData() == 0x01;
+ case VERSION_1_9_4:
+ return (boolean) sets.get(11).getData();
}
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
index 749830f35..ca276ff99 100644
--- 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
@@ -15,7 +15,7 @@ package de.bixilon.minosoft.game.datatypes.entities.meta;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
-public class GhastMetaData extends MobMetaData {
+public class GhastMetaData extends InsentientMetaData {
public GhastMetaData(InByteBuffer buffer) {
super(buffer);
@@ -26,6 +26,8 @@ public class GhastMetaData extends MobMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return (byte) sets.get(16).getData() == 0x01;
+ case VERSION_1_9_4:
+ return (boolean) sets.get(11).getData();
}
return false;
}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/GuardianMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/GuardianMetaData.java
index 4c3c30eab..47b78009d 100644
--- a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/GuardianMetaData.java
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/GuardianMetaData.java
@@ -25,7 +25,9 @@ public class GuardianMetaData extends MobMetaData {
public boolean isElderly() {
switch (version) {
case VERSION_1_8:
- return BitByte.isBitSet((byte) sets.get(16).getData(), 1);
+ return BitByte.isBitMask((byte) sets.get(16).getData(), 0x02);
+ case VERSION_1_9_4:
+ return BitByte.isBitMask((byte) sets.get(11).getData(), 0x04);
}
return false;
}
@@ -33,16 +35,20 @@ public class GuardianMetaData extends MobMetaData {
public boolean isRetractingSpikes() {
switch (version) {
case VERSION_1_8:
- return BitByte.isBitSet((byte) sets.get(16).getData(), 2);
+ return BitByte.isBitSet((byte) sets.get(16).getData(), 0x04);
+ case VERSION_1_9_4:
+ return BitByte.isBitSet((byte) sets.get(11).getData(), 0x02);
}
return false;
}
- public int getTargetId() {
+ public int getTargetEntityId() {
switch (version) {
case VERSION_1_8:
return (int) sets.get(17).getData();
+ case VERSION_1_9_4:
+ return (int) sets.get(12).getData();
}
return 0;
}
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
index d562f269d..609235c36 100644
--- 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
@@ -16,6 +16,8 @@ package de.bixilon.minosoft.game.datatypes.entities.meta;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
import de.bixilon.minosoft.util.BitByte;
+import java.util.UUID;
+
public class HorseMetaData extends AgeableMetaData {
public HorseMetaData(InByteBuffer buffer) {
@@ -27,7 +29,9 @@ public class HorseMetaData extends AgeableMetaData {
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
- return BitByte.isBitSet((int) sets.get(16).getData(), 1);
+ return BitByte.isBitMask((int) sets.get(16).getData(), 0x01);
+ case VERSION_1_9_4:
+ return BitByte.isBitMask((int) sets.get(12).getData(), 0x01);
}
return false;
}
@@ -36,7 +40,9 @@ public class HorseMetaData extends AgeableMetaData {
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
- return BitByte.isBitSet((int) sets.get(16).getData(), 2);
+ return BitByte.isBitMask((int) sets.get(16).getData(), 0x02);
+ case VERSION_1_9_4:
+ return BitByte.isBitMask((int) sets.get(12).getData(), 0x02);
}
return false;
}
@@ -45,7 +51,9 @@ public class HorseMetaData extends AgeableMetaData {
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
- return BitByte.isBitSet((int) sets.get(16).getData(), 3);
+ return BitByte.isBitMask((int) sets.get(16).getData(), 0x04);
+ case VERSION_1_9_4:
+ return BitByte.isBitMask((int) sets.get(12).getData(), 0x04);
}
return false;
}
@@ -54,7 +62,9 @@ public class HorseMetaData extends AgeableMetaData {
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
- return BitByte.isBitSet((int) sets.get(16).getData(), 4);
+ return BitByte.isBitMask((int) sets.get(16).getData(), 0x08);
+ case VERSION_1_9_4:
+ return BitByte.isBitMask((int) sets.get(12).getData(), 0x08);
}
return false;
}
@@ -63,7 +73,9 @@ public class HorseMetaData extends AgeableMetaData {
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
- return BitByte.isBitSet((int) sets.get(16).getData(), 5);
+ return BitByte.isBitMask((int) sets.get(16).getData(), 0x10);
+ case VERSION_1_9_4:
+ return BitByte.isBitMask((int) sets.get(12).getData(), 0x10);
}
return false;
}
@@ -72,7 +84,9 @@ public class HorseMetaData extends AgeableMetaData {
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
- return BitByte.isBitSet((int) sets.get(16).getData(), 6);
+ return BitByte.isBitMask((int) sets.get(16).getData(), 0x40);
+ case VERSION_1_9_4:
+ return BitByte.isBitMask((int) sets.get(12).getData(), 0x40);
}
return false;
}
@@ -81,7 +95,9 @@ public class HorseMetaData extends AgeableMetaData {
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
- return BitByte.isBitSet((int) sets.get(16).getData(), 7);
+ return BitByte.isBitMask((int) sets.get(16).getData(), 0x80);
+ case VERSION_1_9_4:
+ return BitByte.isBitMask((int) sets.get(12).getData(), 0x80);
}
return false;
}
@@ -90,7 +106,9 @@ public class HorseMetaData extends AgeableMetaData {
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
- return HorseType.byId((Integer) sets.get(19).getData());
+ return HorseType.byId((int) sets.get(19).getData());
+ case VERSION_1_9_4:
+ return HorseType.byId((int) sets.get(13).getData());
}
return null;
}
@@ -100,6 +118,8 @@ public class HorseMetaData extends AgeableMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return HorseColor.byId((int) sets.get(20).getData() & 0xFF);
+ case VERSION_1_9_4:
+ return HorseColor.byId((int) sets.get(14).getData() & 0xFF);
}
return null;
}
@@ -109,6 +129,8 @@ public class HorseMetaData extends AgeableMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return HorseDots.byId((int) sets.get(20).getData() & 0xFF00);
+ case VERSION_1_9_4:
+ return HorseDots.byId((int) sets.get(14).getData() & 0xFF00);
}
return null;
}
@@ -123,11 +145,21 @@ public class HorseMetaData extends AgeableMetaData {
return null;
}
+ public UUID getOwnerUUID() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return (UUID) sets.get(15).getData();
+ }
+ return null;
+ }
+
public HorseArmor getArmor() {
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
return HorseArmor.byId((int) sets.get(21).getData());
+ case VERSION_1_9_4:
+ return HorseArmor.byId((int) sets.get(16).getData());
}
return null;
}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/HumanMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/HumanMetaData.java
index e1d0ee678..773383ad3 100644
--- a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/HumanMetaData.java
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/HumanMetaData.java
@@ -13,8 +13,8 @@
package de.bixilon.minosoft.game.datatypes.entities.meta;
+import de.bixilon.minosoft.game.datatypes.player.Hand;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
-import de.bixilon.minosoft.util.BitByte;
public class HumanMetaData extends MobMetaData {
@@ -23,20 +23,13 @@ public class HumanMetaData extends MobMetaData {
}
- public boolean hideCape() {
- switch (version) {
- case VERSION_1_7_10:
- case VERSION_1_8:
- return BitByte.isBitSet((byte) sets.get(16).getData(), 1);
- }
- return false;
- }
-
public float getAbsorptionHearts() {
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
return (float) sets.get(17).getData();
+ case VERSION_1_9_4:
+ return (float) sets.get(10).getData();
}
return 0.0F;
}
@@ -46,9 +39,20 @@ public class HumanMetaData extends MobMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return (int) sets.get(18).getData();
+ case VERSION_1_9_4:
+ return (int) sets.get(11).getData();
}
return 0;
}
+ public Hand getMainHand() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return Hand.byId((byte) sets.get(13).getData());
+ }
+ return Hand.RIGHT;
+ }
+
+
}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/InsentientMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/InsentientMetaData.java
new file mode 100644
index 000000000..a305f515e
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/InsentientMetaData.java
@@ -0,0 +1,47 @@
+/*
+ * 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.util.BitByte;
+
+public class InsentientMetaData extends MobMetaData {
+
+ public InsentientMetaData(InByteBuffer buffer) {
+ super(buffer);
+ }
+
+
+ @Override
+ public boolean hasAI() {
+ switch (version) {
+ case VERSION_1_8:
+ return (byte) sets.get(15).getData() == 0x01;
+ case VERSION_1_9_4:
+ return BitByte.isBitMask((byte) sets.get(10).getData(), 0x01);
+ default:
+ return super.hasAI();
+ }
+ }
+
+ public boolean isLeftHanded() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return BitByte.isBitMask((byte) sets.get(10).getData(), 0x02);
+ }
+ return false;
+ }
+
+
+}
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
index 59d77e49d..74f9edcd7 100644
--- 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
@@ -14,6 +14,7 @@
package de.bixilon.minosoft.game.datatypes.entities.meta;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
+import de.bixilon.minosoft.util.BitByte;
public class IronGolemMetaData extends MobMetaData {
@@ -26,6 +27,8 @@ public class IronGolemMetaData extends MobMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return (byte) sets.get(16).getData() == 0x01;
+ case VERSION_1_9_4:
+ return BitByte.isBitMask((byte) sets.get(11).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
index 0fbcb170e..718abbd01 100644
--- 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
@@ -28,6 +28,8 @@ public class ItemFrameMetaData extends EntityMetaData {
return (Slot) sets.get(2).getData();
case VERSION_1_8:
return (Slot) sets.get(8).getData();
+ case VERSION_1_9_4:
+ return (Slot) sets.get(5).getData();
}
return null;
}
@@ -38,6 +40,8 @@ public class ItemFrameMetaData extends EntityMetaData {
return (byte) sets.get(3).getData();
case VERSION_1_8:
return (byte) sets.get(9).getData();
+ case VERSION_1_9_4:
+ return (byte) sets.get(6).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
index 9233b9717..d0a4f1a06 100644
--- 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
@@ -27,6 +27,8 @@ public class ItemMetaData extends EntityMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return (Slot) sets.get(10).getData();
+ case VERSION_1_9_4:
+ return (Slot) sets.get(5).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
index 5b364efb5..9809f87e6 100644
--- 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
@@ -27,6 +27,8 @@ public class MinecartMetaData extends EntityMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return (int) sets.get(17).getData();
+ case VERSION_1_9_4:
+ return (int) sets.get(5).getData();
}
return 0;
}
@@ -36,15 +38,19 @@ public class MinecartMetaData extends EntityMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return (int) sets.get(18).getData();
+ case VERSION_1_9_4:
+ return (int) sets.get(6).getData();
}
return 0;
}
- public float getDamageTaken() {
+ public float getMultiplier() {
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
return (float) sets.get(19).getData();
+ case VERSION_1_9_4:
+ return (float) sets.get(7).getData();
}
return 0;
}
@@ -54,6 +60,8 @@ public class MinecartMetaData extends EntityMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return Blocks.byId((int) sets.get(20).getData() & 0xFF, (int) sets.get(20).getData() >>> 4);
+ case VERSION_1_9_4:
+ return (Blocks) sets.get(8).getData();
}
return Blocks.AIR;
}
@@ -62,6 +70,8 @@ public class MinecartMetaData extends EntityMetaData {
switch (version) {
case VERSION_1_8:
return (int) sets.get(21).getData();
+ case VERSION_1_9_4:
+ return (int) sets.get(9).getData();
}
return 0;
}
@@ -69,7 +79,9 @@ public class MinecartMetaData extends EntityMetaData {
public boolean isShowingBlock() {
switch (version) {
case VERSION_1_8:
- return (int) sets.get(22).getData() == 0x01;
+ return (byte) sets.get(22).getData() == 0x01;
+ case VERSION_1_9_4:
+ return (boolean) sets.get(10).getData();
}
return false;
}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/MobMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/MobMetaData.java
index c2c2faabc..ac674aad3 100644
--- a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/MobMetaData.java
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/MobMetaData.java
@@ -14,7 +14,9 @@
package de.bixilon.minosoft.game.datatypes.entities.meta;
import de.bixilon.minosoft.game.datatypes.entities.StatusEffects;
+import de.bixilon.minosoft.game.datatypes.player.Hand;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
+import de.bixilon.minosoft.util.BitByte;
public class MobMetaData extends EntityMetaData {
@@ -27,57 +29,68 @@ public class MobMetaData extends EntityMetaData {
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
+ case VERSION_1_9_4:
return (float) sets.get(6).getData();
}
return 0.0F;
}
public StatusEffects getPotionEffectColor() {
+ // ToDo: color?
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
+ case VERSION_1_9_4:
return StatusEffects.byId((int) sets.get(7).getData());
}
return null;
}
- public byte getPotionEffectAmbient() {
+ public boolean isPotionEffectAmbient() {
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
- return (byte) sets.get(8).getData();
+ return (byte) sets.get(8).getData() == 0x01;
+ case VERSION_1_9_4:
+ return (boolean) sets.get(8).getData();
}
- return 0;
+ return false;
}
- public byte getNumberOfArrowsInEntity() {
+ public int getNumberOfArrowsInEntity() {
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
return (byte) sets.get(9).getData();
+ case VERSION_1_9_4:
+ return (int) sets.get(9).getData();
}
return 0;
}
+ @Override
public String getNameTag() {
switch (version) {
case VERSION_1_7_10:
return (String) sets.get(10).getData();
case VERSION_1_8:
return (String) sets.get(2).getData();
+ default:
+ return super.getNameTag();
}
- return null;
}
- public byte getAlwaysShowNameTag() {
+ @Override
+ public boolean isCustomNameVisible() {
switch (version) {
case VERSION_1_7_10:
- return (byte) sets.get(11).getData();
+ return (byte) sets.get(11).getData() == 0x01;
case VERSION_1_8:
- return (byte) sets.get(3).getData();
+ return (byte) sets.get(3).getData() == 0x01;
+ default:
+ return super.isCustomNameVisible();
}
- return 0;
}
public boolean hasAI() {
@@ -88,5 +101,22 @@ public class MobMetaData extends EntityMetaData {
return false;
}
+ public boolean hasHandActive() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return BitByte.isBitMask((byte) sets.get(5).getData(), 0x01);
+ }
+ return false;
+ }
+
+ public Hand getActiveHand() {
+ //ToDo main, offhand
+ switch (version) {
+ case VERSION_1_9_4:
+ return BitByte.isBitMask((byte) sets.get(5).getData(), 0x01) ? Hand.LEFT : Hand.RIGHT;
+ }
+ return Hand.RIGHT;
+ }
+
}
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
index e1184766c..844d91606 100644
--- 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
@@ -22,11 +22,13 @@ public class OcelotMetaData extends TameableMetaData {
}
- public byte getType() {
+ public int getType() {
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
return (byte) sets.get(18).getData();
+ case VERSION_1_9_4:
+ return (int) sets.get(14).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
index d98c3fb01..704625185 100644
--- 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
@@ -27,6 +27,8 @@ public class PigMetaData extends AgeableMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return (byte) sets.get(16).getData() == 0x01;
+ case VERSION_1_9_4:
+ return (boolean) sets.get(12).getData();
}
return false;
}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/PotionMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/PotionMetaData.java
new file mode 100644
index 000000000..c53b19746
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/PotionMetaData.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.game.datatypes.inventory.Slot;
+import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
+
+public class PotionMetaData extends EntityMetaData {
+
+ public PotionMetaData(InByteBuffer buffer) {
+ super(buffer);
+ }
+
+ public Slot getPotion() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return (Slot) sets.get(5).getData();
+ }
+ return null;
+ }
+
+}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/PrimedTNTMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/PrimedTNTMetaData.java
new file mode 100644
index 000000000..385de17f1
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/PrimedTNTMetaData.java
@@ -0,0 +1,31 @@
+/*
+ * 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;
+
+public class PrimedTNTMetaData extends EntityMetaData {
+
+ public PrimedTNTMetaData(InByteBuffer buffer) {
+ super(buffer);
+ }
+
+ public int getFuseTime() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return (int) sets.get(5).getData();
+ }
+ return 0;
+ }
+}
\ No newline at end of file
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 4a02c2340..f95055f0d 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
@@ -26,6 +26,8 @@ public class RabbitMetaData extends TameableMetaData {
switch (version) {
case VERSION_1_8:
return (byte) sets.get(18).getData();
+ case VERSION_1_9_4:
+ return (byte) sets.get(12).getData();
}
return 0;
}
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
index 074a901f3..8b2f6535f 100644
--- 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
@@ -29,6 +29,8 @@ public class SheepMetaData extends AgeableMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return Color.byId((byte) sets.get(16).getData() & 0xF);
+ case VERSION_1_9_4:
+ return Color.byId((byte) sets.get(12).getData() & 0xF);
}
return Color.WHITE;
}
@@ -37,7 +39,9 @@ public class SheepMetaData extends AgeableMetaData {
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
- return BitByte.isBitSet((byte) sets.get(16).getData(), 5);
+ return BitByte.isBitMask((byte) sets.get(16).getData(), 0x10);
+ case VERSION_1_9_4:
+ return BitByte.isBitMask((byte) sets.get(12).getData(), 0x10);
}
return false;
}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/ShulkerMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/ShulkerMetaData.java
new file mode 100644
index 000000000..5ccedf6c9
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/ShulkerMetaData.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.game.datatypes.Direction;
+import de.bixilon.minosoft.game.datatypes.world.BlockPosition;
+import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
+
+public class ShulkerMetaData extends MobMetaData {
+
+ public ShulkerMetaData(InByteBuffer buffer) {
+ super(buffer);
+ }
+
+ public Direction getDirection() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return (Direction) sets.get(11).getData();
+ }
+ return null;
+ }
+
+ public BlockPosition getAttachmentPosition() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return (BlockPosition) sets.get(12).getData();
+ }
+ return null;
+ }
+
+ public byte getShieldHeight() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return (byte) sets.get(13).getData();
+ }
+ return 0;
+ }
+
+
+}
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
index dccc9b881..583191111 100644
--- 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
@@ -26,6 +26,16 @@ public class SkeletonMetaData extends MobMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return (byte) sets.get(13).getData() == 0x01;
+ case VERSION_1_9_4:
+ return (byte) sets.get(11).getData() == 0x01;
+ }
+ return false;
+ }
+
+ public boolean isSwingingArms() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return (boolean) sets.get(12).getData();
}
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
index c60fab3eb..35a385a68 100644
--- 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
@@ -15,17 +15,19 @@ package de.bixilon.minosoft.game.datatypes.entities.meta;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
-public class SlimeMetaData extends MobMetaData {
+public class SlimeMetaData extends InsentientMetaData {
public SlimeMetaData(InByteBuffer buffer) {
super(buffer);
}
- public byte getSize() {
+ public int getSize() {
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
return (byte) sets.get(16).getData();
+ case VERSION_1_9_4:
+ return (int) sets.get(11).getData();
}
return 0;
}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/SnowGolemMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/SnowGolemMetaData.java
new file mode 100644
index 000000000..f1cdb0e73
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/SnowGolemMetaData.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.util.BitByte;
+
+public class SnowGolemMetaData extends MobMetaData {
+
+ public SnowGolemMetaData(InByteBuffer buffer) {
+ super(buffer);
+ }
+
+ public boolean hasNoPumpkinHead() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return BitByte.isBitMask((byte) sets.get(10).getData(), 0x10);
+ }
+ return false;
+ }
+
+
+}
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
index 7520f9ccb..c3a6cbedc 100644
--- 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
@@ -14,6 +14,7 @@
package de.bixilon.minosoft.game.datatypes.entities.meta;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
+import de.bixilon.minosoft.util.BitByte;
public class SpiderMetaData extends MobMetaData {
@@ -27,6 +28,8 @@ public class SpiderMetaData extends MobMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return (byte) sets.get(16).getData() == 0x01;
+ case VERSION_1_9_4:
+ return BitByte.isBitMask((byte) sets.get(11).getData(), 0x01);
}
return false;
}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/TameableMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/TameableMetaData.java
index cfda79bca..136d8ae7e 100644
--- a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/TameableMetaData.java
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/TameableMetaData.java
@@ -16,6 +16,8 @@ package de.bixilon.minosoft.game.datatypes.entities.meta;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
import de.bixilon.minosoft.util.BitByte;
+import java.util.UUID;
+
public class TameableMetaData extends AgeableMetaData {
public TameableMetaData(InByteBuffer buffer) {
@@ -27,7 +29,9 @@ public class TameableMetaData extends AgeableMetaData {
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
- return BitByte.isBitSet((int) sets.get(16).getData(), 0);
+ return BitByte.isBitMask((int) sets.get(16).getData(), 0x01);
+ case VERSION_1_9_4:
+ return BitByte.isBitMask((int) sets.get(12).getData(), 0x01);
}
return false;
}
@@ -36,7 +40,17 @@ public class TameableMetaData extends AgeableMetaData {
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
- return BitByte.isBitSet((int) sets.get(16).getData(), 2);
+ return BitByte.isBitMask((int) sets.get(16).getData(), 0x04);
+ case VERSION_1_9_4:
+ return BitByte.isBitMask((int) sets.get(12).getData(), 0x04);
+ }
+ return false;
+ }
+
+ public boolean isAngry() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return BitByte.isBitMask((int) sets.get(12).getData(), 0x02);
}
return false;
}
@@ -50,4 +64,12 @@ public class TameableMetaData extends AgeableMetaData {
return null;
}
+ public UUID getOwnerUUID() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return (UUID) sets.get(13).getData();
+ }
+ return null;
+ }
+
}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/TippedArrowMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/TippedArrowMetaData.java
new file mode 100644
index 000000000..ef0665615
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/TippedArrowMetaData.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.game.datatypes.Color;
+import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
+
+public class TippedArrowMetaData extends ArrowMetaData {
+
+ public TippedArrowMetaData(InByteBuffer buffer) {
+ super(buffer);
+ }
+
+ public Color getColor() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return Color.byId((int) sets.get(6).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
index e6e72caf5..78a20c0f3 100644
--- 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
@@ -27,6 +27,8 @@ public class VillagerMetaData extends AgeableMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return VillagerType.byId((int) sets.get(16).getData());
+ case VERSION_1_9_4:
+ return VillagerType.byId((int) sets.get(12).getData());
}
return VillagerType.FARMER;
}
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
index e541377c1..776e11511 100644
--- 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
@@ -26,6 +26,8 @@ public class WitchMetaData extends MobMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return (byte) sets.get(21).getData() == 0x01;
+ case VERSION_1_9_4:
+ return (boolean) sets.get(11).getData();
}
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
index 359c319b2..8e97148ed 100644
--- 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
@@ -26,6 +26,8 @@ public class WitherMetaData extends MobMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return (int) sets.get(17).getData();
+ case VERSION_1_9_4:
+ return (int) sets.get(11).getData();
}
return 0;
}
@@ -35,6 +37,8 @@ public class WitherMetaData extends MobMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return (int) sets.get(18).getData();
+ case VERSION_1_9_4:
+ return (int) sets.get(12).getData();
}
return 0;
}
@@ -44,6 +48,8 @@ public class WitherMetaData extends MobMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return (int) sets.get(19).getData();
+ case VERSION_1_9_4:
+ return (int) sets.get(13).getData();
}
return 0;
}
@@ -53,6 +59,8 @@ public class WitherMetaData extends MobMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return (int) sets.get(20).getData();
+ case VERSION_1_9_4:
+ return (int) sets.get(14).getData();
}
return 0;
}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/WitherSkullMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/WitherSkullMetaData.java
new file mode 100644
index 000000000..8d83eb13c
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/WitherSkullMetaData.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;
+
+public class WitherSkullMetaData extends TameableMetaData {
+
+ public WitherSkullMetaData(InByteBuffer buffer) {
+ super(buffer);
+ }
+
+
+ public boolean isInvulnerable() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return (boolean) sets.get(5).getData();
+ }
+ return false;
+ }
+}
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
index 9ff065345..c59ff144d 100644
--- 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
@@ -24,15 +24,18 @@ public class WolfMetaData extends TameableMetaData {
}
+ @Override
public boolean isAngry() {
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
return BitByte.isBitSet((int) sets.get(16).getData(), 1);
+ default:
+ return super.isAngry();
}
- return false;
}
+
public float getHealth() {
switch (version) {
case VERSION_1_7_10:
@@ -42,12 +45,22 @@ public class WolfMetaData extends TameableMetaData {
return 0.00F;
}
+ public float getDamageTaken() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return (float) sets.get(14).getData();
+ }
+ return 0.00F;
+ }
+
public boolean isBegging() {
switch (version) {
case VERSION_1_7_10:
case VERSION_1_8:
return ((byte) sets.get(19).getData()) == 0x01;
+ case VERSION_1_9_4:
+ return ((boolean) sets.get(15).getData());
}
return false;
}
@@ -57,6 +70,8 @@ public class WolfMetaData extends TameableMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return Color.byId((byte) sets.get(20).getData());
+ case VERSION_1_9_4:
+ return Color.byId((byte) sets.get(16).getData());
}
return Color.WHITE;
}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/ZombieMetaData.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/ZombieMetaData.java
index cb4e44c6d..ed5d8a9b3 100644
--- a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/ZombieMetaData.java
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/meta/ZombieMetaData.java
@@ -27,6 +27,8 @@ public class ZombieMetaData extends MobMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return ((byte) sets.get(12).getData()) == 0x01;
+ case VERSION_1_9_4:
+ return ((boolean) sets.get(11).getData());
}
return false;
}
@@ -36,6 +38,8 @@ public class ZombieMetaData extends MobMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return ((byte) sets.get(13).getData()) == 0x01;
+ case VERSION_1_9_4:
+ return ((int) sets.get(12).getData()) >= 0x01; // returns the villager type
}
return false;
}
@@ -45,6 +49,16 @@ public class ZombieMetaData extends MobMetaData {
case VERSION_1_7_10:
case VERSION_1_8:
return ((byte) sets.get(14).getData()) == 0x01;
+ case VERSION_1_9_4:
+ return ((boolean) sets.get(13).getData());
+ }
+ return false;
+ }
+
+ public boolean areHandsHeldUp() {
+ switch (version) {
+ case VERSION_1_9_4:
+ return ((boolean) sets.get(14).getData());
}
return false;
}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/EnderDragon.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/EnderDragon.java
index 536d954cb..2b70ae69a 100644
--- a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/EnderDragon.java
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/EnderDragon.java
@@ -14,16 +14,16 @@
package de.bixilon.minosoft.game.datatypes.entities.mob;
import de.bixilon.minosoft.game.datatypes.entities.*;
+import de.bixilon.minosoft.game.datatypes.entities.meta.EnderDragonMetaData;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
-import de.bixilon.minosoft.game.datatypes.entities.meta.MobMetaData;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
public class EnderDragon extends Mob implements MobInterface {
- MobMetaData metaData;
+ EnderDragonMetaData metaData;
public EnderDragon(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer) {
super(id, location, yaw, pitch, velocity);
- this.metaData = new MobMetaData(buffer);
+ this.metaData = new EnderDragonMetaData(buffer);
}
@Override
@@ -32,13 +32,13 @@ public class EnderDragon extends Mob implements MobInterface {
}
@Override
- public MobMetaData getMetaData() {
+ public EnderDragonMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
- this.metaData = (MobMetaData) metaData;
+ this.metaData = (EnderDragonMetaData) metaData;
}
@Override
@@ -55,4 +55,9 @@ public class EnderDragon extends Mob implements MobInterface {
public int getMaxHealth() {
return 200;
}
+
+ @Override
+ public Class extends EntityMetaData> getMetaDataClass() {
+ return EnderDragonMetaData.class;
+ }
}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Shulker.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Shulker.java
new file mode 100644
index 000000000..f6ce454f7
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/Shulker.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.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.ShulkerMetaData;
+import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
+
+public class Shulker extends Mob implements MobInterface {
+ ShulkerMetaData metaData;
+
+ public Shulker(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer) {
+ super(id, location, yaw, pitch, velocity);
+ this.metaData = new ShulkerMetaData(buffer);
+ }
+
+ @Override
+ public Mobs getEntityType() {
+ return Mobs.SHULKER;
+ }
+
+ @Override
+ public ShulkerMetaData getMetaData() {
+ return metaData;
+ }
+
+ @Override
+ public void setMetaData(EntityMetaData metaData) {
+ this.metaData = (ShulkerMetaData) metaData;
+ }
+
+ @Override
+ public float getWidth() {
+ return 1.0F;
+ }
+
+ @Override
+ public float getHeight() {
+ return 1.0F;
+ }
+
+ @Override
+ public int getMaxHealth() {
+ return 30;
+ }
+
+ @Override
+ public Class extends EntityMetaData> getMetaDataClass() {
+ return ShulkerMetaData.class;
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/SnowGolem.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/SnowGolem.java
index e433d4c1d..078a21d53 100644
--- a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/SnowGolem.java
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/mob/SnowGolem.java
@@ -15,15 +15,15 @@ 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.MobMetaData;
+import de.bixilon.minosoft.game.datatypes.entities.meta.SnowGolemMetaData;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
public class SnowGolem extends Mob implements MobInterface {
- MobMetaData metaData;
+ SnowGolemMetaData metaData;
public SnowGolem(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer) {
super(id, location, yaw, pitch, velocity);
- this.metaData = new MobMetaData(buffer);
+ this.metaData = new SnowGolemMetaData(buffer);
}
@Override
@@ -32,13 +32,13 @@ public class SnowGolem extends Mob implements MobInterface {
}
@Override
- public MobMetaData getMetaData() {
+ public SnowGolemMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
- this.metaData = (MobMetaData) metaData;
+ this.metaData = (SnowGolemMetaData) metaData;
}
@Override
@@ -55,4 +55,9 @@ public class SnowGolem extends Mob implements MobInterface {
public int getMaxHealth() {
return 4;
}
+
+ @Override
+ public Class extends EntityMetaData> getMetaDataClass() {
+ return SnowGolemMetaData.class;
+ }
}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/DragonFireball.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/DragonFireball.java
new file mode 100644
index 000000000..9d220cf68
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/DragonFireball.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.objects;
+
+import de.bixilon.minosoft.game.datatypes.entities.*;
+import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
+
+public class DragonFireball extends EntityObject implements ObjectInterface {
+ final int thrower;
+ EntityMetaData metaData;
+
+ public DragonFireball(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
+ this.thrower = additionalInt;
+ }
+
+ public DragonFireball(int id, Location location, short yaw, short pitch, int additionalInt, Velocity velocity) {
+ super(id, location, yaw, pitch, velocity);
+ this.thrower = additionalInt;
+ }
+
+ @Override
+ public Objects getEntityType() {
+ return Objects.DRAGON_FIREBALL;
+ }
+
+ @Override
+ public EntityMetaData getMetaData() {
+ return metaData;
+ }
+
+ @Override
+ public void setMetaData(EntityMetaData metaData) {
+ this.metaData = metaData;
+ }
+
+ @Override
+ public float getWidth() {
+ return 0.3125F;
+ }
+
+ @Override
+ public float getHeight() {
+ return 0.3125F;
+ }
+
+ public int getThrower() {
+ return thrower;
+ }
+
+}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/FallingBlock.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/FallingBlock.java
index c5d257fce..33060f427 100644
--- a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/FallingBlock.java
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/FallingBlock.java
@@ -16,9 +16,10 @@ package de.bixilon.minosoft.game.datatypes.entities.objects;
import de.bixilon.minosoft.game.datatypes.blocks.Blocks;
import de.bixilon.minosoft.game.datatypes.entities.*;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
+import de.bixilon.minosoft.game.datatypes.entities.meta.FallingBlockMetaData;
public class FallingBlock extends EntityObject implements ObjectInterface {
- EntityMetaData metaData;
+ FallingBlockMetaData metaData;
final Blocks block;
public FallingBlock(int id, Location location, short yaw, short pitch, int additionalInt) {
@@ -38,13 +39,13 @@ public class FallingBlock extends EntityObject implements ObjectInterface {
}
@Override
- public EntityMetaData getMetaData() {
+ public FallingBlockMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
- this.metaData = metaData;
+ this.metaData = (FallingBlockMetaData) metaData;
}
@Override
@@ -58,6 +59,12 @@ public class FallingBlock extends EntityObject implements ObjectInterface {
}
public Blocks getBlock() {
+ //ToDo depends on protocol version
return block;
}
+
+ @Override
+ public Class extends EntityMetaData> getMetaDataClass() {
+ return FallingBlockMetaData.class;
+ }
}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/LeashKnot.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/LeashKnot.java
index 9d85f018b..d60be24b6 100644
--- a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/LeashKnot.java
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/LeashKnot.java
@@ -15,9 +15,10 @@ 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.FishingHookMetaData;
public class LeashKnot extends EntityObject implements ObjectInterface {
- EntityMetaData metaData;
+ FishingHookMetaData metaData;
public LeashKnot(int id, Location location, short yaw, short pitch, int additionalInt) {
super(id, location, yaw, pitch, null);
@@ -34,13 +35,13 @@ public class LeashKnot extends EntityObject implements ObjectInterface {
}
@Override
- public EntityMetaData getMetaData() {
+ public FishingHookMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
- this.metaData = metaData;
+ this.metaData = (FishingHookMetaData) metaData;
}
@Override
@@ -53,4 +54,8 @@ public class LeashKnot extends EntityObject implements ObjectInterface {
return 0.5F;
}
+ @Override
+ public Class extends EntityMetaData> getMetaDataClass() {
+ return FishingHookMetaData.class;
+ }
}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/PrimedTNT.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/PrimedTNT.java
index 333108f01..1a47df19b 100644
--- a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/PrimedTNT.java
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/PrimedTNT.java
@@ -15,9 +15,10 @@ 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.PrimedTNTMetaData;
public class PrimedTNT extends EntityObject implements ObjectInterface {
- EntityMetaData metaData;
+ PrimedTNTMetaData metaData;
public PrimedTNT(int id, Location location, short yaw, short pitch, int additionalInt) {
super(id, location, yaw, pitch, null);
@@ -40,7 +41,7 @@ public class PrimedTNT extends EntityObject implements ObjectInterface {
@Override
public void setMetaData(EntityMetaData metaData) {
- this.metaData = metaData;
+ this.metaData = (PrimedTNTMetaData) metaData;
}
@Override
@@ -52,4 +53,9 @@ public class PrimedTNT extends EntityObject implements ObjectInterface {
public float getHeight() {
return 0.98F;
}
+
+ @Override
+ public Class extends EntityMetaData> getMetaDataClass() {
+ return PrimedTNTMetaData.class;
+ }
}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/ShulkerBullet.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/ShulkerBullet.java
new file mode 100644
index 000000000..e0b589177
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/ShulkerBullet.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.objects;
+
+import de.bixilon.minosoft.game.datatypes.entities.*;
+import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
+
+public class ShulkerBullet extends EntityObject implements ObjectInterface {
+ final int shooter;
+ EntityMetaData metaData;
+
+ public ShulkerBullet(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
+ this.shooter = additionalInt;
+ }
+
+ public ShulkerBullet(int id, Location location, short yaw, short pitch, int additionalInt, Velocity velocity) {
+ super(id, location, yaw, pitch, velocity);
+ this.shooter = additionalInt;
+ }
+
+ @Override
+ public Objects getEntityType() {
+ return Objects.SHULKER_BULLET;
+ }
+
+ @Override
+ public EntityMetaData getMetaData() {
+ return metaData;
+ }
+
+ @Override
+ public void setMetaData(EntityMetaData metaData) {
+ this.metaData = metaData;
+ }
+
+ @Override
+ public float getWidth() {
+ return 0.3125F;
+ }
+
+ @Override
+ public float getHeight() {
+ return 0.3125F;
+ }
+
+
+ public int getShooter() {
+ return shooter;
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/SpectralArrow.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/SpectralArrow.java
new file mode 100644
index 000000000..a2ea27bc2
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/SpectralArrow.java
@@ -0,0 +1,68 @@
+/*
+ * 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.ArrowMetaData;
+import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
+
+public class SpectralArrow extends EntityObject implements ObjectInterface {
+ final int shooter;
+ ArrowMetaData metaData;
+
+ public SpectralArrow(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
+ this.shooter = additionalInt;
+ }
+
+ public SpectralArrow(int id, Location location, short yaw, short pitch, int additionalInt, Velocity velocity) {
+ super(id, location, yaw, pitch, velocity);
+ this.shooter = additionalInt;
+ }
+
+ @Override
+ public Objects getEntityType() {
+ return Objects.SPECTRAL_ARROW;
+ }
+
+ @Override
+ public ArrowMetaData getMetaData() {
+ return metaData;
+ }
+
+ @Override
+ public void setMetaData(EntityMetaData metaData) {
+ this.metaData = (ArrowMetaData) metaData;
+ }
+
+ @Override
+ public float getWidth() {
+ return 0.5F;
+ }
+
+ @Override
+ public float getHeight() {
+ return 0.5F;
+ }
+
+ @Override
+ public Class extends EntityMetaData> getMetaDataClass() {
+ return ArrowMetaData.class;
+ }
+
+ public int getShooter() {
+ return shooter;
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/ThrownPotion.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/ThrownPotion.java
index bde36cba7..d2f670acf 100644
--- a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/ThrownPotion.java
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/ThrownPotion.java
@@ -15,20 +15,21 @@ 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.PotionMetaData;
public class ThrownPotion extends EntityObject implements ObjectInterface {
- EntityMetaData metaData;
- int potion; //ToDo
+ PotionMetaData metaData;
+ StatusEffects potion; //ToDo
public ThrownPotion(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
- this.potion = additionalInt;
+ this.potion = StatusEffects.byId(additionalInt);
}
public ThrownPotion(int id, Location location, short yaw, short pitch, int additionalInt, Velocity velocity) {
super(id, location, yaw, pitch, velocity);
- this.potion = additionalInt;
+ this.potion = StatusEffects.byId(additionalInt);
}
@Override
@@ -37,13 +38,13 @@ public class ThrownPotion extends EntityObject implements ObjectInterface {
}
@Override
- public EntityMetaData getMetaData() {
+ public PotionMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
- this.metaData = metaData;
+ this.metaData = (PotionMetaData) metaData;
}
@Override
@@ -56,4 +57,8 @@ public class ThrownPotion extends EntityObject implements ObjectInterface {
return 0.25F;
}
+ @Override
+ public Class extends EntityMetaData> getMetaDataClass() {
+ return PotionMetaData.class;
+ }
}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/WitherSkull.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/WitherSkull.java
index d1e0cb33a..e244b60e8 100644
--- a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/WitherSkull.java
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/objects/WitherSkull.java
@@ -15,10 +15,11 @@ 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.WitherSkullMetaData;
public class WitherSkull extends EntityObject implements ObjectInterface {
final int thrower;
- EntityMetaData metaData;
+ WitherSkullMetaData metaData;
public WitherSkull(int id, Location location, short yaw, short pitch, int additionalInt) {
super(id, location, yaw, pitch, null);
@@ -37,13 +38,13 @@ public class WitherSkull extends EntityObject implements ObjectInterface {
}
@Override
- public EntityMetaData getMetaData() {
+ public WitherSkullMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
- this.metaData = metaData;
+ this.metaData = (WitherSkullMetaData) metaData;
}
@Override
@@ -59,4 +60,9 @@ public class WitherSkull extends EntityObject implements ObjectInterface {
public int getThrower() {
return thrower;
}
+
+ @Override
+ public Class extends EntityMetaData> getMetaDataClass() {
+ return WitherSkullMetaData.class;
+ }
}
diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/player/Hand.java b/src/main/java/de/bixilon/minosoft/game/datatypes/player/Hand.java
index 0d2688269..7a15fde10 100644
--- a/src/main/java/de/bixilon/minosoft/game/datatypes/player/Hand.java
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/player/Hand.java
@@ -24,6 +24,15 @@ public enum Hand {
this.id = id;
}
+ public static Hand byId(int id) {
+ for (Hand h : values()) {
+ if (h.getId() == id) {
+ return h;
+ }
+ }
+ return null;
+ }
+
public int getId() {
return id;
}
diff --git a/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketSpawnObject.java b/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketSpawnObject.java
index b2732f648..8657f17b9 100644
--- a/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketSpawnObject.java
+++ b/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketSpawnObject.java
@@ -96,10 +96,7 @@ public class PacketSpawnObject implements ClientboundPacket {
try {
// velocity present AND metadata
- Velocity velocity = null;
- if (data != 0) {
- velocity = new Velocity(buffer.readShort(), buffer.readShort(), buffer.readShort());
- }
+ Velocity velocity = new Velocity(buffer.readShort(), buffer.readShort(), buffer.readShort());
object = type.getClazz().getConstructor(int.class, Location.class, short.class, short.class, int.class, Velocity.class).newInstance(entityId, location, yaw, pitch, data, velocity);
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
e.printStackTrace();
diff --git a/src/main/java/de/bixilon/minosoft/util/BitByte.java b/src/main/java/de/bixilon/minosoft/util/BitByte.java
index aef875b76..b5b612890 100644
--- a/src/main/java/de/bixilon/minosoft/util/BitByte.java
+++ b/src/main/java/de/bixilon/minosoft/util/BitByte.java
@@ -21,6 +21,12 @@ public class BitByte {
return bitSet;
}
+ public static boolean isBitMask(int in, int mask) {
+ boolean bitSet;
+ bitSet = ((in & mask) == mask);
+ return bitSet;
+ }
+
public static boolean isBitSetShort(short in, int pos) {
boolean bitSet;
int mask = 1 << pos;