mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-28 07:36:01 +00:00
Added Salt Blocks - generates similarly to clay. Added tooltips for config GUI. Added option to regenerate ores, as this is now a thing. Also...began implementing different tiers of control circuits.
This commit is contained in:
1 parent
63970a29ea
commit
23adf9ad24
16 files changed
+372
-91
No files matched your search
@@ -3,13 +3,17 @@ package mekanism.common;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.Random;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.common.tank.DynamicTankCache;
|
||||
import mekanism.common.tile.TileEntityDynamicTank;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.ChunkCoordIntPair;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
@@ -18,6 +22,39 @@ import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class CommonWorldTickHandler
|
||||
{
|
||||
private static final long maximumDeltaTimeNanoSecs = 16000000; // 16 milliseconds
|
||||
|
||||
private HashMap<Integer, Queue<ChunkCoordIntPair>> chunkRegenMap;
|
||||
|
||||
public void addRegenChunk(int dimensionId, ChunkCoordIntPair chunkCoord)
|
||||
{
|
||||
if(chunkRegenMap == null)
|
||||
{
|
||||
chunkRegenMap = new HashMap<Integer, Queue<ChunkCoordIntPair>>();
|
||||
}
|
||||
|
||||
if(!chunkRegenMap.containsKey(dimensionId))
|
||||
{
|
||||
LinkedList<ChunkCoordIntPair> list = new LinkedList<ChunkCoordIntPair>();
|
||||
list.add(chunkCoord);
|
||||
chunkRegenMap.put(dimensionId, list);
|
||||
}
|
||||
else {
|
||||
if(!chunkRegenMap.get(dimensionId).contains(chunkCoord))
|
||||
{
|
||||
chunkRegenMap.get(dimensionId).add(chunkCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resetRegenChunks()
|
||||
{
|
||||
if(chunkRegenMap != null)
|
||||
{
|
||||
chunkRegenMap.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTick(WorldTickEvent event)
|
||||
{
|
||||
@@ -86,6 +123,42 @@ public class CommonWorldTickHandler
|
||||
|
||||
Mekanism.dynamicInventories.remove(inventoryID);
|
||||
}
|
||||
|
||||
if(chunkRegenMap == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int dimensionId = world.provider.dimensionId;
|
||||
|
||||
//Credit to E. Beef :)
|
||||
if(chunkRegenMap.containsKey(dimensionId))
|
||||
{
|
||||
Queue<ChunkCoordIntPair> chunksToGen = chunkRegenMap.get(dimensionId);
|
||||
long startTime = System.nanoTime();
|
||||
|
||||
while(System.nanoTime() - startTime < maximumDeltaTimeNanoSecs && !chunksToGen.isEmpty())
|
||||
{
|
||||
ChunkCoordIntPair nextChunk = chunksToGen.poll();
|
||||
|
||||
if(nextChunk == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Random fmlRandom = new Random(world.getSeed());
|
||||
long xSeed = fmlRandom.nextLong() >> 2 + 1L;
|
||||
long zSeed = fmlRandom.nextLong() >> 2 + 1L;
|
||||
fmlRandom.setSeed((xSeed*nextChunk.chunkXPos + zSeed*nextChunk.chunkZPos) ^ world.getSeed());
|
||||
|
||||
Mekanism.genHandler.generate(fmlRandom, nextChunk.chunkXPos, nextChunk.chunkZPos, world, world.getChunkProvider(), world.getChunkProvider());
|
||||
}
|
||||
|
||||
if(chunksToGen.isEmpty())
|
||||
{
|
||||
chunkRegenMap.remove(dimensionId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user