Created
April 23, 2016 16:59
-
-
Save tinkerstudent/34276334ca4d521ada0314ad0504fac9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.tinkeracademy.minecraft; | |
| import net.minecraft.entity.passive.EntityOcelot; | |
| import net.minecraft.entity.player.EntityPlayer; | |
| import net.minecraft.init.Items; | |
| import net.minecraft.item.ItemStack; | |
| import net.minecraft.world.World; | |
| public class Cat extends EntityOcelot { | |
| public boolean following; | |
| public Cat(World worldIn) { | |
| super(worldIn); | |
| } | |
| public boolean interact(EntityPlayer player) | |
| { | |
| ItemStack itemstack = player.inventory.getCurrentItem(); | |
| if (itemstack != null && itemstack.getItem() == Items.fish && player.getDistanceSqToEntity(this) < 9.0D) { | |
| this.setTamed(true); | |
| this.setOwnerId(player.getUniqueID().toString()); | |
| this.playTameEffect(true); | |
| this.aiSit.setSitting(true); | |
| this.worldObj.setEntityState(this, (byte)7); | |
| } | |
| return true; | |
| } | |
| public void followPlayer() { | |
| if (!following) { | |
| this.tasks.addTask(12, new CatFollowAI(this, 1.0D, 10.0F, Float.MAX_VALUE)); | |
| following = true; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment