Search in sources :

Example 56 with FakeWorld

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

the class AbstractTileEntityTest method testGetDistanceFrom.

@Test
public void testGetDistanceFrom() {
    T tile = newTile();
    FakeWorld world = FakeWorld.newWorld("testGetDistanceFrom");
    tile.setWorldObj(world);
    double distance = tile.getDistanceFrom(10, 14, 15);
    double distance2 = new Pos(0.5).sub(10, 14, 15).magnitudeSquared();
    assertTrue("Distance = " + distance + "  Distance2 = " + distance2, Math.abs(distance - distance2) < .01);
}
Also used : Pos(com.builtbroken.mc.imp.transform.vector.Pos) FakeWorld(com.builtbroken.mc.testing.junit.world.FakeWorld) AbstractTest(com.builtbroken.mc.testing.junit.AbstractTest) Test(org.junit.Test)

Example 57 with FakeWorld

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

the class AbstractTileEntityTest method testPlacement.

@Test
public void testPlacement() {
    FakeWorld world = FakeWorld.newWorld("testGetBlockMetadata");
    for (int i = 0; i < 16; i++) {
        int placement_meta = block.damageDropped(i);
        world.setBlock(10, 10, 10, block, placement_meta, 3);
        assertTrue(world.getBlock(10, 10, 10) == block);
        assertTrue(world.getTileEntity(10, 10, 10).getClass() == tileClazz);
        world.getTileEntity(10, 10, 10).markDirty();
        //Test placement meta
        int meta = world.getBlockMetadata(10, 10, 10);
        int placed_meta = world.getTileEntity(10, 10, 10).getBlockMetadata();
        assertTrue("World meta = " + meta + " Tile meta = " + placed_meta, placed_meta == meta);
    }
}
Also used : FakeWorld(com.builtbroken.mc.testing.junit.world.FakeWorld) AbstractTest(com.builtbroken.mc.testing.junit.AbstractTest) Test(org.junit.Test)

Example 58 with FakeWorld

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

the class AbstractTileEntityTest method testInvalidate.

@Test
public void testInvalidate() {
    FakeWorld world = FakeWorld.newWorld("testInvalidate");
    world.setBlock(10, 11, 12, block);
    TileEntity tile = world.getTileEntity(10, 11, 12);
    tile.invalidate();
    assertTrue(tile.isInvalid());
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) FakeWorld(com.builtbroken.mc.testing.junit.world.FakeWorld) AbstractTest(com.builtbroken.mc.testing.junit.AbstractTest) Test(org.junit.Test)

Example 59 with FakeWorld

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

the class AbstractTileEntityTest method testWorldObj.

/**
     * Tests {@link TileEntity#setWorldObj(World)} and {@link TileEntity#getWorldObj()}
     */
@Test
public void testWorldObj() {
    T tile = newTile();
    FakeWorld world = FakeWorld.newWorld("testGetWorldObj");
    assertNull(tile.getWorldObj());
    tile.setWorldObj(world);
    assertNotNull(tile.getWorldObj());
}
Also used : FakeWorld(com.builtbroken.mc.testing.junit.world.FakeWorld) AbstractTest(com.builtbroken.mc.testing.junit.AbstractTest) Test(org.junit.Test)

Example 60 with FakeWorld

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

the class AbstractTileEntityTest method testValidate.

@Test
public void testValidate() {
    FakeWorld world = FakeWorld.newWorld("testValidate");
    world.setBlock(10, 11, 12, block);
    TileEntity tile = world.getTileEntity(10, 11, 12);
    tile.validate();
    assertTrue(!tile.isInvalid());
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) FakeWorld(com.builtbroken.mc.testing.junit.world.FakeWorld) AbstractTest(com.builtbroken.mc.testing.junit.AbstractTest) 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.imp.transform.vector.Pos)4 SudoIconReg (com.builtbroken.mc.testing.junit.icons.SudoIconReg)4 ItemStack (net.minecraft.item.ItemStack)4 Cube (com.builtbroken.mc.imp.transform.region.Cube)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)3 Location (com.builtbroken.mc.imp.transform.vector.Location)1 Location (com.builtbroken.mc.lib.transform.vector.Location)1 Pos (com.builtbroken.mc.lib.transform.vector.Pos)1 TileConductor (com.builtbroken.mc.prefab.tile.TileConductor)1 ArrayList (java.util.ArrayList)1