@@ -54,7 +54,7 @@ public class CraftBlockProjectileSource implements BlockProjectileSource {
|
||||
|
||||
@Override
|
||||
public Block getBlock() {
|
||||
return dispenserBlock.getWorld().getWorld().getBlockAt(dispenserBlock.getPosition().getX(), dispenserBlock.getPosition().getY(), dispenserBlock.getPosition().getZ());
|
||||
return dispenserBlock.getLevel().getWorld().getBlockAt(dispenserBlock.getBlockPos().getX(), dispenserBlock.getBlockPos().getY(), dispenserBlock.getBlockPos().getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,63 +66,63 @@ public class CraftBlockProjectileSource implements BlockProjectileSource {
|
||||
public <T extends Projectile> T launchProjectile(Class<? extends T> projectile, Vector velocity) {
|
||||
Validate.isTrue(getBlock().getType() == Material.DISPENSER, "Block is no longer dispenser");
|
||||
// Copied from BlockDispenser.dispense()
|
||||
SourceBlock isourceblock = new SourceBlock((WorldServer) dispenserBlock.getWorld(), dispenserBlock.getPosition());
|
||||
SourceBlock isourceblock = new SourceBlock((WorldServer) dispenserBlock.getLevel(), dispenserBlock.getBlockPos());
|
||||
// Copied from DispenseBehaviorProjectile
|
||||
IPosition iposition = BlockDispenser.a(isourceblock);
|
||||
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING);
|
||||
net.minecraft.world.level.World world = dispenserBlock.getWorld();
|
||||
IPosition iposition = BlockDispenser.getDispensePosition(isourceblock);
|
||||
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING);
|
||||
net.minecraft.world.level.World world = dispenserBlock.getLevel();
|
||||
net.minecraft.world.entity.Entity launch = null;
|
||||
|
||||
if (Snowball.class.isAssignableFrom(projectile)) {
|
||||
launch = new EntitySnowball(world, iposition.getX(), iposition.getY(), iposition.getZ());
|
||||
launch = new EntitySnowball(world, iposition.x(), iposition.y(), iposition.z());
|
||||
} else if (Egg.class.isAssignableFrom(projectile)) {
|
||||
launch = new EntityEgg(world, iposition.getX(), iposition.getY(), iposition.getZ());
|
||||
launch = new EntityEgg(world, iposition.x(), iposition.y(), iposition.z());
|
||||
} else if (EnderPearl.class.isAssignableFrom(projectile)) {
|
||||
launch = new EntityEnderPearl(world, null);
|
||||
launch.setPosition(iposition.getX(), iposition.getY(), iposition.getZ());
|
||||
launch.setPos(iposition.x(), iposition.y(), iposition.z());
|
||||
} else if (ThrownExpBottle.class.isAssignableFrom(projectile)) {
|
||||
launch = new EntityThrownExpBottle(world, iposition.getX(), iposition.getY(), iposition.getZ());
|
||||
launch = new EntityThrownExpBottle(world, iposition.x(), iposition.y(), iposition.z());
|
||||
} else if (ThrownPotion.class.isAssignableFrom(projectile)) {
|
||||
if (LingeringPotion.class.isAssignableFrom(projectile)) {
|
||||
launch = new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ());
|
||||
launch = new EntityPotion(world, iposition.x(), iposition.y(), iposition.z());
|
||||
((EntityPotion) launch).setItem(CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.LINGERING_POTION, 1)));
|
||||
} else {
|
||||
launch = new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ());
|
||||
launch = new EntityPotion(world, iposition.x(), iposition.y(), iposition.z());
|
||||
((EntityPotion) launch).setItem(CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.SPLASH_POTION, 1)));
|
||||
}
|
||||
} else if (AbstractArrow.class.isAssignableFrom(projectile)) {
|
||||
if (TippedArrow.class.isAssignableFrom(projectile)) {
|
||||
launch = new EntityTippedArrow(world, iposition.getX(), iposition.getY(), iposition.getZ());
|
||||
((EntityTippedArrow) launch).setType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false)));
|
||||
launch = new EntityTippedArrow(world, iposition.x(), iposition.y(), iposition.z());
|
||||
((EntityTippedArrow) launch).setPotionType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false)));
|
||||
} else if (SpectralArrow.class.isAssignableFrom(projectile)) {
|
||||
launch = new EntitySpectralArrow(world, iposition.getX(), iposition.getY(), iposition.getZ());
|
||||
launch = new EntitySpectralArrow(world, iposition.x(), iposition.y(), iposition.z());
|
||||
} else {
|
||||
launch = new EntityTippedArrow(world, iposition.getX(), iposition.getY(), iposition.getZ());
|
||||
launch = new EntityTippedArrow(world, iposition.x(), iposition.y(), iposition.z());
|
||||
}
|
||||
((EntityArrow) launch).pickup = EntityArrow.PickupStatus.ALLOWED;
|
||||
((EntityArrow) launch).projectileSource = this;
|
||||
} else if (Fireball.class.isAssignableFrom(projectile)) {
|
||||
double d0 = iposition.getX() + (double) ((float) enumdirection.getAdjacentX() * 0.3F);
|
||||
double d1 = iposition.getY() + (double) ((float) enumdirection.getAdjacentY() * 0.3F);
|
||||
double d2 = iposition.getZ() + (double) ((float) enumdirection.getAdjacentZ() * 0.3F);
|
||||
double d0 = iposition.x() + (double) ((float) enumdirection.getStepX() * 0.3F);
|
||||
double d1 = iposition.y() + (double) ((float) enumdirection.getStepY() * 0.3F);
|
||||
double d2 = iposition.z() + (double) ((float) enumdirection.getStepZ() * 0.3F);
|
||||
Random random = world.random;
|
||||
double d3 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentX();
|
||||
double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentY();
|
||||
double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentZ();
|
||||
double d3 = random.nextGaussian() * 0.05D + (double) enumdirection.getStepX();
|
||||
double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getStepY();
|
||||
double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getStepZ();
|
||||
|
||||
if (SmallFireball.class.isAssignableFrom(projectile)) {
|
||||
launch = new EntitySmallFireball(world, null, d0, d1, d2);
|
||||
} else if (WitherSkull.class.isAssignableFrom(projectile)) {
|
||||
launch = EntityTypes.WITHER_SKULL.a(world);
|
||||
launch.setPosition(d0, d1, d2);
|
||||
launch = EntityTypes.WITHER_SKULL.create(world);
|
||||
launch.setPos(d0, d1, d2);
|
||||
double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
|
||||
|
||||
((EntityFireball) launch).xPower = d3 / d6 * 0.1D;
|
||||
((EntityFireball) launch).yPower = d4 / d6 * 0.1D;
|
||||
((EntityFireball) launch).zPower = d5 / d6 * 0.1D;
|
||||
} else {
|
||||
launch = EntityTypes.FIREBALL.a(world);
|
||||
launch.setPosition(d0, d1, d2);
|
||||
launch = EntityTypes.FIREBALL.create(world);
|
||||
launch.setPos(d0, d1, d2);
|
||||
double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
|
||||
|
||||
((EntityFireball) launch).xPower = d3 / d6 * 0.1D;
|
||||
@@ -148,14 +148,14 @@ public class CraftBlockProjectileSource implements BlockProjectileSource {
|
||||
b *= 1.25F;
|
||||
}
|
||||
// Copied from DispenseBehaviorProjectile
|
||||
((IProjectile) launch).shoot((double) enumdirection.getAdjacentX(), (double) ((float) enumdirection.getAdjacentY() + 0.1F), (double) enumdirection.getAdjacentZ(), b, a);
|
||||
((IProjectile) launch).shoot((double) enumdirection.getStepX(), (double) ((float) enumdirection.getStepY() + 0.1F), (double) enumdirection.getStepZ(), b, a);
|
||||
}
|
||||
|
||||
if (velocity != null) {
|
||||
((T) launch.getBukkitEntity()).setVelocity(velocity);
|
||||
}
|
||||
|
||||
world.addEntity(launch);
|
||||
world.addFreshEntity(launch);
|
||||
return (T) launch.getBukkitEntity();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user