AbstractProjectile now extends Entity and not ObjectEntity

This commit is contained in:
Konstantin Shandurenko 2021-02-25 13:07:55 +03:00
parent 8ca43c4caa
commit 046ebc03f6
7 changed files with 7 additions and 18 deletions

View File

@ -2,12 +2,11 @@ package net.minestom.server.entity.metadata.arrow;
import net.minestom.server.entity.Entity; import net.minestom.server.entity.Entity;
import net.minestom.server.entity.Metadata; import net.minestom.server.entity.Metadata;
import net.minestom.server.entity.metadata.EntityMeta;
import net.minestom.server.entity.metadata.ObjectDataProvider; import net.minestom.server.entity.metadata.ObjectDataProvider;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class ArrowMeta extends EntityMeta implements ObjectDataProvider { public class ArrowMeta extends AbstractArrowMeta implements ObjectDataProvider {
private Entity shooter; private Entity shooter;

View File

@ -8,12 +8,13 @@ import net.minestom.server.utils.Position;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public abstract class AbstractProjectile extends ObjectEntity implements Projectile { public abstract class AbstractProjectile extends Entity implements Projectile {
private final Entity shooter; private final Entity shooter;
public AbstractProjectile(@Nullable Entity shooter, @NotNull EntityType entityType, @NotNull Position spawnPosition) { public AbstractProjectile(@Nullable Entity shooter, @NotNull EntityType entityType, @NotNull Position spawnPosition) {
super(entityType, spawnPosition); super(entityType, spawnPosition);
setGravity(0.02f, 0.04f, 1.96f);
this.shooter = shooter; this.shooter = shooter;
} }

View File

@ -119,10 +119,4 @@ public class EntityAbstractArrow extends AbstractProjectile {
return false; return false;
} }
@Override
public int getObjectData() {
Entity shooter = getShooter();
return shooter == null ? 0 : shooter.getEntityId() + 1;
}
} }

View File

@ -3,6 +3,7 @@ package net.minestom.server.entity.type.projectile;
import net.minestom.server.entity.Entity; import net.minestom.server.entity.Entity;
import net.minestom.server.entity.EntityType; import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.Metadata; import net.minestom.server.entity.Metadata;
import net.minestom.server.entity.metadata.arrow.ArrowMeta;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -11,6 +12,7 @@ public class EntityArrow extends EntityAbstractArrow {
public EntityArrow(@Nullable Entity shooter, @NotNull Position spawnPosition) { public EntityArrow(@Nullable Entity shooter, @NotNull Position spawnPosition) {
super(shooter, EntityType.ARROW, spawnPosition); super(shooter, EntityType.ARROW, spawnPosition);
((ArrowMeta) getEntityMeta()).setShooter(shooter);
} }
} }

View File

@ -40,8 +40,4 @@ public class EntityEyeOfEnder extends AbstractProjectile {
this.metadata.setIndex((byte) 7, Metadata.Slot(itemStack)); this.metadata.setIndex((byte) 7, Metadata.Slot(itemStack));
} }
@Override
public int getObjectData() {
return 0;
}
} }

View File

@ -20,11 +20,6 @@ public class EntityPotion extends AbstractProjectile {
setPotion(potion); setPotion(potion);
} }
@Override
public int getObjectData() {
return 0;
}
@NotNull @NotNull
public ItemStack getPotion() { public ItemStack getPotion() {
return metadata.getIndex((byte) 7, ItemStack.getAirItem()); return metadata.getIndex((byte) 7, ItemStack.getAirItem());

View File

@ -2,6 +2,7 @@ package net.minestom.server.entity.type.projectile;
import net.minestom.server.entity.Entity; import net.minestom.server.entity.Entity;
import net.minestom.server.entity.EntityType; import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.metadata.arrow.SpectralArrowMeta;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -10,6 +11,7 @@ public class EntitySpectralArrow extends EntityAbstractArrow {
public EntitySpectralArrow(@Nullable Entity shooter, @NotNull Position spawnPosition) { public EntitySpectralArrow(@Nullable Entity shooter, @NotNull Position spawnPosition) {
super(shooter, EntityType.SPECTRAL_ARROW, spawnPosition); super(shooter, EntityType.SPECTRAL_ARROW, spawnPosition);
((SpectralArrowMeta) getEntityMeta()).setShooter(shooter);
} }
} }