hey people, i have no programming knowledge at all, and would really appreciate some help. i am trying to modify the flying speed of an entity when mounted and controlled by a player. i have tried to change some values where it said flying speed but nothing worked so far. here is the code:
package drzhark.mocreatures.entity.passive;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import drzhark.mocreatures.MoCTools;
import drzhark.mocreatures.MoCreatures;
import drzhark.mocreatures.entity.MoCEntityAnimal;
import drzhark.mocreatures.entity.MoCEntityTameableAnimal;
import drzhark.mocreatures.entity.item.MoCEntityEgg;
import drzhark.mocreatures.inventory.MoCAnimalChest;
import drzhark.mocreatures.network.MoCMessageHandler;
import drzhark.mocreatures.network.message.MoCMessageAnimation;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EnumCreatureAttribute;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
public class MoCEntityWyvern extends MoCEntityTameableAnimal {
public MoCAnimalChest localchest;
public ItemStack localstack;
public int mouthCounter;
public int wingFlapCounter;
public int diveCounter;
public static final String[] wyvernNames = new String[] {
"Jungle", "Swamp", "Savanna", "Sand", "Mother", "Undead", "Light", "Dark", "Arctic", "Cave",
"Mountain", "Sea" };
public MoCEntityWyvern(World world) {
super(world);
func_70105_a(1.9F, 1.7F);
setAdult(false);
this.field_70138_W = 1.0F;
if (this.field_70146_Z.nextInt(6) == 0) {
setEdad(50 + this.field_70146_Z.nextInt(50));
} else {
setEdad(80 + this.field_70146_Z.nextInt(20));
}
}
protected void func_110147_ax() {
super.func_110147_ax();
func_110148_a(SharedMonsterAttributes.field_111267_a).func_111128_a((getType() >= 5) ? 80.0D : 40.0D);
}
protected void func_70088_a() {
super.func_70088_a();
this.field_70180_af.func_75682_a(22, Byte.valueOf((byte)0));
this.field_70180_af.func_75682_a(23, Byte.valueOf((byte)0));
this.field_70180_af.func_75682_a(24, Byte.valueOf((byte)0));
this.field_70180_af.func_75682_a(25, Byte.valueOf((byte)0));
this.field_70180_af.func_75682_a(26, Byte.valueOf((byte)0));
}
public boolean getIsFlying() {
return (this.field_70180_af.func_75683_a(25) == 1);
}
public void setIsFlying(boolean flag) {
byte input = (byte)(flag ? 1 : 0);
this.field_70180_af.func_75692_b(25, Byte.valueOf(input));
}
public byte getArmorType() {
return this.field_70180_af.func_75683_a(24);
}
public void setArmorType(byte i) {
this.field_70180_af.func_75692_b(24, Byte.valueOf(i));
}
public boolean getIsRideable() {
return (this.field_70180_af.func_75683_a(22) == 1);
}
public void setRideable(boolean flag) {
byte input = (byte)(flag ? 1 : 0);
this.field_70180_af.func_75692_b(22, Byte.valueOf(input));
}
public boolean getIsChested() {
return (this.field_70180_af.func_75683_a(23) == 1);
}
public void setIsChested(boolean flag) {
byte input = (byte)(flag ? 1 : 0);
this.field_70180_af.func_75692_b(23, Byte.valueOf(input));
}
public boolean getIsSitting() {
return (this.field_70180_af.func_75683_a(26) == 1);
}
public void setSitting(boolean flag) {
byte input = (byte)(flag ? 1 : 0);
this.field_70180_af.func_75692_b(26, Byte.valueOf(input));
}
public void selectType() {
if (getType() == 0) {
int i = this.field_70146_Z.nextInt(100);
if (i <= 12) {
setType(1);
} else if (i <= 24) {
setType(2);
} else if (i <= 36) {
setType(3);
} else if (i <= 48) {
setType(4);
} else if (i <= 60) {
setType(9);
} else if (i <= 72) {
setType(10);
} else if (i <= 84) {
setType(11);
} else if (i <= 95) {
setType(12);
} else {
setType(5);
}
}
}
public boolean isNotScared() {
return true;
}
public ResourceLocation getTexture() {
switch (getType()) {
case 1:
return MoCreatures.proxy.getTexture("wyvernjungle.png");
case 2:
return MoCreatures.proxy.getTexture("wyvernmix.png");
case 3:
return MoCreatures.proxy.getTexture("wyvernsand.png");
case 4:
return MoCreatures.proxy.getTexture("wyvernsun.png");
case 5:
return MoCreatures.proxy.getTexture("wyvernmother.png");
case 6:
return MoCreatures.proxy.getTexture("wyvernundead.png");
case 7:
return MoCreatures.proxy.getTexture("wyvernlight.png");
case 8:
return MoCreatures.proxy.getTexture("wyverndark.png");
case 9:
return MoCreatures.proxy.getTexture("wyvernarctic.png");
case 10:
return MoCreatures.proxy.getTexture("wyverncave.png");
case 11:
return MoCreatures.proxy.getTexture("wyvernmountain.png");
case 12:
return MoCreatures.proxy.getTexture("wyvernsea.png");
}
return MoCreatures.proxy.getTexture("wyvernsun.png");
}
public void func_70636_d() {
if (!getIsFlying() && isOnAir() && this.field_70181_x < 0.0D)
this.field_70181_x *= 0.6D;
if (this.mouthCounter > 0 && ++this.mouthCounter > 30)
this.mouthCounter = 0;
if (this.diveCounter > 0 && ++this.diveCounter > 5)
this.diveCounter = 0;
if (this.jumpPending) {
if (this.wingFlapCounter == 0)
MoCTools.playCustomSound((Entity)this, "wingflap", this.field_70170_p);
this.wingFlapCounter = 1;
}
if (isOnAir() && this.field_70146_Z.nextInt(30) == 0)
this.wingFlapCounter = 1;
if (this.wingFlapCounter > 0 && ++this.wingFlapCounter > 20)
this.wingFlapCounter = 0;
if (isFlyingAlone())
this.wingFlapCounter = 1;
if (MoCreatures.isServer()) {
if (!getIsAdult() && this.field_70146_Z.nextInt(500) == 0) {
setEdad(getEdad() + 1);
if (getEdad() >= getMaxAge())
setAdult(true);
}
if (isFlyingAlone() && this.field_70146_Z.nextInt(60) == 0 && !func_70780_i())
wingFlap();
if (isFlyingAlone() && !func_70781_l() && !func_70780_i() && this.field_70789_a == null && this.field_70146_Z.nextInt(20) == 0)
func_70779_j();
if (this.field_70153_n != null) {
setIsFlying(false);
} else if (this.field_70789_a != null && this.field_70146_Z.nextInt(20) == 0) {
setIsFlying(true);
} else if (!getIsTamed() && this.field_70146_Z.nextInt(300) == 0) {
setIsFlying(!getIsFlying());
}
if (!getIsTamed() && this.field_71093_bK == MoCreatures.WyvernLairDimensionID && this.field_70146_Z.nextInt(50) == 0 && this.field_70163_u < 10.0D)
func_70106_y();
}
if (this.field_70181_x > 0.5D)
this.field_70181_x = 0.5D;
super.func_70636_d();
}
public void wingFlap() {
if (this.wingFlapCounter == 0)
MoCTools.playCustomSound((Entity)this, "wyvernwingflap", this.field_70170_p);
this.wingFlapCounter = 1;
this.field_70181_x = 0.5D;
}
public float getSizeFactor() {
return getEdad() * 0.01F;
}
public boolean isFlyingAlone() {
return (getIsFlying() && this.field_70153_n == null);
}
public int flyingHeight() {
return 18;
}
protected float getFlyingSpeed() {
return 0.7F;
}
public boolean func_70085_c(EntityPlayer entityplayer) {
if (super.func_70085_c(entityplayer))
return false;
ItemStack itemstack = entityplayer.field_71071_by.func_70448_g();
if (itemstack != null && itemstack.func_77973_b() == MoCreatures.whip && getIsTamed() && this.field_70153_n == null) {
setSitting(!getIsSitting());
return true;
}
if (itemstack != null && !getIsRideable() && getEdad() > 90 && getIsTamed() && (itemstack.func_77973_b() == Items.field_151141_av || itemstack.func_77973_b() == MoCreatures.horsesaddle)) {
if (--itemstack.field_77994_a == 0)
entityplayer.field_71071_by.func_70299_a(entityplayer.field_71071_by.field_70461_c, null);
setRideable(true);
return true;
}
if (itemstack != null && getIsTamed() && getEdad() > 90 && itemstack.func_77973_b() == Items.field_151138_bX) {
if (getArmorType() == 0)
MoCTools.playCustomSound((Entity)this, "armorput", this.field_70170_p);
dropArmor();
setArmorType((byte)1);
if (--itemstack.field_77994_a == 0)
entityplayer.field_71071_by.func_70299_a(entityplayer.field_71071_by.field_70461_c, null);
return true;
}
if (itemstack != null && getIsTamed() && getEdad() > 90 && itemstack.func_77973_b() == Items.field_151136_bY) {
if (getArmorType() == 0)
MoCTools.playCustomSound((Entity)this, "armorput", this.field_70170_p);
dropArmor();
setArmorType((byte)2);
if (--itemstack.field_77994_a == 0)
entityplayer.field_71071_by.func_70299_a(entityplayer.field_71071_by.field_70461_c, null);
return true;
}
if (itemstack != null && getIsTamed() && getEdad() > 90 && itemstack.func_77973_b() == Items.field_151125_bZ) {
if (getArmorType() == 0)
MoCTools.playCustomSound((Entity)this, "armorput", this.field_70170_p);
dropArmor();
setArmorType((byte)3);
if (--itemstack.field_77994_a == 0)
entityplayer.field_71071_by.func_70299_a(entityplayer.field_71071_by.field_70461_c, null);
return true;
}
if (itemstack != null && getIsTamed() && getEdad() > 90 && !getIsChested() && itemstack.func_77973_b() == Item.func_150898_a((Block)Blocks.field_150486_ae)) {
if (--itemstack.field_77994_a == 0)
entityplayer.field_71071_by.func_70299_a(entityplayer.field_71071_by.field_70461_c, null);
entityplayer.field_71071_by.func_70441_a(new ItemStack(MoCreatures.key));
setIsChested(true);
this.field_70170_p.func_72956_a((Entity)this, "mob.chickenplop", 1.0F, (this.field_70146_Z.nextFloat() - this.field_70146_Z.nextFloat()) * 0.2F + 1.0F);
return true;
}
if (itemstack != null && itemstack.func_77973_b() == MoCreatures.key && getIsChested()) {
if (this.localchest == null)
this.localchest = new MoCAnimalChest("WyvernChest", 14);
if (MoCreatures.isServer())
entityplayer.func_71007_a((IInventory)this.localchest);
return true;
}
if (itemstack != null && itemstack.func_77973_b() == MoCreatures.essencelight && getIsTamed() && getEdad() > 90 && getType() < 5) {
if (--itemstack.field_77994_a == 0) {
entityplayer.field_71071_by.func_70299_a(entityplayer.field_71071_by.field_70461_c, new ItemStack(Items.field_151069_bo));
} else {
entityplayer.field_71071_by.func_70441_a(new ItemStack(Items.field_151069_bo));
}
if (MoCreatures.isServer()) {
int i = getType() + 49;
MoCEntityEgg entityegg = new MoCEntityEgg(this.field_70170_p, i);
entityegg.func_70107_b(entityplayer.field_70165_t, entityplayer.field_70163_u, entityplayer.field_70161_v);
entityplayer.field_70170_p.func_72838_d((Entity)entityegg);
entityegg.field_70181_x += (this.field_70170_p.field_73012_v.nextFloat() * 0.05F);
entityegg.field_70159_w += ((this.field_70170_p.field_73012_v.nextFloat() - this.field_70170_p.field_73012_v.nextFloat()) * 0.3F);
entityegg.field_70179_y += ((this.field_70170_p.field_73012_v.nextFloat() - this.field_70170_p.field_73012_v.nextFloat()) * 0.3F);
}
return true;
}
if (itemstack != null && getType() == 5 && itemstack.func_77973_b() == MoCreatures.essenceundead && getIsTamed()) {
if (--itemstack.field_77994_a == 0) {
entityplayer.field_71071_by.func_70299_a(entityplayer.field_71071_by.field_70461_c, new ItemStack(Items.field_151069_bo));
} else {
entityplayer.field_71071_by.func_70441_a(new ItemStack(Items.field_151069_bo));
}
if (MoCreatures.isServer())
setType(6);
return true;
}
if (itemstack != null && getType() == 5 && itemstack.func_77973_b() == MoCreatures.essencelight && getIsTamed()) {
if (--itemstack.field_77994_a == 0) {
entityplayer.field_71071_by.func_70299_a(entityplayer.field_71071_by.field_70461_c, new ItemStack(Items.field_151069_bo));
} else {
entityplayer.field_71071_by.func_70441_a(new ItemStack(Items.field_151069_bo));
}
if (MoCreatures.isServer())
setType(7);
return true;
}
if (itemstack != null && getType() == 5 && itemstack.func_77973_b() == MoCreatures.essencedarkness && getIsTamed()) {
if (--itemstack.field_77994_a == 0) {
entityplayer.field_71071_by.func_70299_a(entityplayer.field_71071_by.field_70461_c, new ItemStack(Items.field_151069_bo));
} else {
entityplayer.field_71071_by.func_70441_a(new ItemStack(Items.field_151069_bo));
}
if (MoCreatures.isServer())
setType(8);
return true;
}
if (getIsRideable() && getEdad() > 90 && this.field_70153_n == null) {
entityplayer.field_70177_z = this.field_70177_z;
entityplayer.field_70125_A = this.field_70125_A;
if (MoCreatures.isServer()) {
entityplayer.func_70078_a((Entity)this);
setSitting(false);
}
return true;
}
return false;
}
public void dropArmor() {
if (MoCreatures.isServer()) {
int i = getArmorType();
if (i != 0)
MoCTools.playCustomSound((Entity)this, "armoroff", this.field_70170_p);
if (i == 1) {
EntityItem entityitem = new EntityItem(this.field_70170_p, this.field_70165_t, this.field_70163_u, this.field_70161_v, new ItemStack(Items.field_151138_bX, 1));
entityitem.field_145804_b = 10;
this.field_70170_p.func_72838_d((Entity)entityitem);
}
if (i == 2) {
EntityItem entityitem = new EntityItem(this.field_70170_p, this.field_70165_t, this.field_70163_u, this.field_70161_v, new ItemStack(Items.field_151136_bY, 1));
entityitem.field_145804_b = 10;
this.field_70170_p.func_72838_d((Entity)entityitem);
}
if (i == 3) {
EntityItem entityitem = new EntityItem(this.field_70170_p, this.field_70165_t, this.field_70163_u, this.field_70161_v, new ItemStack(Items.field_151125_bZ, 1));
entityitem.field_145804_b = 10;
this.field_70170_p.func_72838_d((Entity)entityitem);
}
setArmorType((byte)0);
}
}
public boolean rideableEntity() {
return true;
}
protected String func_70673_aS() {
return "mocreatures:wyverndying";
}
protected String func_70621_aR() {
openMouth();
return "mocreatures:wyvernhurt";
}
protected String func_70639_aQ() {
openMouth();
return "mocreatures:wyverngrunt";
}
public int func_70627_aG() {
return 400;
}
protected boolean func_70780_i() {
return (this.field_70153_n != null || getIsSitting());
}
public boolean isFlyer() {
return true;
}
protected void func_70069_a(float f) {}
public double func_70042_X() {
return this.field_70131_O * 0.9D * getSizeFactor();
}
public void func_70043_V() {
double dist = getSizeFactor() * 0.3D;
double newPosX = this.field_70165_t - dist * Math.cos((MoCTools.realAngle(this.field_70761_aq - 90.0F) / 57.29578F));
double newPosZ = this.field_70161_v - dist * Math.sin((MoCTools.realAngle(this.field_70761_aq - 90.0F) / 57.29578F));
this.field_70153_n.func_70107_b(newPosX, this.field_70163_u + func_70042_X() + this.field_70153_n.func_70033_W(), newPosZ);
}
protected void func_70785_a(Entity entity, float f) {
if (this.field_70724_aR <= 0 && f < 3.0D && entity.field_70121_D.field_72337_e > this.field_70121_D.field_72338_b && entity.field_70121_D.field_72338_b < this.field_70121_D.field_72337_e) {
this.field_70724_aR = 20;
boolean flag = (this.field_70146_Z.nextInt(3) == 0);
if (flag) {
if (entity instanceof EntityPlayer)
MoCreatures.poisonPlayer((EntityPlayer)entity);
((EntityLivingBase)entity).func_70690_d(new PotionEffect(Potion.field_76436_u.field_76415_H, 200, 0));
MoCTools.playCustomSound((Entity)this, "wyvernpoisoning", this.field_70170_p);
}
int dmg = 5;
if (getType() >= 5)
dmg = 10;
entity.func_70097_a(DamageSource.func_76358_a((EntityLivingBase)this), dmg);
openMouth();
}
}
public boolean func_70097_a(DamageSource damagesource, float i) {
if (super.func_70097_a(damagesource, i)) {
Entity entity = damagesource.func_76346_g();
if (entity != null && getIsTamed() && entity instanceof EntityPlayer)
return false;
if (this.field_70153_n != null && entity == this.field_70153_n)
return false;
if (entity != this && this.field_70170_p.field_73013_u.func_151525_a() > 0)
this.field_70789_a = entity;
return true;
}
return false;
}
protected Entity func_70782_k() {
if (this.field_70170_p.field_73013_u.func_151525_a() > 0 && !getIsTamed()) {
EntityPlayer entityplayer = this.field_70170_p.func_72856_b((Entity)this, 10.0D);
if (entityplayer != null)
return (Entity)entityplayer;
if (this.field_70146_Z.nextInt(500) == 0) {
EntityLivingBase entityliving = getClosestEntityLiving((Entity)this, 8.0D);
return (Entity)entityliving;
}
}
return null;
}
public boolean entitiesToIgnore(Entity entity) {
return (super.entitiesToIgnore(entity) || entity instanceof MoCEntityWyvern || entity instanceof EntityPlayer);
}
public void func_70014_b(NBTTagCompound nbttagcompound) {
super.func_70014_b(nbttagcompound);
nbttagcompound.func_74757_a("Saddle", getIsRideable());
nbttagcompound.func_74757_a("Chested", getIsChested());
nbttagcompound.func_74774_a("ArmorType", getArmorType());
nbttagcompound.func_74757_a("isSitting", getIsSitting());
if (getIsChested() && this.localchest != null) {
NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < this.localchest.func_70302_i_(); i++) {
this.localstack = this.localchest.func_70301_a(i);
if (this.localstack != null) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.func_74774_a("Slot", (byte)i);
this.localstack.func_77955_b(nbttagcompound1);
nbttaglist.func_74742_a((NBTBase)nbttagcompound1);
}
}
nbttagcompound.func_74782_a("Items", (NBTBase)nbttaglist);
}
}
public void func_70037_a(NBTTagCompound nbttagcompound) {
super.func_70037_a(nbttagcompound);
setRideable(nbttagcompound.func_74767_n("Saddle"));
setIsChested(nbttagcompound.func_74767_n("Chested"));
setArmorType(nbttagcompound.func_74771_c("ArmorType"));
setSitting(nbttagcompound.func_74767_n("isSitting"));
if (getIsChested()) {
NBTTagList nbttaglist = nbttagcompound.func_150295_c("Items", 10);
this.localchest = new MoCAnimalChest("WyvernChest", 14);
for (int i = 0; i < nbttaglist.func_74745_c(); i++) {
NBTTagCompound nbttagcompound1 = nbttaglist.func_150305_b(i);
int j = nbttagcompound1.func_74771_c("Slot") & 0xFF;
if (j >= 0 && j < this.localchest.func_70302_i_())
this.localchest.func_70299_a(j, ItemStack.func_77949_a(nbttagcompound1));
}
}
}
public double roperYOffset() {
if (getIsAdult())
return 0.0D;
return (130 - getEdad()) * 0.01D;
}
public int nameYOffset() {
int yOff = getEdad() * -1;
if (yOff < -120)
yOff = -120;
return yOff;
}
public boolean isMyHealFood(ItemStack par1ItemStack) {
return (par1ItemStack != null && (par1ItemStack.func_77973_b() == MoCreatures.ratRaw || par1ItemStack.func_77973_b() == MoCreatures.rawTurkey));
}
private void openMouth() {
if (MoCreatures.isServer()) {
this.mouthCounter = 1;
MoCMessageHandler.INSTANCE.sendToAllAround((IMessage)new MoCMessageAnimation(func_145782_y(), 1), new NetworkRegistry.TargetPoint(this.field_70170_p.field_73011_w.field_76574_g, this.field_70165_t, this.field_70163_u, this.field_70161_v, 64.0D));
}
}
public void performAnimation(int animationType) {
if (animationType == 1)
this.mouthCounter = 1;
if (animationType == 2)
this.diveCounter = 1;
}
public void makeEntityDive() {
if (MoCreatures.isServer())
MoCMessageHandler.INSTANCE.sendToAllAround((IMessage)new MoCMessageAnimation(func_145782_y(), 2), new NetworkRegistry.TargetPoint(this.field_70170_p.field_73011_w.field_76574_g, this.field_70165_t, this.field_70163_u, this.field_70161_v, 64.0D));
super.makeEntityDive();
}
protected void func_70628_a(boolean flag, int x) {
int i = MathHelper.func_76128_c(this.field_70165_t);
int j = MathHelper.func_76128_c(this.field_70121_D.field_72338_b);
int k = MathHelper.func_76128_c(this.field_70161_v);
int chance = MoCreatures.proxy.wyvernEggDropChance;
if (getType() == 5)
chance = MoCreatures.proxy.motherWyvernEggDropChance;
String s = MoCTools.BiomeName(this.field_70170_p, i, j, k);
if (this.field_70146_Z.nextInt(100) < chance)
func_70099_a(new ItemStack(MoCreatures.mocegg, 1, getType() + 49), 0.0F);
}
public boolean func_70067_L() {
return (this.field_70153_n == null);
}
public void dropMyStuff() {
if (MoCreatures.isServer()) {
dropArmor();
MoCTools.dropSaddle((MoCEntityAnimal)this, this.field_70170_p);
if (getIsChested()) {
MoCTools.dropInventory((Entity)this, this.localchest);
MoCTools.dropCustomItem((Entity)this, this.field_70170_p, new ItemStack((Block)Blocks.field_150486_ae, 1));
setIsChested(false);
}
}
}
public float getAdjustedYOffset() {
if (getIsSitting())
return 0.4F;
return 0.0F;
}
public double getCustomSpeed() {
if (this.field_70153_n != null) {
if (getType() < 5)
return 2.0D;
return 3.0D;
}
return 0.8D;
}
private int getMaxAge() {
if (getType() >= 5)
return 180;
return 100;
}
public EnumCreatureAttribute func_70668_bt() {
if (getType() == 6)
return EnumCreatureAttribute.UNDEAD;
return super.func_70668_bt();
}
public boolean swimmerEntity() {
return true;
}
}
0
hey people, i have no programming knowledge at all, and would really appreciate some help. i am trying to modify the flying speed of an entity when mounted and controlled by a player. i have tried to change some values where it said flying speed but nothing worked so far. here is the code: