use of net.minecraft.entity.ai.attributes.AttributeMap in project SpongeCommon by SpongePowered.
the class MixinEntityPlayerMP method refreshScaledHealth.
@Override
public void refreshScaledHealth() {
// We need to use the dirty instances to signify that the player needs to ahve it updated, instead
// of modifying the attribute instances themselves, we bypass other potentially detrimental logi
// that would otherwise break the actual health scaling.
final Set<IAttributeInstance> dirtyInstances = ((AttributeMap) this.getAttributeMap()).getDirtyInstances();
injectScaledHealth(dirtyInstances, true);
// Send the new information to the client.
sendHealthUpdate();
this.connection.sendPacket(new SPacketEntityProperties(this.getEntityId(), dirtyInstances));
// Reset the dirty instances since they've now been manually updated on the client.
dirtyInstances.clear();
}
use of net.minecraft.entity.ai.attributes.AttributeMap in project Charset by CharsetMC.
the class ItemUtils method getAttributeValue.
public static double getAttributeValue(EntityEquipmentSlot slot, ItemStack is, IAttribute attr) {
Multimap<String, AttributeModifier> attrs = is.getItem().getAttributeModifiers(slot, is);
if (attrs != null) {
AttributeMap map = new AttributeMap();
map.applyAttributeModifiers(attrs);
IAttributeInstance instance = map.getAttributeInstance(attr);
if (instance != null) {
return instance.getAttributeValue();
}
}
return 0;
}
use of net.minecraft.entity.ai.attributes.AttributeMap in project Gaspunk by Ladysnake.
the class SicknessTests method setUp.
@Before
public void setUp() {
mockedCreeper = mock(EntityCreeper.class);
// prevent entity.world.isRemote check from crashing
mockedCreeper.world = mock(World.class);
// allow the testing of the air supply attribute
AbstractAttributeMap attributeMap = new AttributeMap();
attributeMap.registerAttribute(CapabilityBreathing.MAX_AIR_SUPPLY);
when(mockedCreeper.getAttributeMap()).thenReturn(attributeMap);
when(mockedCreeper.getEntityAttribute(any())).then(InvocationOnMock::callRealMethod);
// setup capabilities
IBreathingHandler breathingHandler = new CapabilityBreathing.DefaultBreathingHandler(mockedCreeper);
ISicknessHandler sicknessHandler = new CapabilitySickness.DefaultSicknessHandler(mockedCreeper);
when(mockedCreeper.getCapability(any(), any())).then(invocation -> invocation.getArgument(0) == CapabilitySickness.CAPABILITY_SICKNESS ? sicknessHandler : breathingHandler);
when(mockedCreeper.getItemStackFromSlot(any())).thenReturn(ItemStack.EMPTY);
when(mockedCreeper.decreaseAirSupply(anyInt())).then(InvocationOnMock::callRealMethod);
}
Aggregations