net.minecraftforge.fml.common.gameevent.TickEvent.Phase Java Examples

The following examples show how to use net.minecraftforge.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: BleachHack.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
  public void onTick(TickEvent.ClientTickEvent event) {
if (!(event.phase == Phase.END)) return;

try {
	ModuleManager.onUpdate();
  		ModuleManager.updateKeys();
  		
  		if (Minecraft.getInstance().player.ticksExisted % 100 == 0) {
  			fileReader.saveModules();
  			fileReader.saveSettings();
  			fileReader.saveClickGui();
  		}
  		
  		BleachQueue.nextQueue();
  	} catch (Exception e) {}
  }
 
Example #2
Source File: EventCreateWeapon.java    From Levels with GNU General Public License v2.0 6 votes vote down vote up
@SubscribeEvent
public void onCreateWeapon(PlayerTickEvent event)
{
	if (!event.player.getEntityWorld().isRemote)
	{
		if (event.phase == Phase.START)
		{
			for (ItemStack stack : event.player.inventory.mainInventory)
			{
				if (stack != null && (stack.getItem() instanceof ItemSword || stack.getItem() instanceof ItemBow || stack.getItem() instanceof ItemArmor || stack.getItem() instanceof ItemShield))
				{
					create(stack, event.player);
				}
			}
		}
	}
}
 
Example #3
Source File: KeyManager.java    From malmo with MIT License 6 votes vote down vote up
/** 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 #4
Source File: ServerTickHandler.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public void onServerWorldTick(WorldTickEvent event)
{
	World world = event.world;
	if(event.phase == Phase.START)
	{
		if(WorldGen.getInstance() != null)
		{
			if(world.provider.getDimension() == 0)
			{
				WorldGen.getInstance().trimCache();
				WorldGen.getInstance().buildFromQueue();
				WorldGen.getInstance().runUpdateLoop(event.world);
			}
		}			
	}
}
 
Example #5
Source File: ClientStateMachine.java    From malmo with MIT License 6 votes vote down vote up
@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 #6
Source File: VSKeyHandler.java    From Valkyrien-Skies with Apache License 2.0 6 votes vote down vote up
@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 #7
Source File: EventsClient.java    From Valkyrien-Skies with Apache License 2.0 6 votes vote down vote up
@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 #8
Source File: EventsClient.java    From Valkyrien-Skies with Apache License 2.0 6 votes vote down vote up
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onClientTickEvent(ClientTickEvent event) {
    Minecraft mc = Minecraft.getMinecraft();
    if (mc.world != null) {
        if (!mc.isGamePaused()) {
            WorldPhysObjectManager manager = ValkyrienSkiesMod.VS_PHYSICS_MANAGER
                .getManagerForWorld(mc.world);
            if (event.phase == Phase.END) {
                for (PhysicsWrapperEntity wrapper : manager.physicsEntities) {
                    wrapper.getPhysicsObject().onPostTickClient();
                }
                EntityDraggable.tickAddedVelocityForWorld(mc.world);
            }
        }
    }

}
 
Example #9
Source File: WorldEventsCommon.java    From Valkyrien-Skies with Apache License 2.0 6 votes vote down vote up
@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 #10
Source File: WorldEventsCommon.java    From Valkyrien-Skies with Apache License 2.0 6 votes vote down vote up
@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 #11
Source File: ClientRenderHandler.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
@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 #12
Source File: DebugUtil.java    From EnderZoo with Creative Commons Zero v1.0 Universal 6 votes vote down vote up
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onPlayerTickClient(PlayerTickEvent evt) {
  if (evt.side != Side.CLIENT || evt.phase != Phase.END) {
    return;
  }
  RayTraceResult mo = Minecraft.getMinecraft().objectMouseOver;
  if (mo != null && mo.entityHit != null && mo.entityHit instanceof EntityLivingBase) {
    EntityLivingBase el = (EntityLivingBase) mo.entityHit;
    if (el != lastMouseOver) {
      double baseAttack = 0;
      double attack = 0;
      IAttributeInstance damAtt = el.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.ATTACK_DAMAGE);
      if (damAtt != null) {
        baseAttack = damAtt.getBaseValue();
        attack = damAtt.getAttributeValue();
      }
      System.out.println("DebugUtil.onPlayerTickClient: Health: " + el.getMaxHealth() + " Base Damage: " + baseAttack + " Damage: " + attack);
    }
    lastMouseOver = el;
  } else {
    lastMouseOver = null;
  }

}
 
Example #13
Source File: CCCEventHandler.java    From CodeChickenCore with MIT License 5 votes vote down vote up
@SubscribeEvent
public void clientTick(TickEvent.ClientTickEvent event) {
    if(event.phase == Phase.END) {
        CCUpdateChecker.tick();
        renderTime++;
    }
}
 
Example #14
Source File: ClientRenderHandler.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onRenderTick(TickEvent.RenderTickEvent event)
{

	if(event.phase == Phase.START)
	{
		if(ClientRenderHandler.IsGeneratingFirstIsland)
		{
			Minecraft.getMinecraft().skipRenderWorld = true;
			skipRender = true;
		}
		else
		{
			skipRender = false;
		}
	}
	if(event.phase == Phase.END)
	{
		if(skipRender && ClientRenderHandler.IsGeneratingFirstIsland)
		{
			String gen = Core.translate("gui.generatingmapmessage");
			FontRenderer renderer = Minecraft.getMinecraft().fontRenderer;
			ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
			int sizeX = Minecraft.getMinecraft().displayWidth/2;
			int sizeY = Minecraft.getMinecraft().displayHeight/2;

			renderer.drawString(gen, sizeX/2 - (renderer.getStringWidth(gen) / 2)+1, sizeY/2+1, Color.black.getRGB());
			renderer.drawString(gen, sizeX/2 - (renderer.getStringWidth(gen) / 2), sizeY/2, Color.white.getRGB());
			Minecraft.getMinecraft().skipRenderWorld = false;
			skipRender = false;
		}
	}
}
 
Example #15
Source File: DebugUtil.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
@SubscribeEvent
public void onPlayerTick(PlayerTickEvent evt) {
  if (evt.side != Side.SERVER || evt.phase != Phase.START) {
    return;
  }
  evt.player.setHealth(evt.player.getMaxHealth());
}
 
Example #16
Source File: DelayedActionTickHandler.java    From OpenModsLib with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onWorldTick(WorldTickEvent evt) {
	if (evt.side == Side.SERVER && evt.phase == Phase.END) {
		int worldId = evt.world.provider.getDimension();
		Queue<Runnable> callbacks = getWorldQueue(worldId);

		Runnable callback;
		while ((callback = callbacks.poll()) != null) {
			callback.run();
		}
	}
}
 
Example #17
Source File: ClientHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@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 #18
Source File: WEventFactory.java    From ForgeWurst with GNU General Public License v3.0 5 votes vote down vote up
@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 #19
Source File: CableTickHandler.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@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 #20
Source File: ClientHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@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 #21
Source File: ServerHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@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 #22
Source File: EventHandler.java    From Signals with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onPostServerTick(ServerTickEvent event){
    if(event.phase == Phase.END) {
        RailNetworkManager.getServerInstance().onPostServerTick();
        ChunkLoadManager.INSTANCE.update();
    }
}
 
Example #23
Source File: WEventFactory.java    From ForgeWurst with GNU General Public License v3.0 5 votes vote down vote up
@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 #24
Source File: ObservationFromSystemImplementation.java    From malmo with MIT License 5 votes vote down vote up
@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: EssentialsMissingHandler.java    From Cyberware with MIT License 5 votes vote down vote up
@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 #26
Source File: HumanLevelCommandsImplementation.java    From malmo with MIT License 5 votes vote down vote up
/** 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 #27
Source File: HumanLevelCommandsImplementation.java    From malmo with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onClientTick(ClientTickEvent ev)
{
    if (ev.phase == Phase.START)
    {
        // Track average client ticks per second:
        this.clientTickMonitor.beat();
    }
}
 
Example #28
Source File: CommandForWheeledRobotNavigationImplementation.java    From malmo with MIT License 5 votes vote down vote up
/** 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 #29
Source File: MalmoModServer.java    From malmo with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onServerTick(TickEvent.ServerTickEvent ev)
{
    if (ev.side == Side.SERVER && ev.phase == Phase.START)
    {
        this.serverTickMonitor.beat();
    }
}
 
Example #30
Source File: VideoHook.java    From malmo with MIT License 5 votes vote down vote up
/**
 * Called before and after the rendering of the world.
 * 
 * @param event
 *            Contains information about the event.
 */
@SubscribeEvent
public void onRender(RenderTickEvent event)
{
    if( event.phase == Phase.START )
    {
        // this is here in case the user has resized the window during a mission
        resizeIfNeeded();
    }
}