Java Code Examples for net.minecraftforge.fml.common.gameevent.TickEvent.Phase#START
The following examples show how to use
net.minecraftforge.fml.common.gameevent.TickEvent.Phase#START .
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: WorldEventsCommon.java From Valkyrien-Skies with Apache License 2.0 | 6 votes |
@SubscribeEvent public void worldTick(WorldTickEvent event) { if (event.phase == Phase.START) { for (Entity entity : event.world.loadedEntityList) { if (entity instanceof EntityItem) { EntityItem itemEntity = (EntityItem) entity; ItemStack itemStack = itemEntity.getItem(); ICapabilityAntiGravity capability = itemStack.getCapability(ValkyrienSkiesWorld.ANTI_GRAVITY_CAPABILITY, null); if (capability != null) { if (capability.getMultiplier() != 0) { double multiplier = 0.12 / capability.getMultiplier(); // trust me it multiplies Y increase itemEntity.addVelocity(0, .1 - (itemEntity.motionY * multiplier), 0); } } } } } }
Example 2
Source File: WorldEventsCommon.java From Valkyrien-Skies with Apache License 2.0 | 6 votes |
@SubscribeEvent public void playerTick(PlayerTickEvent event) { if (event.phase == Phase.START) { EntityPlayer player = event.player; //TODO: fix the fall damage // @thebest108: what fall damage? // --DaPorkchop_, 28/03/2017 if (VSConfig.doValkyriumLifting && !player.isCreative()) { for (NonNullList<ItemStack> stackArray : player.inventory.allInventories) { for (ItemStack stack : stackArray) { if (stack != null) { if (stack.getItem() instanceof ItemBlock) { ItemBlock blockItem = (ItemBlock) stack.getItem(); if (blockItem.getBlock() instanceof BlockValkyriumOre) { player.addVelocity(0, .0025D * stack.stackSize * VSConfig.valkyriumOreForce, 0); } } else if (stack.getItem() instanceof ItemValkyriumCrystal) { player.addVelocity(0, .0025D * stack.stackSize * VSConfig.valkyriumCrystalForce, 0); } } } } } } }
Example 3
Source File: EventsClient.java From Valkyrien-Skies with Apache License 2.0 | 6 votes |
@SubscribeEvent public void onRenderTickEvent(RenderTickEvent event) { World world = Minecraft.getMinecraft().world; if (world == null) { return; // No ships to worry about. } double partialTicks = event.renderTickTime; if (Minecraft.getMinecraft().isGamePaused()) { partialTicks = Minecraft.getMinecraft().renderPartialTicksPaused; } if (event.phase == Phase.START) { for (PhysicsWrapperEntity wrapper : ValkyrienSkiesMod.VS_PHYSICS_MANAGER .getManagerForWorld(world) .getTickablePhysicsEntities()) { wrapper.getPhysicsObject().getShipTransformationManager() .updateRenderTransform(partialTicks); } } }
Example 4
Source File: ClientRenderHandler.java From TFC2 with GNU General Public License v3.0 | 6 votes |
@SubscribeEvent public void onClientTick(TickEvent.ClientTickEvent event) { World world = Minecraft.getMinecraft().world; if(event.phase == Phase.START) { if(WorldGen.getInstance() != null) { if(world != null && world.provider.getDimension() == 0) { WorldGen.getInstance().trimCache(); WorldGen.getInstance().buildFromQueue(); //We don't update on the client //WorldGen.getInstance().runUpdateLoop(); } } } }
Example 5
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 6
Source File: WEventFactory.java From ForgeWurst with GNU General Public License v3.0 | 5 votes |
@SubscribeEvent public static void onPlayerPreTick(TickEvent.PlayerTickEvent event) { if(event.phase != Phase.START) return; EntityPlayer player = event.player; if(player != WMinecraft.getPlayer()) return; if(!WPlayer.getWorld(player).isRemote) return; MinecraftForge.EVENT_BUS.post(new WUpdateEvent((EntityPlayerSP)player)); }
Example 7
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 8
Source File: HumanLevelCommandsImplementation.java From malmo with MIT License | 5 votes |
/** Called for each screen redraw - approximately three times as often as the other tick events, * under normal conditions.<br> * This is where we want to update our yaw/pitch, in order to get smooth panning etc * (which is how Minecraft itself does it). * The speed of the render ticks is not guaranteed, and can vary from machine to machine, so * we try to account for this in the calculations. * @param ev the RenderTickEvent object for this tick */ @SubscribeEvent public void onRenderTick(TickEvent.RenderTickEvent ev) { if (ev.phase == Phase.START && this.isOverriding()) { // Track average fps: this.renderTickMonitor.beat(); if (this.isOverriding()) { EntityPlayerSP player = Minecraft.getMinecraft().player; if (player != null) { if (this.targetPitchDelta != 0 || this.targetYawDelta != 0) { player.turn(this.targetYawDeltaDelta, this.targetPitchDeltaDelta); this.targetYawDelta -= this.targetYawDeltaDelta; this.targetPitchDelta -= this.targetPitchDeltaDelta; if (this.targetYawDelta / this.targetYawDeltaDelta < 1.0) this.targetYawDeltaDelta = this.targetYawDelta; if (this.targetPitchDelta / this.targetPitchDeltaDelta < 1.0) this.targetPitchDeltaDelta = this.targetPitchDelta; } } } } }
Example 9
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 10
Source File: CommandForWheeledRobotNavigationImplementation.java From malmo with MIT License | 5 votes |
/** Called for each screen redraw - approximately three times as often as the other tick events, * under normal conditions.<br> * This is where we want to update our yaw/pitch, in order to get smooth panning etc * (which is how Minecraft itself does it). * The speed of the render ticks is not guaranteed, and can vary from machine to machine, so * we try to account for this in the calculations. * @param ev the RenderTickEvent object for this tick */ @SubscribeEvent public void onRenderTick(TickEvent.RenderTickEvent ev) { if (ev.phase == Phase.START) { if (this.isOverriding()) { updateYawAndPitch(); } } }
Example 11
Source File: DebugUtil.java From EnderZoo with Creative Commons Zero v1.0 Universal | 5 votes |
@SubscribeEvent public void onPlayerTick(PlayerTickEvent evt) { if (evt.side != Side.SERVER || evt.phase != Phase.START) { return; } evt.player.setHealth(evt.player.getMaxHealth()); }
Example 12
Source File: EssentialsMissingHandler.java From Cyberware with MIT License | 5 votes |
@SubscribeEvent @SideOnly(Side.CLIENT) public void overlayPre(ClientTickEvent event) { if (event.phase == Phase.START && Minecraft.getMinecraft() != null && Minecraft.getMinecraft().thePlayer != null) { EntityPlayer e = Minecraft.getMinecraft().thePlayer; HashMultimap<String, AttributeModifier> multimap = HashMultimap.<String, AttributeModifier>create(); multimap.put(SharedMonsterAttributes.MOVEMENT_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(speedId, "Missing leg speed", -100F, 0)); e.getAttributeMap().removeAttributeModifiers(multimap); } }
Example 13
Source File: WEventFactory.java From ForgeWurst with GNU General Public License v3.0 | 5 votes |
@SubscribeEvent public static void onPlayerPreTick(TickEvent.PlayerTickEvent event) { if(event.phase != Phase.START) return; EntityPlayer player = event.player; if(player != WMinecraft.getPlayer()) return; if(!WPlayer.getWorld(player).isRemote) return; MinecraftForge.EVENT_BUS.post(new WUpdateEvent((EntityPlayerSP)player)); }
Example 14
Source File: ServerStateMachine.java From malmo with MIT License | 4 votes |
@Override protected void onServerTick(ServerTickEvent ev) { if (this.missionHasEnded) return; // In case we get in here after deciding the mission is over. if (!ServerStateMachine.this.checkWatchList()) onError(null); // We've lost a connection - abort the mission. if (ev.phase == Phase.START) { // Measure our performance - especially useful if we've been overclocked. if (this.secondStartTimeMs == 0) this.secondStartTimeMs = System.currentTimeMillis(); long timeNow = System.currentTimeMillis(); if (timeNow - this.secondStartTimeMs > 1000) { long targetTicks = 1000 / TimeHelper.serverTickLength; if (this.tickCount < targetTicks) System.out.println("Warning: managed " + this.tickCount + "/" + targetTicks + " ticks this second."); this.secondStartTimeMs = timeNow; this.tickCount = 0; } this.tickCount++; } MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); if (ev.phase == Phase.END && getHandlers() != null && getHandlers().worldDecorator != null) { World world = server.getEntityWorld(); getHandlers().worldDecorator.update(world); } if (ev.phase == Phase.END) { if (getHandlers() != null && getHandlers().quitProducer != null && getHandlers().quitProducer.doIWantToQuit(currentMissionInit())) { ServerStateMachine.this.quitCode = getHandlers().quitProducer.getOutcome(); onMissionEnded(true); } else if (this.runningAgents.isEmpty()) { ServerStateMachine.this.quitCode = "All agents finished"; onMissionEnded(true); } // We need to make sure we keep the weather within mission parameters. // We set the weather just after building the world, but it's not a permanent setting, // and apparently there is a known bug in Minecraft that means the weather sometimes changes early. // To get around this, we reset it periodically. if (server.getTickCounter() % 500 == 0) { EnvironmentHelper.setMissionWeather(currentMissionInit(), server.getEntityWorld().getWorldInfo()); } } }
Example 15
Source File: NEIClientEventHandler.java From NotEnoughItems with MIT License | 4 votes |
@SubscribeEvent public void clientTickEvent(TickEvent.ClientTickEvent event) { if (event.phase == Phase.START) { Minecraft minecraft = Minecraft.getMinecraft(); if (minecraft.currentScreen instanceof GuiContainer) { objectHandlers.forEach(handler -> handler.guiTick((GuiContainer) minecraft.currentScreen)); } } }
Example 16
Source File: CyberwareMenuHandler.java From Cyberware with MIT License | 4 votes |
@SubscribeEvent public void tick(ClientTickEvent event) { if(event.phase == Phase.START) { if (!KeyBinds.menu.isPressed() && mc.currentScreen == null && wasInScreen > 0) { KeyConflictContext inGame = KeyConflictContext.IN_GAME; mc.gameSettings.keyBindForward.setKeyConflictContext(inGame); mc.gameSettings.keyBindLeft.setKeyConflictContext(inGame); mc.gameSettings.keyBindBack.setKeyConflictContext(inGame); mc.gameSettings.keyBindRight.setKeyConflictContext(inGame); mc.gameSettings.keyBindJump.setKeyConflictContext(inGame); mc.gameSettings.keyBindSneak.setKeyConflictContext(inGame); mc.gameSettings.keyBindSprint.setKeyConflictContext(inGame); if (wasSprinting) { mc.thePlayer.setSprinting(wasSprinting); } wasInScreen--; } } if(event.phase == Phase.END) { if (mc.thePlayer != null && mc.currentScreen == null) { ICyberwareUserData data = CyberwareAPI.getCapability(mc.thePlayer); for (int keyCode : data.getHotkeys()) { if (isPressed(data, keyCode)) { pressed.add(keyCode); if (!lastPressed.contains(keyCode)) { ClientUtils.useActiveItemClient(mc.thePlayer, data.getHotkey(keyCode)); } } } lastPressed = pressed; pressed = new ArrayList<Integer>(); } if (mc.thePlayer != null && CyberwareAPI.getCapability(mc.thePlayer).getNumActiveItems() > 0 && KeyBinds.menu.isPressed() && mc.currentScreen == null) { KeyConflictContext gui = KeyConflictContext.GUI; mc.gameSettings.keyBindForward.setKeyConflictContext(gui); mc.gameSettings.keyBindLeft.setKeyConflictContext(gui); mc.gameSettings.keyBindBack.setKeyConflictContext(gui); mc.gameSettings.keyBindRight.setKeyConflictContext(gui); mc.gameSettings.keyBindJump.setKeyConflictContext(gui); mc.gameSettings.keyBindSneak.setKeyConflictContext(gui); mc.gameSettings.keyBindSprint.setKeyConflictContext(gui); mc.displayGuiScreen(new GuiCyberwareMenu()); CyberwareAPI.getCapability(mc.thePlayer).setOpenedRadialMenu(true); CyberwarePacketHandler.INSTANCE.sendToServer(new OpenRadialMenuPacket()); wasInScreen = 5; } else if (wasInScreen > 0 && mc.currentScreen instanceof GuiCyberwareMenu) { wasSprinting = mc.thePlayer.isSprinting(); } } }
Example 17
Source File: ItemCybereyeUpgrade.java From Cyberware with MIT License | 4 votes |
@SubscribeEvent @SideOnly(Side.CLIENT) public void tickStart(TickEvent.ClientTickEvent event) { Minecraft mc = Minecraft.getMinecraft(); if (event.phase == Phase.START) { wasInUse = inUse; EntityPlayer p = mc.thePlayer; if (!inUse && !wasInUse) { fov = mc.gameSettings.fovSetting; sensitivity = mc.gameSettings.mouseSensitivity; } if (CyberwareAPI.isCyberwareInstalled(p, new ItemStack(this, 1, 4))) { player = p; if (mc.gameSettings.thirdPersonView == 0) { switch (zoomSettingOn) { case 0: mc.gameSettings.fovSetting = fov; mc.gameSettings.mouseSensitivity = sensitivity; break; case 1: mc.gameSettings.fovSetting = fov; mc.gameSettings.mouseSensitivity = sensitivity; int i = 0; while (Math.abs((mc.gameSettings.fovSetting - ((fov + 5F)) / 2.0F)) > 2.5F && i < 200) { mc.gameSettings.fovSetting -= 2.5F; mc.gameSettings.mouseSensitivity -= 0.01F; i++; } break; case 2: mc.gameSettings.fovSetting = fov; mc.gameSettings.mouseSensitivity = sensitivity; i = 0; while (Math.abs((mc.gameSettings.fovSetting - ((fov + 5F)) / 5.0F)) > 2.5F && i < 200) { mc.gameSettings.fovSetting -= 2.5F; mc.gameSettings.mouseSensitivity -= 0.01F; i++; } break; case 3: mc.gameSettings.fovSetting = fov; mc.gameSettings.mouseSensitivity = sensitivity; i = 0; while (Math.abs((mc.gameSettings.fovSetting - ((fov + 5F)) / 12.0F)) > 2.5F && i < 200) { mc.gameSettings.fovSetting -= 2.5F; mc.gameSettings.mouseSensitivity -= 0.01F; i++; } break; } } } else { zoomSettingOn = 0; } inUse = zoomSettingOn != 0; if (!inUse && wasInUse) { mc.gameSettings.fovSetting = fov; mc.gameSettings.mouseSensitivity = sensitivity; } } }
Example 18
Source File: ObservationFromSystemImplementation.java From malmo with MIT License | 4 votes |
@SubscribeEvent public void onRenderTick(TickEvent.RenderTickEvent ev) { if (ev.side == Side.CLIENT && ev.phase == Phase.START) this.renderTickMonitor.beat(); }
Example 19
Source File: EventHandler.java From Signals with GNU General Public License v3.0 | 4 votes |
@SubscribeEvent public void onPreServerTick(ServerTickEvent event){ if(event.phase == Phase.START) { RailNetworkManager.getServerInstance().onPreServerTick(); } }
Example 20
Source File: CCCEventHandler.java From CodeChickenCore with MIT License | 4 votes |
@SubscribeEvent public void renderTick(TickEvent.RenderTickEvent event) { if(event.phase == Phase.START) renderFrame = event.renderTickTime; }