Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- import net.minecraft.server.v1_7_R1.DamageSource;
- import net.minecraft.server.v1_7_R1.EntityAgeable;
- import net.minecraft.server.v1_7_R1.EntityHuman;
- import net.minecraft.server.v1_7_R1.EntityVillager;
- import net.minecraft.server.v1_7_R1.IMerchant;
- import net.minecraft.server.v1_7_R1.ItemStack;
- import net.minecraft.server.v1_7_R1.Items;
- import net.minecraft.server.v1_7_R1.MerchantRecipe;
- import net.minecraft.server.v1_7_R1.MerchantRecipeList;
- import net.minecraft.server.v1_7_R1.NBTTagCompound;
- import net.minecraft.server.v1_7_R1.NPC;
- import net.minecraft.server.v1_7_R1.World;
- public class VillagerShop extends EntityAgeable implements NPC, IMerchant {
- private MerchantRecipeList bu;
- private int riches;
- public VillagerShop(World paramWorld) {
- this(paramWorld, 0);
- }
- public VillagerShop(World paramWorld, int paramInt) {
- super(paramWorld);
- setProfession(paramInt);
- a(0.6F, 1.8F);
- getNavigation().b(false);
- getNavigation().a(false);
- }
- public boolean bk() {
- return true;
- }
- public boolean a(EntityHuman e) {
- if(e.inventory.getItemInHand() != null && e.inventory.getItemInHand().getItem() == Items.DIAMOND){
- Random r = new Random();
- int randX = r.nextInt(40);
- int randZ = r.nextInt(40);
- this.getNavigation().a(this.lastX + randX - 20, e.lastY, this.lastZ + randZ - 20, 1D);
- }else{
- this.getNavigation().a(e.lastX, e.lastY, e.lastZ, 0.5D);
- }
- return true;
- }
- protected void c() {
- super.c();
- this.datawatcher.a(16, Integer.valueOf(0));
- }
- public void b(NBTTagCompound paramNBTTagCompound) {
- super.b(paramNBTTagCompound);
- paramNBTTagCompound.setInt("Profession", getProfession());
- paramNBTTagCompound.setInt("Riches", this.riches);
- if(this.bu != null) paramNBTTagCompound.set("Offers", this.bu.a());
- }
- public void a(NBTTagCompound paramNBTTagCompound) {
- super.a(paramNBTTagCompound);
- setProfession(paramNBTTagCompound.getInt("Profession"));
- this.riches = paramNBTTagCompound.getInt("Riches");
- if(paramNBTTagCompound.hasKeyOfType("Offers", 10)) {
- NBTTagCompound localNBTTagCompound = paramNBTTagCompound.getCompound("Offers");
- this.bu = new MerchantRecipeList(localNBTTagCompound);
- }
- }
- protected String t() {
- if(ca()) { return "mob.villager.haggle"; }
- return "mob.villager.idle";
- }
- protected String aT() {
- return "mob.villager.hit";
- }
- protected String aU() {
- return "mob.villager.death";
- }
- public void setProfession(int paramInt) {
- this.datawatcher.watch(16, Integer.valueOf(paramInt));
- }
- public int getProfession() {
- return this.datawatcher.getInt(16);
- }
- public void die(DamageSource paramDamageSource) {
- super.die(paramDamageSource);
- }
- public void a_(EntityHuman paramEntityHuman) {}
- public EntityHuman b() {
- return null;
- }
- public boolean ca() {
- return false;
- }
- public void a(MerchantRecipe paramMerchantRecipe) {}
- public void a_(ItemStack paramItemStack) {}
- public MerchantRecipeList getOffers(EntityHuman paramEntityHuman) {
- return this.bu;
- }
- @Override
- public EntityAgeable createChild(EntityAgeable arg0) {
- EntityVillager localEntityVillager = new EntityVillager(this.world);
- return localEntityVillager;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement