Search in sources :

Example 31 with FakeWorld

use of com.builtbroken.mc.testing.junit.world.FakeWorld in project Engine by VoltzEngine-Project.

the class AbstractTileTest method testGetTextureName.

@Test
public void testGetTextureName() {
    FakeWorld world = FakeWorld.newWorld("TestGetTextureName");
    world.setBlock(0, 0, 0, block);
    try {
        Method method = Tile.class.getDeclaredMethod("getTextureName");
        method.setAccessible(true);
        Tile tile = ((Tile) world.getTileEntity(0, 0, 0));
        assertTrue(method.invoke(tile) != null);
    } catch (NoSuchMethodException e) {
        fail("Could not find method getTextureName");
    } catch (InvocationTargetException e) {
        fail("Failed to invoke method getTextureName");
    } catch (IllegalAccessException e) {
        fail("Couldn't access method getTextureName");
    }
}
Also used : FakeWorld(com.builtbroken.mc.testing.junit.world.FakeWorld) PacketTile(com.builtbroken.mc.core.network.packet.PacketTile) BlockTile(com.builtbroken.mc.prefab.tile.BlockTile) Tile(com.builtbroken.mc.prefab.tile.Tile) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) Test(org.junit.Test)

Example 32 with FakeWorld

use of com.builtbroken.mc.testing.junit.world.FakeWorld in project Engine by VoltzEngine-Project.

the class AbstractTileTest method testToPos.

@Test
public void testToPos() {
    FakeWorld world = FakeWorld.newWorld("TestTopos");
    world.setBlock(0, 0, 0, block);
    Tile tile = ((Tile) world.getTileEntity(0, 0, 0));
    Pos pos = tile.toPos();
    Pos pos2 = new Pos(tile.x(), tile.y(), tile.z());
    assertTrue("Pos " + pos + " does not equal " + pos2, pos.equals(pos2));
}
Also used : Pos(com.builtbroken.mc.lib.transform.vector.Pos) FakeWorld(com.builtbroken.mc.testing.junit.world.FakeWorld) PacketTile(com.builtbroken.mc.core.network.packet.PacketTile) BlockTile(com.builtbroken.mc.prefab.tile.BlockTile) Tile(com.builtbroken.mc.prefab.tile.Tile) Test(org.junit.Test)

Example 33 with FakeWorld

use of com.builtbroken.mc.testing.junit.world.FakeWorld in project Engine by VoltzEngine-Project.

the class AbstractTileTest method testX.

@Test
public void testX() {
    FakeWorld world = FakeWorld.newWorld("TestX");
    world.setBlock(0, 0, 0, block);
    TileEntity tile = world.getTileEntity(0, 0, 0);
    assertTrue(tile.getClass() == tileClazz);
    assertTrue(tile.xCoord == (int) ((T) tile).x());
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) FakeWorld(com.builtbroken.mc.testing.junit.world.FakeWorld) Test(org.junit.Test)

Example 34 with FakeWorld

use of com.builtbroken.mc.testing.junit.world.FakeWorld in project Engine by VoltzEngine-Project.

the class AbstractTileTest method testDistance.

@Test
public void testDistance() {
    FakeWorld world = FakeWorld.newWorld("TestDistance");
    world.setBlock(0, 0, 0, block);
    Tile tile = ((Tile) world.getTileEntity(0, 0, 0));
    for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
        Pos pos = new Pos(0.5).add(dir);
        Pos center = tile.toPos();
        double distance = tile.distance(pos.x(), pos.y(), pos.z());
        assertTrue("Distance = " + distance + "  Pos = " + pos + "  Center = " + center, Math.abs(distance - 1) <= 0.01);
        player.setLocationAndAngles(pos.x(), pos.y(), pos.z(), 0, 0);
        distance = tile.distance(player);
        assertTrue("Distance = " + distance + "  Pos = " + pos + "  Center = " + center, Math.abs(distance - 1) <= 0.01);
        distance = tile.distance(pos);
        assertTrue("Distance = " + distance + "  Pos = " + pos + "  Center = " + center, Math.abs(distance - 1) <= 0.01);
    }
}
Also used : Pos(com.builtbroken.mc.lib.transform.vector.Pos) FakeWorld(com.builtbroken.mc.testing.junit.world.FakeWorld) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) PacketTile(com.builtbroken.mc.core.network.packet.PacketTile) BlockTile(com.builtbroken.mc.prefab.tile.BlockTile) Tile(com.builtbroken.mc.prefab.tile.Tile) Test(org.junit.Test)

Example 35 with FakeWorld

use of com.builtbroken.mc.testing.junit.world.FakeWorld in project Engine by VoltzEngine-Project.

the class AbstractTileTest method testGetCollisionBounds.

@Test
public void testGetCollisionBounds() {
    FakeWorld world = FakeWorld.newWorld("TestGetCollisionBounds");
    world.setBlock(0, 0, 0, block);
    Tile tile = ((Tile) world.getTileEntity(0, 0, 0));
    Cube cube = tile.getCollisionBounds();
    if (cube != null) {
    // TODO test too see if cube is valid
    }
}
Also used : Cube(com.builtbroken.mc.lib.transform.region.Cube) FakeWorld(com.builtbroken.mc.testing.junit.world.FakeWorld) PacketTile(com.builtbroken.mc.core.network.packet.PacketTile) BlockTile(com.builtbroken.mc.prefab.tile.BlockTile) Tile(com.builtbroken.mc.prefab.tile.Tile) Test(org.junit.Test)

Aggregations

FakeWorld (com.builtbroken.mc.testing.junit.world.FakeWorld)114 Test (org.junit.Test)111 BlockTile (com.builtbroken.mc.prefab.tile.BlockTile)85 Tile (com.builtbroken.mc.prefab.tile.Tile)85 PacketTile (com.builtbroken.mc.core.network.packet.PacketTile)84 AbstractTest (com.builtbroken.mc.testing.junit.AbstractTest)21 TileEntity (net.minecraft.tileentity.TileEntity)11 InvocationTargetException (java.lang.reflect.InvocationTargetException)6 Method (java.lang.reflect.Method)6 Pos (com.builtbroken.mc.lib.transform.vector.Pos)5 SudoIconReg (com.builtbroken.mc.testing.junit.icons.SudoIconReg)4 ItemStack (net.minecraft.item.ItemStack)4 Cube (com.builtbroken.mc.lib.transform.region.Cube)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)3 Location (com.builtbroken.mc.lib.transform.vector.Location)2 TileConductor (com.builtbroken.mc.prefab.tile.TileConductor)1 ArrayList (java.util.ArrayList)1 Block (net.minecraft.block.Block)1 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)1