本文整理汇总了Java中net.minecraftforge.event.world.ChunkDataEvent类的典型用法代码示例。如果您正苦于以下问题:Java ChunkDataEvent类的具体用法?Java ChunkDataEvent怎么用?Java ChunkDataEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ChunkDataEvent类属于net.minecraftforge.event.world包,在下文中一共展示了ChunkDataEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onChunkLoad
import net.minecraftforge.event.world.ChunkDataEvent; //导入依赖的package包/类
@SubscribeEvent
public static void onChunkLoad(ChunkDataEvent.Load event)
{
World world = event.getWorld();
ChunkPos chunkPos = event.getChunk().getPos();
IChunkLevelHolder chunkLevelHolder = getChunkLevelHolder(world);
ChunkLevel chunkLevel = new ChunkLevel(world, chunkPos, getAreaLevel(world, chunkPos));
NBTTagCompound nbt = event.getData();
if (nbt.hasKey(ID.toString(), Constants.NBT.TAG_INT))
{
NBTTagInt levelTag = (NBTTagInt) nbt.getTag(ID.toString());
chunkLevel.deserializeNBT(levelTag);
}
chunkLevelHolder.setChunkLevel(null, chunkLevel);
}
示例2: onChunkSave
import net.minecraftforge.event.world.ChunkDataEvent; //导入依赖的package包/类
@SubscribeEvent
public void onChunkSave(ChunkDataEvent.Save event) {
Map<BlockPos, List<ISemiBlock>> map = semiBlocks.get(event.getChunk());
if (map != null && map.size() > 0) {
NBTTagList tagList = new NBTTagList();
for (Map.Entry<BlockPos, List<ISemiBlock>> entry : map.entrySet()) {
for(ISemiBlock semiBlock : entry.getValue()){
NBTTagCompound t = new NBTTagCompound();
semiBlock.writeToNBT(t);
NBTUtil.setPos(t, entry.getKey());
t.setString("type", getKeyForSemiBlock(semiBlock));
tagList.appendTag(t);
}
}
event.getData().setTag("SemiBlocks", tagList);
}
}
示例3: onChunkLoad
import net.minecraftforge.event.world.ChunkDataEvent; //导入依赖的package包/类
@SubscribeEvent
public void onChunkLoad(ChunkDataEvent.Load event) {
try {
if (!event.getWorld().isRemote) {
if (event.getData().hasKey("SemiBlocks")) {
Map<BlockPos, List<ISemiBlock>> map = getOrCreateMap(event.getChunk());
map.clear();
NBTTagList tagList = event.getData().getTagList("SemiBlocks", 10);
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound t = tagList.getCompoundTagAt(i);
ISemiBlock semiBlock = getSemiBlockForKey(t.getString("type"));
if (semiBlock != null) {
semiBlock.readFromNBT(t);
addSemiBlock(event.getWorld(), NBTUtil.getPos(t), semiBlock, event.getChunk());
}
}
}
}
} catch (Throwable e) {
e.printStackTrace();
}
}
示例4: onChunkSave
import net.minecraftforge.event.world.ChunkDataEvent; //导入依赖的package包/类
@SubscribeEvent
public static void onChunkSave(ChunkDataEvent.Save event) {
if (!event.getWorld().isRemote) {
int dim = event.getWorld().provider.getDimension();
ChunkPos pos = event.getChunk().getPos();
StabilityData stability = getChunkData(dim, pos);
if (stability != StabilityData.NO_DATA) {
event.getData().setTag(STABILITY_KEY, stability.writeToNBT());
}
if (!event.getChunk().isLoaded()) {
removeChunkData(dim, pos);
}
}
}
示例5: onChunkLoad
import net.minecraftforge.event.world.ChunkDataEvent; //导入依赖的package包/类
@SubscribeEvent
public static void onChunkLoad(ChunkDataEvent.Load event) {
if (!event.getWorld().isRemote) {
int dim = event.getWorld().provider.getDimension();
ChunkPos pos = event.getChunk().getPos();
StabilityData stability;
if (event.getData().hasKey(STABILITY_KEY, 10)) {
stability = new StabilityData(event.getData().getCompoundTag(STABILITY_KEY));
} else {
stability = generateChunkStability(event.getWorld().rand);
}
addChunkData(dim, pos, stability);
}
}
示例6: syncCallback
import net.minecraftforge.event.world.ChunkDataEvent; //导入依赖的package包/类
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();
}
示例7: chunkLoaded
import net.minecraftforge.event.world.ChunkDataEvent; //导入依赖的package包/类
@SubscribeEvent
public void chunkLoaded(ChunkDataEvent.Load event)
{
Chunk chunk = event.getChunk();
NBTTagCompound compound = event.getData();
if(!compound.hasKey("terratorial_tag"))
{
Random rand = chunk.getRandomWithSeed(chunk.getWorld().getSeed());
if(rand.nextInt(100) < 4)
{
}
chunk.setChunkModified();
}
}
示例8: callStage2
import net.minecraftforge.event.world.ChunkDataEvent; //导入依赖的package包/类
public void callStage2(QueuedChunk queuedChunk, net.minecraft.world.chunk.Chunk chunk) throws RuntimeException {
if(chunk == null) {
// If the chunk loading failed just do it synchronously (may generate)
queuedChunk.provider.originalLoadChunk(queuedChunk.x, queuedChunk.z);
return;
}
queuedChunk.loader.loadEntities(queuedChunk.world, queuedChunk.compound.func_74775_l("Level"), chunk);
MinecraftForge.EVENT_BUS.post(new ChunkDataEvent.Load(chunk, queuedChunk.compound)); // Don't call ChunkDataEvent.Load async
chunk.field_76641_n = queuedChunk.provider.field_73251_h.func_82737_E();
queuedChunk.provider.field_73244_f.func_76163_a(ChunkCoordIntPair.func_77272_a(queuedChunk.x, queuedChunk.z), chunk);
queuedChunk.provider.field_73245_g.add(chunk);
chunk.func_76631_c();
if (queuedChunk.provider.field_73246_d != null) {
queuedChunk.provider.field_73246_d.func_82695_e(queuedChunk.x, queuedChunk.z);
}
chunk.func_76624_a(queuedChunk.provider, queuedChunk.provider, queuedChunk.x, queuedChunk.z);
}
示例9: loadChunk
import net.minecraftforge.event.world.ChunkDataEvent; //导入依赖的package包/类
@SubscribeEvent
public void loadChunk(ChunkDataEvent.Load event) {
Chunk chunk = event.getChunk();
FlatChunkLayer layer = ((IExtraChunkData) chunk).getFlatLayer();
NBTTagCompound chunkData = event.getData();
if (!chunkData.hasKey(NBT_KEY)) return;
NBTTagList list = chunkData.getTagList(NBT_KEY, Constants.NBT.TAG_COMPOUND);
if (list == null || list.hasNoTags()) return;
Coord at = new Coord(chunk.getWorld(), 0, 0, 0);
int tagEnd = list.tagCount();
for (int i = 0; i < tagEnd; i++) {
NBTTagCompound tag = (NBTTagCompound) list.get(i);
at.x = tag.getInteger("x");
at.y = tag.getInteger("y");
at.z = tag.getInteger("z");
byte faceOrdinal = tag.getByte("side");
EnumFacing face = EnumFacing.VALUES[faceOrdinal];
FlatFace flat = construct(tag);
if (flat != null) {
layer.set(at, face, flat, FlatChunkLayer.FLAGS_SEAMLESS);
}
}
}
示例10: enqueueRetrogen
import net.minecraftforge.event.world.ChunkDataEvent; //导入依赖的package包/类
@SubscribeEvent
public void enqueueRetrogen(ChunkDataEvent.Load event) {
// See also: http://minecraft.curseforge.com/projects/simpleretrogen
if (!FzConfig.enable_retrogen) {
return;
}
final NBTTagCompound data = event.getData();
final String oldKey = data.getString("fzRetro");
if (FzConfig.retrogen_key.equals(oldKey)) {
return;
}
if (event.getChunk().getWorld().isRemote) return;
if (retrogen_active.get() == Boolean.TRUE) {
recursively_loaded.add(event.getChunk());
return;
}
if (FzConfig.retrogen_copper_geyser || FzConfig.retrogen_dark_iron) {
retrogenQueue.add(event.getChunk());
}
}
示例11: saveChunk
import net.minecraftforge.event.world.ChunkDataEvent; //导入依赖的package包/类
@SubscribeEvent
public void saveChunk(ChunkDataEvent.Save event) {
long index = Chunk2Index(event.getChunk());
NBTTagCompound nbt = VintageTG.proxy.getChunkNbt(index); // chunkextranbt_savequeue.get(index);
if (nbt != null) {
event.getData().setTag("vintagecraft", nbt);
mark(event.getChunk().xPosition, event.getChunk().zPosition, "save " + nbt.hasKey("climate"));
} else {
mark(event.getChunk().xPosition, event.getChunk().zPosition, "save-no nbt?");
}
if (!event.getChunk().isLoaded()) {
mark(event.getChunk().xPosition, event.getChunk().zPosition, "removed from list");
// TODO
//VintageCraft.proxy.removeChunkNbt(Chunk2Index(event.getChunk()));
}
}
示例12: callStage2
import net.minecraftforge.event.world.ChunkDataEvent; //导入依赖的package包/类
public void callStage2(QueuedChunk queuedChunk, net.minecraft.world.chunk.Chunk chunk) throws RuntimeException {
if(chunk == null) {
// If the chunk loading failed just do it synchronously (may generate)
queuedChunk.provider.originalLoadChunk(queuedChunk.x, queuedChunk.z);
return;
}
queuedChunk.loader.loadEntities(queuedChunk.world, queuedChunk.compound.getCompoundTag("Level"), chunk);
MinecraftForge.EVENT_BUS.post(new ChunkDataEvent.Load(chunk, queuedChunk.compound)); // Don't call ChunkDataEvent.Load async
chunk.lastSaveTime = queuedChunk.provider.worldObj.getTotalWorldTime();
queuedChunk.provider.loadedChunkHashMap.add(ChunkCoordIntPair.chunkXZ2Int(queuedChunk.x, queuedChunk.z), chunk);
queuedChunk.provider.loadedChunks.add(chunk);
chunk.onChunkLoad();
if (queuedChunk.provider.currentChunkProvider != null) {
queuedChunk.provider.currentChunkProvider.recreateStructures(queuedChunk.x, queuedChunk.z);
}
chunk.populateChunk(queuedChunk.provider, queuedChunk.provider, queuedChunk.x, queuedChunk.z);
}
示例13: saveChunk
import net.minecraftforge.event.world.ChunkDataEvent; //导入依赖的package包/类
public void saveChunk(final World world, final Chunk chunk) throws MinecraftException, IOException {
try {
final NBTTagCompound nbt1 = new NBTTagCompound();
final NBTTagCompound nbt2 = new NBTTagCompound();
nbt1.setTag("Level", nbt2);
// This will generate the chunk into an NBTTagCompound. Compression
// doesn't occur until IO.
writeChunkToNBT(chunk, world, nbt2);
MinecraftForge.EVENT_BUS.post(new ChunkDataEvent.Save(chunk, nbt1));
// Put the write onto the pending list and queue
// up an IO request.
final ChunkCoordIntPair coords = chunk.getChunkCoordIntPair();
pendingIO.put(coords, nbt1);
ThreadedFileIOBase.getThreadedIOInstance().queue(new WriteChunkStream(coords));
} catch (final Exception exception) {
exception.printStackTrace();
}
}
示例14: callStage2
import net.minecraftforge.event.world.ChunkDataEvent; //导入依赖的package包/类
public void callStage2(QueuedChunk queuedChunk, net.minecraft.world.chunk.Chunk chunk) throws RuntimeException {
if (chunk == null) {
// If the chunk loading failed just do it synchronously (may
// generate)
queuedChunk.provider.originalLoadChunk(queuedChunk.x, queuedChunk.z);
return;
}
queuedChunk.loader.loadEntities(queuedChunk.world, queuedChunk.compound.getCompoundTag("Level"), chunk);
MinecraftForge.EVENT_BUS.post(new ChunkDataEvent.Load(chunk, queuedChunk.compound)); // Don't call ChunkDataEvent.Load async
chunk.lastSaveTime = queuedChunk.provider.worldObj.getTotalWorldTime();
queuedChunk.provider.loadedChunkHashMap.add(ChunkCoordIntPair.chunkXZ2Int(queuedChunk.x, queuedChunk.z), chunk);
queuedChunk.provider.loadedChunks.add(chunk);
chunk.onChunkLoad();
if (queuedChunk.provider.currentChunkProvider != null) {
queuedChunk.provider.currentChunkProvider.recreateStructures(queuedChunk.x, queuedChunk.z);
}
chunk.populateChunk(queuedChunk.provider, queuedChunk.provider, queuedChunk.x, queuedChunk.z);
}
示例15: onChunkDataLoad
import net.minecraftforge.event.world.ChunkDataEvent; //导入依赖的package包/类
@SubscribeEvent
public synchronized void onChunkDataLoad(ChunkDataEvent.Load event)
{
if(!event.world.isRemote)
{
if(general.enableWorldRegeneration)
{
NBTTagCompound loadData = event.getData();
if(loadData.getInteger("MekanismWorldGen") == baseWorldGenVersion && loadData.getInteger("MekanismUserWorldGen") == general.userWorldGenVersion)
{
return;
}
ChunkCoordIntPair coordPair = event.getChunk().getChunkCoordIntPair();
worldTickHandler.addRegenChunk(event.world.provider.dimensionId, coordPair);
}
}
}