fix item utils incorrect value handling
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
95aff671c9
commit
8b6e9451ab
@ -6,8 +6,6 @@ import org.joml.Vector3d;
|
|||||||
|
|
||||||
import electrosphere.auth.AuthenticationManager;
|
import electrosphere.auth.AuthenticationManager;
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.entity.types.creature.CreatureTemplate;
|
|
||||||
import electrosphere.entity.types.creature.CreatureUtils;
|
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.menu.MenuGenerators;
|
import electrosphere.menu.MenuGenerators;
|
||||||
import electrosphere.menu.WindowStrings;
|
import electrosphere.menu.WindowStrings;
|
||||||
@ -76,8 +74,6 @@ public class ViewportLoading {
|
|||||||
|
|
||||||
//Run client startup process
|
//Run client startup process
|
||||||
ClientLoading.loadViewport(params);
|
ClientLoading.loadViewport(params);
|
||||||
|
|
||||||
CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(1,1,1), "human", CreatureTemplate.createDefault("human"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -366,7 +366,10 @@ public class ItemUtils {
|
|||||||
* @return true if the item IS in an inventory container, otherwise false
|
* @return true if the item IS in an inventory container, otherwise false
|
||||||
*/
|
*/
|
||||||
public static boolean itemIsInInventory(Entity item){
|
public static boolean itemIsInInventory(Entity item){
|
||||||
return item.containsKey(EntityDataStrings.ITEM_IS_IN_INVENTORY);
|
if(!item.containsKey(EntityDataStrings.ITEM_IS_IN_INVENTORY)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return (boolean)item.getData(EntityDataStrings.ITEM_IS_IN_INVENTORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.joml.Vector3d;
|
import org.joml.Vector3d;
|
||||||
@ -60,14 +59,12 @@ public class ClientEquipStateTests extends EntityTestTemplate {
|
|||||||
|
|
||||||
//verify we still have everything
|
//verify we still have everything
|
||||||
clientSideCreatures = Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.CREATURE);
|
clientSideCreatures = Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.CREATURE);
|
||||||
assertEquals(2, clientSideCreatures.size());
|
assertEquals(1, clientSideCreatures.size());
|
||||||
clientSideItems = Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.ITEM);
|
clientSideItems = Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.ITEM);
|
||||||
assertEquals(2, clientSideItems.size());
|
assertEquals(1, clientSideItems.size());
|
||||||
|
|
||||||
//grab the item in particular
|
//grab the item in particular
|
||||||
Iterator<Entity> entityIterator = clientSideItems.iterator();
|
Entity child = clientSideItems.iterator().next();
|
||||||
entityIterator.next();
|
|
||||||
Entity child = entityIterator.next();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
//verify was equipped
|
//verify was equipped
|
||||||
@ -89,6 +86,9 @@ public class ClientEquipStateTests extends EntityTestTemplate {
|
|||||||
TestEngineUtils.simulateFrames(1);
|
TestEngineUtils.simulateFrames(1);
|
||||||
|
|
||||||
//spawn entities
|
//spawn entities
|
||||||
|
CreatureTemplate creatureTemplate = CreatureTemplate.createDefault("human");
|
||||||
|
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", creatureTemplate);
|
||||||
|
//TODO: associate creature with player object created for viewport
|
||||||
ItemUtils.serverSpawnBasicItem(Globals.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
|
ItemUtils.serverSpawnBasicItem(Globals.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
|
||||||
|
|
||||||
//wait for entities to propagate to client
|
//wait for entities to propagate to client
|
||||||
|
|||||||
@ -4,6 +4,9 @@ import org.junit.jupiter.api.Assertions;
|
|||||||
|
|
||||||
import annotations.FastTest;
|
import annotations.FastTest;
|
||||||
import annotations.UnitTest;
|
import annotations.UnitTest;
|
||||||
|
import electrosphere.entity.Entity;
|
||||||
|
import electrosphere.entity.EntityCreationUtils;
|
||||||
|
import electrosphere.entity.EntityDataStrings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests for item utils
|
* Unit tests for item utils
|
||||||
@ -31,4 +34,13 @@ public class ItemUtilsUnitTests {
|
|||||||
Assertions.assertEquals(null, result);
|
Assertions.assertEquals(null, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@UnitTest
|
||||||
|
@FastTest
|
||||||
|
public void itemIsInInventory_FalseValue_False(){
|
||||||
|
Entity entity = EntityCreationUtils.TEST_createEntity();
|
||||||
|
entity.putData(EntityDataStrings.ITEM_IS_IN_INVENTORY, false);
|
||||||
|
boolean result = ItemUtils.itemIsInInventory(entity);
|
||||||
|
Assertions.assertEquals(false, result);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user