@Override public void onUnequipped(ItemStack stack, EntityLivingBase player) { if(!player.world.isRemote) { Multimap<String, AttributeModifier> attributes = HashMultimap.create(); fillModifiers(attributes, stack); player.getAttributeMap().removeAttributeModifiers(attributes); } }
@Override public void onUnequipped(ItemStack stack, EntityLivingBase player) { if(!player.world.isRemote) { Multimap<String, AttributeModifier> attributes = HashMultimap.create(); fillModifiers(attributes, stack); player.getAttributeMap().removeAttributeModifiers(attributes); } }
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); } } }
private void clearAllStatAttributeModifiers() { for (IBioticStat stat : MatterOverdrive.STAT_REGISTRY.getStats()) { int unlockedLevel = getUnlockedLevel(stat); Multimap<String, AttributeModifier> multimap = stat.attributes(this, unlockedLevel); if (multimap != null) { player.getAttributeMap().removeAttributeModifiers(multimap); } } }
/** * 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)); }
private void clearAllEquipmentAttributeModifiers() { for (int j = 0; j < 5; ++j) { ItemStack itemstack1 = this.inventory.getStackInSlot(j); if (!itemstack1.isEmpty() && itemstack1.getItem() instanceof IBionicPart) { Multimap multimap = ((IBionicPart) itemstack1.getItem()).getModifiers(this, itemstack1); if (multimap != null) { 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 unload(PlethoraFakePlayer player, EntityLivingBase entity) { player.inventory.currentItem = 0; player.setSize(0, 0); player.eyeHeight = player.getDefaultEyeHeight(); for (EntityEquipmentSlot slot : EntityEquipmentSlot.values()) { ItemStack stack = player.getItemStackFromSlot(slot); if (!ItemStack.areItemStacksEqual(stack, entity.getItemStackFromSlot(slot))) { entity.setItemStackToSlot(slot, stack); } if (!stack.isEmpty()) { player.getAttributeMap().removeAttributeModifiers(stack.getAttributeModifiers(slot)); } } NonNullList<ItemStack> main = player.inventory.mainInventory; IItemHandler handler = new EquipmentInvWrapper(entity); for (int i = 1; i < main.size(); i++) { ItemStack stack = main.get(i); for (int j = 0; j < 5; j++) { if (stack.isEmpty()) break; stack = handler.insertItem(j, stack, false); } if (!stack.isEmpty()) { player.dropItem(stack, true, false); } main.set(i, ItemStack.EMPTY); } player.inventory.markDirty(); }
getAttributeMap().removeAttributeModifiers(shield.getAttributeModifiers(EntityEquipmentSlot.OFFHAND));
player.getAttributeMap().removeAttributeModifiers(activeStack.getAttributeModifiers(EntityEquipmentSlot.MAINHAND));