use of net.minecraft.entity.projectile.EntityWitherSkull in project UtilityClient2 by Utility-Client.
the class EntityWither method launchWitherSkullToCoords.
/**
* Launches a Wither skull toward (par2, par4, par6)
*/
private void launchWitherSkullToCoords(int p_82209_1_, double x, double y, double z, boolean invulnerable) {
this.worldObj.playAuxSFXAtEntity((EntityPlayer) null, 1014, new BlockPos(this), 0);
double d0 = this.func_82214_u(p_82209_1_);
double d1 = this.func_82208_v(p_82209_1_);
double d2 = this.func_82213_w(p_82209_1_);
double d3 = x - d0;
double d4 = y - d1;
double d5 = z - d2;
EntityWitherSkull entitywitherskull = new EntityWitherSkull(this.worldObj, this, d3, d4, d5);
if (invulnerable) {
entitywitherskull.setInvulnerable(true);
}
entitywitherskull.posY = d1;
entitywitherskull.posX = d0;
entitywitherskull.posZ = d2;
this.worldObj.spawnEntityInWorld(entitywitherskull);
}
use of net.minecraft.entity.projectile.EntityWitherSkull in project UtilityClient2 by Utility-Client.
the class RenderGlobal method renderEntities.
public void renderEntities(Entity renderViewEntity, ICamera camera, float partialTicks) {
if (this.renderEntitiesStartupCounter > 0) {
--this.renderEntitiesStartupCounter;
} else {
double d0 = renderViewEntity.prevPosX + (renderViewEntity.posX - renderViewEntity.prevPosX) * (double) partialTicks;
double d1 = renderViewEntity.prevPosY + (renderViewEntity.posY - renderViewEntity.prevPosY) * (double) partialTicks;
double d2 = renderViewEntity.prevPosZ + (renderViewEntity.posZ - renderViewEntity.prevPosZ) * (double) partialTicks;
this.theWorld.theProfiler.startSection("prepare");
TileEntityRendererDispatcher.instance.cacheActiveRenderInfo(this.theWorld, this.mc.getTextureManager(), this.mc.fontRendererObj, this.mc.getRenderViewEntity(), partialTicks);
this.renderManager.cacheActiveRenderInfo(this.theWorld, this.mc.fontRendererObj, this.mc.getRenderViewEntity(), this.mc.pointedEntity, this.mc.gameSettings, partialTicks);
this.countEntitiesTotal = 0;
this.countEntitiesRendered = 0;
this.countEntitiesHidden = 0;
Entity entity = this.mc.getRenderViewEntity();
double d3 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double) partialTicks;
double d4 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double) partialTicks;
double d5 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double) partialTicks;
TileEntityRendererDispatcher.staticPlayerX = d3;
TileEntityRendererDispatcher.staticPlayerY = d4;
TileEntityRendererDispatcher.staticPlayerZ = d5;
this.renderManager.setRenderPosition(d3, d4, d5);
this.mc.entityRenderer.enableLightmap();
this.theWorld.theProfiler.endStartSection("global");
List<Entity> list = this.theWorld.getLoadedEntityList();
this.countEntitiesTotal = list.size();
for (int i = 0; i < this.theWorld.weatherEffects.size(); ++i) {
Entity entity1 = (Entity) this.theWorld.weatherEffects.get(i);
++this.countEntitiesRendered;
if (entity1.isInRangeToRender3d(d0, d1, d2)) {
this.renderManager.renderEntitySimple(entity1, partialTicks);
}
}
if (this.isRenderEntityOutlines()) {
GlStateManager.depthFunc(519);
GlStateManager.disableFog();
this.entityOutlineFramebuffer.framebufferClear();
this.entityOutlineFramebuffer.bindFramebuffer(false);
this.theWorld.theProfiler.endStartSection("entityOutlines");
RenderHelper.disableStandardItemLighting();
this.renderManager.setRenderOutlines(true);
for (int j = 0; j < list.size(); ++j) {
Entity entity3 = (Entity) list.get(j);
boolean flag = this.mc.getRenderViewEntity() instanceof EntityLivingBase && ((EntityLivingBase) this.mc.getRenderViewEntity()).isPlayerSleeping();
boolean flag1 = entity3.isInRangeToRender3d(d0, d1, d2) && (entity3.ignoreFrustumCheck || camera.isBoundingBoxInFrustum(entity3.getEntityBoundingBox()) || entity3.riddenByEntity == this.mc.thePlayer) && entity3 instanceof EntityPlayer;
if ((entity3 != this.mc.getRenderViewEntity() || this.mc.gameSettings.thirdPersonView != 0 || flag) && flag1) {
this.renderManager.renderEntitySimple(entity3, partialTicks);
}
}
this.renderManager.setRenderOutlines(false);
RenderHelper.enableStandardItemLighting();
GlStateManager.depthMask(false);
this.entityOutlineShader.loadShaderGroup(partialTicks);
GlStateManager.enableLighting();
GlStateManager.depthMask(true);
this.mc.getFramebuffer().bindFramebuffer(false);
GlStateManager.enableFog();
GlStateManager.enableBlend();
GlStateManager.enableColorMaterial();
GlStateManager.depthFunc(515);
GlStateManager.enableDepth();
GlStateManager.enableAlpha();
}
this.theWorld.theProfiler.endStartSection("entities");
label738: for (RenderGlobal.ContainerLocalRenderInformation renderglobal$containerlocalrenderinformation : this.renderInfos) {
Chunk chunk = this.theWorld.getChunkFromBlockCoords(renderglobal$containerlocalrenderinformation.renderChunk.getPosition());
ClassInheritanceMultiMap<Entity> classinheritancemultimap = chunk.getEntityLists()[renderglobal$containerlocalrenderinformation.renderChunk.getPosition().getY() / 16];
if (!classinheritancemultimap.isEmpty()) {
Iterator iterator = classinheritancemultimap.iterator();
while (true) {
Entity entity2;
boolean flag2;
while (true) {
if (!iterator.hasNext()) {
continue label738;
}
entity2 = (Entity) iterator.next();
flag2 = this.renderManager.shouldRender(entity2, camera, d0, d1, d2) || entity2.riddenByEntity == this.mc.thePlayer;
if (!flag2) {
break;
}
boolean flag3 = this.mc.getRenderViewEntity() instanceof EntityLivingBase ? ((EntityLivingBase) this.mc.getRenderViewEntity()).isPlayerSleeping() : false;
if ((entity2 != this.mc.getRenderViewEntity() || this.mc.gameSettings.thirdPersonView != 0 || flag3) && (entity2.posY < 0.0D || entity2.posY >= 256.0D || this.theWorld.isBlockLoaded(new BlockPos(entity2)))) {
++this.countEntitiesRendered;
this.renderManager.renderEntitySimple(entity2, partialTicks);
break;
}
}
if (!flag2 && entity2 instanceof EntityWitherSkull) {
this.mc.getRenderManager().renderWitherSkull(entity2, partialTicks);
}
}
}
}
this.theWorld.theProfiler.endStartSection("blockentities");
RenderHelper.enableStandardItemLighting();
for (RenderGlobal.ContainerLocalRenderInformation renderglobal$containerlocalrenderinformation1 : this.renderInfos) {
List<TileEntity> list1 = renderglobal$containerlocalrenderinformation1.renderChunk.getCompiledChunk().getTileEntities();
if (!list1.isEmpty()) {
for (TileEntity tileentity2 : list1) {
TileEntityRendererDispatcher.instance.renderTileEntity(tileentity2, partialTicks, -1);
}
}
}
synchronized (this.field_181024_n) {
for (TileEntity tileentity : this.field_181024_n) {
TileEntityRendererDispatcher.instance.renderTileEntity(tileentity, partialTicks, -1);
}
}
this.preRenderDamagedBlocks();
for (DestroyBlockProgress destroyblockprogress : this.damagedBlocks.values()) {
BlockPos blockpos = destroyblockprogress.getPosition();
TileEntity tileentity1 = this.theWorld.getTileEntity(blockpos);
if (tileentity1 instanceof TileEntityChest) {
TileEntityChest tileentitychest = (TileEntityChest) tileentity1;
if (tileentitychest.adjacentChestXNeg != null) {
blockpos = blockpos.offset(EnumFacing.WEST);
tileentity1 = this.theWorld.getTileEntity(blockpos);
} else if (tileentitychest.adjacentChestZNeg != null) {
blockpos = blockpos.offset(EnumFacing.NORTH);
tileentity1 = this.theWorld.getTileEntity(blockpos);
}
}
Block block = this.theWorld.getBlockState(blockpos).getBlock();
if (tileentity1 != null && (block instanceof BlockChest || block instanceof BlockEnderChest || block instanceof BlockSign || block instanceof BlockSkull)) {
TileEntityRendererDispatcher.instance.renderTileEntity(tileentity1, partialTicks, destroyblockprogress.getPartialBlockDamage());
}
}
this.postRenderDamagedBlocks();
this.mc.entityRenderer.disableLightmap();
this.mc.mcProfiler.endSection();
}
}
use of net.minecraft.entity.projectile.EntityWitherSkull in project Magma by magmafoundation.
the class CraftBlockProjectileSource method launchProjectile.
@Override
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()
IBlockSource isourceblock = new BlockSourceImpl(dispenserBlock.getWorld(), dispenserBlock.getPos());
// Copied from DispenseBehaviorProjectile
IPosition iposition = BlockDispenser.getDispensePosition(isourceblock);
EnumFacing enumdirection = (EnumFacing) isourceblock.getBlockState().getValue(BlockDispenser.FACING);
net.minecraft.world.World world = dispenserBlock.getWorld();
net.minecraft.entity.Entity launch = null;
if (Snowball.class.isAssignableFrom(projectile)) {
launch = new EntitySnowball(world, iposition.getX(), iposition.getY(), iposition.getZ());
} else if (Egg.class.isAssignableFrom(projectile)) {
launch = new EntityEgg(world, iposition.getX(), iposition.getY(), iposition.getZ());
} else if (EnderPearl.class.isAssignableFrom(projectile)) {
launch = new EntityEnderPearl(world, null);
launch.setPosition(iposition.getX(), iposition.getY(), iposition.getZ());
} else if (ThrownExpBottle.class.isAssignableFrom(projectile)) {
launch = new EntityExpBottle(world, iposition.getX(), iposition.getY(), iposition.getZ());
} else if (ThrownPotion.class.isAssignableFrom(projectile)) {
if (LingeringPotion.class.isAssignableFrom(projectile)) {
launch = new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ(), CraftItemStack.asNMSCopy(new ItemStack(Material.LINGERING_POTION, 1)));
} else {
launch = new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ(), CraftItemStack.asNMSCopy(new ItemStack(Material.SPLASH_POTION, 1)));
}
} else if (Arrow.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)));
} else if (SpectralArrow.class.isAssignableFrom(projectile)) {
launch = new EntitySpectralArrow(world, iposition.getX(), iposition.getY(), iposition.getZ());
} else {
launch = new EntityTippedArrow(world, iposition.getX(), iposition.getY(), iposition.getZ());
}
((EntityArrow) launch).pickupStatus = EntityArrow.PickupStatus.ALLOWED;
((EntityArrow) launch).projectileSource = this;
} else if (Fireball.class.isAssignableFrom(projectile)) {
double d0 = iposition.getX() + (double) ((float) enumdirection.getFrontOffsetX() * 0.3F);
double d1 = iposition.getY() + (double) ((float) enumdirection.getFrontOffsetY() * 0.3F);
double d2 = iposition.getZ() + (double) ((float) enumdirection.getFrontOffsetZ() * 0.3F);
Random random = world.rand;
double d3 = random.nextGaussian() * 0.05D + (double) enumdirection.getFrontOffsetX();
double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getFrontOffsetY();
double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getFrontOffsetZ();
if (SmallFireball.class.isAssignableFrom(projectile)) {
launch = new EntitySmallFireball(world, null, d0, d1, d2);
} else if (WitherSkull.class.isAssignableFrom(projectile)) {
launch = new EntityWitherSkull(world);
launch.setPosition(d0, d1, d2);
double d6 = (double) MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
((EntityFireball) launch).accelerationX = d3 / d6 * 0.1D;
((EntityFireball) launch).accelerationY = d4 / d6 * 0.1D;
((EntityFireball) launch).accelerationZ = d5 / d6 * 0.1D;
} else {
launch = new EntityLargeFireball(world);
launch.setPosition(d0, d1, d2);
double d6 = (double) MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
((EntityFireball) launch).accelerationX = d3 / d6 * 0.1D;
((EntityFireball) launch).accelerationY = d4 / d6 * 0.1D;
((EntityFireball) launch).accelerationZ = d5 / d6 * 0.1D;
}
((EntityFireball) launch).projectileSource = this;
}
Validate.notNull(launch, "Projectile not supported");
if (launch instanceof IProjectile) {
if (launch instanceof EntityThrowable) {
((EntityThrowable) launch).projectileSource = this;
}
// Values from DispenseBehaviorProjectile
float a = 6.0F;
float b = 1.1F;
if (launch instanceof EntityPotion || launch instanceof ThrownExpBottle) {
// Values from respective DispenseBehavior classes
a *= 0.5F;
b *= 1.25F;
}
// Copied from DispenseBehaviorProjectile
((IProjectile) launch).shoot((double) enumdirection.getFrontOffsetX(), (double) ((float) enumdirection.getFrontOffsetY() + 0.1F), (double) enumdirection.getFrontOffsetZ(), b, a);
}
if (velocity != null) {
((T) launch.getBukkitEntity()).setVelocity(velocity);
}
world.spawnEntity(launch);
return (T) launch.getBukkitEntity();
}
use of net.minecraft.entity.projectile.EntityWitherSkull in project Magma by magmafoundation.
the class CraftWorld method createEntity.
@SuppressWarnings("unchecked")
public net.minecraft.entity.Entity createEntity(Location location, Class<? extends Entity> clazz) throws IllegalArgumentException {
if (location == null || clazz == null) {
throw new IllegalArgumentException("Location or entity class cannot be null");
}
net.minecraft.entity.Entity entity = null;
double x = location.getX();
double y = location.getY();
double z = location.getZ();
float pitch = location.getPitch();
float yaw = location.getYaw();
// order is important for some of these
if (Boat.class.isAssignableFrom(clazz)) {
entity = new EntityBoat(world, x, y, z);
entity.setLocationAndAngles(x, y, z, yaw, pitch);
} else if (FallingBlock.class.isAssignableFrom(clazz)) {
entity = new EntityFallingBlock(world, x, y, z, world.getBlockState(new BlockPos(x, y, z)));
} else if (Projectile.class.isAssignableFrom(clazz)) {
if (Snowball.class.isAssignableFrom(clazz)) {
entity = new EntitySnowball(world, x, y, z);
} else if (Egg.class.isAssignableFrom(clazz)) {
entity = new EntityEgg(world, x, y, z);
} else if (Arrow.class.isAssignableFrom(clazz)) {
if (TippedArrow.class.isAssignableFrom(clazz)) {
entity = new EntityTippedArrow(world);
((EntityTippedArrow) entity).setType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false)));
} else if (SpectralArrow.class.isAssignableFrom(clazz)) {
entity = new EntitySpectralArrow(world);
} else {
entity = new EntityTippedArrow(world);
}
entity.setLocationAndAngles(x, y, z, 0, 0);
} else if (ThrownExpBottle.class.isAssignableFrom(clazz)) {
entity = new EntityExpBottle(world);
entity.setLocationAndAngles(x, y, z, 0, 0);
} else if (EnderPearl.class.isAssignableFrom(clazz)) {
entity = new EntityEnderPearl(world);
entity.setLocationAndAngles(x, y, z, 0, 0);
} else if (ThrownPotion.class.isAssignableFrom(clazz)) {
if (LingeringPotion.class.isAssignableFrom(clazz)) {
entity = new EntityPotion(world, x, y, z, CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.LINGERING_POTION, 1)));
} else {
entity = new EntityPotion(world, x, y, z, CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.SPLASH_POTION, 1)));
}
} else if (Fireball.class.isAssignableFrom(clazz)) {
if (SmallFireball.class.isAssignableFrom(clazz)) {
entity = new EntitySmallFireball(world);
} else if (WitherSkull.class.isAssignableFrom(clazz)) {
entity = new EntityWitherSkull(world);
} else if (DragonFireball.class.isAssignableFrom(clazz)) {
entity = new EntityDragonFireball(world);
} else {
entity = new EntityLargeFireball(world);
}
entity.setLocationAndAngles(x, y, z, yaw, pitch);
Vector direction = location.getDirection().multiply(10);
((EntityFireball) entity).setDirection(direction.getX(), direction.getY(), direction.getZ());
} else if (ShulkerBullet.class.isAssignableFrom(clazz)) {
entity = new EntityShulkerBullet(world);
entity.setLocationAndAngles(x, y, z, yaw, pitch);
} else if (LlamaSpit.class.isAssignableFrom(clazz)) {
entity = new EntityLlamaSpit(world);
entity.setLocationAndAngles(x, y, z, yaw, pitch);
}
} else if (Minecart.class.isAssignableFrom(clazz)) {
if (PoweredMinecart.class.isAssignableFrom(clazz)) {
entity = new EntityMinecartFurnace(world, x, y, z);
} else if (StorageMinecart.class.isAssignableFrom(clazz)) {
entity = new EntityMinecartChest(world, x, y, z);
} else if (ExplosiveMinecart.class.isAssignableFrom(clazz)) {
entity = new EntityMinecartTNT(world, x, y, z);
} else if (HopperMinecart.class.isAssignableFrom(clazz)) {
entity = new EntityMinecartHopper(world, x, y, z);
} else if (SpawnerMinecart.class.isAssignableFrom(clazz)) {
entity = new EntityMinecartMobSpawner(world, x, y, z);
} else if (CommandMinecart.class.isAssignableFrom(clazz)) {
entity = new EntityMinecartCommandBlock(world, x, y, z);
} else {
// Default to rideable minecart for pre-rideable compatibility
entity = new EntityMinecartEmpty(world, x, y, z);
}
} else if (EnderSignal.class.isAssignableFrom(clazz)) {
entity = new EntityEnderEye(world, x, y, z);
} else if (EnderCrystal.class.isAssignableFrom(clazz)) {
entity = new EntityEnderCrystal(world);
entity.setLocationAndAngles(x, y, z, 0, 0);
} else if (LivingEntity.class.isAssignableFrom(clazz)) {
if (Chicken.class.isAssignableFrom(clazz)) {
entity = new EntityChicken(world);
} else if (Cow.class.isAssignableFrom(clazz)) {
if (MushroomCow.class.isAssignableFrom(clazz)) {
entity = new EntityMooshroom(world);
} else {
entity = new EntityCow(world);
}
} else if (Golem.class.isAssignableFrom(clazz)) {
if (Snowman.class.isAssignableFrom(clazz)) {
entity = new EntitySnowman(world);
} else if (IronGolem.class.isAssignableFrom(clazz)) {
entity = new EntityIronGolem(world);
} else if (Shulker.class.isAssignableFrom(clazz)) {
entity = new EntityShulker(world);
}
} else if (Creeper.class.isAssignableFrom(clazz)) {
entity = new EntityCreeper(world);
} else if (Ghast.class.isAssignableFrom(clazz)) {
entity = new EntityGhast(world);
} else if (Pig.class.isAssignableFrom(clazz)) {
entity = new EntityPig(world);
} else if (Player.class.isAssignableFrom(clazz)) {
// need a net server handler for this one
} else if (Sheep.class.isAssignableFrom(clazz)) {
entity = new EntitySheep(world);
} else if (AbstractHorse.class.isAssignableFrom(clazz)) {
if (ChestedHorse.class.isAssignableFrom(clazz)) {
if (Donkey.class.isAssignableFrom(clazz)) {
entity = new EntityDonkey(world);
} else if (Mule.class.isAssignableFrom(clazz)) {
entity = new EntityMule(world);
} else if (Llama.class.isAssignableFrom(clazz)) {
entity = new EntityLlama(world);
}
} else if (SkeletonHorse.class.isAssignableFrom(clazz)) {
entity = new EntitySkeletonHorse(world);
} else if (ZombieHorse.class.isAssignableFrom(clazz)) {
entity = new EntityZombieHorse(world);
} else {
entity = new EntityHorse(world);
}
} else if (Skeleton.class.isAssignableFrom(clazz)) {
if (Stray.class.isAssignableFrom(clazz)) {
entity = new EntityStray(world);
} else if (WitherSkeleton.class.isAssignableFrom(clazz)) {
entity = new EntityWitherSkeleton(world);
} else {
entity = new EntitySkeleton(world);
}
} else if (Slime.class.isAssignableFrom(clazz)) {
if (MagmaCube.class.isAssignableFrom(clazz)) {
entity = new EntityMagmaCube(world);
} else {
entity = new EntitySlime(world);
}
} else if (Spider.class.isAssignableFrom(clazz)) {
if (CaveSpider.class.isAssignableFrom(clazz)) {
entity = new EntityCaveSpider(world);
} else {
entity = new EntitySpider(world);
}
} else if (Squid.class.isAssignableFrom(clazz)) {
entity = new EntitySquid(world);
} else if (Tameable.class.isAssignableFrom(clazz)) {
if (Wolf.class.isAssignableFrom(clazz)) {
entity = new EntityWolf(world);
} else if (Ocelot.class.isAssignableFrom(clazz)) {
entity = new EntityOcelot(world);
} else if (Parrot.class.isAssignableFrom(clazz)) {
entity = new EntityParrot(world);
}
} else if (PigZombie.class.isAssignableFrom(clazz)) {
entity = new EntityPigZombie(world);
} else if (Zombie.class.isAssignableFrom(clazz)) {
if (Husk.class.isAssignableFrom(clazz)) {
entity = new EntityHusk(world);
} else if (ZombieVillager.class.isAssignableFrom(clazz)) {
entity = new EntityZombieVillager(world);
} else {
entity = new EntityZombie(world);
}
} else if (Giant.class.isAssignableFrom(clazz)) {
entity = new EntityGiantZombie(world);
} else if (Silverfish.class.isAssignableFrom(clazz)) {
entity = new EntitySilverfish(world);
} else if (Enderman.class.isAssignableFrom(clazz)) {
entity = new EntityEnderman(world);
} else if (Blaze.class.isAssignableFrom(clazz)) {
entity = new EntityBlaze(world);
} else if (Villager.class.isAssignableFrom(clazz)) {
entity = new EntityVillager(world);
} else if (Witch.class.isAssignableFrom(clazz)) {
entity = new EntityWitch(world);
} else if (Wither.class.isAssignableFrom(clazz)) {
entity = new EntityWither(world);
} else if (ComplexLivingEntity.class.isAssignableFrom(clazz)) {
if (EnderDragon.class.isAssignableFrom(clazz)) {
entity = new EntityDragon(world);
}
} else if (Ambient.class.isAssignableFrom(clazz)) {
if (Bat.class.isAssignableFrom(clazz)) {
entity = new EntityBat(world);
}
} else if (Rabbit.class.isAssignableFrom(clazz)) {
entity = new EntityRabbit(world);
} else if (Endermite.class.isAssignableFrom(clazz)) {
entity = new EntityEndermite(world);
} else if (Guardian.class.isAssignableFrom(clazz)) {
if (ElderGuardian.class.isAssignableFrom(clazz)) {
entity = new EntityElderGuardian(world);
} else {
entity = new EntityGuardian(world);
}
} else if (ArmorStand.class.isAssignableFrom(clazz)) {
entity = new EntityArmorStand(world, x, y, z);
} else if (PolarBear.class.isAssignableFrom(clazz)) {
entity = new EntityPolarBear(world);
} else if (Vex.class.isAssignableFrom(clazz)) {
entity = new EntityVex(world);
} else if (Illager.class.isAssignableFrom(clazz)) {
if (Spellcaster.class.isAssignableFrom(clazz)) {
if (Evoker.class.isAssignableFrom(clazz)) {
entity = new EntityEvoker(world);
} else if (Illusioner.class.isAssignableFrom(clazz)) {
entity = new EntityIllusionIllager(world);
}
} else if (Vindicator.class.isAssignableFrom(clazz)) {
entity = new EntityVindicator(world);
}
}
if (entity != null) {
entity.setPositionAndRotation(x, y, z, yaw, pitch);
// SPIGOT-3587
entity.setRotationYawHead(yaw);
}
} else if (Hanging.class.isAssignableFrom(clazz)) {
Block block = getBlockAt(location);
BlockFace face = BlockFace.SELF;
// 1 full block, also painting smallest size.
int width = 16;
// 1 full block, also painting smallest size.
int height = 16;
if (ItemFrame.class.isAssignableFrom(clazz)) {
width = 12;
height = 12;
} else if (LeashHitch.class.isAssignableFrom(clazz)) {
width = 9;
height = 9;
}
BlockFace[] faces = new BlockFace[] { BlockFace.EAST, BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH };
final BlockPos pos = new BlockPos((int) x, (int) y, (int) z);
for (BlockFace dir : faces) {
net.minecraft.block.Block nmsBlock = CraftMagicNumbers.getBlock(block.getRelative(dir));
if (nmsBlock.getDefaultState().getMaterial().isSolid() || BlockRedstoneDiode.isDiode(nmsBlock.getDefaultState())) {
boolean taken = false;
AxisAlignedBB bb = EntityHanging.calculateBoundingBox(null, pos, CraftBlock.blockFaceToNotch(dir).getOpposite(), width, height);
List<net.minecraft.entity.Entity> list = (List<net.minecraft.entity.Entity>) world.getEntitiesWithinAABBExcludingEntity(null, bb);
for (Iterator<net.minecraft.entity.Entity> it = list.iterator(); !taken && it.hasNext(); ) {
net.minecraft.entity.Entity e = it.next();
if (e instanceof EntityHanging) {
// Hanging entities do not like hanging entities which intersect them.
taken = true;
}
}
if (!taken) {
face = dir;
break;
}
}
}
if (LeashHitch.class.isAssignableFrom(clazz)) {
entity = new EntityLeashKnot(world, new BlockPos((int) x, (int) y, (int) z));
entity.forceSpawn = true;
} else {
// No valid face found
Preconditions.checkArgument(face != BlockFace.SELF, "Cannot spawn hanging entity for %s at %s (no free face)", clazz.getName(), location);
EnumFacing dir = CraftBlock.blockFaceToNotch(face).getOpposite();
if (Painting.class.isAssignableFrom(clazz)) {
entity = new EntityPainting(world, new BlockPos((int) x, (int) y, (int) z), dir);
} else if (ItemFrame.class.isAssignableFrom(clazz)) {
entity = new EntityItemFrame(world, new BlockPos((int) x, (int) y, (int) z), dir);
}
}
if (entity != null && !((EntityHanging) entity).onValidSurface()) {
throw new IllegalArgumentException("Cannot spawn hanging entity for " + clazz.getName() + " at " + location);
}
} else if (TNTPrimed.class.isAssignableFrom(clazz)) {
entity = new EntityTNTPrimed(world, x, y, z, null);
} else if (ExperienceOrb.class.isAssignableFrom(clazz)) {
entity = new EntityXPOrb(world, x, y, z, 0);
} else if (Weather.class.isAssignableFrom(clazz)) {
// not sure what this can do
if (LightningStrike.class.isAssignableFrom(clazz)) {
entity = new EntityLightningBolt(world, x, y, z, false);
// what is this, I don't even
}
} else if (Firework.class.isAssignableFrom(clazz)) {
entity = new EntityFireworkRocket(world, x, y, z, net.minecraft.item.ItemStack.EMPTY);
} else if (AreaEffectCloud.class.isAssignableFrom(clazz)) {
entity = new EntityAreaEffectCloud(world, x, y, z);
} else if (EvokerFangs.class.isAssignableFrom(clazz)) {
entity = new EntityEvokerFangs(world, x, y, z, (float) Math.toRadians(yaw), 0, null);
}
if (entity != null) {
// Spigot start
if (entity instanceof EntityOcelot) {
((EntityOcelot) entity).spawnBonus = false;
}
// Spigot end
return entity;
}
throw new IllegalArgumentException("Cannot spawn an entity for " + clazz.getName());
}
use of net.minecraft.entity.projectile.EntityWitherSkull in project Magma by magmafoundation.
the class CraftLivingEntity method launchProjectile.
@SuppressWarnings("unchecked")
public <T extends Projectile> T launchProjectile(Class<? extends T> projectile, Vector velocity) {
net.minecraft.world.World world = ((CraftWorld) getWorld()).getHandle();
net.minecraft.entity.Entity launch = null;
if (Snowball.class.isAssignableFrom(projectile)) {
launch = new EntitySnowball(world, getHandle());
// ItemSnowball
((EntityThrowable) launch).shoot(getHandle(), getHandle().rotationPitch, getHandle().rotationYaw, 0.0F, 1.5F, 1.0F);
} else if (Egg.class.isAssignableFrom(projectile)) {
launch = new EntityEgg(world, getHandle());
// ItemEgg
((EntityThrowable) launch).shoot(getHandle(), getHandle().rotationPitch, getHandle().rotationYaw, 0.0F, 1.5F, 1.0F);
} else if (EnderPearl.class.isAssignableFrom(projectile)) {
launch = new EntityEnderPearl(world, getHandle());
// ItemEnderPearl
((EntityThrowable) launch).shoot(getHandle(), getHandle().rotationPitch, getHandle().rotationYaw, 0.0F, 1.5F, 1.0F);
} else if (Arrow.class.isAssignableFrom(projectile)) {
if (TippedArrow.class.isAssignableFrom(projectile)) {
launch = new EntityTippedArrow(world, getHandle());
((EntityTippedArrow) launch).setType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false)));
} else if (SpectralArrow.class.isAssignableFrom(projectile)) {
launch = new EntitySpectralArrow(world, getHandle());
} else {
launch = new EntityTippedArrow(world, getHandle());
}
// ItemBow
((EntityArrow) launch).shoot(getHandle(), getHandle().rotationPitch, getHandle().rotationYaw, 0.0F, 3.0F, 1.0F);
} else if (ThrownPotion.class.isAssignableFrom(projectile)) {
if (LingeringPotion.class.isAssignableFrom(projectile)) {
launch = new EntityPotion(world, getHandle(), CraftItemStack.asNMSCopy(new ItemStack(Material.LINGERING_POTION, 1)));
} else {
launch = new EntityPotion(world, getHandle(), CraftItemStack.asNMSCopy(new ItemStack(Material.SPLASH_POTION, 1)));
}
// ItemSplashPotion
((EntityThrowable) launch).shoot(getHandle(), getHandle().rotationPitch, getHandle().rotationYaw, -20.0F, 0.5F, 1.0F);
} else if (ThrownExpBottle.class.isAssignableFrom(projectile)) {
launch = new EntityExpBottle(world, getHandle());
// ItemExpBottle
((EntityThrowable) launch).shoot(getHandle(), getHandle().rotationPitch, getHandle().rotationYaw, -20.0F, 0.7F, 1.0F);
} else if (Fish.class.isAssignableFrom(projectile) && getHandle() instanceof EntityPlayer) {
launch = new EntityFishHook(world, (EntityPlayer) getHandle());
} else if (Fireball.class.isAssignableFrom(projectile)) {
Location location = getEyeLocation();
Vector direction = location.getDirection().multiply(10);
if (SmallFireball.class.isAssignableFrom(projectile)) {
launch = new EntitySmallFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
} else if (WitherSkull.class.isAssignableFrom(projectile)) {
launch = new EntityWitherSkull(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
} else if (DragonFireball.class.isAssignableFrom(projectile)) {
launch = new EntityDragonFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
} else {
launch = new EntityLargeFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
}
((EntityFireball) launch).projectileSource = this;
launch.setLocationAndAngles(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
} else if (LlamaSpit.class.isAssignableFrom(projectile)) {
Location location = getEyeLocation();
Vector direction = location.getDirection();
launch = new EntityLlamaSpit(world);
((EntityLlamaSpit) launch).owner = getHandle();
// EntityLlama
((EntityLlamaSpit) launch).shoot(direction.getX(), direction.getY(), direction.getZ(), 1.5F, 10.0F);
launch.setLocationAndAngles(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
} else if (ShulkerBullet.class.isAssignableFrom(projectile)) {
Location location = getEyeLocation();
launch = new EntityShulkerBullet(world, getHandle(), null, null);
launch.setLocationAndAngles(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
}
Validate.notNull(launch, "Projectile not supported");
if (velocity != null) {
((T) launch.getBukkitEntity()).setVelocity(velocity);
}
world.spawnEntity(launch);
return (T) launch.getBukkitEntity();
}
Aggregations