use of net.minecraft.entity.projectile.EntityTippedArrow in project SilentGems by SilentChaos512.
the class ItemQuiver method createArrow.
@Override
public EntityArrow createArrow(World worldIn, ItemStack quiverStack, EntityLivingBase shooter) {
IItemHandler itemHandler = getInventory(quiverStack);
for (int i = 0; i < itemHandler.getSlots(); ++i) {
ItemStack arrowStack = itemHandler.getStackInSlot(i);
if (!StackHelper.isEmpty(arrowStack) && arrowStack.getItem() instanceof ItemArrow) {
// Found arrow stack in quiver
boolean playerIsCreativeMode = shooter instanceof EntityPlayer && ((EntityPlayer) shooter).capabilities.isCreativeMode;
if (!playerIsCreativeMode) {
// Remove arrow from quiver
itemHandler.extractItem(i, 1, false);
updateQuiver(quiverStack, itemHandler, (EntityPlayer) shooter);
}
// Create arrow entity
ItemArrow itemArrow = (ItemArrow) arrowStack.getItem();
EntityArrow entity = itemArrow.createArrow(worldIn, arrowStack, shooter);
if (!playerIsCreativeMode) {
QuiverHelper.instance.addFiredArrow(entity);
}
return entity;
}
}
// Something went wrong?
SilentGems.logHelper.warning("Quiver could not find arrow! Player: " + shooter.getName());
return new EntityTippedArrow(worldIn, shooter);
}
use of net.minecraft.entity.projectile.EntityTippedArrow in project Minestuck by mraof.
the class RenderSkaiaPortal method render.
@Override
public void render(TileEntitySkaiaPortal te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
Entity temp = new EntityTippedArrow(te.getWorld());
// TODO temp solution for removed getter
Vec3d position = ActiveRenderInfo.projectViewFromEntity(temp, 0);
float var9 = (float) this.rendererDispatcher.entityX;
float var10 = (float) this.rendererDispatcher.entityY;
float var11 = (float) this.rendererDispatcher.entityZ;
GlStateManager.disableLighting();
Random var12 = new Random(31100L);
float var13 = 0.75F;
for (int var14 = 0; var14 < 16; ++var14) {
GlStateManager.pushMatrix();
float var15 = 16 - var14;
float var16 = 0.0625F;
float var17 = 1.0F / (var15 + 1.0F);
if (var14 == 0) {
this.bindTexture(tunnel);
var17 = 0.1F;
var15 = 65.0F;
var16 = 0.125F;
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
}
if (var14 == 1) {
this.bindTexture(particlefield);
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_ONE, GL11.GL_ONE);
var16 = 0.5F;
}
float var18 = (float) (-(y + var13));
float var19 = var18 + (float) position.y;
float var20 = var18 + var15 + (float) position.y;
float var21 = var19 / var20;
var21 += (float) (y + var13);
GlStateManager.translate(var9, var21, var11);
GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_LINEAR);
GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_LINEAR);
GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_LINEAR);
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_EYE_LINEAR);
GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, this.func_76907_a(1.0F, 0.0F, 0.0F, 0.0F));
GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_PLANE, this.func_76907_a(0.0F, 0.0F, 1.0F, 0.0F));
GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_PLANE, this.func_76907_a(0.0F, 0.0F, 0.0F, 1.0F));
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_EYE_PLANE, this.func_76907_a(0.0F, 1.0F, 0.0F, 0.0F));
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.S);
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.T);
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.R);
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.Q);
GlStateManager.popMatrix();
GlStateManager.matrixMode(GL11.GL_TEXTURE);
GlStateManager.pushMatrix();
GlStateManager.loadIdentity();
GlStateManager.translate(0.0F, Minecraft.getSystemTime() % 700000L / 700000.0F, 0.0F);
GlStateManager.scale(var16, var16, var16);
GlStateManager.translate(0.5F, 0.5F, 0.0F);
GlStateManager.rotate((var14 * var14 * 4321 + var14 * 9) * 2.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.translate(-0.5F, -0.5F, 0.0F);
GlStateManager.translate(-var9, -var11, -var10);
var19 = var18 + (float) position.x;
GlStateManager.translate(((float) position.x) * var15 / var19, ((float) position.z) * var15 / var19, -var10);
BufferBuilder var24 = Tessellator.getInstance().getBuffer();
var24.begin(7, DefaultVertexFormats.POSITION_TEX);
var21 = var12.nextFloat() * 0.5F + 0.1F;
float var22 = var12.nextFloat() * 0.5F + 0.4F;
float var23 = var12.nextFloat() * 0.5F + 0.5F;
if (var14 == 0) {
var23 = 1.0F;
var22 = 1.0F;
var21 = 1.0F;
}
GlStateManager.color(var21 * var17, var22 * var17, var23 * var17, 1.0F);
var24.pos(x, y + var13, z).tex(0, 0).endVertex();
var24.pos(x, y + var13, z + 1.0D).tex(0, 1).endVertex();
var24.pos(x + 1.0D, y + var13, z + 1.0D).tex(1, 1).endVertex();
var24.pos(x + 1.0D, y + var13, z).tex(1, 0).endVertex();
Tessellator.getInstance().draw();
GlStateManager.popMatrix();
GlStateManager.matrixMode(GL11.GL_MODELVIEW);
}
GlStateManager.disableBlend();
GlStateManager.disableTexGenCoord(GlStateManager.TexGen.S);
GlStateManager.disableTexGenCoord(GlStateManager.TexGen.T);
GlStateManager.disableTexGenCoord(GlStateManager.TexGen.R);
GlStateManager.disableTexGenCoord(GlStateManager.TexGen.Q);
GlStateManager.enableLighting();
}
use of net.minecraft.entity.projectile.EntityTippedArrow in project Minestuck by mraof.
the class EntityPawn method attackEntityWithRangedAttack.
@Override
public void attackEntityWithRangedAttack(EntityLivingBase target, float f1) {
EntityArrow arrow = new EntityTippedArrow(this.world, this);
double d0 = target.posX - this.posX;
double d1 = target.getEntityBoundingBox().minY + (double) (target.height / 3.0F) - arrow.posY;
double d2 = target.posZ - this.posZ;
double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2);
arrow.shoot(d0, d1 + d3 * 0.2D, d2, 1.6F, 12.0F);
int power = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.POWER, this);
int punch = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.PUNCH, this);
if (power > 0) {
arrow.setDamage(arrow.getDamage() + (double) power * 0.5D + 0.5D);
}
if (punch > 0) {
arrow.setKnockbackStrength(punch);
}
if (EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.FLAME, this) > 0) {
arrow.setFire(100);
}
playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
// EntityPawn pawn = this.getClass() == EntityWhitePawn.class ? new EntityWhitePawn(this.worldObj, 0) : new EntityBlackPawn(this.worldObj, 0);
// pawn.setLocationAndAngles(this.posX, this.posY, this.posZ, 0, 0);
// pawn.initCreature();
// this.worldObj.spawnEntityInWorld(pawn);
// I was just messing around to see if I could make an EntityLiving spawn more EntityLiving, it can
this.world.spawnEntity(arrow);
}
use of net.minecraft.entity.projectile.EntityTippedArrow in project BloodMagic by WayofTime.
the class EntitySentientSpecter method attackEntityWithRangedAttack.
@Override
public void attackEntityWithRangedAttack(EntityLivingBase target, float velocity) {
ItemStack heldStack = this.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND);
if (!heldStack.isEmpty() && heldStack.getItem() == RegistrarBloodMagicItems.SENTIENT_BOW) {
EntityTippedArrow arrowEntity = ((ItemSentientBow) heldStack.getItem()).getArrowEntity(getEntityWorld(), heldStack, target, this, velocity);
if (arrowEntity != null) {
List<PotionEffect> effects = getPotionEffectsForArrowRemovingDuration(0.2f);
for (PotionEffect eff : effects) {
arrowEntity.addEffect(eff);
}
this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
this.getEntityWorld().spawnEntity(arrowEntity);
}
} else {
// TODO: Change to an arrow created by the Sentient Bow
EntityTippedArrow entitytippedarrow = new EntityTippedArrow(this.getEntityWorld(), this);
double d0 = target.posX - this.posX;
double d1 = target.getEntityBoundingBox().minY + (double) (target.height / 3.0F) - entitytippedarrow.posY;
double d2 = target.posZ - this.posZ;
double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2);
// TODO: Yes, it is an accurate arrow. Don't be hatin'
entitytippedarrow.shoot(d0, d1 + d3 * 0.2, d2, 1.6F, 0);
int i = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.POWER, this);
int j = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.PUNCH, this);
entitytippedarrow.setDamage((double) (velocity * 2.0F) + this.rand.nextGaussian() * 0.25D + (double) ((float) this.getEntityWorld().getDifficulty().getDifficultyId() * 0.11F));
if (i > 0) {
entitytippedarrow.setDamage(entitytippedarrow.getDamage() + (double) i * 0.5D + 0.5D);
}
if (j > 0) {
entitytippedarrow.setKnockbackStrength(j);
}
boolean burning = this.isBurning();
burning = burning || EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.FLAME, this) > 0;
if (burning) {
entitytippedarrow.setFire(100);
}
if (// TODO: Add potion effects to the arrows
true) {
entitytippedarrow.addEffect(new PotionEffect(MobEffects.SLOWNESS, 600));
}
this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
this.getEntityWorld().spawnEntity(entitytippedarrow);
}
}
use of net.minecraft.entity.projectile.EntityTippedArrow in project BloodMagic by WayofTime.
the class AlchemyArrayEffectArrowTurret method fireOnTarget.
public void fireOnTarget(World world, BlockPos pos, ItemStack arrowStack, EntityLiving targetMob) {
float vel = 3f;
double damage = 2;
if (!world.isRemote) {
if (arrowStack.getItem() instanceof ItemArrow) {
// ItemArrow arrow = (ItemArrow) arrowStack.getItem();
// EntityArrow entityarrow = arrow.createArrow(world, arrowStack, targetMob);
EntityTippedArrow entityarrow = new EntityTippedArrow(world);
entityarrow.setPotionEffect(arrowStack);
entityarrow.posX = pos.getX() + 0.5;
entityarrow.posY = pos.getY() + 0.5;
entityarrow.posZ = pos.getZ() + 0.5;
double d0 = targetMob.posX - (pos.getX() + 0.5);
double d1 = targetMob.posY + targetMob.height - (pos.getY() + 0.5);
double d2 = targetMob.posZ - (pos.getZ() + 0.5);
double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2);
entityarrow.setDamage(damage);
entityarrow.shoot(d0, d1 + d3 * 0.05, d2, vel, 0);
world.spawnEntity(entityarrow);
}
}
}
Aggregations