Java Code Examples for net.minecraftforge.fml.common.gameevent.TickEvent#ClientTickEvent
The following examples show how to use
net.minecraftforge.fml.common.gameevent.TickEvent#ClientTickEvent .
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: 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 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: 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 5
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.world != null) { if (loadWorld(mc.world)) { NEIClientConfig.setHasSMPCounterPart(false); NEIClientConfig.setInternalEnabled(false); if (!Minecraft.getMinecraft().isSingleplayer() && ClientUtils.inWorld())//wait for server to initiate in singleplayer { NEIClientConfig.loadWorld("remote/" + ClientUtils.getServerIP().replace(':', '~')); } } if (!NEIClientConfig.isEnabled()) { return; } KeyManager.tickKeyStates(); if (mc.currentScreen == null) { NEIController.processCreativeCycling(mc.player.inventory); } } GuiScreen gui = mc.currentScreen; if (gui != lastGui) { if (gui instanceof GuiMainMenu) { lastworld = null; } else if (gui instanceof GuiWorldSelection) { NEIClientConfig.reloadSaves(); } } lastGui = gui; }
Example 6
Source File: YouCouldMakeAReligionOutOfThis.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
@SubscribeEvent @SideOnly(Side.CLIENT) public static void onClientTick(TickEvent.ClientTickEvent event) { if (event.phase == TickEvent.Phase.START) { Minecraft client = Minecraft.getMinecraft(); if (client.world != null && !client.isGamePaused()) { RANDOM.setSeed((client.world.getTotalWorldTime() * M) ^ client.world.getSeed()); if (RANDOM.nextInt(CHANCE) == 0) { ISound sound = PositionedSoundRecord.getMasterRecord(YOU_COULD_MAKE_A_RELIGION_OUT_OF_THIS, 1.0F); client.getSoundHandler().playSound(sound); } } } }
Example 7
Source File: ClientStateMachine.java From malmo with MIT License | 5 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 (++totalTicks > WAIT_MAX_TICKS) { String msg = "Too long waiting for world to be created."; TCPUtils.Log(Level.SEVERE, msg); episodeHasCompletedWithErrors(ClientState.ERROR_TIMED_OUT_WAITING_FOR_WORLD_CREATE, msg); } }
Example 8
Source File: CMMEventHandler.java From Custom-Main-Menu with MIT License | 5 votes |
@SubscribeEvent public void tick(TickEvent.ClientTickEvent event) { if (event.phase == TickEvent.Phase.END) { if (CustomMainMenu.INSTANCE.config != null) CustomMainMenu.INSTANCE.config.tick(); } }
Example 9
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 10
Source File: CooldownHandler.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@SubscribeEvent public static void clientTick(TickEvent.ClientTickEvent event) { if (event.phase != TickEvent.Phase.START) return; if (playerHandler == null) return; if (Minecraft.getMinecraft().player == null) return; if (resetMain) { playerHandler.invoke(Minecraft.getMinecraft().player, 1000); Wizardry.PROXY.setItemStackHandHandler(EnumHand.MAIN_HAND, Minecraft.getMinecraft().player.getHeldItemMainhand()); } if (resetOff) Wizardry.PROXY.setItemStackHandHandler(EnumHand.OFF_HAND, Minecraft.getMinecraft().player.getHeldItemOffhand()); }
Example 11
Source File: FMLEventHandler.java From NOVA-Core with GNU Lesser General Public License v3.0 | 4 votes |
@SubscribeEvent public void tickEnd(TickEvent.ClientTickEvent event) { if (event.phase == TickEvent.Phase.END) { Game.syncTicker().update(); } }
Example 12
Source File: FMLEventHandler.java From NOVA-Core with GNU Lesser General Public License v3.0 | 4 votes |
@SubscribeEvent public void tickEnd(TickEvent.ClientTickEvent event) { if (event.phase == TickEvent.Phase.END) { Game.syncTicker().update(); } }
Example 13
Source File: VersionChecker.java From Wizardry with GNU Lesser General Public License v3.0 | 4 votes |
@SubscribeEvent @SideOnly(Side.CLIENT) public static void onTick(TickEvent.ClientTickEvent event) { if (!ConfigValues.versionCheckerEnabled) return; EntityPlayer player = Minecraft.getMinecraft().player; if (doneChecking && event.phase == TickEvent.Phase.END && player != null && !triedToWarnPlayer) { ITextComponent component = new TextComponentString("[").setStyle(new Style().setColor(TextFormatting.GREEN)) .appendSibling(new TextComponentTranslation("wizardry.misc.update_link").setStyle(new Style().setColor(TextFormatting.GRAY))) .appendSibling(new TextComponentString("]").setStyle(new Style().setColor(TextFormatting.GREEN))); component.getStyle() .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(updateMessage))) .setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://minecraft.curseforge.com/projects/wizardry-mod/files")); if (onlineVersion != null && !onlineVersion.isEmpty()) { String clientBuild = Wizardry.VERSION; if (Utils.compareVersions(onlineVersion, clientBuild) > 0) { ArrayList<String> messages = new ArrayList<>(); String base = "wizardry.update"; int n = 0; while (LibrarianLib.PROXY.canTranslate(base + n)) messages.add(base + n++); if (!messages.isEmpty()) player.sendMessage(new TextComponentTranslation(messages.get(RandUtil.nextInt(messages.size() - 1))).setStyle(new Style().setColor(TextFormatting.YELLOW))); player.sendMessage(new TextComponentTranslation("wizardry.misc.update_checker0") .setStyle(new Style().setColor(TextFormatting.GREEN))); player.sendMessage(new TextComponentTranslation("wizardry.misc.update_checker1") .setStyle(new Style().setColor(TextFormatting.GREEN)) .appendText(" ") .appendSibling(new TextComponentString(clientBuild).setStyle(new Style().setColor(TextFormatting.RED)))); player.sendMessage(new TextComponentTranslation("wizardry.misc.update_checker2") .setStyle(new Style().setColor(TextFormatting.GREEN)) .appendText(" ") .appendSibling(new TextComponentString(onlineVersion).setStyle(new Style().setColor(TextFormatting.YELLOW)))); if (updateMessage != null && !updateMessage.isEmpty()) player.sendMessage(component); } else if (updateMessage != null && !updateMessage.isEmpty()) player.sendMessage(component); } triedToWarnPlayer = true; } }
Example 14
Source File: UnicornTrailRenderer.java From Wizardry with GNU Lesser General Public License v3.0 | 4 votes |
@SideOnly(Side.CLIENT) @SubscribeEvent public static void tick(TickEvent.ClientTickEvent event) { if (event.phase != TickEvent.Phase.END) return; World world = Minecraft.getMinecraft().world; if (world == null) return; List<EntityUnicorn> unicorns = world.getEntities(EntityUnicorn.class, input -> true); for (EntityUnicorn unicorn : unicorns) { if (unicorn == null) continue; if (unicorn.isDead) { positions.remove(unicorn); break; } positions.putIfAbsent(unicorn, new ArrayList<>()); List<Point> poses = positions.get(unicorn); if ((poses.size() >= 1000 || world.getTotalWorldTime() % 20 == 0) && !poses.isEmpty()) { poses.remove(0); } double mot = 0.05; if (poses.size() < 1000) { if (unicorn.motionX >= mot || unicorn.motionX <= -mot || unicorn.motionY >= mot || unicorn.motionY <= -mot || unicorn.motionZ >= mot || unicorn.motionZ <= -mot) { Vec3d backCenter = unicorn.getPositionVector(); Vec3d look = new Vec3d(unicorn.motionX, unicorn.motionY, unicorn.motionZ).normalize(); backCenter = backCenter.add(look.scale(-1)); Vec3d cross = look.crossProduct(new Vec3d(0, 1, 0)).normalize().scale(0.35f); poses.add(new Point(backCenter, cross, world.getTotalWorldTime())); } else if (!poses.isEmpty()) { poses.remove(0); } } } }
Example 15
Source File: ClientStateMachine.java From malmo with MIT License | 4 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); // We need to make sure that both the client and server have paused, // otherwise we are still susceptible to the "Holder Lookups" hang. // Since the server sets its pause state in response to the client's pause state, // and it only performs this check once, at the top of its tick method, // to be sure that the server has had time to set the flag correctly we need to make sure // that at least one server tick method has *started* since the flag was set. // We can't do this by catching the onServerTick events, since we don't receive them when the game is paused. // The following code makes use of the fact that the server both locks and empties the server's futureQueue, // every time through the server tick method. // This locking means that if the client - which needs to wait on the lock - // tries to add an event to the queue in response to an event on the queue being executed, // the newly added event will have to happen in a subsequent tick. if ((Minecraft.getMinecraft().isGamePaused() || Minecraft.getMinecraft().player == null) && ev != null && ev.phase == Phase.END && this.clientTickCount == this.serverTickCount && this.clientTickCount <= 2) { this.clientTickCount++; // Increment our count, and wait for the server to catch up. Minecraft.getMinecraft().getIntegratedServer().addScheduledTask(new Runnable() { public void run() { // Increment the server count. PauseOldServerEpisode.this.serverTickCount++; } }); } if (this.serverTickCount > 2) { episodeHasCompleted(ClientState.CLOSING_OLD_SERVER); } else if (++totalTicks > WAIT_MAX_TICKS) { String msg = "Too long waiting for server episode to pause."; TCPUtils.Log(Level.SEVERE, msg); episodeHasCompletedWithErrors(ClientState.ERROR_TIMED_OUT_WAITING_FOR_EPISODE_PAUSE, msg); } }
Example 16
Source File: AutoBucketFallMod.java From ForgeHax with MIT License | 4 votes |
@SubscribeEvent public void onClientTick(TickEvent.ClientTickEvent event) { if (getLocalPlayer() == null || getLocalPlayer().fallDistance < settingFallHeight.getAsDouble() || !getLocalPlayer().inventory.hasItemStack(WATER_BUCKET) || isInWater(getLocalPlayer()) || isAboveWater(getLocalPlayer())) { return; } Vec3d playerPos = getLocalPlayer().getPositionVector(); Vec3d rayTraceBucket = new Vec3d(playerPos.x, playerPos.y - 5, playerPos.z); Vec3d rayTracePre = new Vec3d( playerPos.x, playerPos.y - preHeight.getAsDouble(), playerPos.z); // find the ground before the player is ready to water bucket RayTraceResult result = MC.world.rayTraceBlocks(playerPos, rayTraceBucket, true); RayTraceResult resultPre = MC.world.rayTraceBlocks(playerPos, rayTracePre, true); if (resultPre != null && resultPre.typeOfHit.equals(Type.BLOCK) && !(getWorld().getBlockState(resultPre.getBlockPos()).getBlock() instanceof BlockLiquid)) { // set the pitch early to not get cucked by ncp getLocalPlayer().prevRotationPitch = 90f; getLocalPlayer().rotationPitch = 90f; int bucketSlot = findBucketHotbar(); if (bucketSlot == -1) { bucketSlot = findBucketInv(); } if (bucketSlot > 8) { swap( bucketSlot, getLocalPlayer().inventory.currentItem); // move bucket from inventory to hotbar } else { MC.player.inventory.currentItem = bucketSlot; } } if (result != null && result.typeOfHit.equals(Type.BLOCK) && !(getWorld().getBlockState(result.getBlockPos()).getBlock() instanceof BlockLiquid)) { getNetworkManager() .sendPacket( new CPacketPlayer.Rotation( getLocalPlayer().rotationYaw, 90, getLocalPlayer().onGround)); // probably unnecessary but doing it anyways getLocalPlayer().prevRotationPitch = 90f; getLocalPlayer().rotationPitch = 90f; // printMessage("Attempted to place water bucket"); MC.playerController.processRightClick(getLocalPlayer(), getWorld(), EnumHand.MAIN_HAND); } }
Example 17
Source File: FullBrightMod.java From ForgeHax with MIT License | 4 votes |
@SubscribeEvent public void onClientTick(TickEvent.ClientTickEvent event) { MC.gameSettings.gammaSetting = 16F; }
Example 18
Source File: SentientBread.java From CommunityMod with GNU Lesser General Public License v2.1 | 4 votes |
@SubscribeEvent public static void onClientTick(TickEvent.ClientTickEvent event) { Minecraft mc = Minecraft.getMinecraft(); if (!isLoaded) { return; } if (event.phase == TickEvent.Phase.END && mc.world != null && !mc.isGamePaused()) { ItemStack stack = mc.player.getActiveItemStack(); if (!stack.isEmpty() && stack.getItem() == Items.BREAD) { Random rand = mc.player.world.rand; if (rand.nextFloat() < 0.04) { String msg = MESSAGES_STOP[rand.nextInt(MESSAGES_STOP.length)]; int i = mc.gameSettings.narrator; if (NARRATOR.active() && (i == 0 || i == 3)) // Don't narrate if the setting is already turned on { NARRATOR.clear(); NARRATOR.say(msg); } mc.player.sendMessage(stack.getTextComponent().appendSibling(new TextComponentString(": " + msg))); } } } }
Example 19
Source File: MagnetModeHandler.java From NotEnoughItems with MIT License | 4 votes |
@SubscribeEvent @SideOnly (Side.CLIENT) public void clientTickEvent(TickEvent.ClientTickEvent event) { if (event.phase == Phase.END || Minecraft.getMinecraft().world == null) { return; } if (!NEIClientConfig.isMagnetModeEnabled()) { return; } EntityPlayer player = Minecraft.getMinecraft().player; Iterator<EntityItem> iterator = clientMagnetItems.iterator(); while (iterator.hasNext()) { EntityItem item = iterator.next(); if (item.cannotPickup()) { continue; } if (item.isDead) { iterator.remove(); } if (item.getEntityData().getBoolean("PreventRemoteMovement")) { continue; } if (!NEIClientUtils.canItemFitInInventory(player, item.getItem())) { continue; } double dx = player.posX - item.posX; double dy = player.posY + player.getEyeHeight() - item.posY; double dz = player.posZ - item.posZ; double absxz = Math.sqrt(dx * dx + dz * dz); double absy = Math.abs(dy); if (absxz > DISTANCE_XZ || absy > DISTANCE_Y) { continue; } if (absxz > 1) { dx /= absxz; dz /= absxz; } if (absy > 1) { dy /= absy; } double vx = item.motionX + SPEED_XZ * dx; double vy = item.motionY + SPEED_Y * dy; double vz = item.motionZ + SPEED_XZ * dz; double absvxz = Math.sqrt(vx * vx + vz * vz); double absvy = Math.abs(vy); double rationspeedxz = absvxz / MAX_SPEED_XZ; if (rationspeedxz > 1) { vx /= rationspeedxz; vz /= rationspeedxz; } double rationspeedy = absvy / MAX_SPEED_Y; if (rationspeedy > 1) { vy /= rationspeedy; } if (absvxz < 0.2 && absxz < 0.2) { item.setDead(); } item.setVelocity(vx, vy, vz); } }
Example 20
Source File: PlayerListener.java From SkyblockAddons with MIT License | 4 votes |
/** * The main timer for the magma boss checker. */ @SubscribeEvent() public void onClientTickMagma(TickEvent.ClientTickEvent e) { if (e.phase == TickEvent.Phase.START) { Minecraft mc = Minecraft.getMinecraft(); if (main.getConfigValues().isEnabled(Feature.MAGMA_WARNING) && main.getUtils().isOnSkyblock()) { if (mc != null && mc.theWorld != null) { if (magmaTick % 5 == 0) { boolean foundBoss = false; long currentTime = System.currentTimeMillis(); for (Entity entity : mc.theWorld.loadedEntityList) { // Loop through all the entities. if (entity instanceof EntityMagmaCube) { EntitySlime magma = (EntitySlime) entity; if (magma.getSlimeSize() > 10) { // Find a big magma boss foundBoss = true; if ((lastBoss == -1 || System.currentTimeMillis() - lastBoss > 1800000)) { lastBoss = System.currentTimeMillis(); main.getRenderListener().setTitleFeature(Feature.MAGMA_WARNING); // Enable warning and disable again in four seconds. magmaTick = 16; // so the sound plays instantly main.getScheduler().schedule(Scheduler.CommandType.RESET_TITLE_FEATURE, main.getConfigValues().getWarningSeconds()); // logServer(mc); } magmaAccuracy = EnumUtils.MagmaTimerAccuracy.SPAWNED; if (currentTime - lastBossSpawnPost > 300000) { lastBossSpawnPost = currentTime; main.getUtils().sendInventiveTalentPingRequest(EnumUtils.MagmaEvent.BOSS_SPAWN); } } } } if (!foundBoss && main.getRenderListener().getTitleFeature() == Feature.MAGMA_WARNING) { main.getRenderListener().setTitleFeature(null); } if (!foundBoss && magmaAccuracy == EnumUtils.MagmaTimerAccuracy.SPAWNED) { magmaAccuracy = EnumUtils.MagmaTimerAccuracy.ABOUT; magmaTime = 7200; if (currentTime - lastBossDeathPost > 300000) { lastBossDeathPost = currentTime; main.getUtils().sendInventiveTalentPingRequest(EnumUtils.MagmaEvent.BOSS_DEATH); } } } if (main.getRenderListener().getTitleFeature() == Feature.MAGMA_WARNING && magmaTick % 4 == 0) { // Play sound every 4 ticks or 1/5 second. main.getUtils().playLoudSound("random.orb", 0.5); } } } magmaTick++; if (magmaTick > 20) { if ((magmaAccuracy == EnumUtils.MagmaTimerAccuracy.EXACTLY || magmaAccuracy == EnumUtils.MagmaTimerAccuracy.ABOUT) && magmaTime == 0) { magmaAccuracy = EnumUtils.MagmaTimerAccuracy.SPAWNED_PREDICTION; main.getScheduler().schedule(Scheduler.CommandType.RESET_MAGMA_PREDICTION, 20); } magmaTime--; magmaTick = 1; } } }