@Override public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) { if(!player.world.isRemote) { Multimap<String, AttributeModifier> attributes = HashMultimap.create(); fillModifiers(attributes, stack); player.getAttributeMap().applyAttributeModifiers(attributes); } }
@Override public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) { if(!player.world.isRemote) { Multimap<String, AttributeModifier> attributes = HashMultimap.create(); fillModifiers(attributes, stack); player.getAttributeMap().applyAttributeModifiers(attributes); } }
map.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier("Loonium Modififer Health", 2, 1)); map.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier("Loonium Modififer Damage", 1.5, 1)); entity.getAttributeMap().applyAttributeModifiers(map);
/** * Refresh the attribute map by removing from the old item and applying the current item * @param attributeMap the map to refresh * @param oldItem the old item whose attributes will be removed * @param currentItem the current item whose attributes will be applied */ public static void refreshAttributes(AbstractAttributeMap attributeMap, ItemStack oldItem, ItemStack currentItem) { if(!oldItem.isEmpty()) attributeMap.removeAttributeModifiers(oldItem.getAttributeModifiers(EntityEquipmentSlot.MAINHAND)); if(!currentItem.isEmpty()) attributeMap.applyAttributeModifiers(currentItem.getAttributeModifiers(EntityEquipmentSlot.OFFHAND)); }
public void updateStatModifyers(IBioticStat stat) { int unlockedLevel = getUnlockedLevel(stat); Multimap<String, AttributeModifier> multimap = stat.attributes(this, unlockedLevel); if (multimap != null) { if (isAndroid()) { if (unlockedLevel > 0) { if (stat.isEnabled(this, unlockedLevel)) { player.getAttributeMap().applyAttributeModifiers(multimap); } else { player.getAttributeMap().removeAttributeModifiers(multimap); } } else { player.getAttributeMap().removeAttributeModifiers(multimap); } } else { player.getAttributeMap().removeAttributeModifiers(multimap); } } }
@Override public void onUpdate() { ItemStack prev = prevWeapon; ItemStack cur = getHeldItemMainhand(); if (!ItemStack.areItemStacksEqual(cur, prev)) { if (!prev.isEmpty()) { getAttributeMap().removeAttributeModifiers(prev.getAttributeModifiers(EntityEquipmentSlot.MAINHAND)); } if (!cur.isEmpty()) { getAttributeMap().applyAttributeModifiers(cur.getAttributeModifiers(EntityEquipmentSlot.MAINHAND)); } prevWeapon = cur.copy(); } if (chargedLocation != null && chargedLocation.chargeItems(new NNList<>(cur))) { killerJoe.markDirty(); } ticksSinceLastSwing++; }
private void manageEquipmentAttributeModifiers() { boolean needsSync = false; for (int j = 0; j < 5; ++j) { ItemStack itemstack = this.previousBionicParts.get(j); ItemStack itemstack1 = this.inventory.getStackInSlot(j); if (!ItemStack.areItemStacksEqual(itemstack1, itemstack)) { //((WorldServer)player.world).getEntityTracker().func_151247_a(player, new S04PacketEntityEquipment(player.getEntityId(), j, itemstack1)); if (!itemstack.isEmpty() && itemstack.getItem() instanceof IBionicPart) { Multimap multimap = ((IBionicPart) itemstack.getItem()).getModifiers(this, itemstack); if (multimap != null) { player.getAttributeMap().removeAttributeModifiers(multimap); } } if (!itemstack1.isEmpty() && itemstack1.getItem() instanceof IBionicPart) { Multimap multimap = ((IBionicPart) itemstack1.getItem()).getModifiers(this, itemstack1); if (multimap != null) { player.getAttributeMap().applyAttributeModifiers(multimap); } } this.previousBionicParts.set(j, itemstack1.copy()); needsSync = true; } } if (needsSync) { sync(EnumSet.of(DataType.INVENTORY), true); } }
@Override public void onUpdate() { ItemStack itemstack = previousItem; ItemStack itemstack1 = getHeldItem(EnumHand.MAIN_HAND); if (!ItemStack.areItemStacksEqual(itemstack1, itemstack)) { if (!itemstack.isEmpty()) { getAttributeMap().removeAttributeModifiers(itemstack.getAttributeModifiers(EntityEquipmentSlot.MAINHAND)); } if (!itemstack1.isEmpty()) { getAttributeMap().applyAttributeModifiers(itemstack1.getAttributeModifiers(EntityEquipmentSlot.MAINHAND)); } myName = "[CoFH]" + (!itemstack1.isEmpty() ? " using " + itemstack1.getDisplayName() : ""); } previousItem = itemstack1.isEmpty() ? ItemStack.EMPTY : itemstack1.copy(); interactionManager.updateBlockRemoving(); //This was commented out beforehand fyi. //if (itemInUse != null) { // tickItemInUse(itemstack); //} }
public static void load(PlethoraFakePlayer player, Entity entity) { player.setWorld(entity.getEntityWorld()); player.setPositionAndRotation(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch); player.rotationYawHead = player.rotationYaw; player.setSize(entity.width, entity.height); player.eyeHeight = entity.height; player.setSneaking(entity.isSneaking()); player.inventory.currentItem = 0; if (entity instanceof EntityLivingBase) { EntityLivingBase living = (EntityLivingBase) entity; for (EntityEquipmentSlot slot : EntityEquipmentSlot.values()) { ItemStack stack = living.getItemStackFromSlot(slot); if (!stack.isEmpty()) { player.setItemStackToSlot(slot, stack.copy()); player.getAttributeMap().applyAttributeModifiers(stack.getAttributeModifiers(slot)); } else { player.setItemStackToSlot(slot, ItemStack.EMPTY); } } } player.inventory.markDirty(); }
if (!getShieldStack().isEmpty()) { shield = getShieldStack().copy(); getAttributeMap().applyAttributeModifiers(shield.getAttributeModifiers(EntityEquipmentSlot.OFFHAND));
player.getAttributeMap().applyAttributeModifiers(activeStack.getAttributeModifiers(EntityEquipmentSlot.MAINHAND));