net.minecraft.util.ClassInheritanceMultiMap Java Examples

The following examples show how to use net.minecraft.util.ClassInheritanceMultiMap. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ActivationRange.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Checks for the activation state of all entities in this chunk.
 *
 * @param chunk
 */
private static void activateChunkEntities(Chunk chunk) {
    for (ClassInheritanceMultiMap<Entity> slice : chunk.entityLists) {
        for (Entity entity : slice) {
            if (entity == null) {
                continue;
            }
            if (MinecraftServer.currentTick > entity.activatedTick) {
                if (entity.defaultActivationState) {
                    entity.activatedTick = MinecraftServer.currentTick;
                    continue;
                }
                switch (entity.activationType) {
                    case 1:
                        if (monsterBB.intersects(entity.getEntityBoundingBox())) {
                            entity.activatedTick = MinecraftServer.currentTick;
                        }
                        break;
                    case 2:
                        if (animalBB.intersects(entity.getEntityBoundingBox())) {
                            entity.activatedTick = MinecraftServer.currentTick;
                        }
                        break;
                    case 3:
                    default:
                        if (miscBB.intersects(entity.getEntityBoundingBox())) {
                            entity.activatedTick = MinecraftServer.currentTick;
                        }
                }
            }
        }
    }
}
 
Example #2
Source File: MCNetworkState.java    From Signals with GNU General Public License v3.0 5 votes vote down vote up
public void onChunkUnload(Chunk chunk){
    for(ClassInheritanceMultiMap<Entity> entities : chunk.getEntityLists()) {
        for(EntityMinecart cart : entities.getByClass(EntityMinecart.class)) {
            removeCart(cart);
        }
    }
}
 
Example #3
Source File: BlockUtils.java    From GriefPrevention with MIT License 5 votes vote down vote up
private static boolean unloadChunk(net.minecraft.world.chunk.Chunk chunk) {
    net.minecraft.world.World mcWorld = chunk.getWorld();
    ChunkProviderServer chunkProviderServer = (ChunkProviderServer) chunk.getWorld().getChunkProvider();

    boolean saveChunk = false;
    if (chunk.needsSaving(true)) {
        saveChunk = true;
    }

    for (ClassInheritanceMultiMap<Entity> classinheritancemultimap : chunk.getEntityLists())
    {
        chunk.getWorld().unloadEntities(classinheritancemultimap);
    }

    if (saveChunk) {
        saveChunkData(chunkProviderServer, chunk);
    }

    chunkProviderServer.id2ChunkMap.remove(ChunkPos.asLong(chunk.x, chunk.z));
    ((ChunkBridge) chunk).bridge$setScheduledForUnload(-1);
    org.spongepowered.api.world.Chunk spongeChunk = (org.spongepowered.api.world.Chunk) chunk;
    for (Direction direction : CARDINAL_SET) {
        Vector3i neighborPosition = spongeChunk.getPosition().add(direction.asBlockOffset());
        ChunkProviderBridge spongeChunkProvider = (ChunkProviderBridge) mcWorld.getChunkProvider();
        net.minecraft.world.chunk.Chunk neighbor = spongeChunkProvider.bridge$getLoadedChunkWithoutMarkingActive(neighborPosition.getX(),
            neighborPosition.getZ());
        if (neighbor != null) {
            int neighborIndex = directionToIndex(direction);
            int oppositeNeighborIndex = directionToIndex(direction.getOpposite());
            ((ChunkBridge) spongeChunk).bridge$setNeighborChunk(neighborIndex, null);
            ((ChunkBridge) neighbor).bridge$setNeighborChunk(oppositeNeighborIndex, null);
        }
    }

    return true;
}
 
Example #4
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
public boolean hasEntities(Chunk nmsChunk) {
    ClassInheritanceMultiMap<Entity>[] entities = nmsChunk.getEntityLists();
    for (int i = 0; i < entities.length; i++) {
        ClassInheritanceMultiMap<Entity> slice = entities[i];
        if (slice != null && !slice.isEmpty()) {
            return true;
        }
    }
    return false;
}
 
Example #5
Source File: SpongeQueue_1_11.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
public boolean hasEntities(Chunk nmsChunk) {
    ClassInheritanceMultiMap<Entity>[] entities = nmsChunk.getEntityLists();
    for (int i = 0; i < entities.length; i++) {
        ClassInheritanceMultiMap<Entity> slice = entities[i];
        if (slice != null && !slice.isEmpty()) {
            return true;
        }
    }
    return false;
}
 
Example #6
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
public boolean hasEntities(Chunk nmsChunk) {
    ClassInheritanceMultiMap<Entity>[] entities = nmsChunk.getEntityLists();
    for (int i = 0; i < entities.length; i++) {
        ClassInheritanceMultiMap<Entity> slice = entities[i];
        if (slice != null && !slice.isEmpty()) {
            return true;
        }
    }
    return false;
}
 
Example #7
Source File: SpongeQueue_1_12.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
public boolean hasEntities(Chunk nmsChunk) {
    ClassInheritanceMultiMap<Entity>[] entities = nmsChunk.getEntityLists();
    for (int i = 0; i < entities.length; i++) {
        ClassInheritanceMultiMap<Entity> slice = entities[i];
        if (slice != null && !slice.isEmpty()) {
            return true;
        }
    }
    return false;
}
 
Example #8
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
public boolean hasEntities(Chunk nmsChunk) {
    ClassInheritanceMultiMap<Entity>[] entities = nmsChunk.getEntityLists();
    for (int i = 0; i < entities.length; i++) {
        ClassInheritanceMultiMap<Entity> slice = entities[i];
        if (slice != null && !slice.isEmpty()) {
            return true;
        }
    }
    return false;
}
 
Example #9
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
public boolean hasEntities(Chunk nmsChunk) {
    ClassInheritanceMultiMap<Entity>[] entities = nmsChunk.getEntityLists();
    for (int i = 0; i < entities.length; i++) {
        ClassInheritanceMultiMap<Entity> slice = entities[i];
        if (slice != null && !slice.isEmpty()) {
            return true;
        }
    }
    return false;
}
 
Example #10
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
public boolean hasEntities(Chunk nmsChunk) {
    ClassInheritanceMultiMap<Entity>[] entities = nmsChunk.getEntityLists();
    for (int i = 0; i < entities.length; i++) {
        ClassInheritanceMultiMap<Entity> slice = entities[i];
        if (slice != null && !slice.isEmpty()) {
            return true;
        }
    }
    return false;
}