use of net.minecraft.entity.ai.attributes.AbstractAttributeMap in project Bewitchment by Um-Mitternacht.
the class BrewAttributeModifier method applyAttributeModifiers.
public void applyAttributeModifiers(AbstractAttributeMap attributeMap, int amplifier) {
for (Map.Entry<IAttribute, AttributeModifier> entry : modifierMap.entrySet()) {
IAttributeInstance attribute = attributeMap.getAttributeInstance(entry.getKey());
if (attribute == null)
continue;
AttributeModifier modifier = entry.getValue();
attribute.removeModifier(modifier);
attribute.applyModifier(new AttributeModifier(modifier.getID(), this.getName() + " " + amplifier, modifier.getAmount() * (amplifier + 1), modifier.getOperation()));
}
}
use of net.minecraft.entity.ai.attributes.AbstractAttributeMap 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);
}
use of net.minecraft.entity.ai.attributes.AbstractAttributeMap in project Bewitchment by Um-Mitternacht.
the class BrewAttributeModifier method removeAttributeModifiers.
public void removeAttributeModifiers(AbstractAttributeMap attributeMapIn, int amplifier) {
for (Map.Entry<IAttribute, AttributeModifier> entry : modifierMap.entrySet()) {
IAttributeInstance attribute = attributeMapIn.getAttributeInstance(entry.getKey());
if (attribute == null)
continue;
attribute.removeModifier(entry.getValue());
}
}
Aggregations