Search in sources :

Example 1 with ISicknessHandler

use of ladysnake.pathos.api.ISicknessHandler in project Gaspunk by Ladysnake.

the class SicknessTests method testSarinTick2.

@Test
public void testSarinTick2() {
    IBreathingHandler breathingHandler = CapabilityBreathing.getHandler(mockedCreeper).get();
    final float concentration = 0.5f;
    final float time = 5;
    for (int i = 0; i < time; i++) {
        breathingHandler.setConcentration(ModGases.SARIN_GAS, concentration);
        breathingHandler.tick();
    }
    ISicknessHandler sicknessHandler = CapabilitySickness.getHandler(mockedCreeper).get();
    LingeringAgent sarinAgent = (LingeringAgent) GasAgents.NERVE;
    SicknessEffect effect = sicknessHandler.getActiveEffect(GasAgents.LINGERING_EFFECTS.get(sarinAgent));
    float potency = ModGases.SARIN_GAS.getAgents().get(0).getPotency();
    float toxicityPerTick = potency * concentration / 20;
    float oracle = toxicityPerTick * time;
    assertEquals(oracle, effect.getSeverity(), 1E-8f);
}
Also used : IBreathingHandler(ladysnake.gaspunk.api.IBreathingHandler) LingeringAgent(ladysnake.gaspunk.gas.agent.LingeringAgent) ISicknessHandler(ladysnake.pathos.api.ISicknessHandler) SicknessEffect(ladysnake.pathos.api.SicknessEffect) Test(org.junit.Test)

Example 2 with ISicknessHandler

use of ladysnake.pathos.api.ISicknessHandler in project Gaspunk by Ladysnake.

the class SicknessTests method testSarinTick.

@Test
public void testSarinTick() {
    IBreathingHandler handler = CapabilityBreathing.getHandler(mockedCreeper).get();
    handler.setConcentration(ModGases.SARIN_GAS, 0.5f);
    handler.tick();
    ISicknessHandler sicknessHandler = CapabilitySickness.getHandler(mockedCreeper).get();
    assertNotNull(sicknessHandler.getActiveEffect(GasAgents.LINGERING_EFFECTS.get(GasAgents.NERVE)));
}
Also used : IBreathingHandler(ladysnake.gaspunk.api.IBreathingHandler) ISicknessHandler(ladysnake.pathos.api.ISicknessHandler) Test(org.junit.Test)

Example 3 with ISicknessHandler

use of ladysnake.pathos.api.ISicknessHandler 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);
}
Also used : AbstractAttributeMap(net.minecraft.entity.ai.attributes.AbstractAttributeMap) AttributeMap(net.minecraft.entity.ai.attributes.AttributeMap) AbstractAttributeMap(net.minecraft.entity.ai.attributes.AbstractAttributeMap) IBreathingHandler(ladysnake.gaspunk.api.IBreathingHandler) EntityCreeper(net.minecraft.entity.monster.EntityCreeper) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ISicknessHandler(ladysnake.pathos.api.ISicknessHandler) World(net.minecraft.world.World) Before(org.junit.Before)

Aggregations

IBreathingHandler (ladysnake.gaspunk.api.IBreathingHandler)3 ISicknessHandler (ladysnake.pathos.api.ISicknessHandler)3 Test (org.junit.Test)2 LingeringAgent (ladysnake.gaspunk.gas.agent.LingeringAgent)1 SicknessEffect (ladysnake.pathos.api.SicknessEffect)1 AbstractAttributeMap (net.minecraft.entity.ai.attributes.AbstractAttributeMap)1 AttributeMap (net.minecraft.entity.ai.attributes.AttributeMap)1 EntityCreeper (net.minecraft.entity.monster.EntityCreeper)1 World (net.minecraft.world.World)1 Before (org.junit.Before)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1