use of xyz.derkades.ublisk.utils.inventory.Item in project Ublisk by Derkades.
the class CustomHealth method updateMaxHealth.
public static void updateMaxHealth(UPlayer player) {
int health = getMaxHealth(player);
int bonusHealth = 0;
for (Item item : player.getInventory().getItems(true, true, true)) {
double percentage = item.getHealthBonusPercentage() / 100.0;
bonusHealth += bonusHealth * percentage;
}
int totalHealth = health + bonusHealth;
player.setAttribute(Attribute.GENERIC_MAX_HEALTH, totalHealth);
player.setHealthScale(20);
}
use of xyz.derkades.ublisk.utils.inventory.Item in project Ublisk by Derkades.
the class Merek method talk.
@Override
public void talk(UPlayer player) {
QuestParticipant qp = player.getQuestParticipant(Quest.INTRODUCTION, this);
UInventory inv = qp.getInventory();
if (inv.containsItems(new Item(Material.LOG, 10), new Item(Material.STRING, 16), new MoneyItem(MoneyItem.Type.DUST).setAmount(10))) {
qp.sendMessage("Great! Now go to Ulric to craft a weapon.");
} else if (inv.containsItems(new Item(Material.STRING, 16), new MoneyItem(MoneyItem.Type.DUST).setAmount(10))) {
qp.sendMessage("Finally get 10 wood logs at the saw");
} else if (inv.containsItems(new Item(Material.WOOL, 4), new MoneyItem(MoneyItem.Type.DUST).setAmount(10))) {
qp.sendMessage("Great job, now please break down your wool into 16 string by using the windmill.");
} else if (inv.contains(Material.GOLD_NUGGET, 10)) {
qp.sendMessage("Now bring me 4 wool by killing sheep.");
} else {
qp.sendMessage("What are you doing out here? You don't even have a weapon yet! I'll tell you what you'll need to make a weapon. First, get 10 gold dust by killing animals.");
}
}
use of xyz.derkades.ublisk.utils.inventory.Item in project Ublisk by Derkades.
the class Sword method getItemStack.
@Override
public ItemStack getItemStack() {
Item item = new Item(this.getMaterial()).setName(this.getColoredName()).setLore(this.getLore());
NBTTagList modifiers = new NBTTagList();
NBTTagCompound damage = new NBTTagCompound();
damage.setString("AttributeName", "generic.attackDamage");
damage.setString("Name", "generic.attackDamage");
damage.setDouble("Amount", this.getDamage());
damage.setInt("Operation", 1);
damage.setInt("UUIDLeast", 652);
damage.setInt("UUIDMost", 12098);
modifiers.add(damage);
if (this.getMovementSpeed() != -1) {
NBTTagCompound speed = new NBTTagCompound();
speed.setString("AttributeName", "generic.movementSpeed");
speed.setString("Name", "generic.movementSpeed");
speed.setDouble("Amount", this.getMovementSpeed());
speed.setInt("Operation", 1);
speed.setInt("UUIDLeast", 652);
speed.setInt("UUIDMost", 12098);
modifiers.add(speed);
}
if (this.getAttackSpeed().getValue() != -1) {
NBTTagCompound attackSpeed = new NBTTagCompound();
attackSpeed.setString("AttributeName", "generic.attackSpeed");
attackSpeed.setString("Name", "generic.attackSpeed");
attackSpeed.setDouble("Amount", this.getAttackSpeed().getValue());
attackSpeed.setInt("Operation", 1);
attackSpeed.setInt("UUIDLeast", 652);
attackSpeed.setInt("UUIDMost", 12098);
modifiers.add(attackSpeed);
}
if (this.getKnockbackResistance() != -1) {
NBTTagCompound knockback = new NBTTagCompound();
knockback.setString("AttributeName", "generic.knockbackResistance");
knockback.setString("Name", "generic.knockbackResistance");
knockback.setDouble("Amount", this.getKnockbackResistance());
knockback.setInt("Operation", 1);
knockback.setInt("UUIDLeast", 652);
knockback.setInt("UUIDMost", 12098);
modifiers.add(knockback);
}
NBTTagCompound compound = item.getNBT();
compound.set("AttributeModifiers", modifiers);
compound.setInt("HideFlags", 7);
compound.setBoolean("Unbreakable", true);
item.setNBT(compound);
item.setDamage(this.getDamage());
return item.getItemStack();
}
Aggregations