@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); }
@Override public <T> void bindEntity(T object) { if(object instanceof EntityPlayerSP) { player = (EntityPlayerSP) object; sensor.bindEntity(player); playerMovementInput = new MovementInputFromOptions(Minecraft.getMinecraft().gameSettings) { @Override public void updatePlayerMoveState() { maintainMovementControl(); } }; player.movementInput = playerMovementInput; isBinded = true; } }
@SideOnly(Side.CLIENT) @Hook("net.minecraft.util.MovementInputFromOptions#func_78898_a") public static Hook.Result updatePlayerMoveState(MovementInputFromOptions input) { if (projectionState && Minecraft.getMinecraft().player.movementInput == input) { input.moveForward = 0; input.moveStrafe = 0; input.backKeyDown = false; input.forwardKeyDown = false; input.leftKeyDown = false; input.rightKeyDown = false; input.jump = false; input.sneak = false; return Hook.Result.NULL; } return Hook.Result.VOID; }
public void setDimensionAndSpawnPlayer(int dimension) { this.theWorld.setInitialSpawnLocation(); this.theWorld.removeAllEntities(); int i = 0; String s = null; if (this.thePlayer != null) { i = this.thePlayer.getEntityId(); this.theWorld.removeEntity(this.thePlayer); s = this.thePlayer.getClientBrand(); } this.renderViewEntity = null; EntityPlayerSP entityplayersp = this.thePlayer; this.thePlayer = this.playerController.func_178892_a(this.theWorld, this.thePlayer == null ? new StatFileWriter() : this.thePlayer.getStatFileWriter()); this.thePlayer.getDataWatcher().updateWatchedObjectsFromList(entityplayersp.getDataWatcher().getAllWatched()); this.thePlayer.dimension = dimension; this.renderViewEntity = this.thePlayer; this.thePlayer.preparePlayerToSpawn(); this.thePlayer.setClientBrand(s); this.theWorld.spawnEntityInWorld(this.thePlayer); this.playerController.flipPlayer(this.thePlayer); this.thePlayer.movementInput = new MovementInputFromOptions(this.gameSettings); this.thePlayer.setEntityId(i); this.playerController.setPlayerCapabilities(this.thePlayer); this.thePlayer.setReducedDebug(entityplayersp.hasReducedDebug()); if (this.currentScreen instanceof GuiGameOver) { this.displayGuiScreen((GuiScreen)null); } }
public void setDimensionAndSpawnPlayer(int dimension) { this.theWorld.setInitialSpawnLocation(); this.theWorld.removeAllEntities(); int i = 0; String s = null; if (this.thePlayer != null) { i = this.thePlayer.getEntityId(); this.theWorld.removeEntity(this.thePlayer); s = this.thePlayer.getClientBrand(); } this.renderViewEntity = null; EntityPlayerSP entityplayersp = this.thePlayer; this.thePlayer = this.playerController.func_178892_a(this.theWorld, this.thePlayer == null ? new StatFileWriter() : this.thePlayer.getStatFileWriter()); this.thePlayer.getDataWatcher().updateWatchedObjectsFromList(entityplayersp.getDataWatcher().getAllWatched()); this.thePlayer.dimension = dimension; this.renderViewEntity = this.thePlayer; this.thePlayer.preparePlayerToSpawn(); this.thePlayer.setClientBrand(s); this.theWorld.spawnEntityInWorld(this.thePlayer); this.playerController.flipPlayer(this.thePlayer); this.thePlayer.movementInput = new MovementInputFromOptions(this.gameSettings); this.thePlayer.setEntityId(i); this.playerController.setPlayerCapabilities(this.thePlayer); this.thePlayer.setReducedDebug(entityplayersp.hasReducedDebug()); if (this.currentScreen instanceof GuiGameOver) { this.displayGuiScreen((GuiScreen) null); } }
public void setDimensionAndSpawnPlayer(int dimension) { this.world.setInitialSpawnLocation(); this.world.removeAllEntities(); int i = 0; String s = null; if (this.player != null) { i = this.player.getEntityId(); this.world.removeEntity(this.player); s = this.player.getServerBrand(); } this.renderViewEntity = null; EntityPlayerSP entityplayersp = this.player; this.player = this.playerController.createClientPlayer(this.world, this.player == null ? new StatisticsManager() : this.player.getStatFileWriter()); this.player.getDataManager().setEntryValues(entityplayersp.getDataManager().getAll()); this.player.dimension = dimension; this.renderViewEntity = this.player; this.player.preparePlayerToSpawn(); this.player.setServerBrand(s); this.world.spawnEntityInWorld(this.player); this.playerController.flipPlayer(this.player); this.player.movementInput = new MovementInputFromOptions(this.gameSettings); this.player.setEntityId(i); this.playerController.setPlayerCapabilities(this.player); this.player.setReducedDebug(entityplayersp.hasReducedDebug()); if (this.currentScreen instanceof GuiGameOver) { this.displayGuiScreen((GuiScreen)null); } }
public void setDimensionAndSpawnPlayer(int dimension) { this.theWorld.setInitialSpawnLocation(); this.theWorld.removeAllEntities(); int i = 0; String s = null; if (this.thePlayer != null) { i = this.thePlayer.getEntityId(); this.theWorld.removeEntity(this.thePlayer); s = this.thePlayer.getServerBrand(); } this.renderViewEntity = null; EntityPlayerSP entityplayersp = this.thePlayer; this.thePlayer = this.playerController.createClientPlayer(this.theWorld, this.thePlayer == null ? new StatisticsManager() : this.thePlayer.getStatFileWriter()); this.thePlayer.getDataManager().setEntryValues(entityplayersp.getDataManager().getAll()); this.thePlayer.dimension = dimension; this.renderViewEntity = this.thePlayer; this.thePlayer.preparePlayerToSpawn(); this.thePlayer.setServerBrand(s); this.theWorld.spawnEntityInWorld(this.thePlayer); this.playerController.flipPlayer(this.thePlayer); this.thePlayer.movementInput = new MovementInputFromOptions(this.gameSettings); this.thePlayer.setEntityId(i); this.playerController.setPlayerCapabilities(this.thePlayer); this.thePlayer.setReducedDebug(entityplayersp.hasReducedDebug()); if (this.currentScreen instanceof GuiGameOver) { this.displayGuiScreen((GuiScreen)null); } }
public void deactivate() { this.active = false; GuiScreen gs = Minecraft.getMinecraft().currentScreen; if (gs != null) { LabelButtonInfo.remove(gs); if (gs instanceof GuiMainMenu) { Minecraft.getMinecraft().displayGuiScreen(new GuiMainMenu()); } } if(Minecraft.getMinecraft().player != null) { Minecraft.getMinecraft().player.movementInput = new MovementInputFromOptions(Minecraft.getMinecraft().gameSettings); } Minecraft.getMinecraft().mouseHelper = new MouseHelper(); Minecraft.getMinecraft().gameSettings.realmsNotifications = true; }
@Override public void unbindEntity() { player.movementInput = new MovementInputFromOptions(Minecraft.getMinecraft().gameSettings); Minecraft.getMinecraft().gameSettings.keyBindAttack = hitKey.originalKeyBinding; Minecraft.getMinecraft().gameSettings.keyBindUseItem = useItemKey.originalKeyBinding; controlsTaken = false; setDefaults(); super.unbindEntity(); }
public void setDimensionAndSpawnPlayer(int par1) { this.theWorld.setSpawnLocation(); this.theWorld.removeAllEntities(); int var2 = 0; String var3 = null; if (this.thePlayer != null) { var2 = this.thePlayer.getEntityId(); this.theWorld.removeEntity(this.thePlayer); var3 = this.thePlayer.func_142021_k(); } this.renderViewEntity = null; this.thePlayer = this.playerController.func_147493_a(this.theWorld, this.thePlayer == null ? new StatFileWriter() : this.thePlayer.func_146107_m()); this.thePlayer.dimension = par1; this.renderViewEntity = this.thePlayer; this.thePlayer.preparePlayerToSpawn(); this.thePlayer.func_142020_c(var3); this.theWorld.spawnEntityInWorld(this.thePlayer); this.playerController.flipPlayer(this.thePlayer); this.thePlayer.movementInput = new MovementInputFromOptions(this.gameSettings); this.thePlayer.setEntityId(var2); this.playerController.setPlayerCapabilities(this.thePlayer); if (this.currentScreen instanceof GuiGameOver) { this.displayGuiScreen((GuiScreen)null); } }
@EventHandler public void deactivate(FMLModDisabledEvent event) { // this class instance is already unregistered from the event bus by Forge itself if (displayStatus() > 0) MinecraftForge.EVENT_BUS.unregister(guiDrawer); if (mc.thePlayer != null) mc.thePlayer.movementInput = new MovementInputFromOptions(mc.gameSettings); }
public void setDimensionAndSpawnPlayer(int p_71354_1_) { this.theWorld.setSpawnLocation(); this.theWorld.removeAllEntities(); int j = 0; String s = null; if (this.thePlayer != null) { j = this.thePlayer.getEntityId(); this.theWorld.removeEntity(this.thePlayer); s = this.thePlayer.func_142021_k(); } this.renderViewEntity = null; this.thePlayer = this.playerController.func_147493_a(this.theWorld, this.thePlayer == null ? new StatFileWriter() : this.thePlayer.getStatFileWriter()); this.thePlayer.dimension = p_71354_1_; this.renderViewEntity = this.thePlayer; this.thePlayer.preparePlayerToSpawn(); this.thePlayer.func_142020_c(s); this.theWorld.spawnEntityInWorld(this.thePlayer); this.playerController.flipPlayer(this.thePlayer); this.thePlayer.movementInput = new MovementInputFromOptions(this.gameSettings); this.thePlayer.setEntityId(j); this.playerController.setPlayerCapabilities(this.thePlayer); if (this.currentScreen instanceof GuiGameOver) { this.displayGuiScreen((GuiScreen)null); } }
public void func_71354_a(int p_71354_1_) { this.field_71441_e.func_72974_f(); this.field_71441_e.func_73022_a(); int var2 = 0; String var3 = null; if(this.field_71439_g != null) { var2 = this.field_71439_g.field_70157_k; this.field_71441_e.func_72900_e(this.field_71439_g); var3 = this.field_71439_g.func_142021_k(); } this.field_71451_h = null; this.field_71439_g = this.field_71442_b.func_78754_a(this.field_71441_e); this.field_71439_g.field_71093_bK = p_71354_1_; this.field_71451_h = this.field_71439_g; this.field_71439_g.func_70065_x(); this.field_71439_g.func_142020_c(var3); this.field_71441_e.func_72838_d(this.field_71439_g); this.field_71442_b.func_78745_b(this.field_71439_g); this.field_71439_g.field_71158_b = new MovementInputFromOptions(this.field_71474_y); this.field_71439_g.field_70157_k = var2; this.field_71442_b.func_78748_a(this.field_71439_g); if(this.field_71462_r instanceof GuiGameOver) { this.func_71373_a((GuiScreen)null); } }
public void setDimensionAndSpawnPlayer(int par1) { this.theWorld.setSpawnLocation(); this.theWorld.removeAllEntities(); int j = 0; String s = null; if (this.thePlayer != null) { j = this.thePlayer.entityId; this.theWorld.removeEntity(this.thePlayer); s = this.thePlayer.func_142021_k(); } this.renderViewEntity = null; this.thePlayer = this.playerController.func_78754_a(this.theWorld); this.thePlayer.dimension = par1; this.renderViewEntity = this.thePlayer; this.thePlayer.preparePlayerToSpawn(); this.thePlayer.func_142020_c(s); this.theWorld.spawnEntityInWorld(this.thePlayer); this.playerController.flipPlayer(this.thePlayer); this.thePlayer.movementInput = new MovementInputFromOptions(this.gameSettings); this.thePlayer.entityId = j; this.playerController.setPlayerCapabilities(this.thePlayer); if (this.currentScreen instanceof GuiGameOver) { this.displayGuiScreen((GuiScreen)null); } }
/** * par2Str is displayed on the loading screen to the user unloads the current world first */ public void loadWorld(WorldClient worldClientIn, String loadingMessage) { if (worldClientIn == null) { NetHandlerPlayClient nethandlerplayclient = this.getNetHandler(); if (nethandlerplayclient != null) { nethandlerplayclient.cleanup(); } if (this.theIntegratedServer != null && this.theIntegratedServer.isAnvilFileSet()) { this.theIntegratedServer.initiateShutdown(); this.theIntegratedServer.setStaticInstance(); } this.theIntegratedServer = null; this.guiAchievement.clearAchievements(); this.entityRenderer.getMapItemRenderer().clearLoadedMaps(); } this.renderViewEntity = null; this.myNetworkManager = null; if (this.loadingScreen != null) { this.loadingScreen.resetProgressAndMessage(loadingMessage); this.loadingScreen.displayLoadingString(""); } if (worldClientIn == null && this.theWorld != null) { this.mcResourcePackRepository.func_148529_f(); this.ingameGUI.func_181029_i(); this.setServerData((ServerData)null); this.integratedServerIsRunning = false; } this.mcSoundHandler.stopSounds(); this.theWorld = worldClientIn; if (worldClientIn != null) { if (this.renderGlobal != null) { this.renderGlobal.setWorldAndLoadRenderers(worldClientIn); } if (this.effectRenderer != null) { this.effectRenderer.clearEffects(worldClientIn); } if (this.thePlayer == null) { this.thePlayer = this.playerController.func_178892_a(worldClientIn, new StatFileWriter()); this.playerController.flipPlayer(this.thePlayer); } this.thePlayer.preparePlayerToSpawn(); worldClientIn.spawnEntityInWorld(this.thePlayer); this.thePlayer.movementInput = new MovementInputFromOptions(this.gameSettings); this.playerController.setPlayerCapabilities(this.thePlayer); this.renderViewEntity = this.thePlayer; } else { this.saveLoader.flushCache(); this.thePlayer = null; } System.gc(); this.systemTime = 0L; }
/** * par2Str is displayed on the loading screen to the user unloads the current * world first */ public void loadWorld(WorldClient worldClientIn, String loadingMessage) { if (worldClientIn == null) { NetHandlerPlayClient nethandlerplayclient = this.getNetHandler(); if (nethandlerplayclient != null) { nethandlerplayclient.cleanup(); } if (this.theIntegratedServer != null && this.theIntegratedServer.isAnvilFileSet()) { this.theIntegratedServer.initiateShutdown(); this.theIntegratedServer.setStaticInstance(); } this.theIntegratedServer = null; this.guiAchievement.clearAchievements(); this.entityRenderer.getMapItemRenderer().clearLoadedMaps(); } this.renderViewEntity = null; this.myNetworkManager = null; if (this.loadingScreen != null) { this.loadingScreen.resetProgressAndMessage(loadingMessage); this.loadingScreen.displayLoadingString(""); } if (worldClientIn == null && this.theWorld != null) { this.mcResourcePackRepository.func_148529_f(); this.ingameGUI.func_181029_i(); this.setServerData((ServerData) null); this.integratedServerIsRunning = false; } this.mcSoundHandler.stopSounds(); this.theWorld = worldClientIn; if (worldClientIn != null) { if (this.renderGlobal != null) { this.renderGlobal.setWorldAndLoadRenderers(worldClientIn); } if (this.effectRenderer != null) { this.effectRenderer.clearEffects(worldClientIn); } if (this.thePlayer == null) { this.thePlayer = this.playerController.func_178892_a(worldClientIn, new StatFileWriter()); this.playerController.flipPlayer(this.thePlayer); } this.thePlayer.preparePlayerToSpawn(); worldClientIn.spawnEntityInWorld(this.thePlayer); this.thePlayer.movementInput = new MovementInputFromOptions(this.gameSettings); this.playerController.setPlayerCapabilities(this.thePlayer); this.renderViewEntity = this.thePlayer; } else { this.saveLoader.flushCache(); this.thePlayer = null; } System.gc(); this.systemTime = 0L; }
private void UpdateStatus(MovementInputFromOptions options, EntityPlayerSP thisPlayer, GameSettings settings) { if(ToggleSneakMod.optionShowHUDText) { String output = ""; boolean isFlying = thisPlayer.capabilities.isFlying; boolean isRiding = thisPlayer.isRiding(); boolean isHoldingSneak = settings.keyBindSneak.isKeyDown(); boolean isHoldingSprint = settings.keyBindSprint.isKeyDown(); if(isFlying) { DecimalFormat numFormat = new DecimalFormat("#.00"); if (ToggleSneakMod.optionEnableFlyBoost && isHoldingSprint) output += "[Flying (" + numFormat.format(ToggleSneakMod.optionFlyBoostAmount) + "x boost)] "; else output += "[Flying] "; } if(isRiding) output += "[Riding] "; if (options.sneak) { if(isFlying) output += "[Descending] "; else if(isRiding) output += "[Dismounting] "; else if(isHoldingSneak) output += "[Sneaking (Key Held)] "; else output += "[Sneaking (Toggled)] "; } else if (this.sprint) { if(!isFlying && !isRiding) { // Detect Vanilla conditions - ToggleSprint disabled, DoubleTapped and Hold & Release boolean isVanilla = this.sprintHeldAndReleased || isDisabled || this.sprintDoubleTapped; if(isHoldingSprint) output += "[Sprinting (Key Held)]"; else if(isVanilla) output += "[Sprinting (Vanilla)]"; else output += "[Sprinting (Toggled)]"; } } RenderTextToHUD.SetHUDText(output); } }
/** * par2Str is displayed on the loading screen to the user unloads the current world first */ public void loadWorld(WorldClient par1WorldClient, String par2Str) { if (par1WorldClient == null) { NetHandlerPlayClient var3 = this.getNetHandler(); if (var3 != null) { var3.cleanup(); } if (this.theIntegratedServer != null) { this.theIntegratedServer.initiateShutdown(); } this.theIntegratedServer = null; this.guiAchievement.func_146257_b(); this.entityRenderer.getMapItemRenderer().func_148249_a(); } this.renderViewEntity = null; this.myNetworkManager = null; if (this.loadingScreen != null) { this.loadingScreen.resetProgressAndMessage(par2Str); this.loadingScreen.resetProgresAndWorkingMessage(""); } if (par1WorldClient == null && this.theWorld != null) { if (this.mcResourcePackRepository.func_148530_e() != null) { this.scheduleResourcesRefresh(); } this.mcResourcePackRepository.func_148529_f(); this.setServerData((ServerData)null); this.integratedServerIsRunning = false; } this.mcSoundHandler.func_147690_c(); this.theWorld = par1WorldClient; if (par1WorldClient != null) { if (this.renderGlobal != null) { this.renderGlobal.setWorldAndLoadRenderers(par1WorldClient); } if (this.effectRenderer != null) { this.effectRenderer.clearEffects(par1WorldClient); } if (this.thePlayer == null) { this.thePlayer = this.playerController.func_147493_a(par1WorldClient, new StatFileWriter()); this.playerController.flipPlayer(this.thePlayer); } this.thePlayer.preparePlayerToSpawn(); par1WorldClient.spawnEntityInWorld(this.thePlayer); this.thePlayer.movementInput = new MovementInputFromOptions(this.gameSettings); this.playerController.setPlayerCapabilities(this.thePlayer); this.renderViewEntity = this.thePlayer; } else { this.saveLoader.flushCache(); this.thePlayer = null; } System.gc(); this.systemTime = 0L; }
public void func_71353_a(WorldClient p_71353_1_, String p_71353_2_) { this.field_71413_E.func_77446_d(); if(p_71353_1_ == null) { NetClientHandler var3 = this.func_71391_r(); if(var3 != null) { var3.func_72547_c(); } if(this.field_71453_ak != null) { this.field_71453_ak.func_74431_f(); } if(this.field_71437_Z != null) { this.field_71437_Z.func_71263_m(); } this.field_71437_Z = null; } this.field_71451_h = null; this.field_71453_ak = null; if(this.field_71461_s != null) { this.field_71461_s.func_73721_b(p_71353_2_); this.field_71461_s.func_73719_c(""); } if(p_71353_1_ == null && this.field_71441_e != null) { this.func_71351_a((ServerData)null); this.field_71455_al = false; } this.field_71416_A.func_77368_a((String)null, 0.0F, 0.0F, 0.0F); this.field_71416_A.func_82464_d(); this.field_71441_e = p_71353_1_; if(p_71353_1_ != null) { if(this.field_71438_f != null) { this.field_71438_f.func_72732_a(p_71353_1_); } if(this.field_71452_i != null) { this.field_71452_i.func_78870_a(p_71353_1_); } if(this.field_71439_g == null) { this.field_71439_g = this.field_71442_b.func_78754_a(p_71353_1_); this.field_71442_b.func_78745_b(this.field_71439_g); } this.field_71439_g.func_70065_x(); p_71353_1_.func_72838_d(this.field_71439_g); this.field_71439_g.field_71158_b = new MovementInputFromOptions(this.field_71474_y); this.field_71442_b.func_78748_a(this.field_71439_g); this.field_71451_h = this.field_71439_g; } else { this.field_71469_aa.func_75800_d(); this.field_71439_g = null; } System.gc(); this.field_71423_H = 0L; }