net.minecraftforge.fml.common.gameevent.TickEvent Java Examples
The following examples show how to use
net.minecraftforge.fml.common.gameevent.TickEvent.
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: NemezEventHandler.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
@SubscribeEvent public static void worldTick(TickEvent.WorldTickEvent event) { if (event.phase == TickEvent.Phase.START) reversals.removeIf((reversal) -> { if (reversal.world.get() == event.world) { if (reversal.nemez.hasNext()) { reversal.nemez.applySnapshot(event.world); if (reversal.pos != null && reversal.world.get().getTotalWorldTime() % PacketNemezReversal.SYNC_AMOUNT == 0) PacketHandler.NETWORK.sendToAllAround(new PacketNemezReversal(reversal.nemez), new NetworkRegistry.TargetPoint(reversal.world.get().provider.getDimension(), reversal.pos.getX() + 0.5, reversal.pos.getY() + 0.5, reversal.pos.getZ() + 0.5, 96)); } else { for (Entity entity : reversal.nemez.getTrackedEntities(event.world)) entity.setNoGravity(false); return true; } } return reversal.world.get() == null; }); }
Example #2
Source File: ClientStateMachine.java From malmo with MIT License | 6 votes |
@Override public void onClientTick(TickEvent.ClientTickEvent ev) { // Check to see whether anything has caused us to abort - if so, go to the abort state. if (inAbortState()) episodeHasCompleted(ClientState.MISSION_ABORTED); if (ev.phase == Phase.END) episodeHasCompleted(ClientState.CREATING_NEW_WORLD); if (++totalTicks > WAIT_MAX_TICKS) { String msg = "Too long waiting for server episode to close."; TCPUtils.Log(Level.SEVERE, msg); episodeHasCompletedWithErrors(ClientState.ERROR_TIMED_OUT_WAITING_FOR_EPISODE_CLOSE, msg); } }
Example #3
Source File: EpisodeEventWrapper.java From malmo with MIT License | 6 votes |
@SubscribeEvent public void onClientTick(TickEvent.ClientTickEvent ev) { // Now pass the event on to the active episode, if there is one: this.stateEpisodeLock.readLock().lock(); if (this.stateEpisode != null && this.stateEpisode.isLive()) { try { this.stateEpisode.onClientTick(ev); } catch (Exception e) { // Do what?? } } this.stateEpisodeLock.readLock().unlock(); }
Example #4
Source File: PlanetEventHandler.java From AdvancedRocketry with MIT License | 6 votes |
@SubscribeEvent public void tick(TickEvent.ServerTickEvent event) { //Tick satellites if(event.phase == event.phase.END) { DimensionManager.getInstance().tickDimensions(); time++; if(!transitionMap.isEmpty()) { Iterator<Entry<Long, TransitionEntity>> itr = transitionMap.entrySet().iterator(); while(itr.hasNext()) { Entry<Long, TransitionEntity> entry = itr.next(); TransitionEntity ent = entry.getValue(); if(ent.entity.world.getTotalWorldTime() >= entry.getKey()) { ent.entity.setLocationAndAngles(ent.location.getX(), ent.location.getY(), ent.location.getZ(), ent.entity.rotationYaw, ent.entity.rotationPitch); ent.entity.getServer().getPlayerList().transferPlayerToDimension((EntityPlayerMP)ent.entity, ent.dimId, new TeleporterNoPortal(ent.entity.getServer().getWorld(ent.dimId))); ent.entity.startRiding(ent.entity2); itr.remove(); } } } } }
Example #5
Source File: ClayRainMod.java From CommunityMod with GNU Lesser General Public License v2.1 | 6 votes |
@SubscribeEvent public void rain(TickEvent.WorldTickEvent e) { if (e.world.isRaining()) { if (e.world.rand.nextInt(5) == 0) { for (EntityPlayer player : e.world.playerEntities) { if (e.world.getBiome(player.getPosition()).canRain()) { double x = e.world.rand.nextInt(maxRange * 2) - maxRange; double y = 255; if (player.posY < 100) y = 130; double z = e.world.rand.nextInt(maxRange * 2) - maxRange; EntityItem clay = new EntityItem(e.world, x + player.posX, y, z + player.posZ, new ItemStack(Items.CLAY_BALL)); clay.lifespan = 200; e.world.spawnEntity(clay); } } } } }
Example #6
Source File: BoatFly.java From ForgeHax with MIT License | 6 votes |
@SubscribeEvent public void onClientTick(TickEvent.ClientTickEvent event) { // check if the player is really riding a entity if (MC.player != null && MC.player.getRidingEntity() != null) { ForgeHaxHooks.isNoClampingActivated = noClamp.getAsBoolean(); ForgeHaxHooks.isNoBoatGravityActivated = noGravity.getAsBoolean(); ForgeHaxHooks.isBoatSetYawActivated = setYaw.getAsBoolean(); if (MC.gameSettings.keyBindJump.isKeyDown()) { // trick the riding entity to think its onground MC.player.getRidingEntity().onGround = false; // teleport up MC.player.getRidingEntity().motionY = MC.gameSettings.keyBindSprint.isKeyDown() ? 5 : 1.5; } else { MC.player.getRidingEntity().motionY = MC.gameSettings.keyBindSprint.isKeyDown() ? -1.0 : -speedY.getAsDouble(); } /*if ((MC.player.posY <= maintainY.getAsDouble()-5D) && (MC.player.posY > maintainY.getAsDouble()-10D) && maintainY.getAsDouble() != 0D) MC.player.getRidingEntity().setPositionAndUpdate(MC.player.posX, maintainY.getAsDouble(), MC.player.posZ );*/ setMoveSpeedEntity(speed.getAsDouble()); } }
Example #7
Source File: AutoMine.java From ForgeHax with MIT License | 6 votes |
@SubscribeEvent public void onTick(TickEvent.ClientTickEvent event) { if (getLocalPlayer() == null || getWorld() == null) { return; } switch (event.phase) { case START: { RayTraceResult tr = LocalPlayerUtils.getMouseOverBlockTrace(); if (tr == null) { setPressed(false); return; } setPressed(true); break; } case END: setPressed(false); break; } }
Example #8
Source File: VanillaWares.java From Cyberware with MIT License | 6 votes |
@SubscribeEvent @SideOnly(Side.CLIENT) public void handleSpiderVision(TickEvent.ClientTickEvent event) { if (event.phase == TickEvent.Phase.START) { EntityPlayer e = Minecraft.getMinecraft().thePlayer; if (CyberwareAPI.isCyberwareInstalled(e, new ItemStack(Items.SPIDER_EYE))) { if (Minecraft.getMinecraft().entityRenderer.getShaderGroup() == null) { Minecraft.getMinecraft().entityRenderer.loadShader(new ResourceLocation("shaders/post/spider.json")); } } else if (e != null && !e.isSpectator()) { ShaderGroup sg = Minecraft.getMinecraft().entityRenderer.getShaderGroup(); if (sg != null && sg.getShaderGroupName().equals("minecraft:shaders/post/spider.json")) { Minecraft.getMinecraft().entityRenderer.stopUseShader(); } } } }
Example #9
Source File: KeyManager.java From malmo with MIT License | 6 votes |
/** Tick event called on the Client.<br> * Used to simulate pressing and releasing of our additional keys.<br> * This is about as close as we can (easily) get in the call stack to the point when Minecraft does the equivalent code for its own keys. * @param ev ClientTickEvent for this tick. */ @SubscribeEvent public void onClientTick(TickEvent.ClientTickEvent ev) { if (ev != null && ev.phase == Phase.START) { for (InternalKey binding : this.additionalKeys) { if (binding.isKeyDown()) { binding.onKeyDown(); } if (binding.isPressed()) { binding.onPressed(); } } } }
Example #10
Source File: Scheduler.java From SkyblockAddons with MIT License | 6 votes |
@SubscribeEvent() public void ticker(TickEvent.ClientTickEvent e) { if (e.phase == TickEvent.Phase.START) { totalTicks++; Set<Command> commands = queue.get(totalTicks); if (commands != null) { for (Command command : commands) { for (int times = 0; times < command.getCount().getValue(); times++) { command.getCommandType().execute(command, times+1); } } queue.remove(totalTicks); } if (totalTicks % 12000 == 0 || delayingMagmaCall) { // check magma boss every 15 minutes if (main.getPlayerListener().getMagmaAccuracy() != EnumUtils.MagmaTimerAccuracy.EXACTLY) { if (main.getUtils().isOnSkyblock()) { delayingMagmaCall = false; main.getUtils().fetchMagmaBossEstimate(); } else if (!delayingMagmaCall) { delayingMagmaCall = true; } } } ChromaManager.increment(); // Run every tick } }
Example #11
Source File: EventManager.java From Logistics-Pipes-2 with MIT License | 6 votes |
@SubscribeEvent public void onWorldTick(TickEvent.WorldTickEvent event){ if (!event.world.isRemote && event.phase == TickEvent.Phase.END){ NBTTagList list = new NBTTagList(); TileEntity[] updateArray = toUpdate.values().toArray(new TileEntity[toUpdate.size()]); for (int i = 0; i < updateArray.length; i ++){ TileEntity t = updateArray[i]; if (!event.world.isRemote){ list.appendTag(t.getUpdateTag()); } } if (!list.hasNoTags()){ NBTTagCompound tag = new NBTTagCompound(); tag.setTag("data", list); LPPacketHandler.INSTANCE.sendToAll(new MessagePipeContentUpdate(tag)); } toUpdate.clear(); } }
Example #12
Source File: PotionNullMovement.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
@SubscribeEvent @SideOnly(Side.CLIENT) public void onTick(TickEvent.ClientTickEvent event) { Minecraft mc = Minecraft.getMinecraft(); EntityPlayerSP player = mc.player; if (player == null) return; if (player.isPotionActive(ModPotions.NULL_MOVEMENT)) { //player.rotationYaw = player.getEntityData().getFloat("rot_yaw"); //player.rotationPitch = player.getEntityData().getFloat("rot_pitch"); //player.prevRotationYaw = player.getEntityData().getFloat("rot_yaw"); //player.prevRotationPitch = player.getEntityData().getFloat("rot_pitch"); if (!(player.movementInput instanceof NullMovementInput)) player.movementInput = new NullMovementInput(player.movementInput); } else if (!(player.movementInput instanceof MovementInputFromOptions)) player.movementInput = new MovementInputFromOptions(mc.gameSettings); }
Example #13
Source File: SpaceObjectManager.java From AdvancedRocketry with MIT License | 6 votes |
@SubscribeEvent public void onServerTick(TickEvent.ServerTickEvent event) { if(DimensionManager.getWorld(Configuration.spaceDimId) == null) return; long worldTime = DimensionManager.getWorld(Configuration.spaceDimId).getTotalWorldTime(); //Assuming server //If no dim undergoing transition then nextTransitionTick = -1 if((nextStationTransitionTick != -1 && worldTime >= nextStationTransitionTick && spaceStationOrbitMap.get(WARPDIMID) != null) || (nextStationTransitionTick == -1 && spaceStationOrbitMap.get(WARPDIMID) != null && !spaceStationOrbitMap.get(WARPDIMID).isEmpty())) { long newNextTransitionTick = -1; for(ISpaceObject obj : spaceStationOrbitMap.get(WARPDIMID)) { if(obj.getTransitionTime() <= worldTime) { moveStationToBody(obj, obj.getDestOrbitingBody()); spaceStationOrbitMap.get(WARPDIMID).remove(obj); } else if(newNextTransitionTick == -1 || obj.getTransitionTime() < newNextTransitionTick) newNextTransitionTick = obj.getTransitionTime(); } nextStationTransitionTick = newNextTransitionTick; } }
Example #14
Source File: EntityFairy.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
@SubscribeEvent public static void onStun(TickEvent.WorldTickEvent event) { if (event.side == Side.CLIENT) return; for (EntityFairy fairy : event.world.getEntities(EntityFairy.class, input -> input != null && !input.isDead)) { fairy.stunned = false; secondary: for (EntityPlayer player : event.world.getEntitiesWithinAABB(EntityPlayer.class, fairy.getEntityBoundingBox().grow(5))) { for (EnumHand hand : EnumHand.values()) { ItemStack stack = player.getHeldItem(hand); if (stack.getItem() == ModItems.FAIRY_BELL) { fairy.stunned = true; break secondary; } } } } }
Example #15
Source File: TooltipOverlayHandler.java From IGW-mod with GNU General Public License v2.0 | 5 votes |
@SubscribeEvent public void tickEnd(TickEvent.RenderTickEvent event){ if(event.phase == TickEvent.Phase.END && TickHandler.showTooltip() && ConfigHandler.shouldShowTooltip && FMLClientHandler.instance().getClient().inGameHasFocus && IGWMod.proxy.getPlayer().world != null) { Minecraft mc = FMLClientHandler.instance().getClient(); ScaledResolution sr = new ScaledResolution(mc); FontRenderer fontRenderer = FMLClientHandler.instance().getClient().fontRenderer; String objectName = TickHandler.getCurrentObjectName(); String moreInfo = "'" + Keyboard.getKeyName(ClientProxy.openInterfaceKey.getKeyCode()) + "' for more info"; fontRenderer.drawString(objectName, sr.getScaledWidth() / 2 - fontRenderer.getStringWidth(objectName) / 2, sr.getScaledHeight() / 2 - 20, 0xFFFFFFFF); fontRenderer.drawString(moreInfo, sr.getScaledWidth() / 2 - fontRenderer.getStringWidth(moreInfo) / 2, sr.getScaledHeight() / 2 - 10, 0xFFFFFFFF); } }
Example #16
Source File: ServerHandler.java From NotEnoughItems with MIT License | 5 votes |
@SubscribeEvent public void tickEvent(TickEvent.WorldTickEvent event) { if (event.phase == Phase.START && !event.world.isRemote && NEIServerConfig.dimTags.containsKey(event.world.provider.getDimension()))//fake worlds that don't call Load { processDisabledProperties(event.world); } }
Example #17
Source File: DelayedGuiDisplayTicker.java From LunatriusCore with MIT License | 5 votes |
@SubscribeEvent public void onClientTick(final TickEvent.ClientTickEvent event) { this.ticks--; if (this.ticks < 0) { Minecraft.getMinecraft().displayGuiScreen(this.guiScreen); MinecraftForge.EVENT_BUS.unregister(this); } }
Example #18
Source File: ClientHandler.java From NotEnoughItems with MIT License | 5 votes |
@SubscribeEvent public void tickEvent(TickEvent.ClientTickEvent event) { if(event.phase == Phase.END) return; Minecraft mc = Minecraft.getMinecraft(); if(mc.theWorld != null) { if(loadWorld(mc.theWorld)) { NEIClientConfig.setHasSMPCounterPart(false); NEIClientConfig.setInternalEnabled(false); if (!Minecraft.getMinecraft().isSingleplayer())//wait for server to initiate in singleplayer NEIClientConfig.loadWorld("remote/" + ClientUtils.getServerIP().replace(':', '~')); } if (!NEIClientConfig.isEnabled()) return; KeyManager.tickKeyStates(); NEIController.updateUnlimitedItems(mc.thePlayer.inventory); if (mc.currentScreen == null) NEIController.processCreativeCycling(mc.thePlayer.inventory); updateMagnetMode(mc.theWorld, mc.thePlayer); } GuiScreen gui = mc.currentScreen; if (gui != lastGui) { if (gui instanceof GuiMainMenu) lastworld = null; else if (gui instanceof GuiSelectWorld) NEIClientConfig.reloadSaves(); } lastGui = gui; }
Example #19
Source File: EventManager.java From Logistics-Pipes-2 with MIT License | 5 votes |
@SideOnly(Side.CLIENT) @SubscribeEvent(priority = EventPriority.HIGHEST) public void onTick(TickEvent.ClientTickEvent event) { if(event.side == Side.CLIENT) { ticks++; ClientProxy.particleRender.updateParticles(); } }
Example #20
Source File: LPWorldGen.java From Logistics-Pipes-2 with MIT License | 5 votes |
@SubscribeEvent public void serverWorldTick(TickEvent.WorldTickEvent event) { if(event.side==Side.CLIENT || event.phase==TickEvent.Phase.START) { return; } int dimension = event.world.provider.getDimension(); int counter = 0; List<ChunkPos> chunks = retrogenChunks.get(dimension); if(chunks!=null && !chunks.isEmpty()) { for(int i=0; i<2; i++) { chunks = retrogenChunks.get(dimension); if(chunks == null || chunks.isEmpty()) { break; } counter++; ChunkPos loc = chunks.get(0); long worldSeed = event.world.getSeed(); Random fmlRandom = new Random(worldSeed); long xSeed = (fmlRandom.nextLong()>>3); long zSeed = (fmlRandom.nextLong()>>3); fmlRandom.setSeed(xSeed * loc.x + zSeed * loc.z ^ worldSeed); this.generateOres(fmlRandom, loc.x, loc.z, event.world, false); chunks.remove(0); } } if(counter>0 && Config.retrogenRemaining) { LogisticsPipes2.logger.info("Retrogen was performed on "+counter+" Chunks, "+Math.max(0, chunks.size())+" chunks remaining"); } }
Example #21
Source File: ObservationFromServer.java From malmo with MIT License | 5 votes |
@SubscribeEvent public void onClientTick(TickEvent.ClientTickEvent ev) { if (this.missionIsRunning) { // Use the client tick to fire messages to the server to request up-to-date stats. // We can then use those stats to fire back to the agent in writeObservationsToJSON. ObservationRequestMessage message = createObservationRequestMessage(); // To make sure only the intended listener receives this message, set the id now: message.id = System.identityHashCode(this); MalmoMod.network.sendToServer(message); } }
Example #22
Source File: EpisodeEventWrapper.java From malmo with MIT License | 5 votes |
@SubscribeEvent public void onServerTick(TickEvent.ServerTickEvent ev) { // Pass the event on to the active episode, if there is one: this.stateEpisodeLock.readLock().lock(); if (this.stateEpisode != null && this.stateEpisode.isLive()) { this.stateEpisode.onServerTick(ev); } this.stateEpisodeLock.readLock().unlock(); }
Example #23
Source File: WorldRetrogen.java From simpleretrogen with GNU General Public License v3.0 | 5 votes |
@SubscribeEvent public void tickStart(TickEvent.WorldTickEvent tick) { World w = tick.world; if (!(w instanceof WorldServer)) { return; } if (tick.phase == TickEvent.Phase.START) { counter = 0; getSemaphoreFor(w); } else { ListMultimap<ChunkPos, String> pending = pendingWork.get(w); if (pending == null) { return; } ImmutableList<Entry<ChunkPos, String>> forProcessing = ImmutableList.copyOf(Iterables.limit(pending.entries(), maxPerTick + 1)); for (Entry<ChunkPos, String> entry : forProcessing) { if (counter++ > maxPerTick) { FMLLog.fine("Completed %d retrogens this tick. There are %d left for world %s", counter, pending.size(), w.getWorldInfo().getWorldName()); return; } runRetrogen((WorldServer)w, entry.getKey(), entry.getValue()); } } }
Example #24
Source File: ObservationFromSystemImplementation.java From malmo with MIT License | 5 votes |
@SubscribeEvent public void onClientTick(TickEvent.ClientTickEvent ev) { super.onClientTick(ev); if (ev.side == Side.CLIENT && ev.phase == Phase.START) this.clientTickMonitor.beat(); }
Example #25
Source File: WorldExtensionManager.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
@SubscribeEvent public void serverTick(TickEvent.WorldTickEvent event) { if(!worldMap.containsKey(event.world)) WorldExtensionManager.onWorldLoad(event.world); if(event.phase == TickEvent.Phase.START) preTick(event.world); else postTick(event.world); }
Example #26
Source File: CableTickHandler.java From AdvancedRocketry with MIT License | 5 votes |
@SubscribeEvent public void onTick(TickEvent.ServerTickEvent tick) { try { if(tick.phase == Phase.END) { NetworkRegistry.dataNetwork.tickAllNetworks(); NetworkRegistry.energyNetwork.tickAllNetworks(); NetworkRegistry.liquidNetwork.tickAllNetworks(); } } catch (ConcurrentModificationException e) { e.printStackTrace(); } }
Example #27
Source File: NemezEventHandler.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@SideOnly(Side.CLIENT) @SubscribeEvent public static void renderTick(TickEvent.RenderTickEvent event) { World world = Minecraft.getMinecraft().world; if (event.phase == TickEvent.Phase.START) { for (Reversal reversal : reversals) { if (reversal.world.get() != world) continue; if (reversal.nemez.hasNext()) reversal.nemez.applySnapshot(world, event.renderTickTime); } } }
Example #28
Source File: LightningTracker.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@SubscribeEvent public void tick(TickEvent.WorldTickEvent event) { newEntries.forEach(e -> entityToEntry.put(e.getTarget(), e)); newEntries.clear(); entityToEntry.keySet().removeIf(entity -> { TrackingEntry entry = entityToEntry.get(entity); Entity caster = entry.getCaster(); int ticks = entry.getTicks(); double potency = entry.getPotency(); double duration = entry.getDuration(); if (ticks > 0) { entry.setTicks(ticks - 1); return false; } entity.setFire((int) duration); int invTime = entity.hurtResistantTime; entity.hurtResistantTime = 0; if (caster instanceof EntityPlayer) entity.attackEntityFrom(new EntityDamageSource("lightningbolt", caster), (float) potency); else entity.attackEntityFrom(DamageSource.LIGHTNING_BOLT, (float) potency); entity.hurtResistantTime = invTime; return true; }); }
Example #29
Source File: CCCEventHandler.java From CodeChickenCore with MIT License | 5 votes |
@SubscribeEvent public void clientTick(TickEvent.ClientTickEvent event) { if(event.phase == Phase.END) { CCUpdateChecker.tick(); renderTime++; } }
Example #30
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())); } }