- 200
- 0
Есть у меня 2 класса, один взят здесь, другой из одного мода, вообщем у того который взят здесь, прямой полёт и ужасный телепорт, а у другого, который из мода, отличный телепорт, но ужасный полёт.
Как добавить телепорт из класса другого мода и вставить в класс с полётом?
Или как добавить хороший полёт в класс с хорошим телепортом?
2 класса:
Хороший полёт
Хороший телепорт
Как добавить телепорт из класса другого мода и вставить в класс с полётом?
Или как добавить хороший полёт в класс с хорошим телепортом?
2 класса:
Хороший полёт
Код:
import java.util.List;
import assets.spidermod.src.SpiderMod;
import net.minecraft.block.Block;
import net.minecraft.enchantment.EnchantmentThorns;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IProjectile;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet70GameEvent;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EntityDamageSourceIndirect;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.EnderTeleportEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class EntityBlasterBullet extends Entity implements IProjectile
{
public int knockbackStrength = 0;
public int xTile = -1;
public int yTile = -1;
public int zTile = -1;
public Entity shootingEntity;
public int ticksInAir;
public double damage = 0.0D;
private MovingObjectPosition EntityLivingBase;
private EntityPlayer player;
public EntityBlasterBullet(World par1World, EntityLivingBase par2EntityLivingBase, float par3, double damage, EntityPlayer par3EntityPlayer)
{
super(par1World);
this.damage = damage;
this.renderDistanceWeight = 10.0D;
this.shootingEntity = par2EntityLivingBase;
this.setSize(0.5F, 0.5F);
this.setLocationAndAngles(par2EntityLivingBase.posX, par2EntityLivingBase.posY + (double)par2EntityLivingBase.getEyeHeight(), par2EntityLivingBase.posZ, par2EntityLivingBase.rotationYaw, par2EntityLivingBase.rotationPitch);
this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
this.posY -= 0.10000000149011612D;
this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
this.setPosition(this.posX, this.posY, this.posZ);
this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
this.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI));
this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, par3 * 1.5F, 1.0F);
this.player = par3EntityPlayer;
}
public void entityInit(){}
public void setThrowableHeading(double par1, double par3, double par5, float par7, float par8)
{
float f2 = MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5);
par1 /= (double)f2;
par3 /= (double)f2;
par5 /= (double)f2;
par1 += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)par8;
par3 += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)par8;
par5 += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)par8;
par1 *= (double)par7;
par3 *= (double)par7;
par5 *= (double)par7;
this.motionX = par1;
this.motionY = par3;
this.motionZ = par5;
}
@SideOnly(Side.CLIENT)
public void setVelocity(double par1, double par3, double par5)
{
this.motionX = par1;
this.motionY = par3;
this.motionZ = par5;
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
{
float f = MathHelper.sqrt_double(par1 * par1 + par5 * par5);
this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(par1, par5) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(par3, (double)f) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch;
this.prevRotationYaw = this.rotationYaw;
this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
}
}
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
par1NBTTagCompound.setShort("xTile", (short)this.xTile);
par1NBTTagCompound.setShort("yTile", (short)this.yTile);
par1NBTTagCompound.setShort("zTile", (short)this.zTile);
}
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
this.xTile = par1NBTTagCompound.getShort("xTile");
this.yTile = par1NBTTagCompound.getShort("yTile");
this.zTile = par1NBTTagCompound.getShort("zTile");
}
public void addSpotEntity(MovingObjectPosition mob){this.EntityLivingBase=mob;}
public void addActionWithBlock(){}
public void addActionWithBlockThread(){}
public void addActionWithEntity(){}
public void addSpotEntityAndBlock(){
Vec3 vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
Vec3 vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks_do_do(vec3, vec31, false, true);
vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
if (movingobjectposition != null)
{
vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
}
Entity entity = null;
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
double d0 = 0.0D;
int l;
float f1;
for (l = 0; l < list.size(); ++l)
{
Entity entity1 = (Entity)list.get(l);
if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity))
{
f1 = 0.3F;
AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand((double)f1, (double)f1, (double)f1);
MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec3, vec31);
if (movingobjectposition1 != null)
{
double d1 = vec3.distanceTo(movingobjectposition1.hitVec);
if (d1 < d0 || d0 == 0.0D)
{
entity = entity1;
d0 = d1;
}
}
}
}
if (entity != null)
{
movingobjectposition = new MovingObjectPosition(entity);
}
if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer)
{
EntityPlayer entityplayer = (EntityPlayer)movingobjectposition.entityHit;
if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer)this.shootingEntity).canAttackPlayer(entityplayer))
{
movingobjectposition = null;
}
}
float f2,f3;
if (movingobjectposition != null)
{
if (movingobjectposition.entityHit != null)
{
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
int i1 = MathHelper.ceiling_double_int((double)f2 * this.damage);
DamageSource damagesource = null;
damagesource=causeBulletDamage(this, this.shootingEntity);
if (!this.worldObj.isRemote)
{
if (movingobjectposition.entityHit != null)
{
if (this.shootingEntity != null)
{}
else
{
movingobjectposition.entityHit.attackEntityFrom(DamageSource.magic, 5.0F);
}
if (movingobjectposition.entityHit instanceof EntityLivingBase)
{
addSpotEntity(movingobjectposition);
addActionWithEntity();
}
}
}
this.setDead();
if (movingobjectposition.entityHit.attackEntityFrom(damagesource, (float)i1))
{
if (movingobjectposition.entityHit instanceof EntityLivingBase)
{
EntityLivingBase entitylivingbase = (EntityLivingBase)movingobjectposition.entityHit;
if (!this.worldObj.isRemote)
{
entitylivingbase.setArrowCountInEntity(entitylivingbase.getArrowCountInEntity() + 1);
}
if (this.knockbackStrength > 0)
{
f3 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
if (f3 > 0.0F)
{
movingobjectposition.entityHit.addVelocity(this.motionX * (double)this.knockbackStrength * 0.6000000238418579D / (double)f3, 0.1D, this.motionZ * (double)this.knockbackStrength * 0.6000000238418579D / (double)f3);
}
}
if (this.shootingEntity != null)
{
EnchantmentThorns.func_92096_a(this.shootingEntity, entitylivingbase, this.rand);
}
if (this.shootingEntity != null && movingobjectposition.entityHit != this.shootingEntity && movingobjectposition.entityHit instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP)
{
((EntityPlayerMP)this.shootingEntity).playerNetServerHandler.sendPacketToPlayer(new Packet70GameEvent(6, 0));
}
}
this.setDead();
}
else
{
this.motionX *= -0.10000000149011612D;
this.motionY *= -0.10000000149011612D;
this.motionZ *= -0.10000000149011612D;
this.rotationYaw += 180.0F;
this.prevRotationYaw += 180.0F;
}
}
else
{
this.xTile = movingobjectposition.blockX;
this.yTile = movingobjectposition.blockY;
this.zTile = movingobjectposition.blockZ;
this.motionX = (double)((float)(movingobjectposition.hitVec.xCoord - this.posX));
this.motionY = (double)((float)(movingobjectposition.hitVec.yCoord - this.posY));
this.motionZ = (double)((float)(movingobjectposition.hitVec.zCoord - this.posZ));
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
this.posX -= this.motionX / (double)f2 * 0.05000000074505806D;
this.posY -= this.motionY / (double)f2 * 0.05000000074505806D;
this.posZ -= this.motionZ / (double)f2 * 0.05000000074505806D;
}
}
}
public void addFlyBullet(){
float f4 = 0.99F;
float f1 = 0.0F;
this.posX += this.motionX;
this.posY += this.motionY;
this.posZ += this.motionZ;
this.motionX *= (double)f4;
this.motionY *= (double)f4;
this.motionZ *= (double)f4;
this.motionY -= (double)f1;
this.setPosition(this.posX, this.posY, this.posZ);
this.doBlockCollisions();
}
public static DamageSource causeBulletDamage(EntityBlasterBullet par1, Entity entity)
{
return (new EntityDamageSourceIndirect("", par1, entity)).setProjectile();
}
public void onUpdate()
{
super.onUpdate();
int i = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile);
if (i > 0)
{
addActionWithBlock();
if ( SpiderMod.setShoter == false ) {
this.player.setPosition((double)this.posX, (double)this.posY+1,(double)this.posZ);
this.player.fallDistance = 0.0F;
} else {
this.worldObj.setBlock((int)this.posX, (int)this.posY, (int)this.posZ, Block.web.blockID);
this.worldObj.setBlock((int)this.posX+1, (int)this.posY, (int)this.posZ, Block.web.blockID);
this.worldObj.setBlock((int)this.posX-1, (int)this.posY, (int)this.posZ, Block.web.blockID);
this.worldObj.setBlock((int)this.posX, (int)this.posY, (int)this.posZ+1, Block.web.blockID);
this.worldObj.setBlock((int)this.posX, (int)this.posY, (int)this.posZ-1, Block.web.blockID);
this.worldObj.setBlock((int)this.posX-1, (int)this.posY, (int)this.posZ-1, Block.web.blockID);
this.worldObj.setBlock((int)this.posX+1, (int)this.posY, (int)this.posZ+1, Block.web.blockID);
this.worldObj.setBlock((int)this.posX+1, (int)this.posY, (int)this.posZ-1, Block.web.blockID);
this.worldObj.setBlock((int)this.posX-1, (int)this.posY, (int)this.posZ+1, Block.web.blockID);
}
this.setDead();
}
addSpotEntityAndBlock();
addFlyBullet();
addActionWithBlockThread();
}
}
Хороший телепорт
Код:
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.EnderTeleportEvent;
public class EntityWebShoot extends EntityThrowable
{
public EntityWebShoot(World par1World)
{
super(par1World);
}
public EntityWebShoot(World par1World, EntityLivingBase par2EntityLivingBase)
{
super(par1World, par2EntityLivingBase);
}
@SideOnly(Side.CLIENT)
public EntityWebShoot(World par1World, double par2, double par4, double par6)
{
super(par1World, par2, par4, par6);
}
/**
* Called when this EntityThrowable hits a block or entity.
*/
protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
{
if (par1MovingObjectPosition.entityHit != null)
{
par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 10.0F);
}
for (int entityplayermp = 0; entityplayermp < 32; ++entityplayermp)
{
this.worldObj.spawnParticle("snowballpoof", this.posX, this.posY + this.rand.nextDouble() * 2.0D, this.posZ, this.rand.nextGaussian(), 0.0D, this.rand.nextGaussian());
}
if (!this.worldObj.isRemote)
{
if (this.getThrower() != null && this.getThrower() instanceof EntityPlayerMP)
{
EntityPlayerMP var4 = (EntityPlayerMP)this.getThrower();
if (!var4.playerNetServerHandler.connectionClosed && var4.worldObj == this.worldObj)
{
EnderTeleportEvent event = new EnderTeleportEvent(var4, this.posX, this.posY, this.posZ, 5.0F);
if (!MinecraftForge.EVENT_BUS.post(event))
{
if (this.getThrower().isRiding())
{
this.getThrower().mountEntity((Entity)null);
}
this.getThrower().setPositionAndUpdate(event.targetX, event.targetY, event.targetZ);
this.getThrower().fallDistance = 0.0F;
}
}
}
this.setDead();
}
}
}