Java Code Examples for net.minecraftforge.fml.relauncher.Side#SERVER
The following examples show how to use
net.minecraftforge.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: WorldGen.java From TFC2 with GNU General Public License v3.0 | 6 votes |
public static void initialize(World world) { if(FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { if(instance == null || SHOULD_RESET_SERVER) { instance = new WorldGen(world); SHOULD_RESET_SERVER = false; } } else { if(instanceClient == null || SHOULD_RESET_CLIENT) { instanceClient = new WorldGen(world); SHOULD_RESET_CLIENT = false; } } }
Example 2
Source File: MessageQuestUpdate.java From ToroQuest with GNU General Public License v3.0 | 6 votes |
@Override public IMessage onMessage(final MessageQuestUpdate message, MessageContext ctx) { if (ctx.side != Side.SERVER) { return null; } final EntityPlayerMP player = ctx.getServerHandler().player; if (player == null) { return null; } final WorldServer worldServer = player.getServerWorld(); worldServer.addScheduledTask(new Runnable() { @Override public void run() { new Worker(message.action).work(message, player); } }); return null; }
Example 3
Source File: MessageRequestPlayerCivilizationSync.java From ToroQuest with GNU General Public License v3.0 | 6 votes |
@Override public IMessage onMessage(final MessageRequestPlayerCivilizationSync message, MessageContext ctx) { if (ctx.side != Side.SERVER) { return null; } final EntityPlayerMP player = ctx.getServerHandler().player; if (player == null) { return null; } final WorldServer worldServer = player.getServerWorld(); worldServer.addScheduledTask(new Runnable() { @Override public void run() { PlayerCivilizationCapabilityImpl.get(player).syncClient(); } }); return null; }
Example 4
Source File: VSKeyHandler.java From Valkyrien-Skies with Apache License 2.0 | 6 votes |
@SideOnly(Side.CLIENT) @SubscribeEvent public void playerTick(PlayerTickEvent event) { if (event.side == Side.SERVER) { return; } if (event.phase == Phase.START) { IShipPilotClient clientPilot = (IShipPilotClient) event.player; clientPilot.onClientTick(); if (dismountKey.isKeyDown() && clientPilot.isPilotingATile()) { BlockPos pilotedPos = clientPilot.getPosBeingControlled(); MessagePlayerStoppedPiloting stopPilotingMessage = new MessagePlayerStoppedPiloting( pilotedPos); ValkyrienSkiesControl.controlNetwork.sendToServer(stopPilotingMessage); clientPilot.stopPilotingEverything(); } } }
Example 5
Source File: WorldTickHandler.java From EmergingTechnology with MIT License | 5 votes |
@SubscribeEvent public void tickEnd(TickEvent.WorldTickEvent event) { if (event.side != Side.SERVER) { return; } if (event.phase == TickEvent.Phase.END) { World world = event.world; int dim = world.provider.getDimension(); ArrayDeque<ChunkPos> chunks = chunksToGen.get(dim); if (chunks != null && !chunks.isEmpty()) { ChunkPos c = chunks.pollFirst(); long worldSeed = world.getSeed(); Random rand = new Random(worldSeed); long xSeed = rand.nextLong() >> 2 + 1L; long zSeed = rand.nextLong() >> 2 + 1L; rand.setSeed(xSeed * c.x + zSeed * c.z ^ worldSeed); OreGenerator.instance.generateWorld(rand, c.x, c.z, world, false); chunksToGen.put(dim, chunks); } else if (chunks != null) { chunksToGen.remove(dim); } } }
Example 6
Source File: WorldUtils.java From OpenModsLib with MIT License | 5 votes |
public static World getWorld(Side side, int dimensionId) { final World result; if (side == Side.SERVER) { result = OpenMods.proxy.getServerWorld(dimensionId); } else { result = OpenMods.proxy.getClientWorld(); Preconditions.checkArgument(result.provider.getDimension() == dimensionId, "Invalid client dimension id %s", dimensionId); } Preconditions.checkNotNull(result, "Invalid world dimension %s", dimensionId); return result; }
Example 7
Source File: MessageSendString.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@Override public IMessage onMessage(final MessageSendString message, MessageContext ctx) { if (ctx.side != Side.SERVER) { EnderUtilities.logger.error("Wrong side in MessageSendString: " + ctx.side); return null; } final EntityPlayerMP sendingPlayer = ctx.getServerHandler().player; if (sendingPlayer == null) { EnderUtilities.logger.error("Sending player was null in MessageSendString"); return null; } final WorldServer playerWorldServer = sendingPlayer.getServerWorld(); if (playerWorldServer == null) { EnderUtilities.logger.error("World was null in MessageSendString"); return null; } playerWorldServer.addScheduledTask(new Runnable() { public void run() { processMessage(message, sendingPlayer); } }); return null; }
Example 8
Source File: ConfigSync.java From TinkersToolLeveling with MIT License | 5 votes |
@SubscribeEvent @SideOnly(Side.SERVER) public void playerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) { if(event.player instanceof EntityPlayerMP && FMLCommonHandler.instance().getSide().isServer()) { ConfigSyncPacket packet = new ConfigSyncPacket(); TinkerToolLeveling.networkWrapper.network.sendTo(packet, (EntityPlayerMP) event.player); } }
Example 9
Source File: AbstractPacket.java From Signals with GNU General Public License v3.0 | 5 votes |
@Override public REQ onMessage(final REQ message, final MessageContext ctx){ if(ctx.side == Side.SERVER) { Signals.proxy.addScheduledTask(() -> { message.handleServerSide(ctx.getServerHandler().player); }, ctx.side == Side.SERVER); } else { Signals.proxy.addScheduledTask(() -> { message.handleClientSide(Signals.proxy.getPlayer()); }, ctx.side == Side.SERVER); } return null; }
Example 10
Source File: MalmoModServer.java From malmo with MIT License | 5 votes |
@SubscribeEvent public void onServerTick(TickEvent.ServerTickEvent ev) { if (ev.side == Side.SERVER && ev.phase == Phase.START) { this.serverTickMonitor.beat(); } }
Example 11
Source File: VanishTracker.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@SubscribeEvent public static void vanishTicker(TickEvent.WorldTickEvent event) { if (event.phase != TickEvent.Phase.END) return; if (event.type != TickEvent.Type.WORLD) return; if (event.side != Side.SERVER) return; final int sizeAddsBefore = adds.size(); final int sizeVanishesBefore = vanishes.size(); for (VanishedObject entry; ((entry = adds.pollFirst()) != null); ) { vanishes.add(entry); } vanishes.removeIf(entry -> { if (--entry.tick < 0) { Entity e = event.world.getEntityByID(entry.entityID); if (e != null && !event.world.isRemote) { event.world.playSound(null, e.getPosition(), ModSounds.ETHEREAL_PASS_BY, SoundCategory.NEUTRAL, 0.5f, 1); } return true; } return false; }); final int sizeAddsAfter = adds.size(); final int sizeVanishesAfter = vanishes.size(); if (!event.world.isRemote && sizeAddsAfter != sizeAddsBefore || sizeVanishesAfter != sizeVanishesBefore) { PacketHandler.NETWORK.sendToAll(new PacketSyncVanish(serialize())); } }
Example 12
Source File: WorldTickHandler.java From YouTubeModdingTutorial with MIT License | 5 votes |
@SubscribeEvent public void tickEnd(TickEvent.WorldTickEvent event) { if (event.side != Side.SERVER) { return; } if (event.phase == TickEvent.Phase.END) { World world = event.world; int dim = world.provider.getDimension(); ArrayDeque<ChunkPos> chunks = chunksToGen.get(dim); if (chunks != null && !chunks.isEmpty()) { ChunkPos c = chunks.pollFirst(); long worldSeed = world.getSeed(); Random rand = new Random(worldSeed); long xSeed = rand.nextLong() >> 2 + 1L; long zSeed = rand.nextLong() >> 2 + 1L; rand.setSeed(xSeed * c.x + zSeed * c.z ^ worldSeed); OreGenerator.instance.generateWorld(rand, c.x, c.z, world, false); chunksToGen.put(dim, chunks); } else if (chunks != null) { chunksToGen.remove(dim); } } }
Example 13
Source File: PacketRequestUpdateAltar.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
@Override public IMessage onMessage(PacketRequestUpdateAltar message, MessageContext ctx) { if (ctx.side == Side.SERVER) { World world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(message.dimension); TileEntity tileEntity = world.getTileEntity(message.pos); if (tileEntity instanceof TileEntityAltar) { return new PacketUpdateAltar((TileEntityAltar) tileEntity); } } else { System.out.println("Bad packet (wrong side: CLIENT)!"); } return null; }
Example 14
Source File: EventHandler.java From Wizardry with GNU Lesser General Public License v3.0 | 4 votes |
@SubscribeEvent public void tickEvent(TickEvent.WorldTickEvent event) { if (event.phase == TickEvent.Phase.END && event.side == Side.SERVER) { FluidTracker.INSTANCE.tick(event.world); } }
Example 15
Source File: MessageGuiSeedStorageClearSeed.java From AgriCraft with MIT License | 4 votes |
@Override public Side getMessageHandlerSide() { return Side.SERVER; }
Example 16
Source File: MessageCompareLight.java From AgriCraft with MIT License | 4 votes |
@Override public Side getMessageHandlerSide() { return Side.SERVER; }
Example 17
Source File: ForgeWurst.java From ForgeWurst with GNU General Public License v3.0 | 4 votes |
@EventHandler public void init(FMLInitializationEvent event) { if(event.getSide() == Side.SERVER) return; String mcClassName = Minecraft.class.getName().replace(".", "/"); FMLDeobfuscatingRemapper remapper = FMLDeobfuscatingRemapper.INSTANCE; obfuscated = !mcClassName.equals(remapper.unmap(mcClassName)); configFolder = Minecraft.getMinecraft().mcDataDir.toPath().resolve("wurst"); try { Files.createDirectories(configFolder); }catch(IOException e) { throw new RuntimeException(e); } hax = new HackList(configFolder.resolve("enabled-hacks.json"), configFolder.resolve("settings.json")); hax.loadEnabledHacks(); hax.loadSettings(); cmds = new CommandList(); keybinds = new KeybindList(configFolder.resolve("keybinds.json")); keybinds.init(); gui = new ClickGui(configFolder.resolve("windows.json")); gui.init(hax); JGoogleAnalyticsTracker.setProxy(System.getenv("http_proxy")); analytics = new GoogleAnalytics("UA-52838431-17", "client.forge.wurstclient.net", configFolder.resolve("analytics.json")); analytics.loadConfig(); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); analytics.getConfigData() .setScreenResolution(screen.width + "x" + screen.height); hud = new IngameHUD(hax, gui); MinecraftForge.EVENT_BUS.register(hud); cmdProcessor = new CommandProcessor(cmds); MinecraftForge.EVENT_BUS.register(cmdProcessor); keybindProcessor = new KeybindProcessor(hax, keybinds, cmdProcessor); MinecraftForge.EVENT_BUS.register(keybindProcessor); updater = new WurstUpdater(); MinecraftForge.EVENT_BUS.register(updater); analytics.trackPageView("/mc" + WMinecraft.VERSION + "/v" + VERSION, "ForgeWurst " + VERSION + " MC" + WMinecraft.VERSION); }
Example 18
Source File: MessageContainerSeedStorage.java From AgriCraft with MIT License | 4 votes |
@Override public Side getMessageHandlerSide() { return Side.SERVER; }
Example 19
Source File: BaseMetals.java From BaseMetals with GNU Lesser General Public License v2.1 | 4 votes |
@SideOnly(Side.SERVER) private void serverPostInit(FMLPostInitializationEvent event){ // server-only code }
Example 20
Source File: WorldGen.java From TFC2 with GNU General Public License v3.0 | 4 votes |
public static WorldGen getInstance() { if(FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) return instance; return instanceClient; }