use of net.minecraft.inventory.EntityEquipmentSlot in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class ItemEvents method addTooltip.
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void addTooltip(ItemTooltipEvent event) {
List<String> tooltip = event.getToolTip();
for (ItemStack stack : MunnyRegistry.munnyValues.keySet()) {
if (areItemStacksEqual(stack, event.getItemStack())) {
event.getToolTip().add(TextFormatting.YELLOW + "Munny: " + MunnyRegistry.munnyValues.get(stack) * event.getItemStack().getCount());
}
}
// TODO Localize all this
if (event.getItemStack().getItem() instanceof ItemKeyblade && event.getEntityPlayer() != null) {
// List<String> tooltip = event.getToolTip();
ItemKeyblade keyblade = (ItemKeyblade) event.getItemStack().getItem();
(tooltip.subList(1, tooltip.size())).clear();
NBTTagList nbttaglist = event.getItemStack().getEnchantmentTagList();
double sharpnessDamage = 0;
for (int i = 0; i < nbttaglist.tagCount(); i++) {
int id = nbttaglist.getCompoundTagAt(i).getShort("id");
int lvl = nbttaglist.getCompoundTagAt(i).getShort("lvl");
// System.out.println(Enchantment.getEnchantmentByID(id).getName());
if (Enchantment.getEnchantmentByID(id).getName().equals("enchantment.damage.all")) {
sharpnessDamage = getSharpnessDamage(lvl);
}
}
double keyStrength = keyblade.getStrength() + sharpnessDamage;
String magicSymbol = (keyblade.getMagic() > 0) ? "+" : "-";
tooltip.add(TextFormatting.RED + "Strength: +" + keyStrength * MainConfig.items.damageMultiplier + " [" + (DamageCalculation.getStrengthDamage(event.getEntityPlayer(), keyblade) + sharpnessDamage) + "]");
tooltip.add(TextFormatting.BLUE + "Magic: " + magicSymbol + keyblade.getMagic() * MainConfig.items.damageMultiplier + " [" + DamageCalculation.getMagicDamage(event.getEntityPlayer(), 1, keyblade) + "]");
if (keyblade.getDescription() != null) {
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
tooltip.add("" + TextFormatting.WHITE + TextFormatting.UNDERLINE + "Description");
tooltip.add(keyblade.description);
tooltip.add("");
} else {
tooltip.add("Hold " + TextFormatting.GREEN + TextFormatting.ITALIC + "Shift" + TextFormatting.GRAY + " for description");
}
}
if (Keyboard.isKeyDown(Keyboard.KEY_LMENU)) {
if (event.getItemStack().hasTagCompound()) {
tooltip.add("" + TextFormatting.WHITE + TextFormatting.UNDERLINE + "Stats");
for (int i = 0; i < nbttaglist.tagCount(); i++) {
int id = nbttaglist.getCompoundTagAt(i).getShort("id");
int lvl = nbttaglist.getCompoundTagAt(i).getShort("lvl");
if (Enchantment.getEnchantmentByID(id) != null) {
tooltip.add(Enchantment.getEnchantmentByID(id).getTranslatedName(lvl));
}
}
}
for (EntityEquipmentSlot entityequipmentslot : EntityEquipmentSlot.values()) {
Multimap<String, AttributeModifier> multimap = event.getItemStack().getAttributeModifiers(entityequipmentslot);
if (!multimap.isEmpty()) {
tooltip.add("");
for (Map.Entry<String, AttributeModifier> entry : multimap.entries()) {
AttributeModifier attributemodifier = (AttributeModifier) entry.getValue();
double d0 = attributemodifier.getAmount();
boolean flag = false;
if (attributemodifier.getID() == UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF")) {
d0 = d0 + event.getEntityPlayer().getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getBaseValue();
d0 = d0 + (double) EnchantmentHelper.getModifierForCreature(event.getItemStack(), EnumCreatureAttribute.UNDEFINED);
flag = true;
}
double d1;
if (attributemodifier.getOperation() != 1 && attributemodifier.getOperation() != 2) {
d1 = d0;
} else {
d1 = d0 * 100.0D;
}
if (entry.getKey() == "generic.attackDamage") {
d1 += event.getEntityPlayer().getCapability(ModCapabilities.PLAYER_STATS, null).getStrength();
}
if (flag) {
tooltip.add(Utils.translateToLocalFormatted("attribute.modifier.equals." + attributemodifier.getOperation(), new Object[] { ItemStack.DECIMALFORMAT.format(d1), Utils.translateToLocal("attribute.name." + (String) entry.getKey()) }));
} else if (d0 > 0.0D) {
tooltip.add(TextFormatting.BLUE + Utils.translateToLocalFormatted("attribute.modifier.plus." + attributemodifier.getOperation(), new Object[] { ItemStack.DECIMALFORMAT.format(d1), Utils.translateToLocal("attribute.name." + (String) entry.getKey()) }));
} else if (d0 < 0.0D) {
d1 = d1 * -1.0D;
tooltip.add(TextFormatting.RED + Utils.translateToLocalFormatted("attribute.modifier.take." + attributemodifier.getOperation(), new Object[] { ItemStack.DECIMALFORMAT.format(d1), Utils.translateToLocal("attribute.name." + (String) entry.getKey()) }));
}
}
}
}
} else {
tooltip.add("Hold " + TextFormatting.YELLOW + TextFormatting.ITALIC + "Alt" + TextFormatting.GRAY + " for more stats");
}
}
if (event.getItemStack().getItem() instanceof ItemKeychain && event.getEntityPlayer() != null) {
// List<String> tooltip = event.getToolTip();
ItemKeyblade keyblade = ((ItemKeychain) event.getItemStack().getItem()).getKeyblade();
if (keyblade != null) {
(tooltip.subList(1, tooltip.size())).clear();
NBTTagList nbttaglist = event.getItemStack().getEnchantmentTagList();
double sharpnessDamage = 0;
for (int i = 0; i < nbttaglist.tagCount(); i++) {
int id = nbttaglist.getCompoundTagAt(i).getShort("id");
int lvl = nbttaglist.getCompoundTagAt(i).getShort("lvl");
if (Enchantment.getEnchantmentByID(id).getName().equals("enchantment.damage.all")) {
sharpnessDamage = getSharpnessDamage(lvl);
}
}
double keyStrength = keyblade.getStrength() + sharpnessDamage;
String magicSymbol = (keyblade.getMagic() > 0) ? "+" : "";
tooltip.add(TextFormatting.RED + "Strength: +" + keyStrength * MainConfig.items.damageMultiplier + " [" + (DamageCalculation.getStrengthDamage(event.getEntityPlayer(), keyblade) + sharpnessDamage) + "]");
tooltip.add(TextFormatting.BLUE + "Magic: " + magicSymbol + keyblade.getMagic() * MainConfig.items.damageMultiplier + " [" + DamageCalculation.getMagicDamage(event.getEntityPlayer(), 1, keyblade) + "]");
if (keyblade.getDescription() != null) {
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
tooltip.add("" + TextFormatting.WHITE + TextFormatting.UNDERLINE + "Description");
tooltip.add(keyblade.description);
tooltip.add("");
} else {
tooltip.add("Hold " + TextFormatting.GREEN + TextFormatting.ITALIC + "Shift" + TextFormatting.GRAY + " for description");
}
}
if (Keyboard.isKeyDown(Keyboard.KEY_LMENU)) {
if (event.getItemStack().hasTagCompound()) {
tooltip.add("" + TextFormatting.WHITE + TextFormatting.UNDERLINE + "Stats");
for (int i = 0; i < nbttaglist.tagCount(); i++) {
int id = nbttaglist.getCompoundTagAt(i).getShort("id");
int lvl = nbttaglist.getCompoundTagAt(i).getShort("lvl");
if (Enchantment.getEnchantmentByID(id) != null) {
tooltip.add(Enchantment.getEnchantmentByID(id).getTranslatedName(lvl));
}
}
}
} else {
tooltip.add("Hold " + TextFormatting.YELLOW + TextFormatting.ITALIC + "Alt" + TextFormatting.GRAY + " for more stats");
}
}
}
if (event.getItemStack().getItem() instanceof IOrgWeapon) {
IOrgWeapon weapon = (IOrgWeapon) event.getItemStack().getItem();
(tooltip.subList(1, tooltip.size())).clear();
NBTTagList nbttaglist = event.getItemStack().getEnchantmentTagList();
double sharpnessDamage = 0;
for (int i = 0; i < nbttaglist.tagCount(); i++) {
int id = nbttaglist.getCompoundTagAt(i).getShort("id");
int lvl = nbttaglist.getCompoundTagAt(i).getShort("lvl");
// System.out.println(Enchantment.getEnchantmentByID(id).getName());
if (Enchantment.getEnchantmentByID(id).getName().equals("enchantment.damage.all")) {
sharpnessDamage = getSharpnessDamage(lvl);
}
}
double keyStrength = weapon.getStrength() + sharpnessDamage;
String magicSymbol = (weapon.getMagic() > 0) ? "+" : "";
tooltip.add(TextFormatting.RED + "Strength: +" + keyStrength + " (" + (DamageCalculation.getOrgStrengthDamage(event.getEntityPlayer(), event.getItemStack()) + sharpnessDamage) + ")");
tooltip.add(TextFormatting.BLUE + "Magic: " + magicSymbol + weapon.getMagic() + " (" + DamageCalculation.getMagicDamage(event.getEntityPlayer(), 1, weapon) + ")");
if (weapon.getDescription() != null) {
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
tooltip.add("" + TextFormatting.WHITE + TextFormatting.UNDERLINE + "Description");
tooltip.add(weapon.getDescription());
tooltip.add("");
} else {
tooltip.add("Hold " + TextFormatting.GREEN + TextFormatting.ITALIC + "Shift" + TextFormatting.GRAY + " for description");
}
}
if (Keyboard.isKeyDown(Keyboard.KEY_LMENU)) {
if (event.getItemStack().hasTagCompound()) {
tooltip.add("" + TextFormatting.WHITE + TextFormatting.UNDERLINE + "Stats");
for (int i = 0; i < nbttaglist.tagCount(); i++) {
int id = nbttaglist.getCompoundTagAt(i).getShort("id");
int lvl = nbttaglist.getCompoundTagAt(i).getShort("lvl");
if (Enchantment.getEnchantmentByID(id) != null) {
tooltip.add(Enchantment.getEnchantmentByID(id).getTranslatedName(lvl));
}
}
}
for (EntityEquipmentSlot entityequipmentslot : EntityEquipmentSlot.values()) {
Multimap<String, AttributeModifier> multimap = event.getItemStack().getAttributeModifiers(entityequipmentslot);
if (!multimap.isEmpty()) {
tooltip.add("");
for (Map.Entry<String, AttributeModifier> entry : multimap.entries()) {
AttributeModifier attributemodifier = (AttributeModifier) entry.getValue();
double d0 = attributemodifier.getAmount();
boolean flag = false;
if (attributemodifier.getID() == UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF")) {
d0 = d0 + event.getEntityPlayer().getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getBaseValue();
d0 = d0 + (double) EnchantmentHelper.getModifierForCreature(event.getItemStack(), EnumCreatureAttribute.UNDEFINED);
flag = true;
}
double d1;
if (attributemodifier.getOperation() != 1 && attributemodifier.getOperation() != 2) {
d1 = d0;
} else {
d1 = d0 * 100.0D;
}
if (entry.getKey() == "generic.attackDamage") {
d1 += event.getEntityPlayer().getCapability(ModCapabilities.PLAYER_STATS, null).getStrength();
}
if (flag) {
tooltip.add(Utils.translateToLocalFormatted("attribute.modifier.equals." + attributemodifier.getOperation(), new Object[] { ItemStack.DECIMALFORMAT.format(d1), Utils.translateToLocal("attribute.name." + (String) entry.getKey()) }));
} else if (d0 > 0.0D) {
tooltip.add(TextFormatting.BLUE + Utils.translateToLocalFormatted("attribute.modifier.plus." + attributemodifier.getOperation(), new Object[] { ItemStack.DECIMALFORMAT.format(d1), Utils.translateToLocal("attribute.name." + (String) entry.getKey()) }));
} else if (d0 < 0.0D) {
d1 = d1 * -1.0D;
tooltip.add(TextFormatting.RED + Utils.translateToLocalFormatted("attribute.modifier.take." + attributemodifier.getOperation(), new Object[] { ItemStack.DECIMALFORMAT.format(d1), Utils.translateToLocal("attribute.name." + (String) entry.getKey()) }));
}
}
}
}
} else {
tooltip.add("Hold " + TextFormatting.YELLOW + TextFormatting.ITALIC + "Alt" + TextFormatting.GRAY + " for more stats");
}
}
if (event.getItemStack().getItem() instanceof IOrgWeapon && event.getItemStack().getItem() != ModItems.DreamShield) {
String member = ((IOrgWeapon) event.getItemStack().getItem()).getMember().toString();
tooltip.add(member.substring(0, 1) + member.substring(1, member.length()).toLowerCase());
}
Item ghostBlox = Item.getItemFromBlock(ModBlocks.GhostBlox);
if (event.getItemStack().getItem() == ghostBlox) {
if (!KeyboardHelper.isShiftDown()) {
event.getToolTip().add(TextFormatting.ITALIC + Utils.translateToLocal(Strings.HoldForInfo));
} else {
int x = 30;
String s = Utils.translateToLocal(Strings.GhostBloxDesc).replace("%s", Utils.translateToLocal(ModBlocks.GhostBlox.getUnlocalizedName() + ".name"));
s = s.replaceAll("(.{" + x + ",}?)\\s+", "$1\n");
String[] splitS = s.split("\n");
for (String element : splitS) event.getToolTip().add(element);
}
}
Item dangerBlox = Item.getItemFromBlock(ModBlocks.DangerBlox);
if (event.getItemStack().getItem() == dangerBlox) {
if (!KeyboardHelper.isShiftDown()) {
event.getToolTip().add(TextFormatting.ITALIC + Utils.translateToLocal(Strings.HoldForInfo));
} else {
int x = 30;
String s = Utils.translateToLocal(Strings.DangerBloxDesc).replace("%s", Utils.translateToLocal(ModBlocks.DangerBlox.getUnlocalizedName() + ".name"));
s = s.replaceAll("(.{" + x + ",}?)\\s+", "$1\n");
String[] splitS = s.split("\n");
for (String element : splitS) event.getToolTip().add(element);
}
}
Item bounceBlox = Item.getItemFromBlock(ModBlocks.BounceBlox);
if (event.getItemStack().getItem() == bounceBlox) {
if (!KeyboardHelper.isShiftDown()) {
event.getToolTip().add(TextFormatting.ITALIC + Utils.translateToLocal(Strings.HoldForInfo));
} else {
int x = 30;
String s = Utils.translateToLocal(Strings.BounceBloxDesc).replace("%s", Utils.translateToLocal(ModBlocks.BounceBlox.getUnlocalizedName() + ".name"));
s = s.replaceAll("(.{" + x + ",}?)\\s+", "$1\n");
String[] splitS = s.split("\n");
for (String element : splitS) event.getToolTip().add(element);
}
}
Item magnetBlox = Item.getItemFromBlock(ModBlocks.MagnetBlox);
if (event.getItemStack().getItem() == magnetBlox) {
if (!KeyboardHelper.isShiftDown()) {
event.getToolTip().add(TextFormatting.ITALIC + Utils.translateToLocal(Strings.HoldForInfo));
} else {
event.getToolTip().add("This Block is WIP and doesn't work at all.");
event.getToolTip().add("It won't crash your game though.");
}
}
Item kkchest = Item.getItemFromBlock(ModBlocks.KKChest);
if (event.getItemStack().getItem() == kkchest) {
// event.getToolTip().add(Utils.translateToLocal(Strings.KKChestDesc_1));
if (!KeyboardHelper.isShiftDown())
event.getToolTip().add(TextFormatting.ITALIC + Utils.translateToLocal(Strings.HoldForInfo));
else
event.getToolTip().add(Utils.translateToLocal(Strings.KKChestDesc_2));
}
Item savepoint = Item.getItemFromBlock(ModBlocks.SavePoint);
if (event.getItemStack().getItem() == savepoint)
if (!KeyboardHelper.isShiftDown())
event.getToolTip().add(TextFormatting.ITALIC + Utils.translateToLocal(Strings.HoldForInfo));
else
event.getToolTip().add(Utils.translateToLocal(Strings.SavePointDesc));
}
use of net.minecraft.inventory.EntityEquipmentSlot in project takumicraft by TNTModders.
the class EntityFighterCreeper method takumiExplodeEvent.
@Override
public boolean takumiExplodeEvent(Detonate event) {
event.getAffectedEntities().removeIf(entity -> entity instanceof EntityHorseCreeper);
if (!this.world.isRemote) {
for (int i = 0; i < (6 + this.rand.nextInt(5)) * (this.getPowered() ? 1.5 : 1); i++) {
EntityZombieCreeper zombieCreeper = new EntityZombieCreeper(this.world);
zombieCreeper.copyLocationAndAnglesFrom(this);
for (EntityEquipmentSlot slot : EntityEquipmentSlot.values()) {
zombieCreeper.setItemStackToSlot(slot, this.getItemStackFromSlot(slot));
}
if (this.getPowered()) {
TakumiUtils.takumiSetPowered(zombieCreeper, true);
}
zombieCreeper.setAttackTarget(this.getAttackTarget());
this.world.spawnEntity(zombieCreeper);
}
}
return true;
}
use of net.minecraft.inventory.EntityEquipmentSlot in project ImmersiveEngineering by BluSunrize.
the class CommonProxy method getServerGuiElement.
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if (ID >= Lib.GUIID_Base_Item) {
EntityEquipmentSlot slot = EntityEquipmentSlot.values()[ID / 100];
// Slot determined, get actual ID
ID %= 100;
ItemStack item = player.getItemStackFromSlot(slot);
if (!item.isEmpty() && item.getItem() instanceof IGuiItem && ((IGuiItem) item.getItem()).getGuiID(item) == ID) {
if (ID == Lib.GUIID_Revolver && item.getItem() instanceof IEItemInterfaces.IBulletContainer)
return new ContainerRevolver(player.inventory, world, slot, item);
if (ID == Lib.GUIID_Toolbox && item.getItem() instanceof ItemToolbox)
return new ContainerToolbox(player.inventory, world, slot, item);
if (ID == Lib.GUIID_MaintenanceKit && item.getItem() instanceof ItemMaintenanceKit)
return new ContainerMaintenanceKit(player.inventory, world, slot, item);
}
} else {
TileEntity te = world.getTileEntity(new BlockPos(x, y, z));
if (te instanceof IGuiTile) {
Object gui = null;
if (ID == Lib.GUIID_CokeOven && te instanceof TileEntityCokeOven)
gui = new ContainerCokeOven(player.inventory, (TileEntityCokeOven) te);
if (ID == Lib.GUIID_AlloySmelter && te instanceof TileEntityAlloySmelter)
gui = new ContainerAlloySmelter(player.inventory, (TileEntityAlloySmelter) te);
if (ID == Lib.GUIID_BlastFurnace && te instanceof TileEntityBlastFurnace)
gui = new ContainerBlastFurnace(player.inventory, (TileEntityBlastFurnace) te);
if (ID == Lib.GUIID_WoodenCrate && te instanceof TileEntityWoodenCrate)
gui = new ContainerCrate(player.inventory, (TileEntityWoodenCrate) te);
if (ID == Lib.GUIID_Workbench && te instanceof TileEntityModWorkbench)
gui = new ContainerModWorkbench(player.inventory, world, (TileEntityModWorkbench) te);
if (ID == Lib.GUIID_Sorter && te instanceof TileEntitySorter)
gui = new ContainerSorter(player.inventory, (TileEntitySorter) te);
if (ID == Lib.GUIID_Squeezer && te instanceof TileEntitySqueezer)
gui = new ContainerSqueezer(player.inventory, (TileEntitySqueezer) te);
if (ID == Lib.GUIID_Fermenter && te instanceof TileEntityFermenter)
gui = new ContainerFermenter(player.inventory, (TileEntityFermenter) te);
if (ID == Lib.GUIID_Refinery && te instanceof TileEntityRefinery)
gui = new ContainerRefinery(player.inventory, (TileEntityRefinery) te);
if (ID == Lib.GUIID_ArcFurnace && te instanceof TileEntityArcFurnace)
gui = new ContainerArcFurnace(player.inventory, (TileEntityArcFurnace) te);
if (ID == Lib.GUIID_Assembler && te instanceof TileEntityAssembler)
gui = new ContainerAssembler(player.inventory, (TileEntityAssembler) te);
if (ID == Lib.GUIID_AutoWorkbench && te instanceof TileEntityAutoWorkbench)
gui = new ContainerAutoWorkbench(player.inventory, (TileEntityAutoWorkbench) te);
if (ID == Lib.GUIID_Mixer && te instanceof TileEntityMixer)
gui = new ContainerMixer(player.inventory, (TileEntityMixer) te);
if (ID == Lib.GUIID_Turret && te instanceof TileEntityTurret)
gui = new ContainerTurret(player.inventory, (TileEntityTurret) te);
if (ID == Lib.GUIID_FluidSorter && te instanceof TileEntityFluidSorter)
gui = new ContainerFluidSorter(player.inventory, (TileEntityFluidSorter) te);
if (ID == Lib.GUIID_Belljar && te instanceof TileEntityBelljar)
gui = new ContainerBelljar(player.inventory, (TileEntityBelljar) te);
if (ID == Lib.GUIID_ToolboxBlock && te instanceof TileEntityToolbox)
gui = new ContainerToolboxBlock(player.inventory, (TileEntityToolbox) te);
if (gui != null)
((IGuiTile) te).onGuiOpened(player, false);
return gui;
}
}
return null;
}
Aggregations