cpw.mods.fml.common.gameevent.TickEvent.Phase Java Examples
The following examples show how to use
cpw.mods.fml.common.gameevent.TickEvent.Phase.
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: TickDynamicMod.java From TickDynamic with MIT License | 6 votes |
@SubscribeEvent(priority=EventPriority.LOWEST) public void tickEventEnd(ServerTickEvent event) { if(event.phase == Phase.END) { getTimedGroup("other").endTimer(); root.endTick(true); if(debugTimer) System.out.println("Tick time used: " + (root.getTimeUsed()/root.timeMilisecond) + "ms"); //After every world is done ticking, re-balance the time slices according //to the data gathered during the tick. root.balanceTime(); //Calculate TPS updateTPS(); if(saveConfig) { saveConfig = false; config.save(); } } }
Example #2
Source File: MovingStructure.java From Framez with GNU General Public License v3.0 | 6 votes |
public void tick(Phase phase) { FakeWorld.getFakeWorld(this); if (progress >= 1) return; if (phase == Phase.END) { if (progress == 0) { if (!getWorld().isRemote) NetworkHandler.instance().sendToAllAround(new PacketStartMoving(motor, this), getWorld(), 128); startMoving(); if (!getWorld().isRemote) NetworkHandler.instance().sendToAllAround(new PacketBlockSync(motor, this), getWorld(), 128); } progress += speed; moveEntities(); if (progress >= 1) finishMoving(); } }
Example #3
Source File: PacketStartMoving.java From Framez with GNU General Public License v3.0 | 6 votes |
@Override public void handleClientSide(EntityPlayer player) { TileEntity tile = player.worldObj.getTileEntity(x, y, z); if (tile == null || !(tile instanceof TileMotor)) return; TileMotor te = (TileMotor) tile; structure = new MovingStructure(te, te.getMovement(), speed); for (Vec3i b : blocks) structure.addBlock(new MovingBlock(b.setWorld(player.worldObj), structure, null).snapshot()); MovingStructure s = te.getStructure(); if (s != null) { while (s.getProgress() < 1) { s.tick(Phase.START); s.tick(Phase.END); } } te.setStructure(structure); MovementScheduler.instance().addStructure(structure); }
Example #4
Source File: TerminalManagerServer.java From OpenPeripheral-Addons with MIT License | 5 votes |
@SubscribeEvent public void onPlayerTick(PlayerTickEvent evt) { if (evt.phase == Phase.START && evt.player instanceof EntityPlayerMP) { final Optional<Long> guid = TerminalIdAccess.instance.getIdFrom(evt.player); if (guid.isPresent()) { TileEntityGlassesBridge listener = listeners.get(guid.get()); if (listener != null) listener.registerTerminal((EntityPlayerMP)evt.player); } } }
Example #5
Source File: TerminalManagerClient.java From OpenPeripheral-Addons with MIT License | 5 votes |
@SubscribeEvent public void onClientTick(ClientTickEvent evt) { if (evt.phase == Phase.END) { final EntityPlayer player = Minecraft.getMinecraft().thePlayer; terminalGuid = player != null? TerminalIdAccess.instance.getIdFrom(player) : Optional.<Long> absent(); } }
Example #6
Source File: WRAddonEventHandler.java From WirelessRedstone with MIT License | 5 votes |
@SubscribeEvent public void clientTick(ClientTickEvent event) { if(ClientUtils.inWorld()) { if (event.phase == Phase.START) TriangTexManager.processAllTextures(); else RedstoneEtherAddons.client().tick(); } }
Example #7
Source File: WRAddonEventHandler.java From WirelessRedstone with MIT License | 5 votes |
@SubscribeEvent public void serverTick(ServerTickEvent event) { if(event.phase == Phase.START) RedstoneEtherAddons.server().processTrackers(); else { RedstoneEtherAddons.server().tickTriangs(); RedstoneEtherAddons.server().updateREPTimeouts(); } }
Example #8
Source File: CommonPlayerTicker.java From archimedes-ships with MIT License | 5 votes |
@SubscribeEvent public void onPlayerTick(PlayerTickEvent e) { if (e.phase == Phase.END && e.player.ridingEntity instanceof EntityParachute && e.player.ridingEntity.ticksExisted < 40) { if (e.player.isSneaking()) { e.player.setSneaking(false); } } }
Example #9
Source File: ClientTickHandler.java From SimplyJetpacks with MIT License | 5 votes |
@SubscribeEvent public void onClientTick(ClientTickEvent evt) { if (evt.phase == Phase.START) { tickStart(); } else { tickEnd(); } }
Example #10
Source File: CraftingGridKeyHandler.java From Translocators with MIT License | 5 votes |
@SubscribeEvent @SideOnly(Side.CLIENT) public void tick(ClientTickEvent event) { if(event.phase != Phase.END) return; boolean pressed = getIsKeyPressed(); if(pressed != wasPressed) { wasPressed = pressed; if(pressed) onKeyPressed(); } }
Example #11
Source File: TileMotor.java From Framez with GNU General Public License v3.0 | 5 votes |
@Override public void onUnload() { MovingStructure s = getStructure(); if (s != null) while (s.getProgress() < 1) { s.tick(Phase.START); s.tick(Phase.END); } }
Example #12
Source File: ChunkLoaderEventHandler.java From ChickenChunks with MIT License | 5 votes |
@SubscribeEvent public void worldTick(WorldTickEvent event) { if (event.phase == Phase.END && !event.world.isRemote) { ChunkLoaderManager.tickEnd((WorldServer) event.world); PlayerChunkViewerManager.instance().calculateChunkChanges((WorldServer) event.world); } }
Example #13
Source File: TankSynchroniser.java From EnderStorage with MIT License | 5 votes |
@SubscribeEvent public void tickEnd(ClientTickEvent event) { if(event.phase == Phase.END) if(ClientUtils.inWorld()) clientState.update(); }
Example #14
Source File: TankSynchroniser.java From EnderStorage with MIT License | 5 votes |
@SubscribeEvent public void tickEnd(ServerTickEvent event) { if(event.phase == Phase.END && playerItemTankStates != null) for(Entry<String, PlayerItemTankCache> entry : playerItemTankStates.entrySet()) entry.getValue().update(); }
Example #15
Source File: WorldEventHandler.java From TickDynamic with MIT License | 5 votes |
@SubscribeEvent public void worldTickEvent(WorldTickEvent event) { Profiler profiler = event.world.theProfiler; if(!(profiler instanceof CustomProfiler)) return; CustomProfiler customProfiler = (CustomProfiler)profiler; if(event.phase == Phase.START) { customProfiler.setStage(CustomProfiler.Stage.BeforeLoop); } else { customProfiler.setStage(CustomProfiler.Stage.None); } }
Example #16
Source File: ChunkLoaderEventHandler.java From ChickenChunks with MIT License | 4 votes |
@SubscribeEvent public void serverTick(ServerTickEvent event) { if (event.phase == Phase.END) PlayerChunkViewerManager.instance().update(); }
Example #17
Source File: HUDTickHandler.java From SimplyJetpacks with MIT License | 4 votes |
@SubscribeEvent public void onRenderTick(RenderTickEvent evt) { if (evt.phase == Phase.END && (Config.enableFuelHUD || Config.enableStateHUD)) { tickEnd(); } }
Example #18
Source File: KeyHandler.java From SimplyJetpacks with MIT License | 4 votes |
@SubscribeEvent public void onClientTick(ClientTickEvent evt) { if (evt.phase == Phase.START) { tickStart(); } }
Example #19
Source File: WRAddonEventHandler.java From WirelessRedstone with MIT License | 4 votes |
@SubscribeEvent public void worldTick(WorldTickEvent event) { if(event.phase == Phase.START) RedstoneEtherAddons.server().processSMPMaps(event.world); }
Example #20
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 #21
Source File: WRCoreEventHandler.java From WirelessRedstone with MIT License | 4 votes |
@SubscribeEvent public void clientTick(ClientTickEvent event) { if(event.phase == Phase.START) WirelessBolt.update(WirelessBolt.clientboltlist); }
Example #22
Source File: WRCoreEventHandler.java From WirelessRedstone with MIT License | 4 votes |
@SubscribeEvent public void serverTick(ServerTickEvent event) { if(event.phase == Phase.START) WirelessBolt.update(WirelessBolt.serverboltlist); }
Example #23
Source File: WRCoreEventHandler.java From WirelessRedstone with MIT License | 4 votes |
@SubscribeEvent public void serverTick(WorldTickEvent event) { if(event.phase == Phase.END && !event.world.isRemote) RedstoneEther.server().tick(event.world); }
Example #24
Source File: TickDynamicMod.java From TickDynamic with MIT License | 4 votes |
@SubscribeEvent(priority=EventPriority.HIGHEST) public void tickEventStart(ServerTickEvent event) { if(event.phase == Phase.START) { if(!versionCheckDone) { VersionChecker.VersionData versionData = versionChecker.getVersionData(); if(versionData != null) { versionCheckDone = true; if(versionData.checkOk) { //TODO: Parse versions, split at ',', then split version numbers at '.' System.out.println("TickDynamic version check: Latest version = " + versionData.modVersion + ". Download URL: http://" + versionData.updateUrl); } else System.out.println("TickDynamic version check: Error while checking latest version!"); } } TimedGroup externalGroup = getTimedGroup("external"); externalGroup.endTimer(); //Set the correct externalGroup time long msPerTick = 50; long overTime = externalGroup.getTimeUsed() - (msPerTick*externalGroup.timeMilisecond); //overTime = time used above given tick time long overTimeTick = (msPerTick*externalGroup.timeMilisecond) - (root.getTimeUsed() - externalGroup.getTimeUsed()); if(overTimeTick < 0) overTime += overTimeTick; /*System.out.println("TickTime: " + ((root.getTimeUsed()-externalGroup.getTimeUsed())/(double)externalGroup.timeMilisecond) + " Full Tick time: " + (externalGroup.getTimeUsed()/(double)externalGroup.timeMilisecond) + " External time used: " + (overTime/(double)externalGroup.timeMilisecond)+"ms");*/ if(overTime < 0) externalGroup.setTimeUsed(0); else externalGroup.setTimeUsed(overTime); externalGroup.startTimer(); //Clear any values from the previous tick for all worlds. root.newTick(true); getTimedGroup("other").startTimer(); } }