EntityObjects wip (2)

This commit is contained in:
bixilon 2020-06-12 23:36:48 +02:00
parent ff687914ad
commit f6508ff891
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
16 changed files with 990 additions and 2 deletions

View File

@ -14,10 +14,24 @@
package de.bixilon.minosoft.game.datatypes.entities;
import de.bixilon.minosoft.game.datatypes.Identifier;
import de.bixilon.minosoft.game.datatypes.entities.objects.Boat;
import de.bixilon.minosoft.game.datatypes.entities.objects.*;
public enum Objects implements EntityEnumInterface {
BOAT(new Identifier("boat"), 1, Boat.class);
BOAT(new Identifier("boat"), 1, Boat.class),
ITEM_STACK(null, 2, ItemStack.class),
MINECART(new Identifier("minecart"), 10, Minecart.class),
PRIMED_TNT(new Identifier("tnt"), 50, PrimedTNT.class),
ENDER_CRYSTAL(new Identifier("ender_crystal"), 51, EnderCrystal.class),
ARROW(new Identifier("arrow"), 60, Arrow.class),
SNOWBALL(new Identifier("snowball"), 61, Snowball.class),
EGG(new Identifier("egg"), 62, Egg.class),
FIRE_BALL(new Identifier("fire_ball"), 63, FireBall.class),
FIRE_CHARGE(new Identifier("fire_charge"), 64, FireCharge.class),
ENDER_PEARL(new Identifier("ender_pearl"), 65, Enderpearl.class),
WITHER_SKULL(new Identifier("wither_skull"), 66, WitherSkull.class),
FALLING_BLOCK(new Identifier("falling_block"), 70, FallingBlock.class),
ITEM_FRAME(new Identifier("item_frame"), 71, ItemFrame.class),
;
final Identifier identifier;
final int type;

View File

@ -52,6 +52,9 @@ public class EntityMetaData {
case VECTOR:
data = new Vector(buffer.readInteger(), buffer.readInteger(), buffer.readInteger());
break;
case SLOT:
data = buffer.readSlot(v);
break;
default:
throw new IllegalStateException("Unexpected value: " + type);
}

View File

@ -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 <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.EntityObject;
import de.bixilon.minosoft.game.datatypes.entities.Location;
import de.bixilon.minosoft.game.datatypes.entities.ObjectInterface;
import de.bixilon.minosoft.game.datatypes.entities.Objects;
import de.bixilon.minosoft.game.datatypes.entities.meta.ArrowMetaData;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Arrow extends EntityObject implements ObjectInterface {
ArrowMetaData metaData;
int shooter;
public Arrow(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
this.shooter = additionalInt;
}
@Override
public Objects getEntityType() {
return Objects.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;
}
}

View File

@ -0,0 +1,67 @@
/*
* 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.EntityObject;
import de.bixilon.minosoft.game.datatypes.entities.Location;
import de.bixilon.minosoft.game.datatypes.entities.ObjectInterface;
import de.bixilon.minosoft.game.datatypes.entities.Objects;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Egg extends EntityObject implements ObjectInterface {
EntityMetaData metaData;
int thrower;
public Egg(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
this.thrower = additionalInt;
}
@Override
public Objects getEntityType() {
return Objects.EGG;
}
@Override
public EntityMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
this.metaData = metaData;
}
@Override
public float getWidth() {
return 0.25F;
}
@Override
public float getHeight() {
return 0.25F;
}
@Override
public Class<? extends EntityMetaData> getMetaDataClass() {
return EntityMetaData.class;
}
public int getThrower() {
return thrower;
}
}

View File

@ -0,0 +1,62 @@
/*
* 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.EntityObject;
import de.bixilon.minosoft.game.datatypes.entities.Location;
import de.bixilon.minosoft.game.datatypes.entities.ObjectInterface;
import de.bixilon.minosoft.game.datatypes.entities.Objects;
import de.bixilon.minosoft.game.datatypes.entities.meta.EnderCrystalMetaData;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class EnderCrystal extends EntityObject implements ObjectInterface {
EnderCrystalMetaData metaData;
public EnderCrystal(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
}
@Override
public Objects getEntityType() {
return Objects.ENDER_CRYSTAL;
}
@Override
public EnderCrystalMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
this.metaData = (EnderCrystalMetaData) metaData;
}
@Override
public float getWidth() {
return 2F;
}
@Override
public float getHeight() {
return 2F;
}
@Override
public Class<? extends EntityMetaData> getMetaDataClass() {
return EnderCrystalMetaData.class;
}
}

View File

@ -0,0 +1,62 @@
/*
* 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.EntityObject;
import de.bixilon.minosoft.game.datatypes.entities.Location;
import de.bixilon.minosoft.game.datatypes.entities.ObjectInterface;
import de.bixilon.minosoft.game.datatypes.entities.Objects;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Enderpearl extends EntityObject implements ObjectInterface {
EntityMetaData metaData;
public Enderpearl(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
}
@Override
public Objects getEntityType() {
return Objects.ENDER_PEARL;
}
@Override
public EntityMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
this.metaData = metaData;
}
@Override
public float getWidth() {
return 0.25F;
}
@Override
public float getHeight() {
return 0.25F;
}
@Override
public Class<? extends EntityMetaData> getMetaDataClass() {
return EntityMetaData.class;
}
}

View File

@ -0,0 +1,62 @@
/*
* 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.EntityObject;
import de.bixilon.minosoft.game.datatypes.entities.Location;
import de.bixilon.minosoft.game.datatypes.entities.ObjectInterface;
import de.bixilon.minosoft.game.datatypes.entities.Objects;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class EyeOfEnder extends EntityObject implements ObjectInterface {
EntityMetaData metaData;
public EyeOfEnder(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
}
@Override
public Objects getEntityType() {
return Objects.EYE_OF_ENDER;
}
@Override
public EntityMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
this.metaData = metaData;
}
@Override
public float getWidth() {
return 0.25F;
}
@Override
public float getHeight() {
return 0.25F;
}
@Override
public Class<? extends EntityMetaData> getMetaDataClass() {
return EntityMetaData.class;
}
}

View File

@ -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 <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.blocks.Block;
import de.bixilon.minosoft.game.datatypes.entities.EntityObject;
import de.bixilon.minosoft.game.datatypes.entities.Location;
import de.bixilon.minosoft.game.datatypes.entities.ObjectInterface;
import de.bixilon.minosoft.game.datatypes.entities.Objects;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class FallingBlock extends EntityObject implements ObjectInterface {
EntityMetaData metaData;
Block block;
public FallingBlock(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
block = Block.byLegacy(additionalInt & 0xFFF, additionalInt >> 12);
}
@Override
public Objects getEntityType() {
return Objects.FALLING_BLOCK;
}
@Override
public EntityMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
this.metaData = metaData;
}
@Override
public float getWidth() {
return 0.98F;
}
@Override
public float getHeight() {
return 0.98F;
}
@Override
public Class<? extends EntityMetaData> getMetaDataClass() {
return EntityMetaData.class;
}
public Block getBlock() {
return block;
}
}

View File

@ -0,0 +1,67 @@
/*
* 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.EntityObject;
import de.bixilon.minosoft.game.datatypes.entities.Location;
import de.bixilon.minosoft.game.datatypes.entities.ObjectInterface;
import de.bixilon.minosoft.game.datatypes.entities.Objects;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class FireBall extends EntityObject implements ObjectInterface {
EntityMetaData metaData;
int thrower;
public FireBall(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
this.thrower = additionalInt;
}
@Override
public Objects getEntityType() {
return Objects.FIRE_BALL;
}
@Override
public EntityMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
this.metaData = metaData;
}
@Override
public float getWidth() {
return 1.0F;
}
@Override
public float getHeight() {
return 1.0F;
}
@Override
public Class<? extends EntityMetaData> getMetaDataClass() {
return EntityMetaData.class;
}
public int getThrower() {
return thrower;
}
}

View File

@ -0,0 +1,67 @@
/*
* 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.EntityObject;
import de.bixilon.minosoft.game.datatypes.entities.Location;
import de.bixilon.minosoft.game.datatypes.entities.ObjectInterface;
import de.bixilon.minosoft.game.datatypes.entities.Objects;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class FireCharge extends EntityObject implements ObjectInterface {
EntityMetaData metaData;
int thrower;
public FireCharge(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
this.thrower = additionalInt;
}
@Override
public Objects getEntityType() {
return Objects.FIRE_CHARGE;
}
@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;
}
@Override
public Class<? extends EntityMetaData> getMetaDataClass() {
return EntityMetaData.class;
}
public int getThrower() {
return thrower;
}
}

View File

@ -0,0 +1,95 @@
/*
* 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.EntityObject;
import de.bixilon.minosoft.game.datatypes.entities.Location;
import de.bixilon.minosoft.game.datatypes.entities.ObjectInterface;
import de.bixilon.minosoft.game.datatypes.entities.Objects;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.game.datatypes.entities.meta.ItemFrameMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class ItemFrame extends EntityObject implements ObjectInterface {
ItemFrameMetaData metaData;
FrameDirection direction;
public ItemFrame(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
direction = FrameDirection.byId(additionalInt);
}
@Override
public Objects getEntityType() {
return Objects.ITEM_FRAME;
}
@Override
public ItemFrameMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
this.metaData = (ItemFrameMetaData) metaData;
}
@Override
public float getWidth() {
return 1.0F; //ToDo
}
@Override
public float getHeight() {
return 1.0F; //ToDo
}
@Override
public Class<? extends EntityMetaData> getMetaDataClass() {
return ItemFrameMetaData.class;
}
public FrameDirection getDirection() { // orientation
return direction;
}
public enum FrameDirection {
SOUTH(0),
WEST(1),
NORTH(2),
EAST(3);
final int id;
FrameDirection(int id) {
this.id = id;
}
public static FrameDirection byId(int id) {
for (FrameDirection d : values()) {
if (d.getId() == id) {
return d;
}
}
return null;
}
public int getId() {
return id;
}
}
}

View File

@ -0,0 +1,62 @@
/*
* 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.EntityObject;
import de.bixilon.minosoft.game.datatypes.entities.Location;
import de.bixilon.minosoft.game.datatypes.entities.ObjectInterface;
import de.bixilon.minosoft.game.datatypes.entities.Objects;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.game.datatypes.entities.meta.ItemMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class ItemStack extends EntityObject implements ObjectInterface {
ItemMetaData metaData;
public ItemStack(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
}
@Override
public Objects getEntityType() {
return Objects.ITEM_STACK;
}
@Override
public ItemMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
this.metaData = (ItemMetaData) metaData;
}
@Override
public float getWidth() {
return 0.25F;
}
@Override
public float getHeight() {
return 0.25F;
}
@Override
public Class<? extends EntityMetaData> getMetaDataClass() {
return ItemMetaData.class;
}
}

View File

@ -0,0 +1,96 @@
/*
* 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.EntityObject;
import de.bixilon.minosoft.game.datatypes.entities.Location;
import de.bixilon.minosoft.game.datatypes.entities.ObjectInterface;
import de.bixilon.minosoft.game.datatypes.entities.Objects;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.game.datatypes.entities.meta.MinecartMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Minecart extends EntityObject implements ObjectInterface {
MinecartType type;
MinecartMetaData metaData;
public Minecart(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null);
type = MinecartType.byType(additionalInt);
}
@Override
public Objects getEntityType() {
return Objects.MINECART;
}
@Override
public MinecartMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
this.metaData = (MinecartMetaData) metaData;
}
@Override
public float getWidth() {
return 0.98F;
}
@Override
public float getHeight() {
return 0.7F;
}
@Override
public Class<? extends EntityMetaData> getMetaDataClass() {
return MinecartMetaData.class;
}
public MinecartType getType() {
return type;
}
public enum MinecartType {
EMPTY(0),
CHEST_MINECART(1),
FURNACE_MINECART(2),
TNT_MINECART(3),
SPAWNER_MINECART(3),
HOPPPER_MINECART(4),
HOPPER_MINECART(5),
COMMAND_BLOCK_MINECART(6);
final int id;
MinecartType(int id) {
this.id = id;
}
public static MinecartType byType(int type) {
for (MinecartType t : values()) {
if (t.getId() == type) {
return t;
}
}
return null;
}
public int getId() {
return id;
}
}
}

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.objects;
import de.bixilon.minosoft.game.datatypes.entities.EntityObject;
import de.bixilon.minosoft.game.datatypes.entities.Location;
import de.bixilon.minosoft.game.datatypes.entities.ObjectInterface;
import de.bixilon.minosoft.game.datatypes.entities.Objects;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class PrimedTNT extends EntityObject implements ObjectInterface {
EntityMetaData metaData;
public PrimedTNT(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
}
@Override
public Objects getEntityType() {
return Objects.PRIMED_TNT;
}
@Override
public EntityMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
this.metaData = metaData;
}
@Override
public float getWidth() {
return 0.98F;
}
@Override
public float getHeight() {
return 0.98F;
}
@Override
public Class<? extends EntityMetaData> getMetaDataClass() {
return EntityMetaData.class;
}
}

View File

@ -0,0 +1,67 @@
/*
* 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.EntityObject;
import de.bixilon.minosoft.game.datatypes.entities.Location;
import de.bixilon.minosoft.game.datatypes.entities.ObjectInterface;
import de.bixilon.minosoft.game.datatypes.entities.Objects;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Snowball extends EntityObject implements ObjectInterface {
EntityMetaData metaData;
int thrower;
public Snowball(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
this.thrower = additionalInt;
}
@Override
public Objects getEntityType() {
return Objects.SNOWBALL;
}
@Override
public EntityMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
this.metaData = metaData;
}
@Override
public float getWidth() {
return 0.25F;
}
@Override
public float getHeight() {
return 0.25F;
}
@Override
public Class<? extends EntityMetaData> getMetaDataClass() {
return EntityMetaData.class;
}
public int getThrower() {
return thrower;
}
}

View File

@ -0,0 +1,67 @@
/*
* 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.EntityObject;
import de.bixilon.minosoft.game.datatypes.entities.Location;
import de.bixilon.minosoft.game.datatypes.entities.ObjectInterface;
import de.bixilon.minosoft.game.datatypes.entities.Objects;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class WitherSkull extends EntityObject implements ObjectInterface {
EntityMetaData metaData;
int thrower;
public WitherSkull(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
this.thrower = additionalInt;
}
@Override
public Objects getEntityType() {
return Objects.WITHER_SKULL;
}
@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;
}
@Override
public Class<? extends EntityMetaData> getMetaDataClass() {
return EntityMetaData.class;
}
public int getThrower() {
return thrower;
}
}