@Override public Entity changeDimension(int dimensionIn) { if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, dimensionIn)) { return this; } ObfuscationReflectionHelper.setPrivateValue(EntityPlayerMP.class, this, true, "invulnerableDimensionChange", "field_184851_cj"); if (dimension == 1 && dimensionIn == 1) { world.removeEntity(this); if (!queuedEndExit) { queuedEndExit = true; connection.sendPacket(new SPacketChangeGameState(4, 0.0F)); } return this; } else { if (dimension == 0 && dimensionIn == 1) { dimensionIn = 1; } mcServer.getPlayerList().changePlayerDimension(this, dimensionIn); return this; } }
@SubscribeEvent public void onPacketIncoming(PacketEvent.Incoming.Pre event) { if(event.getPacket() instanceof SPacketChangeGameState) { int state = ((SPacketChangeGameState) event.getPacket()).getGameState(); float strength = ((SPacketChangeGameState) event.getPacket()).getValue(); boolean isRainState = false; switch (state) { case 1: isRainState = true; setState(true, 0.f, 0.f); break; case 2: isRainState = true; setState(false, 1.f, 1.f); break; case 7: isRainState = true; setState(strength, strength); break; } if(isRainState) { disableRain(); event.setCanceled(true); } } }
/** * Sets the player's game mode and sends it to them. */ public void setGameType(GameType gameType) { this.interactionManager.setGameType(gameType); this.connection.sendPacket(new SPacketChangeGameState(3, (float)gameType.getID())); if (gameType == GameType.SPECTATOR) { this.dismountRidingEntity(); } else { this.setSpectatingEntity(this); } this.sendPlayerAbilities(); this.markPotionsDirty(); }
/** * Updates the time and weather for the given player to those of the given world */ public void updateTimeAndWeatherForPlayer(EntityPlayerMP playerIn, WorldServer worldIn) { WorldBorder worldborder = this.mcServer.worldServers[0].getWorldBorder(); playerIn.connection.sendPacket(new SPacketWorldBorder(worldborder, SPacketWorldBorder.Action.INITIALIZE)); playerIn.connection.sendPacket(new SPacketTimeUpdate(worldIn.getTotalWorldTime(), worldIn.getWorldTime(), worldIn.getGameRules().getBoolean("doDaylightCycle"))); BlockPos blockpos = worldIn.getSpawnPoint(); playerIn.connection.sendPacket(new SPacketSpawnPosition(blockpos)); if (worldIn.isRaining()) { playerIn.connection.sendPacket(new SPacketChangeGameState(1, 0.0F)); playerIn.connection.sendPacket(new SPacketChangeGameState(7, worldIn.getRainStrength(1.0F))); playerIn.connection.sendPacket(new SPacketChangeGameState(8, worldIn.getThunderStrength(1.0F))); } }
@Override protected void onImpact(RayTraceResult result) { if (result.typeOfHit == Type.ENTITY && result.entityHit != this.getThrower()) { result.entityHit.attackEntityFrom(DamageSource.causeIndirectDamage(this, this.getThrower()), 5); result.entityHit.addVelocity(this.motionX, 0.6D, this.motionZ); if (this.getThrower() != null && result.entityHit != this.getThrower() && result.entityHit instanceof EntityPlayer && this.getThrower() instanceof EntityPlayerMP) { ((EntityPlayerMP)this.getThrower()).connection.sendPacket(new SPacketChangeGameState(6, 0.0F)); } } for(int j = 0; j < 8; j++) { this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_NORMAL, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_NORMAL, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); this.worldObj.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); this.worldObj.spawnParticle(EnumParticleTypes.SMOKE_LARGE, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); this.worldObj.spawnParticle(EnumParticleTypes.FLAME, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); } this.setDead(); }
@Override protected void onImpact(RayTraceResult result) { if (result.typeOfHit == RayTraceResult.Type.ENTITY) { EntityLivingBase thrower = getThrower(); // prevent damaging thrower if (result.entityHit == thrower) return; Entity entity = result.entityHit; DamageSource ds = createDamageSource(null == thrower ? this : thrower); if (isBurning() && !(entity instanceof EntityEnderman)) entity.setFire(5); if (entity.attackEntityFrom(ds, getDamage())) { if (entity instanceof EntityLivingBase) { EntityLivingBase base = (EntityLivingBase) entity; if (knockbackStrength > 0) { float f1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); if (f1 > 0f) { base.addVelocity(motionX * knockbackStrength * 0.6000000238418579D / f1, 0.1D, motionZ * knockbackStrength * 0.6000000238418579D / f1); } } if (null != thrower) { EnchantmentHelper.applyThornEnchantments(base, thrower); EnchantmentHelper.applyArthropodEnchantments(thrower, base); if (base != thrower && base instanceof EntityPlayer && thrower instanceof EntityPlayerMP) { ((EntityPlayerMP)thrower).connection.sendPacket(new SPacketChangeGameState(6, 0.0F)); } } } } } if (!worldObj.isRemote) setDead(); }
/** * Updates all weather states. */ protected void updateWeather() { boolean flag = this.isRaining(); super.updateWeather(); if (this.prevRainingStrength != this.rainingStrength) { this.mcServer.getPlayerList().sendPacketToAllPlayersInDimension(new SPacketChangeGameState(7, this.rainingStrength), this.provider.getDimensionType().getId()); } if (this.prevThunderingStrength != this.thunderingStrength) { this.mcServer.getPlayerList().sendPacketToAllPlayersInDimension(new SPacketChangeGameState(8, this.thunderingStrength), this.provider.getDimensionType().getId()); } if (flag != this.isRaining()) { if (flag) { this.mcServer.getPlayerList().sendPacketToAllPlayers(new SPacketChangeGameState(2, 0.0F)); } else { this.mcServer.getPlayerList().sendPacketToAllPlayers(new SPacketChangeGameState(1, 0.0F)); } this.mcServer.getPlayerList().sendPacketToAllPlayers(new SPacketChangeGameState(7, this.rainingStrength)); this.mcServer.getPlayerList().sendPacketToAllPlayers(new SPacketChangeGameState(8, this.thunderingStrength)); } }
protected void updateAITasks() { super.updateAITasks(); int i = 1200; if ((this.ticksExisted + this.getEntityId()) % 1200 == 0) { Potion potion = MobEffects.MINING_FATIGUE; List<EntityPlayerMP> list = this.world.<EntityPlayerMP>getPlayers(EntityPlayerMP.class, new Predicate<EntityPlayerMP>() { public boolean apply(@Nullable EntityPlayerMP p_apply_1_) { return EntityElderGuardian.this.getDistanceSqToEntity(p_apply_1_) < 2500.0D && p_apply_1_.interactionManager.survivalOrAdventure(); } }); int j = 2; int k = 6000; int l = 1200; for (EntityPlayerMP entityplayermp : list) { if (!entityplayermp.isPotionActive(potion) || entityplayermp.getActivePotionEffect(potion).getAmplifier() < 2 || entityplayermp.getActivePotionEffect(potion).getDuration() < 1200) { entityplayermp.connection.sendPacket(new SPacketChangeGameState(10, 0.0F)); entityplayermp.addPotionEffect(new PotionEffect(potion, 6000, 2)); } } } if (!this.hasHome()) { this.setHomePosAndDistance(new BlockPos(this), 16); } }
private void fixWorldWeather() { if (this.worldInfo.isRaining() || this.worldInfo.isThundering()) { this.worldInfo.setRainTime(0); this.worldInfo.setRaining(false); this.setRainStrength(0.0F); this.worldInfo.setThunderTime(0); this.worldInfo.setThundering(false); this.setThunderStrength(0.0F); this.mcServer.getPlayerList().sendPacketToAllPlayers(new SPacketChangeGameState(2, 0.0F)); this.mcServer.getPlayerList().sendPacketToAllPlayers(new SPacketChangeGameState(7, 0.0F)); this.mcServer.getPlayerList().sendPacketToAllPlayers(new SPacketChangeGameState(8, 0.0F)); } }
/** * Updates all weather states. */ protected void updateWeather() { boolean flag = this.isRaining(); super.updateWeather(); if (this.prevRainingStrength != this.rainingStrength) { this.mcServer.getPlayerList().sendPacketToAllPlayersInDimension(new SPacketChangeGameState(7, this.rainingStrength), this.provider.getDimension()); } if (this.prevThunderingStrength != this.thunderingStrength) { this.mcServer.getPlayerList().sendPacketToAllPlayersInDimension(new SPacketChangeGameState(8, this.thunderingStrength), this.provider.getDimension()); } /* The function in use here has been replaced in order to only send the weather info to players in the correct dimension, * rather than to all players on the server. This is what causes the client-side rain, as the * client believes that it has started raining locally, rather than in another dimension. */ if (flag != this.isRaining()) { if (flag) { this.mcServer.getPlayerList().sendPacketToAllPlayersInDimension(new SPacketChangeGameState(2, 0.0F), this.provider.getDimension()); } else { this.mcServer.getPlayerList().sendPacketToAllPlayersInDimension(new SPacketChangeGameState(1, 0.0F), this.provider.getDimension()); } this.mcServer.getPlayerList().sendPacketToAllPlayersInDimension(new SPacketChangeGameState(7, this.rainingStrength), this.provider.getDimension()); this.mcServer.getPlayerList().sendPacketToAllPlayersInDimension(new SPacketChangeGameState(8, this.thunderingStrength), this.provider.getDimension()); } }
protected void updateAITasks() { super.updateAITasks(); if (this.isElder()) { int i = 1200; int j = 1200; int k = 6000; int l = 2; if ((this.ticksExisted + this.getEntityId()) % 1200 == 0) { Potion potion = MobEffects.MINING_FATIGUE; for (EntityPlayerMP entityplayermp : this.worldObj.getPlayers(EntityPlayerMP.class, new Predicate<EntityPlayerMP>() { public boolean apply(@Nullable EntityPlayerMP p_apply_1_) { return EntityGuardian.this.getDistanceSqToEntity(p_apply_1_) < 2500.0D && p_apply_1_.interactionManager.survivalOrAdventure(); } })) { if (!entityplayermp.isPotionActive(potion) || entityplayermp.getActivePotionEffect(potion).getAmplifier() < 2 || entityplayermp.getActivePotionEffect(potion).getDuration() < 1200) { entityplayermp.connection.sendPacket(new SPacketChangeGameState(10, 0.0F)); entityplayermp.addPotionEffect(new PotionEffect(potion, 6000, 2)); } } } if (!this.hasHome()) { this.setHomePosAndDistance(new BlockPos(this), 16); } } }
/** * Updates the time and weather for the given player to those of the given world */ public void updateTimeAndWeatherForPlayer(EntityPlayerMP playerIn, WorldServer worldIn) { WorldBorder worldborder = this.mcServer.worldServers[0].getWorldBorder(); playerIn.connection.sendPacket(new SPacketWorldBorder(worldborder, SPacketWorldBorder.Action.INITIALIZE)); playerIn.connection.sendPacket(new SPacketTimeUpdate(worldIn.getTotalWorldTime(), worldIn.getWorldTime(), worldIn.getGameRules().getBoolean("doDaylightCycle"))); if (worldIn.isRaining()) { playerIn.connection.sendPacket(new SPacketChangeGameState(1, 0.0F)); playerIn.connection.sendPacket(new SPacketChangeGameState(7, worldIn.getRainStrength(1.0F))); playerIn.connection.sendPacket(new SPacketChangeGameState(8, worldIn.getThunderStrength(1.0F))); } }
protected void onRangedImpact(RayTraceResult result) { result.entityHit.attackEntityFrom(DamageSource.causeIndirectDamage(this, this.getThrower()), 5); result.entityHit.addVelocity(this.motionX, 0.6D, this.motionZ); if (this.getThrower() != null && result.entityHit != this.getThrower() && result.entityHit instanceof EntityPlayer && this.getThrower() instanceof EntityPlayerMP) { ((EntityPlayerMP)this.getThrower()).connection.sendPacket(new SPacketChangeGameState(6, 0.0F)); } }
public void applyEntityHitEffects(Entity entityHit) { if (isBurning() && !(entityHit instanceof EntityEnderman)) { entityHit.setFire(5); } if (entityHit instanceof EntityLivingBase) { EntityLivingBase entityliving = (EntityLivingBase) entityHit; if (this.knockbackStrength > 0) { float f1 = MathHelper.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); if (f1 > 0.0F) { entityliving.addVelocity( this.motionX * (double) this.knockbackStrength * 0.6000000238418579D / (double) f1, 0.1D, this.motionZ * (double) this.knockbackStrength * 0.6000000238418579D / (double) f1); } } if (this.shootingEntity instanceof EntityLivingBase) { EnchantmentHelper.applyThornEnchantments(entityliving, this.shootingEntity); EnchantmentHelper.applyArthropodEnchantments((EntityLivingBase) this.shootingEntity, entityliving); } this.arrowHit(entityliving); if (this.shootingEntity != null && entityliving != this.shootingEntity && entityliving instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP) { ((EntityPlayerMP) this.shootingEntity).connection.sendPacket(new SPacketChangeGameState(6, 0.0F)); } } }
@Override public int executeActivateBehavior(TileEntityTrophy tile, EntityPlayer player) { if (player instanceof EntityPlayerMP) { ((EntityPlayerMP)player).connection.sendPacket(new SPacketChangeGameState(10, 0.0F)); } return 100; }
@Nullable public Entity changeDimension(int dimensionIn) { this.invulnerableDimensionChange = true; if (this.dimension == 1 && dimensionIn == 1) { this.world.removeEntity(this); if (!this.playerConqueredTheEnd) { this.playerConqueredTheEnd = true; if (this.hasAchievement(AchievementList.THE_END2)) { this.connection.sendPacket(new SPacketChangeGameState(4, 0.0F)); } else { this.addStat(AchievementList.THE_END2); this.connection.sendPacket(new SPacketChangeGameState(4, 1.0F)); } } return this; } else { if (this.dimension == 0 && dimensionIn == 1) { this.addStat(AchievementList.THE_END); dimensionIn = 1; } else { this.addStat(AchievementList.PORTAL); } this.mcServer.getPlayerList().changePlayerDimension(this, dimensionIn); this.connection.sendPacket(new SPacketEffect(1032, BlockPos.ORIGIN, 0, false)); this.lastExperience = -1; this.lastHealth = -1.0F; this.lastFoodLevel = -1; return this; } }
public void handleChangeGameState(SPacketChangeGameState packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); EntityPlayer entityplayer = this.gameController.player; int i = packetIn.getGameState(); float f = packetIn.getValue(); int j = MathHelper.floor(f + 0.5F); if (i >= 0 && i < SPacketChangeGameState.MESSAGE_NAMES.length && SPacketChangeGameState.MESSAGE_NAMES[i] != null) { entityplayer.addChatComponentMessage(new TextComponentTranslation(SPacketChangeGameState.MESSAGE_NAMES[i], new Object[0]), false); } if (i == 1) { this.clientWorldController.getWorldInfo().setRaining(true); this.clientWorldController.setRainStrength(0.0F); } else if (i == 2) { this.clientWorldController.getWorldInfo().setRaining(false); this.clientWorldController.setRainStrength(1.0F); } else if (i == 3) { this.gameController.playerController.setGameType(GameType.getByID(j)); } else if (i == 4) { if (j == 0) { this.gameController.player.connection.sendPacket(new CPacketClientStatus(CPacketClientStatus.State.PERFORM_RESPAWN)); this.gameController.displayGuiScreen(new GuiDownloadTerrain(this)); } else if (j == 1) { this.gameController.displayGuiScreen(new GuiWinGame()); } } else if (i == 5) { GameSettings gamesettings = this.gameController.gameSettings; if (f == 0.0F) { this.gameController.displayGuiScreen(new GuiScreenDemo()); } else if (f == 101.0F) { this.gameController.ingameGUI.getChatGUI().printChatMessage(new TextComponentTranslation("demo.help.movement", new Object[] {GameSettings.getKeyDisplayString(gamesettings.keyBindForward.getKeyCode()), GameSettings.getKeyDisplayString(gamesettings.keyBindLeft.getKeyCode()), GameSettings.getKeyDisplayString(gamesettings.keyBindBack.getKeyCode()), GameSettings.getKeyDisplayString(gamesettings.keyBindRight.getKeyCode())})); } else if (f == 102.0F) { this.gameController.ingameGUI.getChatGUI().printChatMessage(new TextComponentTranslation("demo.help.jump", new Object[] {GameSettings.getKeyDisplayString(gamesettings.keyBindJump.getKeyCode())})); } else if (f == 103.0F) { this.gameController.ingameGUI.getChatGUI().printChatMessage(new TextComponentTranslation("demo.help.inventory", new Object[] {GameSettings.getKeyDisplayString(gamesettings.keyBindInventory.getKeyCode())})); } } else if (i == 6) { this.clientWorldController.playSound(entityplayer, entityplayer.posX, entityplayer.posY + (double)entityplayer.getEyeHeight(), entityplayer.posZ, SoundEvents.ENTITY_ARROW_HIT_PLAYER, SoundCategory.PLAYERS, 0.18F, 0.45F); } else if (i == 7) { this.clientWorldController.setRainStrength(f); } else if (i == 8) { this.clientWorldController.setThunderStrength(f); } else if (i == 10) { this.clientWorldController.spawnParticle(EnumParticleTypes.MOB_APPEARANCE, entityplayer.posX, entityplayer.posY, entityplayer.posZ, 0.0D, 0.0D, 0.0D, new int[0]); this.clientWorldController.playSound(entityplayer, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_ELDER_GUARDIAN_CURSE, SoundCategory.HOSTILE, 1.0F, 1.0F); } }
public void updateBlockRemoving() { super.updateBlockRemoving(); ++this.gameModeTicks; long i = this.theWorld.getTotalWorldTime(); long j = i / 24000L + 1L; if (!this.displayedIntro && this.gameModeTicks > 20) { this.displayedIntro = true; this.thisPlayerMP.connection.sendPacket(new SPacketChangeGameState(5, 0.0F)); } this.demoTimeExpired = i > 120500L; if (this.demoTimeExpired) { ++this.demoEndedReminder; } if (i % 24000L == 500L) { if (j <= 6L) { this.thisPlayerMP.addChatMessage(new TextComponentTranslation("demo.day." + j, new Object[0])); } } else if (j == 1L) { if (i == 100L) { this.thisPlayerMP.connection.sendPacket(new SPacketChangeGameState(5, 101.0F)); } else if (i == 175L) { this.thisPlayerMP.connection.sendPacket(new SPacketChangeGameState(5, 102.0F)); } else if (i == 250L) { this.thisPlayerMP.connection.sendPacket(new SPacketChangeGameState(5, 103.0F)); } } else if (j == 5L && i % 24000L == 22000L) { this.thisPlayerMP.addChatMessage(new TextComponentTranslation("demo.day.warning", new Object[0])); } }
@Nullable public Entity changeDimension(int dimensionIn) { if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, dimensionIn)) return this; this.invulnerableDimensionChange = true; if (this.dimension == 1 && dimensionIn == 1) { this.worldObj.removeEntity(this); if (!this.playerConqueredTheEnd) { this.playerConqueredTheEnd = true; if (this.hasAchievement(AchievementList.THE_END2)) { this.connection.sendPacket(new SPacketChangeGameState(4, 0.0F)); } else { this.addStat(AchievementList.THE_END2); this.connection.sendPacket(new SPacketChangeGameState(4, 1.0F)); } } return this; } else { if (this.dimension == 0 && dimensionIn == 1) { this.addStat(AchievementList.THE_END); dimensionIn = 1; } else { this.addStat(AchievementList.PORTAL); } this.mcServer.getPlayerList().changePlayerDimension(this, dimensionIn); this.connection.sendPacket(new SPacketEffect(1032, BlockPos.ORIGIN, 0, false)); this.lastExperience = -1; this.lastHealth = -1.0F; this.lastFoodLevel = -1; return this; } }
public void handleChangeGameState(SPacketChangeGameState packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); EntityPlayer entityplayer = this.gameController.thePlayer; int i = packetIn.getGameState(); float f = packetIn.getValue(); int j = MathHelper.floor_float(f + 0.5F); if (i >= 0 && i < SPacketChangeGameState.MESSAGE_NAMES.length && SPacketChangeGameState.MESSAGE_NAMES[i] != null) { entityplayer.addChatComponentMessage(new TextComponentTranslation(SPacketChangeGameState.MESSAGE_NAMES[i], new Object[0])); } if (i == 1) { this.clientWorldController.getWorldInfo().setRaining(true); this.clientWorldController.setRainStrength(0.0F); } else if (i == 2) { this.clientWorldController.getWorldInfo().setRaining(false); this.clientWorldController.setRainStrength(1.0F); } else if (i == 3) { this.gameController.playerController.setGameType(GameType.getByID(j)); } else if (i == 4) { if (j == 0) { this.gameController.thePlayer.connection.sendPacket(new CPacketClientStatus(CPacketClientStatus.State.PERFORM_RESPAWN)); this.gameController.displayGuiScreen(new GuiDownloadTerrain(this)); } else if (j == 1) { this.gameController.displayGuiScreen(new GuiWinGame()); } } else if (i == 5) { GameSettings gamesettings = this.gameController.gameSettings; if (f == 0.0F) { this.gameController.displayGuiScreen(new GuiScreenDemo()); } else if (f == 101.0F) { this.gameController.ingameGUI.getChatGUI().printChatMessage(new TextComponentTranslation("demo.help.movement", new Object[] {gamesettings.keyBindForward.getDisplayName(), gamesettings.keyBindLeft.getDisplayName(), gamesettings.keyBindBack.getDisplayName(), gamesettings.keyBindRight.getDisplayName()})); } else if (f == 102.0F) { this.gameController.ingameGUI.getChatGUI().printChatMessage(new TextComponentTranslation("demo.help.jump", new Object[] {gamesettings.keyBindJump.getDisplayName()})); } else if (f == 103.0F) { this.gameController.ingameGUI.getChatGUI().printChatMessage(new TextComponentTranslation("demo.help.inventory", new Object[] {gamesettings.keyBindInventory.getDisplayName()})); } } else if (i == 6) { this.clientWorldController.playSound(entityplayer, entityplayer.posX, entityplayer.posY + (double)entityplayer.getEyeHeight(), entityplayer.posZ, SoundEvents.ENTITY_ARROW_HIT_PLAYER, SoundCategory.PLAYERS, 0.18F, 0.45F); } else if (i == 7) { this.clientWorldController.setRainStrength(f); } else if (i == 8) { this.clientWorldController.setThunderStrength(f); } else if (i == 10) { this.clientWorldController.spawnParticle(EnumParticleTypes.MOB_APPEARANCE, entityplayer.posX, entityplayer.posY, entityplayer.posZ, 0.0D, 0.0D, 0.0D, new int[0]); this.clientWorldController.playSound(entityplayer, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_ELDER_GUARDIAN_CURSE, SoundCategory.HOSTILE, 1.0F, 1.0F); } }
@Override public void updateWeather() { if (!hasNoSky()) { if (!world.isRemote && world.provider.getDimension() == 0) { world.getWorldInfo().setRainTime(48000); world.getWorldInfo().setRaining(false); int i = world.getWorldInfo().getCleanWeatherTime(); if (i > 0) { --i; world.getWorldInfo().setCleanWeatherTime(i); world.getWorldInfo().setThunderTime(world.getWorldInfo().isThundering() ? 1 : 2); world.getWorldInfo().setRainTime(world.getWorldInfo().isRaining() ? 1 : 2); } int j = world.getWorldInfo().getThunderTime(); if (j <= 0) { if (world.getWorldInfo().isThundering()) { world.getWorldInfo().setThunderTime(world.rand.nextInt(12000) + 3600); } else { world.getWorldInfo().setThunderTime(world.rand.nextInt(168000) + 12000); } } else { --j; world.getWorldInfo().setThunderTime(j); if (j <= 0) { world.getWorldInfo().setThundering(!world.getWorldInfo().isThundering()); } } world.prevThunderingStrength = world.thunderingStrength; /*if (worldObj.getWorldInfo().isThundering()) { worldObj.thunderingStrength = (float)((double)worldObj.thunderingStrength + 0.01D); } else { worldObj.thunderingStrength = (float)((double)worldObj.thunderingStrength - 0.01D); } worldObj.thunderingStrength = MathHelper.clamp_float(worldObj.thunderingStrength, 0.0F, 1.0F);*/ world.prevRainingStrength = world.rainingStrength; Iterator iterator = world.playerEntities.iterator(); //TODO: Add thunder support while (iterator.hasNext()) { EntityPlayerMP player = (EntityPlayerMP) iterator.next(); if(!player.isDead && player.dimension == 0) { float old = player.getEntityData().getFloat("oldPrecipitation"); float precip = (float)WeatherManager.getInstance().getPrecipitation((int)player.posX, (int)player.posZ); if(precip != old) { player.connection.sendPacket(new SPacketChangeGameState(7, precip)); } } } } } }
protected void handleEntityHit(Entity entity) { // FFQLogger.info("EntityCustomArrow handleEntityHit(): [%s] with base damage = %f", this.getClass().getName(), this.getDamage()); float f2 = MathHelper.sqrt(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); int k = MathHelper.ceil((double)f2 * this.getDamage()); if (this.getIsCritical()) { k += this.rand.nextInt(k / 2 + 2); } DamageSource damagesource; if (this.shootingEntity == null) { damagesource = DamageSource.causeArrowDamage(this, this); } else { damagesource = DamageSource.causeArrowDamage(this, this.shootingEntity); } if (this.isBurning() && !(entity instanceof EntityEnderman)) { entity.setFire(5); } if (entity.attackEntityFrom(damagesource, (float)k)) { if (entity instanceof EntityLivingBase) { EntityLivingBase entitylivingbase = (EntityLivingBase)entity; if (!this.world.isRemote) { entitylivingbase.setArrowCountInEntity(entitylivingbase.getArrowCountInEntity() + 1); } if (this.knockbackStrength > 0) { float f4 = MathHelper.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); if (f4 > 0.0F) { entity.addVelocity(this.motionX * (double)this.knockbackStrength * 0.6000000238418579D / (double)f4, 0.1D, this.motionZ * (double)this.knockbackStrength * 0.6000000238418579D / (double)f4); } } if (this.shootingEntity instanceof EntityLivingBase) { EnchantmentHelper.applyThornEnchantments(entitylivingbase, this.shootingEntity); EnchantmentHelper.applyArthropodEnchantments((EntityLivingBase)this.shootingEntity, entitylivingbase); } if (this.shootingEntity != null && entity != this.shootingEntity && entity instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP) { ((EntityPlayerMP)this.shootingEntity).connection.sendPacket(new SPacketChangeGameState(6, 0.0F)); } } this.playSound(SoundEvents.ENTITY_ARROW_HIT, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); if (!(entity instanceof EntityEnderman)) { this.setDead(); } } else { this.motionX *= -0.10000000149011612D; this.motionY *= -0.10000000149011612D; this.motionZ *= -0.10000000149011612D; this.rotationYaw += 180.0F; this.prevRotationYaw += 180.0F; this.ticksInAir = 0; } }
void handleChangeGameState(SPacketChangeGameState packetIn);