net.minecraft.world.Heightmap Java Examples

The following examples show how to use net.minecraft.world.Heightmap. 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: GCOreFeature.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Override
public boolean generate(ServerWorldAccess serverWorldAccess, StructureAccessor structureAccessor, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, GCOreFeatureConfig oreFeatureConfig) {
    float f = random.nextFloat() * 3.1415927F;
    float g = (float) oreFeatureConfig.size / 8.0F;
    int i = MathHelper.ceil(((float) oreFeatureConfig.size / 16.0F * 2.0F + 1.0F) / 2.0F);
    double d = (float) blockPos.getX() + MathHelper.sin(f) * g;
    double e = (float) blockPos.getX() - MathHelper.sin(f) * g;
    double h = (float) blockPos.getZ() + MathHelper.cos(f) * g;
    double j = (float) blockPos.getZ() - MathHelper.cos(f) * g;
    double l = blockPos.getY() + random.nextInt(3) - 2;
    double m = blockPos.getY() + random.nextInt(3) - 2;
    int n = blockPos.getX() - MathHelper.ceil(g) - i;
    int o = blockPos.getY() - 2 - i;
    int p = blockPos.getZ() - MathHelper.ceil(g) - i;
    int q = 2 * (MathHelper.ceil(g) + i);
    int r = 2 * (2 + i);

    for (int s = n; s <= n + q; ++s) {
        for (int t = p; t <= p + q; ++t) {
            if (o <= serverWorldAccess.getTopY(Heightmap.Type.OCEAN_FLOOR_WG, s, t)) {
                return this.generateVeinPart(serverWorldAccess, random, oreFeatureConfig, d, e, h, j, l, m, n, o, p, q, r);
            }
        }
    }

    return false;
}
 
Example #2
Source File: MixinClientChunkManager.java    From multiconnect with MIT License 5 votes vote down vote up
@Inject(method = "loadChunkFromPacket", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/WorldChunk;getSectionArray()[Lnet/minecraft/world/chunk/ChunkSection;"))
private void recalculateHeightmaps(int x, int z, BiomeArray biomeArray, PacketByteBuf buf, CompoundTag tag, int verticalStripMask, boolean bl, CallbackInfoReturnable<WorldChunk> ci) {
    if (ConnectionInfo.protocolVersion <= Protocols.V1_13_2) {
        WorldChunk chunk = this.chunk.get();
        for (ChunkSection section : chunk.getSectionArray()) {
            if (section != null) {
                section.calculateCounts();
            }
        }
        Heightmap.populateHeightmaps(chunk, CLIENT_HEIGHTMAPS);
    }
    this.chunk.set(null);
}
 
Example #3
Source File: World_scarpetPlopMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Redirect(method = "getTopY", at = @At(
        value = "INVOKE",
        target = "net/minecraft/world/chunk/WorldChunk.sampleHeightmap(Lnet/minecraft/world/Heightmap$Type;II)I"
))
private int fixSampleHeightmap(WorldChunk chunk, Heightmap.Type type, int x, int z)
{
    if (CarpetSettings.skipGenerationChecks)
    {
        Heightmap.Type newType = type;
        if (type == Heightmap.Type.OCEAN_FLOOR_WG) newType = Heightmap.Type.OCEAN_FLOOR;
        else if (type == Heightmap.Type.WORLD_SURFACE_WG) newType = Heightmap.Type.WORLD_SURFACE;
        return chunk.sampleHeightmap(newType, x, z);
    }
    return chunk.sampleHeightmap(type, x, z);
}
 
Example #4
Source File: HallowedEntities.java    From the-hallow with MIT License 4 votes vote down vote up
public static void init() {
	@SuppressWarnings("unused") Object classloading = SpawnRestriction.class;
	SpawnRestrictionInvoker.invokeRegister(HallowedEntities.MUMMY, SpawnRestriction.Location.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, HostileEntity::canSpawnInDark);
	EntityComponentCallback.event(VillagerEntity.class).register((player, components) -> components.put(CANDY, new VillagerCandyComponent()));
}
 
Example #5
Source File: SpawnRestrictionInvoker.java    From the-hallow with MIT License 4 votes vote down vote up
@Invoker
public static <T extends MobEntity> void invokeRegister(EntityType<T> type, SpawnRestriction.Location location, Heightmap.Type heightmapType, SpawnRestriction.SpawnPredicate<T> restriction) {
	throw new UnsupportedOperationException();
}