Java 类net.minecraft.util.math.ChunkPos 实例源码

项目:CustomWorldGen    文件:AnvilChunkLoader.java   
public Object[] loadChunk__Async(World worldIn, int x, int z) throws IOException
{
    ChunkPos chunkpos = new ChunkPos(x, z);
    NBTTagCompound nbttagcompound = (NBTTagCompound)this.chunksToRemove.get(chunkpos);

    if (nbttagcompound == null)
    {
        DataInputStream datainputstream = RegionFileCache.getChunkInputStream(this.chunkSaveLocation, x, z);

        if (datainputstream == null)
        {
            return null;
        }

        nbttagcompound = this.dataFixer.process(FixTypes.CHUNK, CompressedStreamTools.read(datainputstream));
    }

    return this.checkedReadChunkFromNBT__Async(worldIn, x, z, nbttagcompound);
}
项目:CustomWorldGen    文件:ChunkIOProvider.java   
public void syncCallback()
{
    if (chunk == null)
    {
        this.runCallbacks();
        return;
    }

    // Load Entities
    this.loader.loadEntities(this.chunkInfo.world, this.nbt.getCompoundTag("Level"), this.chunk);

    MinecraftForge.EVENT_BUS.post(new ChunkDataEvent.Load(this.chunk, this.nbt)); // Don't call ChunkDataEvent.Load async

    this.chunk.setLastSaveTime(provider.worldObj.getTotalWorldTime());
    this.provider.chunkGenerator.recreateStructures(this.chunk, this.chunkInfo.x, this.chunkInfo.z);

    provider.id2ChunkMap.put(ChunkPos.asLong(this.chunkInfo.x, this.chunkInfo.z), this.chunk);
    this.chunk.onChunkLoad();
    this.chunk.populateChunk(provider, provider.chunkGenerator);

    this.runCallbacks();
}
项目:Backmemed    文件:WorldClient.java   
public WorldClient(NetHandlerPlayClient netHandler, WorldSettings settings, int dimension, EnumDifficulty difficulty, Profiler profilerIn)
{
    super(new SaveHandlerMP(), new WorldInfo(settings, "MpServer"), makeWorldProvider(dimension), profilerIn, true);
    this.ambienceTicks = this.rand.nextInt(12000);
    this.viewableChunks = Sets.<ChunkPos>newHashSet();
    this.connection = netHandler;
    this.getWorldInfo().setDifficulty(difficulty);
    this.provider.registerWorld(this);
    this.setSpawnPoint(new BlockPos(8, 64, 8));
    this.chunkProvider = this.createChunkProvider();
    this.mapStorage = new SaveDataMemoryStorage();
    this.calculateInitialSkylight();
    this.calculateInitialWeather();
    Reflector.call(this, Reflector.ForgeWorld_initCapabilities, new Object[0]);
    Reflector.postForgeBusEvent(Reflector.WorldEvent_Load_Constructor, new Object[] {this});

    if (this.mc.playerController != null && this.mc.playerController.getClass() == PlayerControllerMP.class)
    {
        this.mc.playerController = new PlayerControllerOF(this.mc, netHandler);
    }
}
项目:CustomWorldGen    文件:WorldClient.java   
public WorldClient(NetHandlerPlayClient netHandler, WorldSettings settings, int dimension, EnumDifficulty difficulty, Profiler profilerIn)
{
    super(new SaveHandlerMP(), new WorldInfo(settings, "MpServer"), net.minecraftforge.common.DimensionManager.createProviderFor(dimension), profilerIn, true);
    this.ambienceTicks = this.rand.nextInt(12000);
    this.viewableChunks = Sets.<ChunkPos>newHashSet();
    this.connection = netHandler;
    this.getWorldInfo().setDifficulty(difficulty);
    this.provider.registerWorld(this);
    this.setSpawnPoint(new BlockPos(8, 64, 8)); //Forge: Moved below registerWorld to prevent NPE in our redirect.
    this.chunkProvider = this.createChunkProvider();
    this.mapStorage = new SaveDataMemoryStorage();
    this.calculateInitialSkylight();
    this.calculateInitialWeather();
    this.initCapabilities();
    net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Load(this));
}
项目:Loot-Slash-Conquer    文件:EventEntityJoinWorld.java   
@SubscribeEvent
public void onEntityJoinWorld(EntityJoinWorldEvent event)
{
    if (event.getEntity() instanceof EntityLivingBase && !(event.getEntity() instanceof EntityPlayer))
    {
        EntityLivingBase entity = (EntityLivingBase) event.getEntity();
        World world = entity.getEntityWorld();
        IEnemyLevel enemyLevelCap = entity.getCapability(CapabilityEnemyLevel.ENEMY_LEVEL, null);
        IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);

        if (enemyLevelCap != null && chunkLevelHolder != null)
        {
            if (enemyLevelCap.getEnemyLevel() == 0)
            {
                IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(new ChunkPos(entity.getPosition()));
                int level = chunkLevel.getChunkLevel();

                enemyLevelCap.setEnemyLevel(level);
                entity.setCustomNameTag("Level: " + enemyLevelCap.getEnemyLevel());

                if (level > 1) setAttributeModifiers(entity, level);
            }
        }
    }
}
项目:Loot-Slash-Conquer    文件:ItemShadowfall.java   
@Override
public void createSpecial(ItemStack stack, NBTTagCompound nbt, World world, ChunkPos pos) 
{
    IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
    IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(pos);
    int level = chunkLevel.getChunkLevel();

    Rarity.setRarity(nbt, Rarity.LEGENDARY);
    nbt.setInteger("Level", level);

    // Attributes
    WeaponAttribute.DEXTERITY.addAttribute(nbt, 10);
    WeaponAttribute.MAX_DAMAGE.addAttribute(nbt, 3);
    WeaponAttribute.LIFE_STEAL.addAttribute(nbt, 0.15);

    ItemGeneratorHelper.setAttributeModifiers(nbt, stack);
}
项目:Loot-Slash-Conquer    文件:ItemDivineRapier.java   
@Override
public void createSpecial(ItemStack stack, NBTTagCompound nbt, World world, ChunkPos pos) 
{
    IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
    IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(pos);
    int level = chunkLevel.getChunkLevel();

    Rarity.setRarity(nbt, Rarity.LEGENDARY);
    nbt.setInteger("Level", level);

    // Attributes
    WeaponAttribute.FIRE.addAttribute(nbt, 5);
    WeaponAttribute.STRENGTH.addAttribute(nbt, 3);
    WeaponAttribute.DURABLE.addAttribute(nbt, 0.3);

    ItemGeneratorHelper.setAttributeModifiers(nbt, stack);
}
项目:Loot-Slash-Conquer    文件:ItemAlakaslam.java   
@Override
public void createSpecial(ItemStack stack, NBTTagCompound nbt, World world, ChunkPos pos) 
{
    IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
    IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(pos);
    int level = chunkLevel.getChunkLevel();

    Rarity.setRarity(nbt, Rarity.EXOTIC);
    nbt.setInteger("Level", level);

    // Attributes
    WeaponAttribute.STRENGTH.addAttribute(nbt, 10);
    WeaponAttribute.FORTITUDE.addAttribute(nbt, 10);
    WeaponAttribute.FROST.addAttribute(nbt, 7);

    ItemGeneratorHelper.setAttributeModifiers(nbt, stack);
}
项目:Loot-Slash-Conquer    文件:ItemGoldenPummel.java   
@Override
public void createSpecial(ItemStack stack, NBTTagCompound nbt, World world, ChunkPos pos) 
{
    IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
    IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(pos);
    int level = chunkLevel.getChunkLevel();

    Rarity.setRarity(nbt, Rarity.LEGENDARY);
    nbt.setInteger("Level", level);

    // Attributes
    WeaponAttribute.FORTITUDE.addAttribute(nbt, 10);
    WeaponAttribute.LIGHTNING.addAttribute(nbt, 7);
    WeaponAttribute.MANA_STEAL.addAttribute(nbt, 0.2);

    ItemGeneratorHelper.setAttributeModifiers(nbt, stack);
}
项目:Loot-Slash-Conquer    文件:ItemDoomshadow.java   
@Override
public void createSpecial(ItemStack stack, NBTTagCompound nbt, World world, ChunkPos pos) 
{
    IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
    IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(pos);
    int level = chunkLevel.getChunkLevel();

    Rarity.setRarity(nbt, Rarity.LEGENDARY);
    nbt.setInteger("Level", level);

    // Attributes
    WeaponAttribute.STRENGTH.addAttribute(nbt, 6);
    WeaponAttribute.FORTITUDE.addAttribute(nbt, 4);
    WeaponAttribute.CHAINED.addAttribute(nbt, 10);

    ItemGeneratorHelper.setAttributeModifiers(nbt, stack);
}
项目:Loot-Slash-Conquer    文件:ItemExcaliburRapier.java   
@Override
public void createSpecial(ItemStack stack, NBTTagCompound nbt, World world, ChunkPos pos) 
{
    IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
    IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(pos);
    int level = chunkLevel.getChunkLevel();

    Rarity.setRarity(nbt, Rarity.EXOTIC);
    nbt.setInteger("Level", level);

    // Attributes
    WeaponAttribute.FIRE.addAttribute(nbt, 3);
    WeaponAttribute.FROST.addAttribute(nbt, 3);
    WeaponAttribute.LIGHTNING.addAttribute(nbt, 3);
    WeaponAttribute.STRENGTH.addAttribute(nbt, 8);

    ItemGeneratorHelper.setAttributeModifiers(nbt, stack);
}
项目:Loot-Slash-Conquer    文件:ItemBlazefury.java   
@Override
public void createSpecial(ItemStack stack, NBTTagCompound nbt, World world, ChunkPos pos) 
{
    IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
    IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(pos);
    int level = chunkLevel.getChunkLevel();

    Rarity.setRarity(nbt, Rarity.LEGENDARY);
    nbt.setInteger("Level", level);
    ItemGeneratorHelper.setRune(nbt);

    // Attributes
    WeaponAttribute.FIRE.addAttribute(nbt, 3);
    WeaponAttribute.FROST.addAttribute(nbt, 3);
    WeaponAttribute.LIGHTNING.addAttribute(nbt, 3);

    // Damage and Attack Speed
    double baseDamage = this.getBaseDamage();
    double baseAttackSpeed = this.getBaseAttackSpeed();
    double weightedDamage = ItemGeneratorHelper.getWeightedDamage(nbt, Rarity.getRarity(nbt), baseDamage);
    double weightedAttackSpeed = ItemGeneratorHelper.getWeightedAttackSpeed(Rarity.getRarity(nbt), baseAttackSpeed);

    ItemGeneratorHelper.setMinMaxDamage(nbt, weightedDamage);
    nbt.setDouble("AttackSpeed", weightedAttackSpeed);
}
项目:Loot-Slash-Conquer    文件:ItemGazeOfTruth.java   
@Override
public void createSpecial(ItemStack stack, NBTTagCompound nbt, World world, ChunkPos pos) 
{
    IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
    IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(pos);
    int level = chunkLevel.getChunkLevel();

    Rarity.setRarity(nbt, Rarity.EXOTIC);
    nbt.setInteger("Level", level);
    ItemGeneratorHelper.setRune(nbt);

    // Attributes
    WeaponAttribute.FIRE.addAttribute(nbt, 5);
    WeaponAttribute.MIN_DAMAGE.addAttribute(nbt, 3);
    WeaponAttribute.FORTITUDE.addAttribute(nbt, 5);
    WeaponAttribute.CHAINED.addAttribute(nbt, 15);

    // Damage and Attack Speed
    double baseDamage = this.getBaseDamage();
    double baseAttackSpeed = this.getBaseAttackSpeed();
    double weightedDamage = ItemGeneratorHelper.getWeightedDamage(nbt, Rarity.getRarity(nbt), baseDamage);
    double weightedAttackSpeed = ItemGeneratorHelper.getWeightedAttackSpeed(Rarity.getRarity(nbt), baseAttackSpeed);

    ItemGeneratorHelper.setMinMaxDamage(nbt, weightedDamage);
    nbt.setDouble("AttackSpeed", weightedAttackSpeed);
}
项目:Loot-Slash-Conquer    文件:ItemMoonlitRod.java   
@Override
public void createSpecial(ItemStack stack, NBTTagCompound nbt, World world, ChunkPos pos) 
{
    IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
    IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(pos);
    int level = chunkLevel.getChunkLevel();

    Rarity.setRarity(nbt, Rarity.LEGENDARY);
    nbt.setInteger("Level", level);
    ItemGeneratorHelper.setRune(nbt);

    // Attributes
    WeaponAttribute.INTELLIGENCE.addAttribute(nbt, 3);
    WeaponAttribute.WISDOM.addAttribute(nbt, 3);
    WeaponAttribute.LIGHTNING.addAttribute(nbt, 5);

    // Damage and Attack Speed
    double baseDamage = this.getBaseDamage();
    double baseAttackSpeed = this.getBaseAttackSpeed();
    double weightedDamage = ItemGeneratorHelper.getWeightedDamage(nbt, Rarity.getRarity(nbt), baseDamage);
    double weightedAttackSpeed = ItemGeneratorHelper.getWeightedAttackSpeed(Rarity.getRarity(nbt), baseAttackSpeed);

    ItemGeneratorHelper.setMinMaxDamage(nbt, weightedDamage);
    nbt.setDouble("AttackSpeed", weightedAttackSpeed);
}
项目:harshencastle    文件:VolatileChunkProvider.java   
@Override
public Chunk provideChunk(int x, int z) {
    Chunk chunk = this.loadChunk(x, z);

    if (chunk == null) {
        long i = ChunkPos.asLong(x, z);

        try {
            chunk = ((IChunkProvider) chunkGenerator).provideChunk(x, z);
        }
        catch (Throwable throwable) {
            CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Exception generating new chunk");
            CrashReportCategory crashreportcategory = crashreport.makeCategory("Chunk to be generated");
            crashreportcategory.addCrashSection("Location",
                    String.format("%d,%d", new Object[] { Integer.valueOf(x), Integer.valueOf(z) }));
            crashreportcategory.addCrashSection("Position hash", Long.valueOf(i));
            crashreportcategory.addCrashSection("Generator", chunkGenerator);
            throw new ReportedException(crashreport);
        }

        id2ChunkMap.put(i, chunk);
        chunk.onLoad();
    }

    return chunk;
}
项目:CustomWorldGen    文件:ForgeChunkManager.java   
public static Iterator<Chunk> getPersistentChunksIterableFor(final World world, Iterator<Chunk> chunkIterator)
{
    final ImmutableSetMultimap<ChunkPos, Ticket> persistentChunksFor = getPersistentChunksFor(world);
    final ImmutableSet.Builder<Chunk> builder = ImmutableSet.builder();
    world.theProfiler.startSection("forcedChunkLoading");
    builder.addAll(Iterators.transform(persistentChunksFor.keys().iterator(), new Function<ChunkPos, Chunk>() {
        @Nullable
        @Override
        public Chunk apply(@Nullable ChunkPos input)
        {
            return world.getChunkFromChunkCoords(input.chunkXPos, input.chunkZPos);
        }
    }));
    world.theProfiler.endStartSection("regularChunkLoading");
    builder.addAll(chunkIterator);
    world.theProfiler.endSection();
    return builder.build().iterator();
}
项目:InControl    文件:StructureCache.java   
public boolean isInStructure(World world, String structure, BlockPos pos) {
    int dimension = world.provider.getDimension();
    ChunkPos cp = new ChunkPos(pos);
    long cplong = ChunkPos.asLong(cp.chunkXPos, cp.chunkZPos);
    StructureCacheEntry entry = new StructureCacheEntry(structure, dimension, cplong);
    if (structureCache.containsKey(entry)) {
        return structureCache.get(entry);
    }

    MapGenStructureData data = (MapGenStructureData) world.getPerWorldStorage().getOrLoadData(MapGenStructureData.class, structure);
    if (data == null) {
        return false;
    }

    Set<Long> longs = parseStructureData(data);
    for (Long l : longs) {
        structureCache.put(new StructureCacheEntry(structure, dimension, l), true);
    }
    if (structureCache.containsKey(entry)) {
        return true;
    } else {
        structureCache.put(entry, false);
        return false;
    }
}
项目:Etheric    文件:WorldGenRift.java   
@Override
public boolean generate(World worldIn, Random rand, BlockPos position) {

    if (!worldIn.isRemote && StabilityHandler.getChunkStability(worldIn.provider.getDimension(),
            new ChunkPos(position)) < 0.65F) {
        if (Config.RIFT_FREQUENCY > 0 && rand.nextInt(Config.RIFT_FREQUENCY) == 0) {
            int x = position.getX() + rand.nextInt(16);
            int z = position.getZ() + rand.nextInt(16);
            BlockPos genPos = worldIn.getTopSolidOrLiquidBlock(new BlockPos(x, 0, z)).up(rand.nextInt(3) + 2);

            for (int i = 0; i < 5; i++) {
                if (!worldIn.isAirBlock(genPos.up(i))) {
                    return false;
                }
            }
            worldIn.setBlockState(genPos, RegistryManager.rift.getDefaultState());
            return true;
        }
    }

    return false;
}
项目:Etheric    文件:StabilityHandler.java   
@SubscribeEvent
public static void onServerWorldTick(TickEvent.WorldTickEvent event) {
    if (event.side != Side.CLIENT) {

        int dim = event.world.provider.getDimension();
        if (ticks % 20 == 0) {
            for (ChunkPos pos : getDirtyChunks(dim)) {
                event.world.markChunkDirty(new BlockPos(pos.x << 4, 16, pos.z << 4), null);
            }
            getDirtyChunks(dim).clear();

            // for (InstabilityEvent e : instabilityEvents.get(dim)) {
            // e.affectChunk(event.world);
            // }
            // instabilityEvents.clear();
        }

        ticks++;
    }
}
项目:CustomWorldGen    文件:MapGenStronghold.java   
protected boolean canSpawnStructureAtCoords(int chunkX, int chunkZ)
{
    if (!this.ranBiomeCheck)
    {
        this.generatePositions();
        this.ranBiomeCheck = true;
    }

    for (ChunkPos chunkpos : this.structureCoords)
    {
        if (chunkX == chunkpos.chunkXPos && chunkZ == chunkpos.chunkZPos)
        {
            return true;
        }
    }

    return false;
}
项目:modName    文件:Tile.java   
private ChunkPos[][] createChunkArray()
{
    ChunkPos[][] chunkArray = new ChunkPos[4][4];

    for(int i=0; i<4; i++)
    {
        for(int j=0; j<4; j++)
        {
            int chunkZ = this.tilePosition.z * 4 + j;
            int chunkX = this.tilePosition.x * 4 - 2 * (this.tilePosition.z % 2);

            chunkArray[i][j] = new ChunkPos(chunkX, chunkZ);
        }
    }

    return chunkArray;
}
项目:Backmemed    文件:MapGenStronghold.java   
public MapGenStronghold(Map<String, String> p_i2068_1_)
{
    this();

    for (Entry<String, String> entry : p_i2068_1_.entrySet())
    {
        if (((String)entry.getKey()).equals("distance"))
        {
            this.distance = MathHelper.getDouble((String)entry.getValue(), this.distance, 1.0D);
        }
        else if (((String)entry.getKey()).equals("count"))
        {
            this.structureCoords = new ChunkPos[MathHelper.getInt((String)entry.getValue(), this.structureCoords.length, 1)];
        }
        else if (((String)entry.getKey()).equals("spread"))
        {
            this.spread = MathHelper.getInt((String)entry.getValue(), this.spread, 1);
        }
    }
}
项目:CustomWorldGen    文件:MapGenStronghold.java   
public MapGenStronghold(Map<String, String> p_i2068_1_)
{
    this();

    for (Entry<String, String> entry : p_i2068_1_.entrySet())
    {
        if (((String)entry.getKey()).equals("distance"))
        {
            this.distance = MathHelper.parseDoubleWithDefaultAndMax((String)entry.getValue(), this.distance, 1.0D);
        }
        else if (((String)entry.getKey()).equals("count"))
        {
            this.structureCoords = new ChunkPos[MathHelper.parseIntWithDefaultAndMax((String)entry.getValue(), this.structureCoords.length, 1)];
        }
        else if (((String)entry.getKey()).equals("spread"))
        {
            this.spread = MathHelper.parseIntWithDefaultAndMax((String)entry.getValue(), this.spread, 1);
        }
    }
}
项目:CustomWorldGen    文件:StructureOceanMonument.java   
public void writeToNBT(NBTTagCompound tagCompound)
{
    super.writeToNBT(tagCompound);
    NBTTagList nbttaglist = new NBTTagList();

    for (ChunkPos chunkpos : this.processed)
    {
        NBTTagCompound nbttagcompound = new NBTTagCompound();
        nbttagcompound.setInteger("X", chunkpos.chunkXPos);
        nbttagcompound.setInteger("Z", chunkpos.chunkZPos);
        nbttaglist.appendTag(nbttagcompound);
    }

    tagCompound.setTag("Processed", nbttaglist);
}
项目:Backmemed    文件:ChunkProviderServer.java   
/**
 * Unloads a chunk
 */
public void unload(Chunk chunkIn)
{
    if (this.worldObj.provider.canDropChunk(chunkIn.xPosition, chunkIn.zPosition))
    {
        this.droppedChunksSet.add(Long.valueOf(ChunkPos.asLong(chunkIn.xPosition, chunkIn.zPosition)));
        chunkIn.unloaded = true;
    }
}
项目:Backmemed    文件:WorldServer.java   
@Nullable
public List<NextTickListEntry> getPendingBlockUpdates(Chunk chunkIn, boolean p_72920_2_)
{
    ChunkPos chunkpos = chunkIn.getChunkCoordIntPair();
    int i = (chunkpos.chunkXPos << 4) - 2;
    int j = i + 16 + 2;
    int k = (chunkpos.chunkZPos << 4) - 2;
    int l = k + 16 + 2;
    return this.getPendingBlockUpdates(new StructureBoundingBox(i, 0, k, j, 256, l), p_72920_2_);
}
项目:Backmemed    文件:StructureOceanMonument.java   
public void writeToNBT(NBTTagCompound tagCompound)
{
    super.writeToNBT(tagCompound);
    NBTTagList nbttaglist = new NBTTagList();

    for (ChunkPos chunkpos : this.processed)
    {
        NBTTagCompound nbttagcompound = new NBTTagCompound();
        nbttagcompound.setInteger("X", chunkpos.chunkXPos);
        nbttagcompound.setInteger("Z", chunkpos.chunkZPos);
        nbttaglist.appendTag(nbttagcompound);
    }

    tagCompound.setTag("Processed", nbttaglist);
}
项目:Loot-Slash-Conquer    文件:ItemGenerator.java   
/** Creates a melee weapon/armor with randomized stats. */
public static void create(ItemStack stack, NBTTagCompound nbt, World world, ChunkPos pos)
{
    /*
     * Set rarity
     * Set level
     * Generate attributes based on Rarity
     *      - Common: 0-1 attributes
     *      - Uncommon: 1-2 attributes
     *      - Rare: 2-3 attributes
     *      - Legendary: 3-4 attributes
     *      - Mythic: 4-5 attributes
     * Generate base damage and base attack speed
     * Generate name based on attributes + material/type
     */

    if (Rarity.getRarity(nbt) != Rarity.DEFAULT)
    {
        IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
        IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(pos);
        int level = chunkLevel.getChunkLevel();

        //Rarity.setRarity(nbt, Rarity.getRandomRarity(nbt, ItemGeneratorHelper.rand)); // sets a random rarity
        ItemGeneratorHelper.setTypes(stack, nbt);
        nbt.setInteger("Level", level); // set level to current player level
        ItemGeneratorHelper.setRandomAttributes(stack, nbt, Rarity.getRarity(nbt));
        ItemGeneratorHelper.setAttributeModifiers(nbt, stack);
        nbt.setInteger("HideFlags", 6); // hides Attribute Modifier and Unbreakable tags
    }
}
项目:modName    文件:ChunkProviderBasic.java   
public boolean populateFeatures(ChunkPos chunkpos) {
    boolean village = false;

    for (MapGenStructure mapgenstructure : this.structureGenerators)
    {
        boolean flag = mapgenstructure.generateStructure(this.world, this.random, chunkpos);

        if (mapgenstructure instanceof MapGenVillage)
        {
            village |= flag;
        }
    }

    return village;
}
项目:Backmemed    文件:MapGenStructure.java   
protected void initializeStructureData(World worldIn)
{
    if (this.structureData == null)
    {
        this.structureData = (MapGenStructureData)worldIn.loadItemData(MapGenStructureData.class, this.getStructureName());

        if (this.structureData == null)
        {
            this.structureData = new MapGenStructureData(this.getStructureName());
            worldIn.setItemData(this.getStructureName(), this.structureData);
        }
        else
        {
            NBTTagCompound nbttagcompound = this.structureData.getTagCompound();

            for (String s : nbttagcompound.getKeySet())
            {
                NBTBase nbtbase = nbttagcompound.getTag(s);

                if (nbtbase.getId() == 10)
                {
                    NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbtbase;

                    if (nbttagcompound1.hasKey("ChunkX") && nbttagcompound1.hasKey("ChunkZ"))
                    {
                        int i = nbttagcompound1.getInteger("ChunkX");
                        int j = nbttagcompound1.getInteger("ChunkZ");
                        StructureStart structurestart = MapGenStructureIO.getStructureStart(nbttagcompound1, worldIn);

                        if (structurestart != null)
                        {
                            this.structureMap.put(ChunkPos.asLong(i, j), structurestart);
                        }
                    }
                }
            }
        }
    }
}
项目:minecraft-territorialdealings    文件:_FactionSaveData.java   
public void removeChunk(ChunkPos pos) 
{
    _ChunkSaveData data = new _ChunkSaveData(pos, 0);

    if (this.chunkList.contains(data))  // Will compare by position
    {
        this.chunkList.remove(data);
    }
    // else, huh?
}
项目:CustomWorldGen    文件:ForgeChunkManager.java   
/**
 * Reorganize the internal chunk list so that the chunk supplied is at the *end* of the list
 * This helps if you wish to guarantee a certain "automatic unload ordering" for the chunks
 * in the ticket list
 *
 * @param ticket The ticket holding the chunk list
 * @param chunk The chunk you wish to push to the end (so that it would be unloaded last)
 */
public static void reorderChunk(Ticket ticket, ChunkPos chunk)
{
    if (ticket == null || chunk == null || !ticket.requestedChunks.contains(chunk))
    {
        return;
    }
    ticket.requestedChunks.remove(chunk);
    ticket.requestedChunks.add(chunk);
}
项目:harshencastle    文件:VolatileChunkProvider.java   
@Nullable
public Chunk loadChunk(int x, int z, Runnable runnable) {
    Chunk chunk = getLoadedChunk(x, z);
    if (chunk == null) {
        long pos = ChunkPos.asLong(x, z);
        chunk = net.minecraftforge.common.ForgeChunkManager.fetchDormantChunk(pos, worldObj);
        if (chunk != null) {
            if (!loadingChunks.add(pos)) {
                net.minecraftforge.fml.common.FMLLog.bigWarning(
                        "There is an attempt to load a chunk (%d,%d) in dimension %d that is already being loaded. This will cause weird chunk breakages.",
                        x, z, worldObj.provider.getDimension());
            }

            if (chunk != null) {
                id2ChunkMap.put(ChunkPos.asLong(x, z), chunk);
                chunk.onLoad();
                chunk.populate(this, chunkGenerator);
            }

            loadingChunks.remove(pos);
        }
    }

    // If we didn't load the chunk async and have a callback run it now
    if (runnable != null) {
        runnable.run();
    }
    return chunk;
}
项目:CustomWorldGen    文件:SPacketMultiBlockChange.java   
public SPacketMultiBlockChange(int p_i46959_1_, short[] p_i46959_2_, Chunk p_i46959_3_)
{
    this.chunkPos = new ChunkPos(p_i46959_3_.xPosition, p_i46959_3_.zPosition);
    this.changedBlocks = new SPacketMultiBlockChange.BlockUpdateData[p_i46959_1_];

    for (int i = 0; i < this.changedBlocks.length; ++i)
    {
        this.changedBlocks[i] = new SPacketMultiBlockChange.BlockUpdateData(p_i46959_2_[i], p_i46959_3_);
    }
}
项目:Etheric    文件:StabilityWorldData.java   
public StabilityData getStabilityData(ChunkPos inPos) {
    for (ChunkPos cPos : chunkData.keySet()) {
        if (cPos.equals(inPos)) {
            return chunkData.get(cPos);
        }
    }
    return StabilityData.NO_DATA;
}
项目:Etheric    文件:StabilityWorldData.java   
public float getBaseStability(ChunkPos inPos) {
    for (ChunkPos cPos : chunkData.keySet()) {
        if (cPos.equals(inPos)) {
            return chunkData.get(cPos).getBaseStability();
        }
    }
    return -1;
}
项目:Etheric    文件:StabilityWorldData.java   
public float getStability(ChunkPos inPos) {
    for (ChunkPos cPos : chunkData.keySet()) {
        if (cPos.equals(inPos)) {
            return chunkData.get(cPos).getStability();
        }
    }
    return -1;
}
项目:Etheric    文件:StabilityWorldData.java   
public float setStability(ChunkPos inPos, float stability) {
    for (ChunkPos cPos : chunkData.keySet()) {
        if (cPos.equals(inPos)) {
            return chunkData.get(cPos).setStability(stability).getStability();
        }
    }
    return -1F;
}
项目:Backmemed    文件:StructureOceanMonument.java   
public void readFromNBT(NBTTagCompound tagCompound)
{
    super.readFromNBT(tagCompound);

    if (tagCompound.hasKey("Processed", 9))
    {
        NBTTagList nbttaglist = tagCompound.getTagList("Processed", 10);

        for (int i = 0; i < nbttaglist.tagCount(); ++i)
        {
            NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
            this.processed.add(new ChunkPos(nbttagcompound.getInteger("X"), nbttagcompound.getInteger("Z")));
        }
    }
}
项目:CustomWorldGen    文件:ChunkProviderServer.java   
/**
 * Unloads chunks that are marked to be unloaded. This is not guaranteed to unload every such chunk.
 */
public boolean unloadQueuedChunks()
{
    if (!this.worldObj.disableLevelSaving)
    {
        if (!this.droppedChunksSet.isEmpty())
        {
            for (ChunkPos forced : this.worldObj.getPersistentChunks().keySet())
            {
                this.droppedChunksSet.remove(ChunkPos.asLong(forced.chunkXPos, forced.chunkZPos));
            }

            Iterator<Long> iterator = this.droppedChunksSet.iterator();

            for (int i = 0; i < 100 && iterator.hasNext(); iterator.remove())
            {
                Long olong = (Long)iterator.next();
                Chunk chunk = (Chunk)this.id2ChunkMap.get(olong);

                if (chunk != null && chunk.unloaded)
                {
                    chunk.onChunkUnload();
                    this.saveChunkData(chunk);
                    this.saveChunkExtraData(chunk);
                    this.id2ChunkMap.remove(olong);
                    ++i;
                    net.minecraftforge.common.ForgeChunkManager.putDormantChunk(ChunkPos.asLong(chunk.xPosition, chunk.zPosition), chunk);
                    if (id2ChunkMap.size() == 0 && net.minecraftforge.common.ForgeChunkManager.getPersistentChunksFor(this.worldObj).size() == 0 && !this.worldObj.provider.getDimensionType().shouldLoadSpawn()){
                        net.minecraftforge.common.DimensionManager.unloadWorld(this.worldObj.provider.getDimension());
                        break;
                    }
                }
            }
        }

        this.chunkLoader.chunkTick();
    }

    return false;
}