All 1.13.2 metadata and entities/objects

This commit is contained in:
Bixilon 2020-07-10 19:10:25 +02:00
parent 4f7e64112b
commit 0b74cea68d
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
24 changed files with 1069 additions and 66 deletions

View File

@ -102,10 +102,10 @@ public enum Entities {
COD(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 8)}, Cod.class),
DOLPHIN(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 12)}, Dolphin.class),
DROWNED(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 14)}, Drowned.class),
ENDERMITE(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 19)}, Endermite.class),
ENDERMITE(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_8, 67), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 19)}, Endermite.class),
MINECART_FURNACE(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 42)}, MinecartFurnace.class),
MINECART_HOPPER(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 43)}, MinecartHopper.class),
MINECART_SPAWNER(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 44)}, MinecarSpawner.class),
MINECART_SPAWNER(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 44)}, MinecartSpawner.class),
MINECART_TNT(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 45)}, MinecartTNT.class),
PUFFERFISH(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 52)}, Pufferfish.class),
SALMON(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 57)}, Salmon.class),
@ -132,16 +132,15 @@ public enum Entities {
public static Entities byId(int id, ProtocolVersion version) {
for (Entities entity : values()) {
if (entity.getType() == id) {
if (entity.getValueMap().get(version) == id) {
return entity;
}
}
return null;
}
public int getType() {
return type;
public VersionValueMap<Integer> getValueMap() {
return valueMap;
}
public Class<? extends Entity> getClazz() {

View File

@ -16,17 +16,43 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import java.util.HashMap;
public class PufferFishMetaData extends FishMetaData {
public class PufferfishMetaData extends FishMetaData {
public PufferFishMetaData(HashMap<Integer, MetaDataSet> sets, ProtocolVersion version) {
public PufferfishMetaData(HashMap<Integer, MetaDataSet> sets, ProtocolVersion version) {
super(sets, version);
}
public int getPuffState() {
public PufferStates getPufferState() {
switch (version) {
case VERSION_1_13_2:
return (int) sets.get(13).getData();
return PufferStates.byId((int) sets.get(13).getData());
}
return PufferStates.UN_PUFFED;
}
public enum PufferStates {
UN_PUFFED(0),
SEMI_PUFFED(1),
FULLY_PUFFED(2);
final int id;
PufferStates(int id) {
this.id = id;
}
public static PufferStates byId(int id) {
for (PufferStates state : values()) {
if (state.getId() == id) {
return state;
}
}
return null;
}
public int getId() {
return id;
}
return 0;
}
}

View File

@ -12,7 +12,6 @@
*/
package de.bixilon.minosoft.game.datatypes.entities.meta;
import de.bixilon.minosoft.game.datatypes.world.BlockPosition;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import java.util.HashMap;
@ -24,51 +23,11 @@ public class RabbitMetaData extends TameableMetaData {
}
public BlockPosition getHomePosition() {
public int getType() {
switch (version) {
case VERSION_1_13_2:
return (BlockPosition) sets.get(13).getData();
return (int) sets.get(13).getData();
}
return new BlockPosition(0, (short) 0, 0);
}
public boolean hasEgg() {
switch (version) {
case VERSION_1_13_2:
return (boolean) sets.get(14).getData();
}
return false;
}
public boolean isLayingEgg() {
switch (version) {
case VERSION_1_13_2:
return (boolean) sets.get(15).getData();
}
return false;
}
public BlockPosition getTravelPosition() {
switch (version) {
case VERSION_1_13_2:
return (BlockPosition) sets.get(16).getData();
}
return new BlockPosition(0, (short) 0, 0);
}
public boolean isGoingHome() {
switch (version) {
case VERSION_1_13_2:
return (boolean) sets.get(17).getData();
}
return false;
}
public boolean isTraveling() {
switch (version) {
case VERSION_1_13_2:
return (boolean) sets.get(18).getData();
}
return false;
return 0;
}
}

View File

@ -0,0 +1,74 @@
/*
* Codename Minosoft
* Copyright (C) 2020 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.game.datatypes.entities.meta;
import de.bixilon.minosoft.game.datatypes.world.BlockPosition;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import java.util.HashMap;
public class TurtleMetaData extends AgeableMetaData {
public TurtleMetaData(HashMap<Integer, MetaDataSet> sets, ProtocolVersion version) {
super(sets, version);
}
public BlockPosition getHomePosition() {
switch (version) {
case VERSION_1_13_2:
return (BlockPosition) sets.get(13).getData();
}
return new BlockPosition(0, (short) 0, 0);
}
public boolean hasEgg() {
switch (version) {
case VERSION_1_13_2:
return (boolean) sets.get(14).getData();
}
return false;
}
public boolean isLayingEgg() {
switch (version) {
case VERSION_1_13_2:
return (boolean) sets.get(15).getData();
}
return false;
}
public BlockPosition getTravelPosition() {
switch (version) {
case VERSION_1_13_2:
return (BlockPosition) sets.get(16).getData();
}
return new BlockPosition(0, (short) 0, 0);
}
public boolean isGoingHome() {
switch (version) {
case VERSION_1_13_2:
return (boolean) sets.get(17).getData();
}
return false;
}
public boolean isTraveling() {
switch (version) {
case VERSION_1_13_2:
return (boolean) sets.get(18).getData();
}
return false;
}
}

View File

@ -0,0 +1,66 @@
/*
* Codename Minosoft
* Copyright (C) 2020 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.game.datatypes.entities.mob;
import de.bixilon.minosoft.game.datatypes.entities.*;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.game.datatypes.entities.meta.FishMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import java.util.HashMap;
public class Cod extends Mob implements MobInterface {
FishMetaData metaData;
public Cod(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap<Integer, EntityMetaData.MetaDataSet> sets, ProtocolVersion version) {
super(entityId, location, yaw, pitch, velocity);
this.metaData = new FishMetaData(sets, version);
}
@Override
public Entities getEntityType() {
return Entities.COD;
}
@Override
public FishMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
this.metaData = (FishMetaData) metaData;
}
@Override
public float getWidth() {
return 0.5F;
}
@Override
public float getHeight() {
return 0.3F;
}
@Override
public int getMaxHealth() {
return 3;
}
@Override
public Class<? extends EntityMetaData> getMetaDataClass() {
return FishMetaData.class;
}
}

View File

@ -0,0 +1,66 @@
/*
* Codename Minosoft
* Copyright (C) 2020 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.game.datatypes.entities.mob;
import de.bixilon.minosoft.game.datatypes.entities.*;
import de.bixilon.minosoft.game.datatypes.entities.meta.DolphinMetaData;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import java.util.HashMap;
public class Dolphin extends Mob implements MobInterface {
DolphinMetaData metaData;
public Dolphin(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap<Integer, EntityMetaData.MetaDataSet> sets, ProtocolVersion version) {
super(entityId, location, yaw, pitch, velocity);
this.metaData = new DolphinMetaData(sets, version);
}
@Override
public Entities getEntityType() {
return Entities.DOLPHIN;
}
@Override
public DolphinMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
this.metaData = (DolphinMetaData) metaData;
}
@Override
public float getWidth() {
return 0.9F;
}
@Override
public float getHeight() {
return 0.6F;
}
@Override
public int getMaxHealth() {
return 10;
}
@Override
public Class<? extends EntityMetaData> getMetaDataClass() {
return DolphinMetaData.class;
}
}

View File

@ -0,0 +1,72 @@
/*
* Codename Minosoft
* Copyright (C) 2020 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.game.datatypes.entities.mob;
import de.bixilon.minosoft.game.datatypes.entities.*;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.game.datatypes.entities.meta.ZombieMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import java.util.HashMap;
public class Drowned extends Mob implements MobInterface {
ZombieMetaData metaData;
public Drowned(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap<Integer, EntityMetaData.MetaDataSet> sets, ProtocolVersion version) {
super(entityId, location, yaw, pitch, velocity);
this.metaData = new ZombieMetaData(sets, version);
}
@Override
public Entities getEntityType() {
return Entities.DROWNED;
}
@Override
public ZombieMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
this.metaData = (ZombieMetaData) metaData;
}
@Override
public float getWidth() {
if (metaData.isChild()) {
return 0.3F;
}
return 0.6F;
}
@Override
public float getHeight() {
if (metaData.isChild()) {
return 0.975F;
}
return 1.95F;
}
@Override
public int getMaxHealth() {
return 20;
}
@Override
public Class<? extends EntityMetaData> getMetaDataClass() {
return ZombieMetaData.class;
}
}

View File

@ -0,0 +1,61 @@
/*
* Codename Minosoft
* Copyright (C) 2020 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.game.datatypes.entities.mob;
import de.bixilon.minosoft.game.datatypes.entities.*;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import java.util.HashMap;
public class Endermite extends Mob implements MobInterface {
EntityMetaData metaData;
public Endermite(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap<Integer, EntityMetaData.MetaDataSet> sets, ProtocolVersion version) {
super(entityId, location, yaw, pitch, velocity);
this.metaData = new EntityMetaData(sets, version);
}
@Override
public Entities getEntityType() {
return Entities.ENDERMITE;
}
@Override
public EntityMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
this.metaData = metaData;
}
@Override
public float getWidth() {
return 0.4F;
}
@Override
public float getHeight() {
return 0.3F;
}
@Override
public int getMaxHealth() {
return 8;
}
}

View File

@ -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 <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.game.datatypes.entities.mob;
import de.bixilon.minosoft.game.datatypes.entities.*;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import java.util.HashMap;
public class FishingBobber extends Mob implements MobInterface {
EntityMetaData metaData;
public FishingBobber(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap<Integer, EntityMetaData.MetaDataSet> sets, ProtocolVersion version) {
super(entityId, location, yaw, pitch, velocity);
this.metaData = new EntityMetaData(sets, version);
}
@Override
public Entities getEntityType() {
return Entities.FISHING_BOBBER;
}
@Override
public EntityMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
this.metaData = metaData;
}
@Override
public float getWidth() {
return 0.0F;
}
@Override
public float getHeight() {
return 0.0F;
}
@Override
public int getMaxHealth() {
return 1;
}
}

View File

@ -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 <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.game.datatypes.entities.mob;
import de.bixilon.minosoft.game.datatypes.entities.*;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import java.util.HashMap;
public class LightningBolt extends Mob implements MobInterface {
EntityMetaData metaData;
public LightningBolt(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap<Integer, EntityMetaData.MetaDataSet> sets, ProtocolVersion version) {
super(entityId, location, yaw, pitch, velocity);
this.metaData = new EntityMetaData(sets, version);
}
@Override
public Entities getEntityType() {
return Entities.LIGHTNING_BOLT;
}
@Override
public EntityMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
this.metaData = metaData;
}
@Override
public float getWidth() {
return 0.0F;
}
@Override
public float getHeight() {
return 0.0F;
}
@Override
public int getMaxHealth() {
return 1;
}
}

View File

@ -0,0 +1,65 @@
/*
* Codename Minosoft
* Copyright (C) 2020 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.game.datatypes.entities.mob;
import de.bixilon.minosoft.game.datatypes.entities.*;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.game.datatypes.entities.meta.PhantomMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import java.util.HashMap;
public class Phantom extends Mob implements MobInterface {
PhantomMetaData metaData;
public Phantom(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap<Integer, EntityMetaData.MetaDataSet> sets, ProtocolVersion version) {
super(entityId, location, yaw, pitch, velocity);
this.metaData = new PhantomMetaData(sets, version);
}
@Override
public Entities getEntityType() {
return Entities.PHANTOM;
}
@Override
public PhantomMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
this.metaData = (PhantomMetaData) metaData;
}
@Override
public float getWidth() {
return 0.9F;
}
@Override
public float getHeight() {
return 0.5F;
}
@Override
public int getMaxHealth() {
return 20;
}
@Override
public Class<? extends EntityMetaData> getMetaDataClass() {
return PhantomMetaData.class;
}
}

View File

@ -0,0 +1,82 @@
/*
* Codename Minosoft
* Copyright (C) 2020 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.game.datatypes.entities.mob;
import de.bixilon.minosoft.game.datatypes.entities.*;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.game.datatypes.entities.meta.PufferfishMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import java.util.HashMap;
public class Pufferfish extends Mob implements MobInterface {
PufferfishMetaData metaData;
public Pufferfish(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap<Integer, EntityMetaData.MetaDataSet> sets, ProtocolVersion version) {
super(entityId, location, yaw, pitch, velocity);
this.metaData = new PufferfishMetaData(sets, version);
}
@Override
public Entities getEntityType() {
return Entities.PUFFERFISH;
}
@Override
public PufferfishMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
this.metaData = (PufferfishMetaData) metaData;
}
@Override
public float getWidth() {
switch (metaData.getPufferState()) {
case UN_PUFFED:
return 0.35F;
case SEMI_PUFFED:
return 0.5F;
case FULLY_PUFFED:
return 0.7F;
}
return 0.35F;
}
@Override
public float getHeight() {
switch (metaData.getPufferState()) {
case UN_PUFFED:
return 0.35F;
case SEMI_PUFFED:
return 0.5F;
case FULLY_PUFFED:
return 0.7F;
}
return 0.35F;
}
@Override
public int getMaxHealth() {
return 3;
}
@Override
public Class<? extends EntityMetaData> getMetaDataClass() {
return PufferfishMetaData.class;
}
}

View File

@ -15,17 +15,17 @@ package de.bixilon.minosoft.game.datatypes.entities.mob;
import de.bixilon.minosoft.game.datatypes.entities.*;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.game.datatypes.entities.meta.RabbitMetaData;
import de.bixilon.minosoft.game.datatypes.entities.meta.TurtleMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import java.util.HashMap;
public class Rabbit extends Mob implements MobInterface {
RabbitMetaData metaData;
TurtleMetaData metaData;
public Rabbit(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap<Integer, EntityMetaData.MetaDataSet> sets, ProtocolVersion version) {
super(entityId, location, yaw, pitch, velocity);
this.metaData = new RabbitMetaData(sets, version);
this.metaData = new TurtleMetaData(sets, version);
}
@Override
@ -34,13 +34,13 @@ public class Rabbit extends Mob implements MobInterface {
}
@Override
public RabbitMetaData getMetaData() {
public TurtleMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
this.metaData = (RabbitMetaData) metaData;
this.metaData = (TurtleMetaData) metaData;
}
@Override
@ -60,6 +60,6 @@ public class Rabbit extends Mob implements MobInterface {
@Override
public Class<? extends EntityMetaData> getMetaDataClass() {
return RabbitMetaData.class;
return TurtleMetaData.class;
}
}

View File

@ -0,0 +1,66 @@
/*
* Codename Minosoft
* Copyright (C) 2020 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.game.datatypes.entities.mob;
import de.bixilon.minosoft.game.datatypes.entities.*;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.game.datatypes.entities.meta.FishMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import java.util.HashMap;
public class Salmon extends Mob implements MobInterface {
FishMetaData metaData;
public Salmon(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap<Integer, EntityMetaData.MetaDataSet> sets, ProtocolVersion version) {
super(entityId, location, yaw, pitch, velocity);
this.metaData = new FishMetaData(sets, version);
}
@Override
public Entities getEntityType() {
return Entities.SALMON;
}
@Override
public FishMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
this.metaData = (FishMetaData) metaData;
}
@Override
public float getWidth() {
return 0.7F;
}
@Override
public float getHeight() {
return 0.4F;
}
@Override
public int getMaxHealth() {
return 3;
}
@Override
public Class<? extends EntityMetaData> getMetaDataClass() {
return FishMetaData.class;
}
}

View File

@ -0,0 +1,66 @@
/*
* Codename Minosoft
* Copyright (C) 2020 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.game.datatypes.entities.mob;
import de.bixilon.minosoft.game.datatypes.entities.*;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.game.datatypes.entities.meta.FishMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import java.util.HashMap;
public class TropicalFish extends Mob implements MobInterface {
FishMetaData metaData;
public TropicalFish(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap<Integer, EntityMetaData.MetaDataSet> sets, ProtocolVersion version) {
super(entityId, location, yaw, pitch, velocity);
this.metaData = new FishMetaData(sets, version);
}
@Override
public Entities getEntityType() {
return Entities.SALMON;
}
@Override
public FishMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
this.metaData = (FishMetaData) metaData;
}
@Override
public float getWidth() {
return 0.5F;
}
@Override
public float getHeight() {
return 0.4F;
}
@Override
public int getMaxHealth() {
return 3;
}
@Override
public Class<? extends EntityMetaData> getMetaDataClass() {
return FishMetaData.class;
}
}

View File

@ -0,0 +1,72 @@
/*
* Codename Minosoft
* Copyright (C) 2020 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.game.datatypes.entities.mob;
import de.bixilon.minosoft.game.datatypes.entities.*;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.game.datatypes.entities.meta.TurtleMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import java.util.HashMap;
public class Turtle extends Mob implements MobInterface {
TurtleMetaData metaData;
public Turtle(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap<Integer, EntityMetaData.MetaDataSet> sets, ProtocolVersion version) {
super(entityId, location, yaw, pitch, velocity);
this.metaData = new TurtleMetaData(sets, version);
}
@Override
public Entities getEntityType() {
return Entities.TURTLE;
}
@Override
public TurtleMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
this.metaData = (TurtleMetaData) metaData;
}
@Override
public float getWidth() {
if (metaData.isAdult()) {
return 1.2F;
}
return 0.36F;
}
@Override
public float getHeight() {
if (metaData.isAdult()) {
return 0.4F;
}
return 0.12F;
}
@Override
public int getMaxHealth() {
return 30;
}
@Override
public Class<? extends EntityMetaData> getMetaDataClass() {
return TurtleMetaData.class;
}
}

View File

@ -39,7 +39,7 @@ public class MinecartCommandBlock extends EntityObject implements ObjectInterfac
@Override
public Entities getEntityType() {
return Entities.MINECART_RIDE_ABLE;
return Entities.MINECART_COMMAND_BLOCK;
}
@Override
@ -67,4 +67,8 @@ public class MinecartCommandBlock extends EntityObject implements ObjectInterfac
return CommandBlockMinecartMetaData.class;
}
public Minecart.MinecartType getType() {
return Minecart.MinecartType.COMMAND_BLOCK;
}
}

View File

@ -0,0 +1,74 @@
/*
* Codename Minosoft
* Copyright (C) 2020 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.game.datatypes.entities.objects;
import de.bixilon.minosoft.game.datatypes.entities.*;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.game.datatypes.entities.meta.FurnaceMinecartMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import java.util.HashMap;
public class MinecartFurnace extends EntityObject implements ObjectInterface {
FurnaceMinecartMetaData metaData;
public MinecartFurnace(int entityId, Location location, short yaw, short pitch, int additionalInt) {
super(entityId, location, yaw, pitch, null);
}
public MinecartFurnace(int entityId, Location location, short yaw, short pitch, int additionalInt, Velocity velocity) {
super(entityId, location, yaw, pitch, velocity);
}
public MinecartFurnace(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap<Integer, EntityMetaData.MetaDataSet> sets, ProtocolVersion version) {
super(entityId, location, yaw, pitch, velocity);
this.metaData = new FurnaceMinecartMetaData(sets, version);
}
@Override
public Entities getEntityType() {
return Entities.MINECART_FURNACE;
}
@Override
public FurnaceMinecartMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
this.metaData = (FurnaceMinecartMetaData) metaData;
}
@Override
public float getWidth() {
return 0.98F;
}
@Override
public float getHeight() {
return 0.7F;
}
@Override
public Class<? extends EntityMetaData> getMetaDataClass() {
return FurnaceMinecartMetaData.class;
}
public Minecart.MinecartType getType() {
return Minecart.MinecartType.FURNACE;
}
}

View File

@ -0,0 +1,43 @@
/*
* Codename Minosoft
* Copyright (C) 2020 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.game.datatypes.entities.objects;
import de.bixilon.minosoft.game.datatypes.entities.Location;
import de.bixilon.minosoft.game.datatypes.entities.ObjectInterface;
import de.bixilon.minosoft.game.datatypes.entities.Velocity;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import java.util.HashMap;
public class MinecartHopper extends Minecart implements ObjectInterface {
public MinecartHopper(int entityId, Location location, short yaw, short pitch, int additionalInt) {
super(entityId, location, yaw, pitch, additionalInt, null);
}
public MinecartHopper(int entityId, Location location, short yaw, short pitch, int additionalInt, Velocity velocity) {
super(entityId, location, yaw, pitch, additionalInt, velocity);
}
public MinecartHopper(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap<Integer, EntityMetaData.MetaDataSet> sets, ProtocolVersion version) {
super(entityId, location, yaw, pitch, 0, velocity);
}
@Override
public Minecart.MinecartType getType() {
return MinecartType.HOPPER;
}
}

View File

@ -0,0 +1,43 @@
/*
* Codename Minosoft
* Copyright (C) 2020 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.game.datatypes.entities.objects;
import de.bixilon.minosoft.game.datatypes.entities.Location;
import de.bixilon.minosoft.game.datatypes.entities.ObjectInterface;
import de.bixilon.minosoft.game.datatypes.entities.Velocity;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import java.util.HashMap;
public class MinecartSpawner extends Minecart implements ObjectInterface {
public MinecartSpawner(int entityId, Location location, short yaw, short pitch, int additionalInt) {
super(entityId, location, yaw, pitch, additionalInt, null);
}
public MinecartSpawner(int entityId, Location location, short yaw, short pitch, int additionalInt, Velocity velocity) {
super(entityId, location, yaw, pitch, additionalInt, velocity);
}
public MinecartSpawner(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap<Integer, EntityMetaData.MetaDataSet> sets, ProtocolVersion version) {
super(entityId, location, yaw, pitch, 0, velocity);
}
@Override
public MinecartType getType() {
return MinecartType.SPAWNER;
}
}

View File

@ -0,0 +1,43 @@
/*
* Codename Minosoft
* Copyright (C) 2020 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.game.datatypes.entities.objects;
import de.bixilon.minosoft.game.datatypes.entities.Location;
import de.bixilon.minosoft.game.datatypes.entities.ObjectInterface;
import de.bixilon.minosoft.game.datatypes.entities.Velocity;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import java.util.HashMap;
public class MinecartTNT extends Minecart implements ObjectInterface {
public MinecartTNT(int entityId, Location location, short yaw, short pitch, int additionalInt) {
super(entityId, location, yaw, pitch, additionalInt, null);
}
public MinecartTNT(int entityId, Location location, short yaw, short pitch, int additionalInt, Velocity velocity) {
super(entityId, location, yaw, pitch, additionalInt, velocity);
}
public MinecartTNT(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap<Integer, EntityMetaData.MetaDataSet> sets, ProtocolVersion version) {
super(entityId, location, yaw, pitch, 0, velocity);
}
@Override
public MinecartType getType() {
return MinecartType.TNT;
}
}

View File

@ -41,6 +41,7 @@ public class PacketEntityMetadata implements ClientboundPacket {
case VERSION_1_10:
case VERSION_1_11_2:
case VERSION_1_12_2:
case VERSION_1_13_2:
entityId = buffer.readVarInt();
break;
default:

View File

@ -37,7 +37,7 @@ public class PacketSpawnMob implements ClientboundPacket {
case VERSION_1_7_10:
case VERSION_1_8: {
int entityId = buffer.readVarInt();
Entities type = Entities.byId(buffer.readByte());
Entities type = Entities.byId(buffer.readByte(), buffer.getVersion());
Location location = new Location(buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger());
short yaw = buffer.readAngle();
short pitch = buffer.readAngle();
@ -58,7 +58,7 @@ public class PacketSpawnMob implements ClientboundPacket {
case VERSION_1_10: {
int entityId = buffer.readVarInt();
UUID uuid = buffer.readUUID();
Entities type = Entities.byId(buffer.readByte());
Entities type = Entities.byId(buffer.readByte(), buffer.getVersion());
Location location = new Location(buffer.readDouble(), buffer.readDouble(), buffer.readDouble());
short yaw = buffer.readAngle();
short pitch = buffer.readAngle();
@ -79,7 +79,7 @@ public class PacketSpawnMob implements ClientboundPacket {
case VERSION_1_13_2: {
int entityId = buffer.readVarInt();
UUID uuid = buffer.readUUID();
Entities type = Entities.byId(buffer.readVarInt());
Entities type = Entities.byId(buffer.readVarInt(), buffer.getVersion());
Location location = new Location(buffer.readDouble(), buffer.readDouble(), buffer.readDouble());
short yaw = buffer.readAngle();
short pitch = buffer.readAngle();

View File

@ -366,7 +366,8 @@ public class InByteBuffer {
}
break;
}
case VERSION_1_12_2: {
case VERSION_1_12_2:
case VERSION_1_13_2: {
byte index = readByte();
while (index != (byte) 0xFF) {
EntityMetaData.Types type = EntityMetaData.Types.byId(readVarInt(), version);