Java Code Examples for cpw.mods.fml.relauncher.Side#SERVER
The following examples show how to use
cpw.mods.fml.relauncher.Side#SERVER .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServerEventHandler.java From Et-Futurum with The Unlicense | 6 votes |
@SubscribeEvent @SuppressWarnings("unchecked") public void onWorldTick(TickEvent.ServerTickEvent event) { if (event.phase != TickEvent.Phase.END || event.side != Side.SERVER) return; if (EtFuturum.enablePlayerSkinOverlay) if (playerLoggedInCooldown != null) if (--playerLoggedInCooldown <= 0) { for (World world : MinecraftServer.getServer().worldServers) for (EntityPlayer player : (List<EntityPlayer>) world.playerEntities) { NBTTagCompound nbt = player.getEntityData(); if (nbt.hasKey(SetPlayerModelCommand.MODEL_KEY, Constants.NBT.TAG_BYTE)) { boolean isAlex = nbt.getBoolean(SetPlayerModelCommand.MODEL_KEY); EtFuturum.networkWrapper.sendToAll(new SetPlayerModelMessage(player, isAlex)); } } playerLoggedInCooldown = null; } }
Example 2
Source File: MoCEntityHorse.java From mocreaturesdev with GNU General Public License v3.0 | 6 votes |
/** * Called to vanish Horse */ public void vanishHorse() { setPathToEntity(null); this.motionX = 0D; this.motionZ = 0D; //dropMyStuff(); if (this.isBagger()) { MoCTools.dropInventory(this, this.localhorsechest); dropBags(); } if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { MoCServerPacketHandler.sendVanishPacket(this.entityId, worldObj.provider.dimensionId); setVanishC((byte) 1); } MoCTools.playCustomSound(this, "vanish", worldObj); }
Example 3
Source File: ItemGPSTool.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
public static ChunkPosition getGPSLocation(ItemStack gpsTool){ NBTTagCompound compound = gpsTool.stackTagCompound; if(compound != null) { String var = getVariable(gpsTool); if(!var.equals("") && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { ChunkPosition pos = GlobalVariableManager.getInstance().getPos(var); setGPSLocation(gpsTool, pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ); } int x = compound.getInteger("x"); int y = compound.getInteger("y"); int z = compound.getInteger("z"); if(x != 0 || y != 0 || z != 0) { return new ChunkPosition(x, y, z); } else { return null; } } else { return null; } }
Example 4
Source File: PacketAbortTransform.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
@Override public IMessage onMessage(PacketAbortTransform message, MessageContext ctx) { if(ctx.side == Side.SERVER) { if(ctx.getServerHandler().playerEntity.getEntityId() == entityId) { } } else { TransformationHelper.onAbortTransformation(entityId); } return null; }
Example 5
Source File: QCraftProxyCommon.java From qcraft-mod with Apache License 2.0 | 5 votes |
@SubscribeEvent public void onPlayerLogin( PlayerEvent.PlayerLoggedInEvent event ) { EntityPlayer player = event.player; if( FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER ) { QCraft.clearUnverifiedLuggage( player ); // Shouldn't be necessary, but can't hurt QCraft.requestLuggage( player ); } }
Example 6
Source File: QCraftProxyCommon.java From qcraft-mod with Apache License 2.0 | 5 votes |
@SubscribeEvent public void onPlayerLogout( PlayerEvent.PlayerLoggedOutEvent event ) { EntityPlayer player = event.player; if( FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER ) { QCraft.clearUnverifiedLuggage( player ); } }
Example 7
Source File: MessageBase.java From AdvancedMod with GNU General Public License v3.0 | 5 votes |
@Override public REQ onMessage(REQ message, MessageContext ctx){ if(ctx.side == Side.SERVER) { handleServerSide(message, ctx.getServerHandler().playerEntity); } else { handleClientSide(message, AdvancedMod.proxy.getClientPlayer()); } return null; }
Example 8
Source File: AdvancedModEventHandler.java From AdvancedMod with GNU General Public License v3.0 | 5 votes |
/** * Using the PlayerTickEvent. Note that this is from cpw.mods.fml.common.gameevent, so to make this method be called, this class needs to be registered at FMLCommonHandler.instance().bus().register(new AdvancedModEventHandler()). * @param event */ @SubscribeEvent public void onPlayerTick(PlayerTickEvent event){ if(event.side == Side.SERVER && event.phase == TickEvent.Phase.END) { List<Entity> entities = event.player.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(event.player.posX - 3, event.player.posY - 3, event.player.posZ - 3, event.player.posX + 3, event.player.posY + 3, event.player.posZ + 3)); for(Entity entity : entities) { if(entity != event.player) { //entity.setVelocity(0, 1, 0); //This will crash when run on a dedicated server, because Entity#setVelocity is marked with @SideOnly(Side.CLIENT), and therefore stripped from a dedicated server instance. entity.motionX = 0;//The solution is to do this. entity.motionY = 1; entity.motionZ = 0; } } } }
Example 9
Source File: AbstractPacket.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public REQ onMessage(REQ message, MessageContext ctx){ if(ctx.side == Side.SERVER) { handleServerSide(message, ctx.getServerHandler().playerEntity); } else { handleClientSide(message, PneumaticCraft.proxy.getPlayer()); } return null; }
Example 10
Source File: BigReactorsTickHandler.java From BigReactors with MIT License | 5 votes |
@SubscribeEvent public void onWorldTick(TickEvent.WorldTickEvent event) { if(event.side == Side.SERVER && event.phase == TickEvent.Phase.END) { if(chunkRegenMap == null) { return; } if(event.world.isRemote) { return; } int dimensionId = event.world.provider.dimensionId; if(chunkRegenMap.containsKey(dimensionId)) { // Split up regen so it takes at most 16 millisec per frame to allow for ~55-60 FPS Queue<ChunkCoordIntPair> chunksToGen = chunkRegenMap.get(dimensionId); long startTime = System.nanoTime(); while(System.nanoTime() - startTime < maximumDeltaTimeNanoSecs && !chunksToGen.isEmpty()) { // Regenerate chunk ChunkCoordIntPair nextChunk = chunksToGen.poll(); if(nextChunk == null) { break; } Random fmlRandom = new Random(event.world.getSeed()); long xSeed = fmlRandom.nextLong() >> 2 + 1L; long zSeed = fmlRandom.nextLong() >> 2 + 1L; fmlRandom.setSeed((xSeed * nextChunk.chunkXPos + zSeed * nextChunk.chunkZPos) ^ event.world.getSeed()); BigReactors.worldGenerator.generateChunk(fmlRandom, nextChunk.chunkXPos, nextChunk.chunkZPos, event.world); } if(chunksToGen.isEmpty()) { chunkRegenMap.remove(dimensionId); } } } }
Example 11
Source File: CommonProxy.java From Gadomancy with GNU Lesser General Public License v3.0 | 4 votes |
public Side getSide() { return this instanceof ClientProxy ? Side.CLIENT : Side.SERVER; }
Example 12
Source File: WorldTickEventHandler.java From Et-Futurum with The Unlicense | 4 votes |
@SubscribeEvent public void tick(WorldTickEvent event) { if (event.side != Side.SERVER || event.phase != Phase.END || isReplacing) return; if (replacements == null) { replacements = new HashMap<Block, Block>(); if (EtFuturum.enableBrewingStands) replacements.put(Blocks.brewing_stand, ModBlocks.brewing_stand); if (EtFuturum.enableColourfulBeacons) replacements.put(Blocks.beacon, ModBlocks.beacon); if (EtFuturum.enableEnchants) replacements.put(Blocks.enchanting_table, ModBlocks.enchantment_table); if (EtFuturum.enableInvertedDaylightSensor) replacements.put(Blocks.daylight_detector, ModBlocks.daylight_sensor); } if (replacements.isEmpty()) return; isReplacing = true; World world = event.world; for (int i = 0; i < world.loadedTileEntityList.size(); i++) { TileEntity tile = (TileEntity) world.loadedTileEntityList.get(i); int x = tile.xCoord; int y = tile.yCoord; int z = tile.zCoord; Block replacement = replacements.get(world.getBlock(x, y, z)); if (replacement != null && ((IConfigurable) replacement).isEnabled()) { NBTTagCompound nbt = new NBTTagCompound(); tile.writeToNBT(nbt); if (tile instanceof IInventory) { IInventory invt = (IInventory) tile; for (int j = 0; j < invt.getSizeInventory(); j++) invt.setInventorySlotContents(j, null); } world.setBlock(x, y, z, replacement); TileEntity newTile = world.getTileEntity(x, y, z); newTile.readFromNBT(nbt); break; } } isReplacing = false; }
Example 13
Source File: OmniOcular.java From OmniOcular with Apache License 2.0 | 4 votes |
@NetworkCheckHandler public static boolean check(Map<String, String> remote, Side side) { return !(side == Side.SERVER && !remote.isEmpty() && !remote.containsKey(Reference.MOD_ID)); }
Example 14
Source File: MoCreatures.java From mocreaturesdev with GNU General Public License v3.0 | 4 votes |
public static boolean isServer() { return (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER); }
Example 15
Source File: AmadronOfferManager.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
public static AmadronOfferManager getInstance(){ return FMLCommonHandler.instance().getSide() == Side.SERVER ? SERVER_INSTANCE : CLIENT_INSTANCE; }