本文整理汇总了Java中codechicken.lib.util.CommonUtils类的典型用法代码示例。如果您正苦于以下问题:Java CommonUtils类的具体用法?Java CommonUtils怎么用?Java CommonUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CommonUtils类属于codechicken.lib.util包,在下文中一共展示了CommonUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: jamTile
import codechicken.lib.util.CommonUtils; //导入依赖的package包/类
private void jamTile() {
if (world.isRemote || target == null)
return;
RedstoneEtherServer ether = (RedstoneEtherServer) this.ether;
if (canhittarget) {
TileEntity tile = RedstoneEther.getTile(world, target);
if (tile == null || !(tile instanceof ITileWireless)) {
ether.unjamTile(world, target.getX(), target.getY(), target.getZ());
return;
}
ITileWireless wirelesstile = (ITileWireless) tile;
int freq = wirelesstile.getFreq();
if (freq == 0) {
ether.unjamTile(world, target.getX(), target.getY(), target.getZ());
return;
}
ether.jamNode(world, target, CommonUtils.getDimension(world), freq);
wirelesstile.jamTile();
} else {
ether.unjamTile(world, target.getX(), target.getY(), target.getZ());
}
}
示例2: verifyChunkTransmitters
import codechicken.lib.util.CommonUtils; //导入依赖的package包/类
public void verifyChunkTransmitters(World world, int chunkx, int chunkz)
{
int dimension = CommonUtils.getDimension(world);
DimensionalEtherHash ether = ethers.get(dimension);
int blockxmin = chunkx * 16;
int blockxmax = blockxmin + 15;
int blockzmin = chunkz * 16;
int blockzmax = blockzmin + 15;
ArrayList<BlockPos> transmittingblocks = new ArrayList<>(ether.transmittingblocks.keySet());
for(BlockPos node : transmittingblocks)
{
if(node.getX() >= blockxmin && node.getX() <= blockxmax && node.getZ() >= blockzmin && node.getZ() <= blockzmax)
{
TileEntity tile = RedstoneEther.getTile(world, node);
int freq = ether.transmittingblocks.get(node).freq;
if(tile == null || !(tile instanceof ITileWireless) || ((ITileWireless)tile).getFreq() != freq)
{
remTransmitter(world, node, freq);
System.out.println("Removed Badly Synced node at:"+node.getX()+","+node.getY()+","+node.getZ()+" on "+freq+" in dim"+dimension);
}
}
}
}
示例3: setTransmitter
import codechicken.lib.util.CommonUtils; //导入依赖的package包/类
public void setTransmitter(World world, BlockPos node, int freq, boolean on)
{
if(freq == 0)
{
return;
}
int dimension = CommonUtils.getDimension(world);
if(isNodeInAOEofJammer(node, dimension))
{
jamNodeSometime(world, node, dimension, freq);
}
TXNodeInfo info = ethers.get(dimension).transmittingblocks.get(node);
if(info == null)
ethers.get(dimension).transmittingblocks.put(node, new TXNodeInfo(freq, on));
else
info.on = on;
freqarray[freq].setTransmitter(world, node, dimension, on);
}
示例4: entityJamTest
import codechicken.lib.util.CommonUtils; //导入依赖的package包/类
private void entityJamTest(World world)
{
if(world.getTotalWorldTime() % 10 != 0)
return;
int dimension = CommonUtils.getDimension(world);
for(Iterator<BlockPos> iterator = ethers.get(dimension).jammerset.iterator(); iterator.hasNext();)
{
BlockPos jammer = iterator.next();
List<Entity> entitiesinrange = world.getEntitiesWithinAABBExcludingEntity(null, new AxisAlignedBB(jammer.getX()-9.5, jammer.getY()-9.5, jammer.getZ()-9.5, jammer.getX()+10.5, jammer.getY()+10.5, jammer.getZ()+10.5));
for(Iterator<Entity> iterator2 = entitiesinrange.iterator(); iterator2.hasNext();)
{
Entity entity = iterator2.next();
if(!(entity instanceof EntityLivingBase))
continue;
if(entity instanceof EntityPlayer)
if(isPlayerJammed((EntityPlayer)entity))
continue;
jamEntitySometime((EntityLivingBase) entity);
}
}
}
示例5: loadDimension
import codechicken.lib.util.CommonUtils; //导入依赖的package包/类
@SuppressWarnings ("unchecked")
public void loadDimension(WorldServer world) {
PacketCustom packet = new PacketCustom(channel, 2).compress();
int dim = CommonUtils.getDimension(world);
packet.writeInt(dim);
Collection<Chunk> allchunks = world.getChunkProvider().getLoadedChunks();
packet.writeInt(allchunks.size());
for (Chunk chunk : allchunks) {
packet.writeInt(chunk.x);
packet.writeInt(chunk.z);
}
Map<Ticket, Collection<ChunkPos>> tickets = ForgeChunkManager.getPersistentChunksFor(world).inverse().asMap();
packet.writeInt(tickets.size());
for (Entry<Ticket, Collection<ChunkPos>> entry : tickets.entrySet()) {
writeTicketToPacket(packet, entry.getKey(), entry.getValue());
}
packet.sendToPlayer(owner);
}
示例6: remChunkLoader
import codechicken.lib.util.CommonUtils; //导入依赖的package包/类
public void remChunkLoader(IChickenChunkLoader loader) {
int dim = CommonUtils.getDimension(loader.getLoaderWorld());
if (dormant) {
Set<BlockPos> coords = dormantLoaders.get(dim);
if (coords != null) {
coords.remove(loader.getPosition());
}
} else {
Set<ChunkPos> chunks = forcedChunksByLoader.remove(loader);
if (chunks == null) {
return;
}
unforceChunks(loader, dim, chunks, true);
}
setDirty();
}
示例7: updateChunkLoader
import codechicken.lib.util.CommonUtils; //导入依赖的package包/类
public void updateChunkLoader(IChickenChunkLoader loader) {
Set<ChunkPos> loaderChunks = forcedChunksByLoader.get(loader);
if (loaderChunks == null) {
addChunkLoader(loader);
return;
}
HashSet<ChunkPos> oldChunks = new HashSet<>(loaderChunks);
HashSet<ChunkPos> newChunks = new HashSet<>();
for (ChunkPos chunk : loader.getChunks()) {
if (!oldChunks.remove(chunk)) {
newChunks.add(chunk);
}
}
int dim = CommonUtils.getDimension(loader.getLoaderWorld());
if (!oldChunks.isEmpty()) {
unforceChunks(loader, dim, oldChunks, false);
}
if (!newChunks.isEmpty()) {
forceChunks(loader, dim, newChunks);
}
}
示例8: revive
import codechicken.lib.util.CommonUtils; //导入依赖的package包/类
public void revive(World world) {
Set<BlockPos> coords = dormantLoaders.get(CommonUtils.getDimension(world));
if (coords == null) {
return;
}
//addChunkLoader will add to the coord set if we are dormant
ArrayList<BlockPos> verifyCoords = new ArrayList<>(coords);
coords.clear();
for (BlockPos coord : verifyCoords) {
reviving = true;
TileEntity tile = world.getTileEntity(coord);
reviving = false;
if (tile instanceof IChickenChunkLoader) {
ChunkLoaderManager.addChunkLoader((IChickenChunkLoader) tile);
}
}
}
示例9: dumpFile
import codechicken.lib.util.CommonUtils; //导入依赖的package包/类
public void dumpFile() {
try {
File file = new File(CommonUtils.getMinecraftDir(), "dumps/" + getFileName(name.replaceFirst(".+\\.", "")));
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
if (!file.exists()) {
file.createNewFile();
}
dumpTo(file);
NEIClientUtils.printChatMessage(dumpMessage(file));
} catch (Exception e) {
LogHelper.errorError("Error dumping " + renderName() + " mode: " + getMode(), e);
}
}
示例10: loadServerWorld
import codechicken.lib.util.CommonUtils; //导入依赖的package包/类
public static void loadServerWorld(World world) {
int dimension = CommonUtils.getDimension(world);
if (serverEther == null)
new RedstoneEtherServer().init(world);
serverEther.addEther(world, dimension);
}
示例11: saveEther
import codechicken.lib.util.CommonUtils; //导入依赖的package包/类
public void saveEther(World world)
{
int dimension = CommonUtils.getDimension(world);
if(!ethers.containsKey(dimension))
return;
for(RedstoneEtherFrequency freq : ethers.get(dimension).freqsToSave)
freq.saveFreq(dimension);
ethers.get(dimension).freqsToSave.clear();
SaveManager.getInstance(dimension).removeTrailingSectors();
SaveManager.saveDimensionHash();
}
示例12: remTransmitter
import codechicken.lib.util.CommonUtils; //导入依赖的package包/类
public void remTransmitter(World world, BlockPos node, int freq)
{
if(freq == 0)
{
return;
}
int dimension = CommonUtils.getDimension(world);
ethers.get(dimension).jammednodes.remove(node);
ethers.get(dimension).transmittingblocks.remove(node);
freqarray[freq].remTransmitter(world, node, dimension);
}
示例13: addReceiver
import codechicken.lib.util.CommonUtils; //导入依赖的package包/类
public void addReceiver(World world, BlockPos node, int freq)
{
if(freq == 0)
return;
int dimension = CommonUtils.getDimension(world);
if(isNodeInAOEofJammer(node, dimension))
{
jamNodeSometime(world, node, dimension, freq);
}
ethers.get(dimension).recievingblocks.put(node, freq);
freqarray[freq].addReceiver(world, node, dimension);
}
示例14: remReceiver
import codechicken.lib.util.CommonUtils; //导入依赖的package包/类
public void remReceiver(World world, BlockPos node, int freq)
{
if(freq == 0)
return;
int dimension = CommonUtils.getDimension(world);
ethers.get(dimension).jammednodes.remove(node);
ethers.get(dimension).recievingblocks.remove(node);
freqarray[freq].remReceiver(world, node, dimension);
}
示例15: addJammer
import codechicken.lib.util.CommonUtils; //导入依赖的package包/类
public void addJammer(World world, BlockPos jammer)
{
int dimension = CommonUtils.getDimension(world);
ethers.get(dimension).jammerset.add(jammer);
jamNodesInAOEOfJammer(world, jammer, dimension);
}