/
TickHandlerWorld.java
57 lines (46 loc) · 1.8 KB
/
TickHandlerWorld.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package mods.natura.worldgen.retro;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Random;
import net.minecraft.world.World;
import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.TickType;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Type;
import cpw.mods.fml.common.gameevent.TickEvent.WorldTickEvent;
public class TickHandlerWorld
{
public static TickHandlerWorld instance = new TickHandlerWorld();
public static HashMap chunksToGen = new HashMap();
@SubscribeEvent
public void onTick (WorldTickEvent event)
{
if (event.phase.equals(Phase.END) && event.type.equals(Type.WORLD))
{
World world = (World) event.world;
int dim = world.provider.dimensionId;
ArrayList chunks = (ArrayList) chunksToGen.get(Integer.valueOf(dim));
if (chunks != null && chunks.size() > 0)
{
ChunkCoord c = (ChunkCoord) chunks.get(0);
long worldSeed = world.getSeed();
Random rand = new Random(worldSeed);
long xSeed = rand.nextLong() >> 2 + 1L;
long zSeed = rand.nextLong() >> 2 + 1L;
rand.setSeed(xSeed * c.chunkX + zSeed * c.chunkZ ^ worldSeed);
WorldHandler.instance.generateWorld(rand, c.chunkX, c.chunkZ, world, true);
chunks.remove(0);
chunksToGen.put(Integer.valueOf(dim), chunks);
}
}
}
/* @Override
public String getLabel ()
{
return "NaturaWorld";
}*/
}