Search in sources :

Example 26 with Tile

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

the class TestTile method testPlacement.

public void testPlacement() {
    FakeWorld world = FakeWorld.newWorld("TileTest");
    world.setBlock(0, 0, 0, getBlock());
    Block block = world.getBlock(0, 0, 0);
    TileEntity tile = world.getTileEntity(0, 0, 0);
    assertNotNull("Test block failed to place", block);
    assertTrue("Test block did not place as an instance of BlockTile", block instanceof BlockTile);
    assertNotNull("Test block did not place with a tile", tile);
    assertTrue("Test block's tile is not an instance of Tile", tile instanceof Tile);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) FakeWorld(com.builtbroken.mc.testing.junit.world.FakeWorld) Block(net.minecraft.block.Block) BlockTile(com.builtbroken.mc.prefab.tile.BlockTile) BlockTile(com.builtbroken.mc.prefab.tile.BlockTile) Tile(com.builtbroken.mc.prefab.tile.Tile)

Example 27 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 instance 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 spatial - instance of the spatial block used to provide all the data for the block
     * @param name    - name the block will use for look up map, registry, texture, etc
     */
public BlockTile newBlock(String name, Tile spatial) {
    String actual_name = name;
    debug("-----------------------------------------------------------");
    debug(" Creating new spatial block name='" + name + "'  Tile='" + spatial + "'");
    if (actual_name == null || actual_name.isEmpty()) {
        if (spatial.name != null && !spatial.name.isEmpty()) {
            actual_name = spatial.name;
        } else {
            Engine.instance.logger().warn(name() + " Tile: " + spatial + " has no defined name to register with and could cause issues with world loading. In order to prevent the game from crashing we are falling back to using the class name.");
            actual_name = LanguageUtility.decapitalizeFirst(spatial.getClass().getSimpleName().replace("Tile", ""));
        }
    }
    BlockTile block = new BlockTile(spatial, modPrefix, defaultTab);
    spatial.setBlock(block);
    block = newBlock(actual_name, block, spatial.itemBlock);
    temp_registry_list.add(spatial);
    Tile newTile = spatial.newTile();
    debug("\t NewTile='" + newTile + "'");
    if (newTile != null) {
        registerTile(actual_name, block, spatial, newTile);
    }
    debug("-----------------------------------------------------------");
    return block;
}
Also used : BlockTile(com.builtbroken.mc.prefab.tile.BlockTile) BlockTile(com.builtbroken.mc.prefab.tile.BlockTile) Tile(com.builtbroken.mc.prefab.tile.Tile)

Example 28 with Tile

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

the class BlockRenderHandler method renderWorldBlock.

@Override
public boolean renderWorldBlock(IBlockAccess access, int x, int y, int z, Block block, int modelId, RenderBlocks renderBlocks) {
    /**
         * Try TileEntity rendering
         */
    TileEntity tile = access.getTileEntity(x, y, z);
    if (tile instanceof Tile) {
        if (((Tile) tile).renderStatic(renderBlocks, new Pos(x, y, z), 0)) {
            return true;
        }
    }
    /**
         * Try Block rendering
         */
    if (block instanceof BlockTile) {
        BlockTile dummy = (BlockTile) block;
        tile = dummy.inject(access, x, y, z);
        boolean b = ((Tile) tile).renderStatic(renderBlocks, new Pos(x, y, z), 0);
        dummy.eject();
        return b;
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Pos(com.builtbroken.mc.imp.transform.vector.Pos) BlockTile(com.builtbroken.mc.prefab.tile.BlockTile) Tile(com.builtbroken.mc.prefab.tile.Tile) BlockTile(com.builtbroken.mc.prefab.tile.BlockTile)

Example 29 with Tile

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

the class AbstractTileTest method testNotifyBlocksOfNeighborChange.

@Test
public void testNotifyBlocksOfNeighborChange() {
    FakeWorld world = FakeWorld.newWorld("TestNotifyBlocksOfNeighborChange");
    world.setBlock(0, 0, 0, block);
    Tile tile = ((Tile) world.getTileEntity(0, 0, 0));
    tile.notifyBlocksOfNeighborChange();
}
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 30 with Tile

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

the class AbstractTileTest method testOnPostplaced.

@Test
public void testOnPostplaced() {
    FakeWorld world = FakeWorld.newWorld("TestOnpostplaced");
    world.setBlock(0, 0, 0, block);
    Tile tile = ((Tile) world.getTileEntity(0, 0, 0));
    tile.onPostPlaced(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)

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