Skip to content

Instantly share code, notes, and snippets.

@tinkerstudent
Created April 23, 2016 16:59
Show Gist options
  • Select an option

  • Save tinkerstudent/34276334ca4d521ada0314ad0504fac9 to your computer and use it in GitHub Desktop.

Select an option

Save tinkerstudent/34276334ca4d521ada0314ad0504fac9 to your computer and use it in GitHub Desktop.
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