Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.minecraft.src;
- import java.util.Random;
- public class EntitySmartPhone extends EntityTameable
- {
- public EntitySmartPhone(World par1World)
- {
- super(par1World);
- setSize(0.9F, 1.3F);
- getNavigator().func_48664_a(true);
- tasks.addTask(2, aiSit);
- tasks.addTask(5, new EntityAIFollowOwner(this, 0.3F, 10F, 5F));
- tasks.addTask(9, new EntityAIMate(this, 0.23F));
- tasks.addTask(10, new EntityAIWander(this, 0.23F));
- tasks.addTask(11, new EntityAIWatchClosest(this, net.minecraft.src.EntityPlayer.class, 10F));
- }
- private static final ItemStack defaultHeldItem;
- protected void entityInit()
- {
- super.entityInit();
- dataWatcher.addObject(18, Byte.valueOf((byte)0));
- }
- public void onUpdate()
- {
- super.onUpdate();
- }
- public boolean isAIEnabled()
- {
- return true;
- }
- protected boolean canDespawn()
- {
- return !isTamed();
- }
- protected void fall(float f)
- {
- }
- public int getMaxHealth()
- {
- return 10;
- }
- public String getTexture()
- {
- if(!isTamed())
- {
- if(on == true)
- {
- return "/mods/on.png";
- }
- else
- {
- return "/mods/off.png";
- }
- }
- else
- {
- if(on == true)
- {
- return "/mods/tamedon.png";
- }
- else
- {
- return "/mods/tamedoff.png";
- }
- }
- }
- public int foodNum;
- public int tamedNum;
- public void writeEntityToNBT(NBTTagCompound nbt)
- {
- super.writeEntityToNBT(nbt);
- nbt.setBoolean("on", on);
- nbt.setInteger("foodnum", foodNum);
- nbt.setInteger("tamednum", tamedNum);
- }
- public void readEntityFromNBT(NBTTagCompound nbt)
- {
- super.readEntityFromNBT(nbt);
- on = nbt.getBoolean("on");
- tamedNum = nbt.getInteger("tamednum");
- foodNum = nbt.getInteger("foodnum");
- }
- /*public ItemStack getHeldItem()
- {
- return defaultHeldItem;
- }*/
- /*protected String getLivingSound()
- {
- return "mob.cow";
- }
- protected String getHurtSound()
- {
- return "mob.cowhurt";
- }
- protected String getDeathSound()
- {
- return "mob.cowhurt";
- }*/
- protected float getSoundVolume()
- {
- return 0.4F;
- }
- protected void dropFewItems(boolean par1, int par2)
- {
- if(on == false)
- {
- boolean g = rand.nextBoolean();
- if(g == true)
- {
- int num = rand.nextInt(3) + 1;
- for(int k = 0; k < num; k++)
- {
- dropItem(Item.diamond.shiftedIndex, 1);
- }
- }
- else
- {
- int lol = rand.nextInt(8);
- if(lol <= 3)
- {
- dropItem(Item.diamond.shiftedIndex, 1);
- }
- else if(lol >= 4 && lol <= 6)
- {
- dropItem(Item.diamond.shiftedIndex, 2);
- }
- else if(lol >= 7 && lol <= 8)
- {
- dropItem(Item.diamond.shiftedIndex, 3);
- }
- }
- }
- else
- {
- int num = rand.nextInt(3) + 1;
- switch(num)
- {
- case 1:
- dropItem(Item.diamond.shiftedIndex, 2);
- break;
- case 2:
- dropItem(Item.cookie.shiftedIndex, 2);
- break;
- case 3:
- dropItem(Item.appleGold.shiftedIndex, 2);
- break;
- case 4:
- dropItem(Item.swordDiamond.shiftedIndex, 2);
- break;
- }
- }
- }
- public boolean on;
- public boolean interact(EntityPlayer par1EntityPlayer)
- {
- ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
- if(tamedNum == 0)
- {
- tamedNum = rand.nextInt(3) + 1;
- }
- if (!isTamed())
- {
- //Taming
- if (itemstack != null && itemstack.itemID == Block.dirt.blockID && par1EntityPlayer.getDistanceSqToEntity(this) < 9D)
- {
- itemstack.stackSize--;
- foodNum++;
- if (itemstack.stackSize <= 0)
- {
- par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
- }
- if (!worldObj.isRemote && foodNum >= tamedNum)
- {
- setTamed(true);
- setOwner(par1EntityPlayer.username);
- aiSit.func_48407_a(true);
- worldObj.setEntityState(this, (byte)7);
- ModLoader.getMinecraftInstance().thePlayer.addChatMessage("Tamed!");
- }
- else
- {
- ModLoader.getMinecraftInstance().thePlayer.addChatMessage(Integer.toString(tamedNum - foodNum));
- }
- }
- return true;
- }
- else
- {
- on = !on;
- }
- return super.interact(par1EntityPlayer);
- }
- public EntityAnimal spawnBabyAnimal(EntityAnimal par1EntityAnimal)
- {
- return new EntitySmartPhone(worldObj);
- }
- public int func_48148_ad()
- {
- return dataWatcher.getWatchableObjectByte(18);
- }
- static
- {
- defaultHeldItem = new ItemStack(Block.oreDiamond, 1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement