package electrosphere.entity.state.equip; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.List; import org.joml.Vector3d; import annotations.IntegrationTest; import electrosphere.engine.Globals; import electrosphere.entity.Entity; import electrosphere.entity.state.inventory.InventoryUtils; import electrosphere.entity.types.attach.AttachUtils; import electrosphere.entity.types.creature.CreatureTemplate; import electrosphere.entity.types.creature.CreatureUtils; import electrosphere.entity.types.item.ItemUtils; import template.EntityTestTemplate; import testutils.TestEngineUtils; /** * Server equip state tests */ public class ServerEquipStateTests extends EntityTestTemplate { @IntegrationTest public void spawningWithEquippedItem(){ TestEngineUtils.simulateFrames(1); //spawn entities CreatureTemplate creatureTemplate = CreatureTemplate.createDefault("human"); Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", creatureTemplate); Entity katana = ItemUtils.serverSpawnBasicItem(Globals.realmManager.first(), new Vector3d(0,0,0), "Katana2H"); //equip Entity inInventoryItem = InventoryUtils.serverAttemptStoreItem(creature, katana); ServerEquipState serverEquipState = ServerEquipState.getServerEquipState(creature); serverEquipState.commandAttemptEquip(inInventoryItem, serverEquipState.getEquipPoint("handsCombined")); //propagate to client TestEngineUtils.simulateFrames(2); // //verify was equipped assertNotNull(serverEquipState.getEquippedItemAtPoint("handsCombined")); List children = AttachUtils.getChildrenList(creature); assertNotNull(children); assertEquals(1, children.size()); Entity child = children.get(0); assertTrue(ItemUtils.isItem(child)); assertTrue(ItemUtils.isWeapon(child)); assertNotNull(AttachUtils.getParent(child)); assertEquals(AttachUtils.getParent(child), creature); } }