Search in sources :

Example 1 with IHasMass

use of com.builtbroken.mc.api.IHasMass in project Engine by VoltzEngine-Project.

the class MassRegistry method getMass.

@Override
public double getMass(World world, int x, int y, int z) {
    double mass;
    if (world != null) {
        // Checks if the chunk is loaded
        if (world instanceof WorldServer) {
            ChunkProviderServer providerServer = ((WorldServer) world).theChunkProviderServer;
            if (!providerServer.chunkExists(x >> 4, z >> 4)) {
                return -1;
            }
        }
        Block block = world.getBlock(x, y, z);
        int meta = world.getBlockMetadata(x, y, z);
        TileEntity tile = world.getTileEntity(x, y, z);
        if (tile instanceof IHasMass) {
            mass = ((IHasMass) tile).getMass();
            if (mass >= 0) {
                return mass;
            }
        }
        mass = getMass(block, meta);
        return mass >= 0 ? mass : getMass(block);
    }
    return -1;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IHasMass(com.builtbroken.mc.api.IHasMass) ChunkProviderServer(net.minecraft.world.gen.ChunkProviderServer) Block(net.minecraft.block.Block) WorldServer(net.minecraft.world.WorldServer)

Example 2 with IHasMass

use of com.builtbroken.mc.api.IHasMass in project Engine by VoltzEngine-Project.

the class MassRegistry method getMass.

@Override
public double getMass(World world, int x, int y, int z) {
    double mass;
    if (world != null) {
        //Checks if the chunk is loaded
        if (world instanceof WorldServer) {
            ChunkProviderServer providerServer = ((WorldServer) world).theChunkProviderServer;
            if (!providerServer.chunkExists(x >> 4, z >> 4)) {
                return -1;
            }
        }
        Block block = world.getBlock(x, y, z);
        int meta = world.getBlockMetadata(x, y, z);
        TileEntity tile = world.getTileEntity(x, y, z);
        if (tile instanceof IHasMass) {
            mass = ((IHasMass) tile).getMass();
            if (mass >= 0) {
                return mass;
            }
        }
        mass = getMass(block, meta);
        return mass >= 0 ? mass : getMass(block);
    }
    return -1;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IHasMass(com.builtbroken.mc.api.IHasMass) ChunkProviderServer(net.minecraft.world.gen.ChunkProviderServer) Block(net.minecraft.block.Block) WorldServer(net.minecraft.world.WorldServer)

Aggregations

IHasMass (com.builtbroken.mc.api.IHasMass)2 Block (net.minecraft.block.Block)2 TileEntity (net.minecraft.tileentity.TileEntity)2 WorldServer (net.minecraft.world.WorldServer)2 ChunkProviderServer (net.minecraft.world.gen.ChunkProviderServer)2