cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent Java Examples
The following examples show how to use
cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent.
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: AdvancedModEventHandler.java From AdvancedMod with GNU General Public License v3.0 | 5 votes |
/** * Using the PlayerTickEvent. Note that this is from cpw.mods.fml.common.gameevent, so to make this method be called, this class needs to be registered at FMLCommonHandler.instance().bus().register(new AdvancedModEventHandler()). * @param event */ @SubscribeEvent public void onPlayerTick(PlayerTickEvent event){ if(event.side == Side.SERVER && event.phase == TickEvent.Phase.END) { List<Entity> entities = event.player.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(event.player.posX - 3, event.player.posY - 3, event.player.posZ - 3, event.player.posX + 3, event.player.posY + 3, event.player.posZ + 3)); for(Entity entity : entities) { if(entity != event.player) { //entity.setVelocity(0, 1, 0); //This will crash when run on a dedicated server, because Entity#setVelocity is marked with @SideOnly(Side.CLIENT), and therefore stripped from a dedicated server instance. entity.motionX = 0;//The solution is to do this. entity.motionY = 1; entity.motionZ = 0; } } } }
Example #2
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 #3
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); } } }