Search in sources :

Example 56 with Tile

use of com.builtbroken.mc.prefab.tile.Tile in project Engine by VoltzEngine-Project.

the class AbstractTileTest method testOnRemove.

@Test
public void testOnRemove() {
    FakeWorld world = FakeWorld.newWorld("TestOnRemove");
    world.setBlock(0, 0, 0, block);
    Tile tile = ((Tile) world.getTileEntity(0, 0, 0));
    tile.onRemove(block, 0);
}
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) Test(org.junit.Test)

Example 57 with Tile

use of com.builtbroken.mc.prefab.tile.Tile in project Engine by VoltzEngine-Project.

the class AbstractTileTest method testGetOwnerProfile.

@Test
public void testGetOwnerProfile() {
    FakeWorld world = FakeWorld.newWorld("TestGetOwnerprofile");
    world.setBlock(0, 0, 0, block);
    Tile tile = ((Tile) world.getTileEntity(0, 0, 0));
    tile.getOwnerProfile();
}
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) Test(org.junit.Test)

Example 58 with Tile

use of com.builtbroken.mc.prefab.tile.Tile in project Engine by VoltzEngine-Project.

the class AbstractTileTest method testDetermineOrientation.

@Test
public void testDetermineOrientation() {
    FakeWorld world = FakeWorld.newWorld("TestDetermineOrientation");
    world.setBlock(0, 0, 0, block);
    Tile tile = ((Tile) world.getTileEntity(0, 0, 0));
    tile.determineOrientation(player);
//TODO maybe check to ensure direction is valid
}
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) Test(org.junit.Test)

Example 59 with Tile

use of com.builtbroken.mc.prefab.tile.Tile in project Engine by VoltzEngine-Project.

the class AbstractTileTest method testOnPlayerActivated.

@Test
public void testOnPlayerActivated() {
    world.setBlock(0, 0, 0, block);
    Tile tile = (Tile) world.getTileEntity(0, 0, 0);
    for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
        //We divide the face of the tile into 16 sub sections
        for (int i = 0; i <= 256; i++) {
            tile.onPlayerActivated(player, dir.ordinal(), getNextClick(dir, i));
        }
    }
}
Also used : 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 60 with Tile

use of com.builtbroken.mc.prefab.tile.Tile in project Engine by VoltzEngine-Project.

the class ModManager method newBlock.

/**
     * Creates a new block based on the Tile class provided
     * Handles most common registration and data input tasks for the creation of the block.
     * This includes registering the block, tile, built in item & tile renders. It also inits
     * the instance used for the block itself.
     *
     * @param spatialClass - class that will provide all the data to be used when creating the block.
     * @param args         - arguments needed to create a new instance of the spatial class
     */
public BlockTile newBlock(String name, Class<? extends Tile> spatialClass, Object... args) {
    try {
        Tile spatial;
        if (args != null && args.length > 0) {
            List<Class> paramTypes = new ArrayList();
            for (Object arg : args) {
                paramTypes.add(arg.getClass());
            }
            spatial = spatialClass.getConstructor(paramTypes.toArray(new Class[paramTypes.size()])).newInstance();
        } else {
            spatial = spatialClass.newInstance();
        }
        return newBlock(name, spatial);
    } catch (Exception e) {
        throw new RuntimeException(name() + " Tile [" + spatialClass.getSimpleName() + "] failed to be created:", e);
    }
}
Also used : ArrayList(java.util.ArrayList) BlockTile(com.builtbroken.mc.prefab.tile.BlockTile) Tile(com.builtbroken.mc.prefab.tile.Tile) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

BlockTile (com.builtbroken.mc.prefab.tile.BlockTile)93 Tile (com.builtbroken.mc.prefab.tile.Tile)93 PacketTile (com.builtbroken.mc.core.network.packet.PacketTile)88 Test (org.junit.Test)88 FakeWorld (com.builtbroken.mc.testing.junit.world.FakeWorld)85 InvocationTargetException (java.lang.reflect.InvocationTargetException)9 Method (java.lang.reflect.Method)8 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)6 ItemStack (net.minecraft.item.ItemStack)5 Pos (com.builtbroken.mc.imp.transform.vector.Pos)4 SudoIconReg (com.builtbroken.mc.testing.junit.icons.SudoIconReg)4 Cube (com.builtbroken.mc.imp.transform.region.Cube)3 ArrayList (java.util.ArrayList)2 TileEntity (net.minecraft.tileentity.TileEntity)2 Location (com.builtbroken.mc.imp.transform.vector.Location)1 Block (net.minecraft.block.Block)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)1 Explosion (net.minecraft.world.Explosion)1