use of org.bukkit.craftbukkit.v.entity.CraftEntity in project Arclight by IzzelAliz.
the class EntityMixin method addPassenger.
public boolean addPassenger(Entity entity) {
if (entity.getRidingEntity() != (Object) this) {
throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)");
} else {
// CraftBukkit start
com.google.common.base.Preconditions.checkState(!((EntityBridge) entity).bridge$getPassengers().contains(this), "Circular entity riding! %s %s", this, entity);
CraftEntity craft = (CraftEntity) ((EntityBridge) entity).bridge$getBukkitEntity().getVehicle();
Entity orig = craft == null ? null : craft.getHandle();
if (getBukkitEntity() instanceof Vehicle && ((EntityBridge) entity).bridge$getBukkitEntity() instanceof org.bukkit.entity.LivingEntity) {
VehicleEnterEvent event = new VehicleEnterEvent((Vehicle) getBukkitEntity(), ((EntityBridge) entity).bridge$getBukkitEntity());
// Suppress during worldgen
if (this.valid) {
Bukkit.getPluginManager().callEvent(event);
}
CraftEntity craftn = (CraftEntity) ((EntityBridge) entity).bridge$getBukkitEntity().getVehicle();
Entity n = craftn == null ? null : craftn.getHandle();
if (event.isCancelled() || n != orig) {
return false;
}
}
// CraftBukkit end
// Spigot start
org.spigotmc.event.entity.EntityMountEvent event = new org.spigotmc.event.entity.EntityMountEvent(((EntityBridge) entity).bridge$getBukkitEntity(), this.getBukkitEntity());
// Suppress during worldgen
if (this.valid) {
Bukkit.getPluginManager().callEvent(event);
}
if (event.isCancelled()) {
return false;
}
// Spigot end
if (!this.world.isRemote && entity instanceof PlayerEntity && !(this.getControllingPassenger() instanceof PlayerEntity)) {
this.passengers.add(0, entity);
} else {
this.passengers.add(entity);
}
}
// CraftBukkit
return true;
}
use of org.bukkit.craftbukkit.v.entity.CraftEntity in project Arclight by IzzelAliz.
the class EggEntityMixin method onImpact.
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
protected void onImpact(final RayTraceResult movingobjectposition) {
if (movingobjectposition.getType() == RayTraceResult.Type.ENTITY) {
((EntityRayTraceResult) movingobjectposition).getEntity().attackEntityFrom(DamageSource.causeThrownDamage((EggEntity) (Object) this, this.getThrower()), 0.0f);
}
if (!this.world.isRemote) {
boolean hatching = this.rand.nextInt(8) == 0;
byte b0 = 1;
if (this.rand.nextInt(32) == 0) {
b0 = 4;
}
if (!hatching) {
b0 = 0;
}
org.bukkit.entity.EntityType hatchingType = org.bukkit.entity.EntityType.CHICKEN;
final Entity shooter = this.getThrower();
if (shooter instanceof ServerPlayerEntity) {
final PlayerEggThrowEvent event = new PlayerEggThrowEvent(((ServerPlayerEntityBridge) shooter).bridge$getBukkitEntity(), (Egg) this.getBukkitEntity(), hatching, b0, hatchingType);
Bukkit.getPluginManager().callEvent(event);
b0 = event.getNumHatches();
hatching = event.isHatching();
hatchingType = event.getHatchingType();
}
if (hatching) {
for (int i = 0; i < b0; ++i) {
Entity entity = ((CraftEntity) ((WorldBridge) this.world).bridge$getWorld().spawnEntity(new Location(((WorldBridge) this.world).bridge$getWorld(), this.posX, this.posY, this.posZ, this.rotationYaw, 0.0f), hatchingType)).getHandle();
if (((EntityBridge) entity).bridge$getBukkitEntity() instanceof Ageable) {
((Ageable) ((EntityBridge) entity).bridge$getBukkitEntity()).setBaby();
}
((WorldBridge) this.world).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.EGG);
this.world.getWorld().addEntity(entity);
}
}
this.world.setEntityState((EggEntity) (Object) this, (byte) 3);
this.remove();
}
}
use of org.bukkit.craftbukkit.v.entity.CraftEntity in project Arclight by IzzelAliz.
the class FollowOwnerGoalMixin_1_14 method arclight$teleport.
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/TameableEntity;setLocationAndAngles(DDDFF)V"))
public void arclight$teleport(TameableEntity tameableEntity, double x, double y, double z, float yaw, float pitch) {
CraftEntity craftEntity = ((EntityBridge) this.tameable).bridge$getBukkitEntity();
Location location = new Location(craftEntity.getWorld(), x, y, z, yaw, pitch);
EntityTeleportEvent event = new EntityTeleportEvent(craftEntity, craftEntity.getLocation(), location);
Bukkit.getPluginManager().callEvent(event);
if (!(arclight$cancelled = event.isCancelled())) {
tameableEntity.setLocationAndAngles(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch());
}
}
use of org.bukkit.craftbukkit.v.entity.CraftEntity in project Arclight by IzzelAliz.
the class FollowOwnerGoalMixin_1_15 method arclight$teleport.
@Redirect(method = "tryToTeleportToLocation", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/TameableEntity;setLocationAndAngles(DDDFF)V"))
public void arclight$teleport(TameableEntity tameableEntity, double x, double y, double z, float yaw, float pitch) {
CraftEntity craftEntity = ((EntityBridge) this.tameable).bridge$getBukkitEntity();
Location location = new Location(craftEntity.getWorld(), x, y, z, yaw, pitch);
EntityTeleportEvent event = new EntityTeleportEvent(craftEntity, craftEntity.getLocation(), location);
Bukkit.getPluginManager().callEvent(event);
if (!(arclight$cancelled = event.isCancelled())) {
tameableEntity.setLocationAndAngles(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch());
}
}
use of org.bukkit.craftbukkit.v.entity.CraftEntity in project Arclight by IzzelAliz.
the class EntityMixin method removePassenger.
public boolean removePassenger(Entity entity) {
// CraftBukkit
if (entity.getRidingEntity() == (Object) this) {
throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)");
} else {
// CraftBukkit start
CraftEntity craft = (CraftEntity) ((EntityBridge) entity).bridge$getBukkitEntity().getVehicle();
Entity orig = craft == null ? null : craft.getHandle();
if (getBukkitEntity() instanceof Vehicle && ((EntityBridge) entity).bridge$getBukkitEntity() instanceof org.bukkit.entity.LivingEntity) {
VehicleExitEvent event = new VehicleExitEvent((Vehicle) getBukkitEntity(), (org.bukkit.entity.LivingEntity) ((EntityBridge) entity).bridge$getBukkitEntity());
Bukkit.getPluginManager().callEvent(event);
CraftEntity craftn = (CraftEntity) ((EntityBridge) entity).bridge$getBukkitEntity().getVehicle();
Entity n = craftn == null ? null : craftn.getHandle();
if (event.isCancelled() || n != orig) {
return false;
}
}
// CraftBukkit end
// Spigot start
org.spigotmc.event.entity.EntityDismountEvent event = new org.spigotmc.event.entity.EntityDismountEvent(((EntityBridge) entity).bridge$getBukkitEntity(), this.getBukkitEntity());
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return false;
}
// Spigot end
this.passengers.remove(entity);
((EntityBridge) entity).bridge$setRideCooldown(60);
}
// CraftBukkit
return true;
}
Aggregations