Search in sources :

Example 6 with ChunkProviderServer

use of net.minecraft.world.gen.ChunkProviderServer 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

ChunkProviderServer (net.minecraft.world.gen.ChunkProviderServer)6 WorldServer (net.minecraft.world.WorldServer)5 Chunk (net.minecraft.world.chunk.Chunk)3 Collection (java.util.Collection)2 Entity (net.minecraft.entity.Entity)2 ChatComponentText (net.minecraft.util.ChatComponentText)2 IHasMass (com.builtbroken.mc.api.IHasMass)1 EntitySelector (com.builtbroken.mc.prefab.entity.selector.EntitySelector)1 Predicate (com.google.common.base.Predicate)1 Block (net.minecraft.block.Block)1 IMob (net.minecraft.entity.monster.IMob)1 SPacketUnloadChunk (net.minecraft.network.play.server.SPacketUnloadChunk)1 PlayerChunkMap (net.minecraft.server.management.PlayerChunkMap)1 PlayerChunkMapEntry (net.minecraft.server.management.PlayerChunkMapEntry)1 TileEntity (net.minecraft.tileentity.TileEntity)1