Created
July 4, 2014 17:15
-
-
Save WillR27/504d06491a9d0f44ed43 to your computer and use it in GitHub Desktop.
This file contains 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
public boolean interact(EntityPlayer entityPlayer) { | |
ItemStack itemstack = entityPlayer.inventory.getCurrentItem(); | |
String playerName = entityPlayer.getCommandSenderName(); | |
boolean tamed = this.isTamed(); | |
GuiNewChat chat = client.ingameGUI.getChatGUI(); | |
Item item = itemstack.getItem(); | |
if (playerName.equalsIgnoreCase(this.getOwnerName())) { | |
if (entityPlayer.isSneaking()) { | |
if (itemstack == null && !this.worldObj.isRemote) { | |
chat.printChatMessage(new ChatComponentText("XP: " + this.xp + "/" + this.requiredXP + " | " + "Level: " + this.level)); | |
chat.printChatMessage(new ChatComponentText("Health: " + (int) this.getHealth() + "/" + (int) this.maxHealth + " | " + "Attack Damage: " + (int) this.attackDamage)); | |
} | |
if(itemstack != null) { | |
if( | |
((item == Blocklings.itemWoodenUpgrade && this.currentUpgradeTier == 1 && this.level >= 2) || | |
( item == Blocklings.itemCobblestoneUpgrade && this.currentUpgradeTier == 2 && this.level >= 3) || | |
( item == Blocklings.itemStoneUpgrade && this.currentUpgradeTier == 3 && this.level >= 4) || | |
( item == Blocklings.itemIronUpgrade && this.currentUpgradeTier == 4 && this.level >= 5) || | |
( item == Blocklings.itemLapisLazuliUpgrade && this.currentUpgradeTier == 5 && this.level >= 6) || | |
( item == Blocklings.itemGoldUpgrade && this.currentUpgradeTier == 6 && this.level >= 7) || | |
( item == Blocklings.itemDiamondUpgrade && this.currentUpgradeTier == 7 && this.level >= 8) || | |
( item == Blocklings.itemEmeraldUpgrade && this.currentUpgradeTier == 8 && this.level >= 9) || | |
( item == Blocklings.itemObsidianUpgrade && this.currentUpgradeTier == 9 && this.level >= 10)) | |
) { | |
++this.currentUpgradeTier; | |
setMaxHealth(); | |
setAttackDamage(); | |
this.heal((float)maxHealth - this.getHealth()); | |
if (!entityPlayer.capabilities.isCreativeMode) { | |
--itemstack.stackSize; | |
if (itemstack.stackSize <= 0) { | |
entityPlayer.inventory.setInventorySlotContents(entityPlayer.inventory.currentItem, (ItemStack)null); | |
} | |
} | |
String upgradeName = null; | |
if (item == Blocklings.itemWoodenUpgrade) { upgradeName = "Wooden"; } | |
else if (item == Blocklings.itemCobblestoneUpgrade) { upgradeName = "Cobblestone"; } | |
else if (item == Blocklings.itemStoneUpgrade) { upgradeName = "Stone"; } | |
else if (item == Blocklings.itemIronUpgrade) { upgradeName = "Iron"; } | |
else if (item == Blocklings.itemLapisLazuliUpgrade) { upgradeName = "Lapis Lazuli"; } | |
else if (item == Blocklings.itemGoldUpgrade) { upgradeName = "Gold"; } | |
else if (item == Blocklings.itemDiamondUpgrade) { upgradeName = "Diamond"; } | |
else if (item == Blocklings.itemEmeraldUpgrade) { upgradeName = "Emerald"; } | |
else if (item == Blocklings.itemObsidianUpgrade) { upgradeName = "Obsidian"; } | |
chat.printChatMessage(new ChatComponentText(upgradeName + " Upgrade Applied")); | |
CreatePacketServerSide.sendS2CEntitySync(this); | |
} | |
} | |
} else if (tamed) { | |
this.aiSit.setSitting(!this.isSitting()); | |
} | |
} else if (itemstack != null && !tamed && (item == Item.getItemFromBlock(Blocks.red_flower) || item == Item.getItemFromBlock(Blocks.yellow_flower))) { | |
if (!entityPlayer.capabilities.isCreativeMode) { | |
--itemstack.stackSize; | |
if (itemstack.stackSize <= 0) { | |
entityPlayer.inventory.setInventorySlotContents(entityPlayer.inventory.currentItem, (ItemStack)null); | |
} | |
} | |
if (this.rand.nextInt(2) == 0) { | |
this.setTamed(true); | |
this.setPathToEntity((PathEntity)null); | |
this.setAttackTarget((EntityLivingBase)null); | |
this.setOwner(playerName); | |
this.playTameEffect(true); | |
this.worldObj.setEntityState(this, (byte)7); | |
} else { | |
this.playTameEffect(false); | |
this.worldObj.setEntityState(this, (byte)6); | |
} | |
return true; | |
} | |
return super.interact(entityPlayer); | |
} | |
public void onLivingUpdate() { | |
super.onLivingUpdate(); | |
if (this.attackTimer > 0) { | |
--this.attackTimer; | |
if (!this.worldObj.isRemote) { | |
CreatePacketServerSide.sendS2CEntitySync(this); | |
} | |
} | |
if (i < 3 && !worldObj.isRemote) { | |
CreatePacketServerSide.sendS2CEntitySync(this); | |
i++; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment