本文整理汇总了Java中ethanjones.cubes.core.event.world.block.BlockChangedEvent类的典型用法代码示例。如果您正苦于以下问题:Java BlockChangedEvent类的具体用法?Java BlockChangedEvent怎么用?Java BlockChangedEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BlockChangedEvent类属于ethanjones.cubes.core.event.world.block包,在下文中一共展示了BlockChangedEvent类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setBlock3
import ethanjones.cubes.core.event.world.block.BlockChangedEvent; //导入依赖的package包/类
public void setBlock3(Block block, int x, int y, int z, int meta, int ref, int n) {
if (block != null && block.blockData()) {
addBlockData(block, x, y, z, meta);
}
doUpdatesThisArea(x, y, z, ref);
int hmRef = x + z * SIZE_BLOCKS;
if (y > heightmap[hmRef] && block != null)
heightmap[hmRef] = y;
if (y == heightmap[hmRef] && block == null)
calculateHeight(x, z);
modify();
lock.writeUnlock();
int b = blocks[ref];
Block old = IDManager.toBlock(b & 0xFFFFF);
// Must be after lock released to prevent dead locks
if (TransparencyManager.isTransparent(b) != TransparencyManager.isTransparent(n))
doUpdatesOtherAreas(x, y, z, ref);
new BlockChangedEvent(new BlockReference().setFromBlockCoordinates(x + minBlockX, y, z + minBlockZ), old,
(b >> 20) & 0xFF, block, meta, this).post();
}
示例2: blockChanged
import ethanjones.cubes.core.event.world.block.BlockChangedEvent; //导入依赖的package包/类
@EventHandler(critical = true)
public void blockChanged(BlockChangedEvent event) {
BlockReference blockReference = event.getBlockReference();
Block oldBlock = event.getOldBlock();
Block newBlock = event.getNewBlock();
int oldMeta = event.getOldMeta();
int newMeta = event.getNewMeta();
blockChangedOld(oldBlock, oldMeta, newBlock, newMeta);
Performance.start(PerformanceTags.LIGHT_UPDATE);
Area area = event.getArea();
LightWorldSection lws = new LightWorldSection(area);
try {
// Block light
BlockLight.removeLight(blockReference.blockX, blockReference.blockY, blockReference.blockZ, area, lws);
if (newBlock != null && newBlock.getLightLevel(newMeta) > 0) {
BlockLight.addLight(blockReference.blockX, blockReference.blockY, blockReference.blockZ,
event.getNewBlock().getLightLevel(newMeta), area, lws);
}
BlockLight.spreadLight(blockReference.blockX, blockReference.blockY, blockReference.blockZ, area, lws);
// Sunlight
if (newBlock != null && !newBlock.isTransparent(newMeta)) {
SunLight.removeSunlight(blockReference.blockX, blockReference.blockY, blockReference.blockZ, area, lws);
} else {
SunLight.addSunlight(blockReference.blockX, blockReference.blockY, blockReference.blockZ, area, lws);
}
} catch (AreaNotLoadedException e) {
Log.error("Failed to update light", e);
}
lws.unlock();
Performance.stop(PerformanceTags.LIGHT_UPDATE);
}
示例3: blockChanged
import ethanjones.cubes.core.event.world.block.BlockChangedEvent; //导入依赖的package包/类
@EventHandler(critical = true)
public void blockChanged(BlockChangedEvent event) {
BlockReference blockReference = event.getBlockReference();
Block oldBlock = event.getOldBlock();
Block newBlock = event.getNewBlock();
int oldMeta = event.getOldMeta();
int newMeta = event.getNewMeta();
if ((oldBlock == null ? 0 : oldBlock.getLightLevel(oldMeta)) == (newBlock == null ? 0 : newBlock.getLightLevel(newMeta)) && TransparencyManager.isTransparent(oldBlock, oldMeta) == TransparencyManager.isTransparent(newBlock, newMeta)) {
return;
}
Performance.start(PerformanceTags.LIGHT_UPDATE);
Area area = event.getArea();
LightWorldSection lws = new LightWorldSection(area);
try {
// Block light
BlockLight.removeLight(blockReference.blockX, blockReference.blockY, blockReference.blockZ, area, lws);
if (newBlock != null && newBlock.getLightLevel(newMeta) > 0) {
BlockLight.addLight(blockReference.blockX, blockReference.blockY, blockReference.blockZ, event.getNewBlock().getLightLevel(newMeta), area, lws);
}
BlockLight.spreadLight(blockReference.blockX, blockReference.blockY, blockReference.blockZ, area, lws);
// Sunlight
if (newBlock != null && !newBlock.isTransparent(newMeta)) {
SunLight.removeSunlight(blockReference.blockX, blockReference.blockY, blockReference.blockZ, area, lws);
} else {
SunLight.addSunlight(blockReference.blockX, blockReference.blockY, blockReference.blockZ, area, lws);
}
} catch (AreaNotLoadedException e) {
Log.error("Failed to update light", e);
}
lws.unlock();
Performance.stop(PerformanceTags.LIGHT_UPDATE);
}
示例4: setBlock
import ethanjones.cubes.core.event.world.block.BlockChangedEvent; //导入依赖的package包/类
public void setBlock(Block block, int x, int y, int z, int meta) {
if (y < 0) return;
int n = block == null ? 0 : block.intID;
n += (meta & 0xFF) << 20;
lock.writeLock();
if (isUnloaded() && lock.writeUnlock(true)) return;
setupArrays(y);
int ref = getRef(x, y, z);
int b = blocks[ref];
blocks[ref] = n;
Block old = IDManager.toBlock(b & 0xFFFFF);
if (old != null && old.blockData() && old != block) {
removeBlockData(x, y, z);
}
if (block != null && block.blockData()) {
addBlockData(block, x, y, z, meta);
}
doUpdatesThisArea(x, y, z, ref);
int hmRef = x + z * SIZE_BLOCKS;
if (y > heightmap[hmRef] && block != null) heightmap[hmRef] = y;
if (y == heightmap[hmRef] && block == null) calculateHeight(x, z);
modify();
lock.writeUnlock();
//Must be after lock released to prevent dead locks
if (TransparencyManager.isTransparent(b) != TransparencyManager.isTransparent(n))
doUpdatesOtherAreas(x, y, z, ref);
new BlockChangedEvent(new BlockReference().setFromBlockCoordinates(x + minBlockX, y, z + minBlockZ), old, (b >> 20) & 0xFF, block, meta, this).post();
}