net.minecraft.network.play.server.SPacketChangeGameState Java Examples
The following examples show how to use
net.minecraft.network.play.server.SPacketChangeGameState.
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: NoWeather.java From ForgeHax with MIT License | 6 votes |
@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: // end rain isRainState = false; setState(false, 0.f, 0.f); break; case 2: // start rain isRainState = true; setState(true, 1.f, 1.f); break; case 7: // fade value: sky brightness isRainState = true; // needs to be cancelled to avoid flicker break; } if (isRainState) { disableRain(); event.setCanceled(true); } } }
Example #2
Source File: WorldProviderSurface.java From TFC2 with GNU General Public License v3.0 | 4 votes |
@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)); } } } } } }