java类net.minecraft.world.gen.MapGenBase的实例源码

EventListener.java 文件源码 项目:McWorldGenLoop 阅读 26 收藏 0 点赞 0 评论 0
@SubscribeEvent
public void onEvent(ChunkProviderEvent.ReplaceBiomeBlocks event){
    int dim = event.world.provider.getDimensionId();
    if(this.replacedMapGensDimensions.contains(dim)){
        //don't touch, we already replaced it
        return;
    }
    this.replacedMapGensDimensions.add(dim);
    IChunkProvider prov = event.chunkProvider;
    if(!(prov instanceof ChunkProviderGenerate)){
        return;
    }
    List<Field> genFields = ReflectionUtil.getFieldsByType(MapGenBase.class, ChunkProviderGenerate.class, false);

    for(Field field : genFields){
        MapGenBase value = ReflectionUtil.getValue(field, prov, MapGenBase.class);
        value = WorldGenUtil.tileableMapGen(value);
        ReflectionUtil.setValue(field, prov, value);
    }
}
MapGenTileableUtil.java 文件源码 项目:McWorldGenLoop 阅读 19 收藏 0 点赞 0 评论 0
public static void generateTileable(MapGenBase base, IChunkProvider chunkProvider, //
        World worldIn, int chunkX, int chunkZ, ChunkPrimer blocks) {
    // radius is the inly int field in MapGenBase
    int radius = ReflectionUtil.getValueByType(int.class, MapGenBase.class, base, false);

    // set world
    Field worldField = ReflectionUtil.getFieldByType(World.class, MapGenBase.class, false);
    ReflectionUtil.setValue(worldField, base, worldIn);

    // This is the same rand instance that will be used by other generator
    Random rand = ReflectionUtil.getValueByType(Random.class, MapGenBase.class, base, false);
    rand.setSeed(worldIn.getSeed());
    long randX = rand.nextLong();
    long randZ = rand.nextLong();

    int bitmask = Bits.bitmaskClamped(Config.loopBits(worldIn.provider.getDimensionId()) - 4);

    Method meth = ReflectionUtil.findMethod(MapGenBase.class, void.class, false, //
            World.class, int.class, int.class, int.class, int.class, ChunkPrimer.class);

    for (int xOrigin = chunkX - radius; xOrigin <= chunkX + radius; ++xOrigin) {
        for (int zOrigin = chunkZ - radius; zOrigin <= chunkZ + radius; ++zOrigin) {
            int xOriginMod = xOrigin & bitmask;
            int zOriginMod = zOrigin & bitmask;

            long xSeed = (long) xOriginMod * randX;
            long zSeedi2 = (long) zOriginMod * randZ;
            rand.setSeed(xSeed ^ zSeedi2 ^ worldIn.getSeed());

            ReflectionUtil.invokeMethod(void.class, base, meth, //
                    worldIn, xOrigin, zOrigin, chunkX, chunkZ, blocks);
        }
    }
}
MapGenStructure.java 文件源码 项目:Backmemed 阅读 31 收藏 0 点赞 0 评论 0
protected static BlockPos func_191069_a(World p_191069_0_, MapGenStructure p_191069_1_, BlockPos p_191069_2_, int p_191069_3_, int p_191069_4_, int p_191069_5_, boolean p_191069_6_, int p_191069_7_, boolean p_191069_8_)
{
    int i = p_191069_2_.getX() >> 4;
    int j = p_191069_2_.getZ() >> 4;
    int k = 0;

    for (Random random = new Random(); k <= p_191069_7_; ++k)
    {
        for (int l = -k; l <= k; ++l)
        {
            boolean flag = l == -k || l == k;

            for (int i1 = -k; i1 <= k; ++i1)
            {
                boolean flag1 = i1 == -k || i1 == k;

                if (flag || flag1)
                {
                    int j1 = i + p_191069_3_ * l;
                    int k1 = j + p_191069_3_ * i1;

                    if (j1 < 0)
                    {
                        j1 -= p_191069_3_ - 1;
                    }

                    if (k1 < 0)
                    {
                        k1 -= p_191069_3_ - 1;
                    }

                    int l1 = j1 / p_191069_3_;
                    int i2 = k1 / p_191069_3_;
                    Random random1 = p_191069_0_.setRandomSeed(l1, i2, p_191069_5_);
                    l1 = l1 * p_191069_3_;
                    i2 = i2 * p_191069_3_;

                    if (p_191069_6_)
                    {
                        l1 = l1 + (random1.nextInt(p_191069_3_ - p_191069_4_) + random1.nextInt(p_191069_3_ - p_191069_4_)) / 2;
                        i2 = i2 + (random1.nextInt(p_191069_3_ - p_191069_4_) + random1.nextInt(p_191069_3_ - p_191069_4_)) / 2;
                    }
                    else
                    {
                        l1 = l1 + random1.nextInt(p_191069_3_ - p_191069_4_);
                        i2 = i2 + random1.nextInt(p_191069_3_ - p_191069_4_);
                    }

                    MapGenBase.func_191068_a(p_191069_0_.getSeed(), random, l1, i2);
                    random.nextInt();

                    if (p_191069_1_.canSpawnStructureAtCoords(l1, i2))
                    {
                        if (!p_191069_8_ || !p_191069_0_.func_190526_b(l1, i2))
                        {
                            return new BlockPos((l1 << 4) + 8, 64, (i2 << 4) + 8);
                        }
                    }
                    else if (k == 0)
                    {
                        break;
                    }
                }
            }

            if (k == 0)
            {
                break;
            }
        }
    }

    return null;
}
TerrainGen.java 文件源码 项目:CustomWorldGen 阅读 19 收藏 0 点赞 0 评论 0
public static MapGenBase getModdedMapGen(MapGenBase original, InitMapGenEvent.EventType type)
{
    InitMapGenEvent event = new InitMapGenEvent(type, original);
    MinecraftForge.TERRAIN_GEN_BUS.post(event);
    return event.getNewGen();
}
InitMapGenEvent.java 文件源码 项目:CustomWorldGen 阅读 24 收藏 0 点赞 0 评论 0
InitMapGenEvent(EventType type, MapGenBase original)
{
    this.type = type;
    this.originalGen = original;
    this.setNewGen(original);
}
TerrainGen.java 文件源码 项目:TRHS_Club_Mod_2016 阅读 22 收藏 0 点赞 0 评论 0
public static MapGenBase getModdedMapGen(MapGenBase original, InitMapGenEvent.EventType type)
{
    InitMapGenEvent event = new InitMapGenEvent(type, original);
    MinecraftForge.TERRAIN_GEN_BUS.post(event);
    return event.newGen;
}
InitMapGenEvent.java 文件源码 项目:TRHS_Club_Mod_2016 阅读 23 收藏 0 点赞 0 评论 0
InitMapGenEvent(EventType type, MapGenBase original)
{
    this.type = type;
    this.originalGen = original;
    this.newGen = original;
}
WorldGenUtil.java 文件源码 项目:McWorldGenLoop 阅读 20 收藏 0 点赞 0 评论 0
public static MapGenBase tileableMapGen(MapGenBase originalGen) {
    logger.info("Creating new Generator for typr: " + originalGen.getClass());
    return new MapGenTileable(originalGen);
}
MapGenTileable.java 文件源码 项目:McWorldGenLoop 阅读 20 收藏 0 点赞 0 评论 0
public MapGenTileable(MapGenBase generator){
    this.generator = generator;
}
TerrainGen.java 文件源码 项目:CauldronGit 阅读 20 收藏 0 点赞 0 评论 0
public static MapGenBase getModdedMapGen(MapGenBase original, InitMapGenEvent.EventType type)
{
    InitMapGenEvent event = new InitMapGenEvent(type, original);
    MinecraftForge.TERRAIN_GEN_BUS.post(event);
    return event.newGen;
}
InitMapGenEvent.java 文件源码 项目:CauldronGit 阅读 21 收藏 0 点赞 0 评论 0
InitMapGenEvent(EventType type, MapGenBase original)
{
    this.type = type;
    this.originalGen = original;
    this.newGen = original;
}
MapGenDeadzone.java 文件源码 项目:ClockworkPhase2 阅读 20 收藏 0 点赞 0 评论 0
public MapGenDeadzone(MapGenBase base) {
    this.childGen = base;
}
InitMapGenEventRunes.java 文件源码 项目:Runes-And-Silver 阅读 22 收藏 0 点赞 0 评论 0
InitMapGenEventRunes(EventType type, MapGenBase original)
{
    this.type = type;
    this.originalGen = original;
    this.newGen = original;
}
TerrainGen.java 文件源码 项目:Cauldron 阅读 19 收藏 0 点赞 0 评论 0
public static MapGenBase getModdedMapGen(MapGenBase original, InitMapGenEvent.EventType type)
{
    InitMapGenEvent event = new InitMapGenEvent(type, original);
    MinecraftForge.TERRAIN_GEN_BUS.post(event);
    return event.newGen;
}
InitMapGenEvent.java 文件源码 项目:Cauldron 阅读 21 收藏 0 点赞 0 评论 0
InitMapGenEvent(EventType type, MapGenBase original)
{
    this.type = type;
    this.originalGen = original;
    this.newGen = original;
}
TerrainGen.java 文件源码 项目:Cauldron 阅读 25 收藏 0 点赞 0 评论 0
public static MapGenBase getModdedMapGen(MapGenBase original, InitMapGenEvent.EventType type)
{
    InitMapGenEvent event = new InitMapGenEvent(type, original);
    MinecraftForge.TERRAIN_GEN_BUS.post(event);
    return event.newGen;
}
InitMapGenEvent.java 文件源码 项目:Cauldron 阅读 20 收藏 0 点赞 0 评论 0
InitMapGenEvent(EventType type, MapGenBase original)
{
    this.type = type;
    this.originalGen = original;
    this.newGen = original;
}
TerrainGen.java 文件源码 项目:Cauldron 阅读 24 收藏 0 点赞 0 评论 0
public static MapGenBase getModdedMapGen(MapGenBase original, InitMapGenEvent.EventType type)
{
    InitMapGenEvent event = new InitMapGenEvent(type, original);
    MinecraftForge.TERRAIN_GEN_BUS.post(event);
    return event.newGen;
}
InitMapGenEvent.java 文件源码 项目:Cauldron 阅读 21 收藏 0 点赞 0 评论 0
InitMapGenEvent(EventType type, MapGenBase original)
{
    this.type = type;
    this.originalGen = original;
    this.newGen = original;
}
TerrainGen.java 文件源码 项目:RuneCraftery 阅读 20 收藏 0 点赞 0 评论 0
public static MapGenBase getModdedMapGen(MapGenBase original, InitMapGenEvent.EventType type)
{
    InitMapGenEvent event = new InitMapGenEvent(type, original);
    MinecraftForge.TERRAIN_GEN_BUS.post(event);
    return event.newGen;
}
InitMapGenEvent.java 文件源码 项目:RuneCraftery 阅读 22 收藏 0 点赞 0 评论 0
InitMapGenEvent(EventType type, MapGenBase original)
{
    this.type = type;
    this.originalGen = original;
    this.newGen = original;
}
TerrainGen.java 文件源码 项目:RuneCraftery 阅读 19 收藏 0 点赞 0 评论 0
public static MapGenBase getModdedMapGen(MapGenBase original, InitMapGenEvent.EventType type)
{
    InitMapGenEvent event = new InitMapGenEvent(type, original);
    MinecraftForge.TERRAIN_GEN_BUS.post(event);
    return event.newGen;
}
InitMapGenEvent.java 文件源码 项目:RuneCraftery 阅读 25 收藏 0 点赞 0 评论 0
InitMapGenEvent(EventType type, MapGenBase original)
{
    this.type = type;
    this.originalGen = original;
    this.newGen = original;
}
TerrainGen.java 文件源码 项目:BetterNutritionMod 阅读 22 收藏 0 点赞 0 评论 0
public static MapGenBase getModdedMapGen(MapGenBase original, InitMapGenEvent.EventType type)
{
    InitMapGenEvent event = new InitMapGenEvent(type, original);
    MinecraftForge.TERRAIN_GEN_BUS.post(event);
    return event.newGen;
}
InitMapGenEvent.java 文件源码 项目:BetterNutritionMod 阅读 24 收藏 0 点赞 0 评论 0
InitMapGenEvent(EventType type, MapGenBase original)
{
    this.type = type;
    this.originalGen = original;
    this.newGen = original;
}
InitMapGenEvent.java 文件源码 项目:CustomWorldGen 阅读 19 收藏 0 点赞 0 评论 0
public MapGenBase getOriginalGen() { return originalGen; }
InitMapGenEvent.java 文件源码 项目:CustomWorldGen 阅读 23 收藏 0 点赞 0 评论 0
public MapGenBase getNewGen() { return newGen; }
InitMapGenEvent.java 文件源码 项目:CustomWorldGen 阅读 21 收藏 0 点赞 0 评论 0
public void setNewGen(MapGenBase newGen) { this.newGen = newGen; }


问题


面经


文章

微信
公众号

扫码关注公众号