|
7 | 7 |
|
8 | 8 | package micdoodle8.mods.galacticraft.planets.venus.client;
|
9 | 9 |
|
10 |
| -import com.google.common.collect.Maps; |
11 | 10 | import java.util.Iterator;
|
12 | 11 | import java.util.Map;
|
13 |
| -import micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider; |
14 |
| -import micdoodle8.mods.galacticraft.core.client.CloudRenderer; |
15 |
| -import micdoodle8.mods.galacticraft.core.proxy.ClientProxyCore; |
16 |
| -import micdoodle8.mods.galacticraft.core.util.PlayerUtil; |
17 |
| -import micdoodle8.mods.galacticraft.planets.venus.ConfigManagerVenus; |
18 |
| -import micdoodle8.mods.galacticraft.planets.venus.dimension.WorldProviderVenus; |
| 12 | + |
19 | 13 | import net.minecraft.client.Minecraft;
|
20 | 14 | import net.minecraft.client.entity.EntityPlayerSP;
|
21 | 15 | import net.minecraft.client.multiplayer.WorldClient;
|
22 | 16 | import net.minecraft.init.SoundEvents;
|
23 | 17 | import net.minecraft.util.SoundCategory;
|
24 | 18 | import net.minecraft.util.math.BlockPos;
|
| 19 | + |
25 | 20 | import net.minecraftforge.fml.client.FMLClientHandler;
|
26 | 21 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
27 | 22 | import net.minecraftforge.fml.common.gameevent.TickEvent;
|
28 |
| -import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; |
29 |
| -import net.minecraftforge.fml.common.gameevent.TickEvent.RenderTickEvent; |
30 | 23 | import net.minecraftforge.fml.relauncher.Side;
|
31 | 24 | import net.minecraftforge.fml.relauncher.SideOnly;
|
32 | 25 |
|
| 26 | +import micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider; |
| 27 | +import micdoodle8.mods.galacticraft.core.client.CloudRenderer; |
| 28 | +import micdoodle8.mods.galacticraft.core.proxy.ClientProxyCore; |
| 29 | +import micdoodle8.mods.galacticraft.planets.venus.ConfigManagerVenus; |
| 30 | +import micdoodle8.mods.galacticraft.planets.venus.dimension.WorldProviderVenus; |
| 31 | + |
| 32 | +import com.google.common.collect.Maps; |
| 33 | + |
33 | 34 | @SideOnly(Side.CLIENT)
|
34 | 35 | public class TickHandlerClientVenus
|
35 | 36 | {
|
36 | 37 |
|
37 | 38 | private Map<BlockPos, Integer> lightning = Maps.newHashMap();
|
38 | 39 |
|
39 |
| - @SubscribeEvent |
40 |
| - public void onRenderTick(RenderTickEvent event) |
41 |
| - { |
42 |
| - final Minecraft minecraft = FMLClientHandler.instance().getClient(); |
43 |
| - final EntityPlayerSP player = minecraft.player; |
44 |
| - final EntityPlayerSP playerBaseClient = PlayerUtil.getPlayerBaseClientFromPlayer(player, false); |
45 |
| - |
46 |
| - if (event.phase == Phase.END) |
47 |
| - { |
48 |
| - } |
49 |
| - } |
50 |
| - |
51 | 40 | @SubscribeEvent
|
52 | 41 | public void renderLightning(ClientProxyCore.EventSpecialRender event)
|
53 | 42 | {
|
54 |
| - final Minecraft minecraft = FMLClientHandler.instance().getClient(); |
55 |
| - final EntityPlayerSP player = minecraft.player; |
| 43 | + final Minecraft minecraft = FMLClientHandler.instance().getClient(); |
| 44 | + final EntityPlayerSP player = minecraft.player; |
56 | 45 | if (player != null && !ConfigManagerVenus.disableAmbientLightning)
|
57 | 46 | {
|
58 | 47 | Iterator<Map.Entry<BlockPos, Integer>> it = lightning.entrySet().iterator();
|
59 | 48 | while (it.hasNext())
|
60 | 49 | {
|
61 | 50 | Map.Entry<BlockPos, Integer> entry = it.next();
|
62 |
| - long seed = entry.getValue() / 10 + entry.getKey().getX() + entry.getKey().getZ(); |
63 |
| - FakeLightningBoltRenderer.renderBolt(seed, entry.getKey().getX() - ClientProxyCore.playerPosX, entry.getKey().getY() - ClientProxyCore.playerPosY, |
64 |
| - entry.getKey().getZ() - ClientProxyCore.playerPosZ); |
| 51 | + long seed = entry.getValue() / 10 + entry.getKey().getX() + entry.getKey().getZ(); |
| 52 | + FakeLightningBoltRenderer.renderBolt(seed, entry.getKey().getX() - ClientProxyCore.playerPosX, entry.getKey().getY() - ClientProxyCore.playerPosY, entry.getKey().getZ() - ClientProxyCore.playerPosZ); |
65 | 53 | }
|
66 | 54 | }
|
67 | 55 | }
|
@@ -100,40 +88,42 @@ public void onClientTick(TickEvent.ClientTickEvent event)
|
100 | 88 | @SubscribeEvent
|
101 | 89 | public void onPlayerTick(TickEvent.PlayerTickEvent event)
|
102 | 90 | {
|
103 |
| - final Minecraft minecraft = FMLClientHandler.instance().getClient(); |
104 |
| - final EntityPlayerSP player = minecraft.player; |
| 91 | + final Minecraft minecraft = FMLClientHandler.instance().getClient(); |
| 92 | + final EntityPlayerSP player = minecraft.player; |
105 | 93 |
|
106 | 94 | if (player == event.player)
|
107 | 95 | {
|
108 |
| - if (!ConfigManagerVenus.disableAmbientLightning) |
| 96 | + // Maybe check for the right provider before we continue |
| 97 | + if (player.world.provider instanceof WorldProviderVenus) |
109 | 98 | {
|
110 |
| - Iterator<Map.Entry<BlockPos, Integer>> it = lightning.entrySet().iterator(); |
111 |
| - while (it.hasNext()) |
| 99 | + if (!ConfigManagerVenus.disableAmbientLightning) |
112 | 100 | {
|
113 |
| - Map.Entry<BlockPos, Integer> entry = it.next(); |
114 |
| - int val = entry.getValue(); |
115 |
| - if (val - 1 <= 0) |
| 101 | + Iterator<Map.Entry<BlockPos, Integer>> it = lightning.entrySet().iterator(); |
| 102 | + while (it.hasNext()) |
116 | 103 | {
|
117 |
| - it.remove(); |
118 |
| - } else |
| 104 | + Map.Entry<BlockPos, Integer> entry = it.next(); |
| 105 | + int val = entry.getValue(); |
| 106 | + if (val - 1 <= 0) |
| 107 | + { |
| 108 | + it.remove(); |
| 109 | + } else |
| 110 | + { |
| 111 | + entry.setValue(val - 1); |
| 112 | + } |
| 113 | + } |
| 114 | + if (player.getRNG().nextInt(300 + (int) (800F * minecraft.world.rainingStrength)) == 0) |
119 | 115 | {
|
120 |
| - entry.setValue(val - 1); |
| 116 | + double freq = player.getRNG().nextDouble() * Math.PI * 2.0F; |
| 117 | + double dist = 180.0F; |
| 118 | + double dX = dist * Math.cos(freq); |
| 119 | + double dZ = dist * Math.sin(freq); |
| 120 | + double posX = player.posX + dX; |
| 121 | + double posY = 70; |
| 122 | + double posZ = player.posZ + dZ; |
| 123 | + minecraft.world.playSound(player, posX, posY, posZ, SoundEvents.ENTITY_LIGHTNING_THUNDER, SoundCategory.WEATHER, 500.0F + player.getRNG().nextFloat() * 500F, 1.0F + player.getRNG().nextFloat() * 0.2F); |
| 124 | + lightning.put(new BlockPos(posX, posY, posZ), 20); |
121 | 125 | }
|
122 | 126 | }
|
123 |
| - |
124 |
| - if (player.getRNG().nextInt(300 + (int) (800F * minecraft.world.rainingStrength)) == 0 && minecraft.world.provider instanceof WorldProviderVenus) |
125 |
| - { |
126 |
| - double freq = player.getRNG().nextDouble() * Math.PI * 2.0F; |
127 |
| - double dist = 180.0F; |
128 |
| - double dX = dist * Math.cos(freq); |
129 |
| - double dZ = dist * Math.sin(freq); |
130 |
| - double posX = player.posX + dX; |
131 |
| - double posY = 70; |
132 |
| - double posZ = player.posZ + dZ; |
133 |
| - minecraft.world.playSound(player, posX, posY, posZ, SoundEvents.ENTITY_LIGHTNING_THUNDER, SoundCategory.WEATHER, 500.0F + player.getRNG().nextFloat() * 500F, |
134 |
| - 1.0F + player.getRNG().nextFloat() * 0.2F); |
135 |
| - lightning.put(new BlockPos(posX, posY, posZ), 20); |
136 |
| - } |
137 | 127 | }
|
138 | 128 | }
|
139 | 129 | }
|
|
0 commit comments