mirror of
https://github.com/GTNewHorizons/Gadomancy.git
synced 2026-11-18 03:15:22 +00:00
- TC Eldritch Challenge: Update
This commit is contained in:
1 parent
2632b3efb7
commit
d40366dfdc
7 files changed
+53
-41
No files matched your search
@@ -52,7 +52,7 @@ public class TileAdditionalEldritchPortal extends TileEldritchPortal {
|
||||
//Teleporting there.
|
||||
|
||||
startTracking(toTeleport, new ExtendedChunkCoordinates(new ChunkCoordinates(xCoord, yCoord, zCoord), toTeleport.dimension));
|
||||
TCMazeHandler.createSessionWaitForTeleport(toTeleport, toTeleport.posX, toTeleport.posY, toTeleport.posZ);
|
||||
TCMazeHandler.createSessionWaitForTeleport(toTeleport);
|
||||
} else {
|
||||
//Teleporting back.
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ public class TileNodeManipulator extends TileWandPedestal implements IAspectCont
|
||||
List players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1).expand(15, 15, 15));
|
||||
if(!players.isEmpty()) {
|
||||
EntityPlayer player = (EntityPlayer) players.get(0);
|
||||
TCMazeHandler.createSessionWaitForTeleport(player, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
//TCMazeHandler.createSessionWaitForTeleport(player, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
}
|
||||
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
|
||||
@@ -57,7 +57,7 @@ public class EventHandlerWorld {
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.NORMAL)
|
||||
public void on(WorldEvent.Load e) {
|
||||
if (!e.world.isRemote && e.world.equals(MinecraftServer.getServer().getEntityWorld())) {
|
||||
if (!e.world.isRemote && e.world.provider.dimensionId == 0) {
|
||||
Gadomancy.loadModData();
|
||||
|
||||
GolemEnumHelper.validateSavedMapping();
|
||||
@@ -109,7 +109,7 @@ public class EventHandlerWorld {
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.NORMAL)
|
||||
public void on(WorldEvent.Unload e) {
|
||||
if (!e.world.isRemote && e.world.equals(MinecraftServer.getServer().getEntityWorld())) {
|
||||
if (!e.world.isRemote && e.world.provider.dimensionId == 0) {
|
||||
Gadomancy.unloadModData();
|
||||
|
||||
TCMazeHandler.closeAllSessionsAndCleanup();
|
||||
|
||||
@@ -3,6 +3,7 @@ package makeo.gadomancy.common.utils.world;
|
||||
import makeo.gadomancy.common.utils.world.fake.FakeWorldTCGeneration;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EnumCreatureType;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityMobSpawner;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
@@ -12,6 +13,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.gen.ChunkProviderServer;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.terraingen.PopulateChunkEvent;
|
||||
import thaumcraft.common.entities.EntityPermanentItem;
|
||||
@@ -62,7 +64,7 @@ public class ChunkProviderTCOuter implements IChunkProvider {
|
||||
for(Integer[] pos : buf.tiles) {
|
||||
TileEntity te = buf.blockData[pos[3]].createTileEntity(worldObj, buf.metaBuffer[pos[3]]);
|
||||
if(te != null) {
|
||||
worldObj.loadedTileEntityList.add(te);
|
||||
worldObj.addTileEntity(te);
|
||||
chunk.func_150812_a(pos[0] & 15, pos[1], pos[2] & 15, te);
|
||||
te.blockMetadata = buf.metaBuffer[pos[3]];
|
||||
}
|
||||
@@ -76,46 +78,42 @@ public class ChunkProviderTCOuter implements IChunkProvider {
|
||||
ChunkPosition pos = new ChunkPosition(te.xCoord & 15, te.yCoord, te.zCoord & 15);
|
||||
if(!chunk.chunkTileEntityMap.containsKey(pos)) {
|
||||
System.out.println("INVALID TE at: " + te.xCoord + ", " + te.yCoord + ", " + te.zCoord + " --- Not found in its parent chunk " + chunk.xPosition + ", " + chunk.zPosition);
|
||||
//throw new IllegalStateException("INVALID TE");
|
||||
continue;
|
||||
throw new IllegalStateException("INVALID TE");
|
||||
}
|
||||
TileEntity correspondingTE = (TileEntity) chunk.chunkTileEntityMap.get(pos);
|
||||
if(te instanceof TileEntityMobSpawner) {
|
||||
if(!(correspondingTE instanceof TileEntityMobSpawner)) {
|
||||
System.out.println("DATA INCONSISTENCY - TE at " + te.xCoord + ", " + te.yCoord + ", " + te.zCoord + " EXPECTED: " + te.getClass().getSimpleName() + " GIVEN " + correspondingTE.getClass().getSimpleName());
|
||||
//throw new IllegalStateException();
|
||||
it.remove();
|
||||
continue;
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
((TileEntityMobSpawner) correspondingTE).func_145881_a().setEntityName(((TileEntityMobSpawner) te).func_145881_a().getEntityNameToSpawn());
|
||||
} else if(te instanceof TileEldritchLock) {
|
||||
if(!(correspondingTE instanceof TileEldritchLock)) {
|
||||
System.out.println("DATA INCONSISTENCY - TE at " + te.xCoord + ", " + te.yCoord + ", " + te.zCoord + " EXPECTED: " + te.getClass().getSimpleName() + " GIVEN " + correspondingTE.getClass().getSimpleName());
|
||||
//throw new IllegalStateException();
|
||||
it.remove();
|
||||
continue;
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
((TileEldritchLock) correspondingTE).setFacing(((TileEldritchLock) te).getFacing());
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setByte("facing", ((TileEldritchLock) te).getFacing());
|
||||
compound.setShort("count", (short) -1);
|
||||
((TileEldritchLock) correspondingTE).readCustomNBT(compound);
|
||||
} else if(te instanceof TileCrystal) {
|
||||
if(!(correspondingTE instanceof TileCrystal)) {
|
||||
System.out.println("DATA INCONSISTENCY - TE at " + te.xCoord + ", " + te.yCoord + ", " + te.zCoord + " EXPECTED: " + te.getClass().getSimpleName() + " GIVEN " + correspondingTE.getClass().getSimpleName());
|
||||
//throw new IllegalStateException();
|
||||
it.remove();
|
||||
continue;
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
((TileCrystal) correspondingTE).orientation = ((TileCrystal) te).orientation;
|
||||
} else if(te instanceof TileEldritchCrabSpawner) {
|
||||
if(!(correspondingTE instanceof TileEldritchCrabSpawner)) {
|
||||
System.out.println("DATA INCONSISTENCY - TE at " + te.xCoord + ", " + te.yCoord + ", " + te.zCoord + " EXPECTED: " + te.getClass().getSimpleName() + " GIVEN " + correspondingTE.getClass().getSimpleName());
|
||||
//throw new IllegalStateException();
|
||||
it.remove();
|
||||
continue;
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
((TileEldritchCrabSpawner) correspondingTE).setFacing(((TileEldritchCrabSpawner) te).getFacing());
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setByte("facing", ((TileEldritchCrabSpawner) te).getFacing());
|
||||
((TileEldritchCrabSpawner) correspondingTE).readCustomNBT(compound);
|
||||
} else {
|
||||
throw new IllegalStateException("Unexpected TileEntity: " + te);
|
||||
}
|
||||
@@ -148,8 +146,6 @@ public class ChunkProviderTCOuter implements IChunkProvider {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//System.out.println("Creating NEW Chunk");
|
||||
|
||||
Block[] ablock = new Block[blockArr.length];
|
||||
System.arraycopy(blockArr, 0, ablock, 0, blockArr.length);
|
||||
byte[] meta = new byte[metaArr.length];
|
||||
|
||||
@@ -73,7 +73,7 @@ public class TCMazeHandler {
|
||||
WorldUtil.tryTeleportBack((EntityPlayerMP) player, 0);
|
||||
ChunkCoordinates cc = out.getSpawnPoint();
|
||||
int y = w.getTopSolidOrLiquidBlock(cc.posX, cc.posZ);
|
||||
player.setPosition(cc.posX + 0.5, y, cc.posZ + 0.5);
|
||||
player.setPositionAndUpdate(cc.posX + 0.5, y, cc.posZ + 0.5);
|
||||
}
|
||||
}
|
||||
for (EntityPlayer player : runningSessions.keySet()) {
|
||||
@@ -87,11 +87,11 @@ public class TCMazeHandler {
|
||||
/*
|
||||
* Coordinates wanted here are the absolute Portal coordinates.
|
||||
*/
|
||||
public static boolean createSessionWaitForTeleport(EntityPlayer player, double pX, double pY, double pZ) {
|
||||
public static boolean createSessionWaitForTeleport(EntityPlayer player) {
|
||||
if (hasOpenSession(player) || !hasFreeSessionSpace()) return false;
|
||||
WorldServer w = MinecraftServer.getServer().worldServerForDimension(ModConfig.dimOuterId);
|
||||
reserveSessionSpace(player);
|
||||
setupSession(player, w, pX, pY, pZ);
|
||||
setupSession(player, w);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -99,24 +99,24 @@ public class TCMazeHandler {
|
||||
runningSessions.put(player, TCMazeSession.placeholder());
|
||||
}
|
||||
|
||||
private static void setupSession(EntityPlayer player, WorldServer world, double pX, double pY, double pZ) {
|
||||
private static void setupSession(EntityPlayer player, WorldServer world) {
|
||||
Vec3 currentPos = Vec3.createVectorHelper(player.posX, player.posY, player.posZ);
|
||||
int originDim = player.worldObj.provider.dimensionId;
|
||||
Map<CellLoc, Short> locs = calculateCellLocs(world, pX, pZ);
|
||||
Map<CellLoc, Short> locs = calculateCellLocs(world);
|
||||
MazeBuilderThread t = new MazeBuilderThread((EntityPlayerMP) player, locs, originDim, currentPos);
|
||||
t.start();
|
||||
}
|
||||
|
||||
private static Map<CellLoc, Short> calculateCellLocs(WorldServer world, double pX, double pZ) {
|
||||
private static Map<CellLoc, Short> calculateCellLocs(WorldServer world) {
|
||||
ConcurrentHashMap<CellLoc, Short> oldDat = MazeHandler.labyrinth;
|
||||
ConcurrentHashMap<CellLoc, Short> bufferOld = new ConcurrentHashMap<CellLoc, Short>(labyrinthCopy);
|
||||
MazeHandler.labyrinth = labyrinthCopy;
|
||||
int chX = ((int) pX) >> 4;
|
||||
int chZ = ((int) pZ) >> 4;
|
||||
int chX = getHighestPossibleRandWH(); //To ensure we're always +x and +z
|
||||
int chZ = getHighestPossibleRandWH();
|
||||
int w = randWH(world.rand);
|
||||
int h = randWH(world.rand);
|
||||
while (MazeHandler.mazesInRange(chX, chZ, w, h)) {
|
||||
chX++;
|
||||
chX++; //We grow the mazes in +x direction!
|
||||
}
|
||||
MazeThread mt = new MazeThread(chX, chZ, w, h, world.rand.nextLong());
|
||||
mt.run();
|
||||
@@ -141,10 +141,18 @@ public class TCMazeHandler {
|
||||
return ModConfig.maxMazeCount == -1 || runningSessions.size() < ModConfig.maxMazeCount;
|
||||
}
|
||||
|
||||
/*
|
||||
Change getHighestPossibleRandWH accordingly if modifying this.
|
||||
*/
|
||||
private static int randWH(Random random) {
|
||||
return 17 + random.nextInt(2) * 2;
|
||||
}
|
||||
|
||||
private static int getHighestPossibleRandWH() {
|
||||
//Add something to ensure 100% we never get in minus coordinates!
|
||||
return 29; //21 + ensured 8
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
runningSessions = new HashMap<EntityPlayer, TCMazeSession>();
|
||||
}
|
||||
@@ -172,6 +180,7 @@ public class TCMazeHandler {
|
||||
labyrinthCopy.remove(loc);
|
||||
forceChunkUnloading(ws, loc.x, loc.z);
|
||||
}
|
||||
System.out.println("new weight: " + labyrinthCopy.size());
|
||||
}
|
||||
|
||||
private static void forceChunkUnloading(WorldServer ws, int chX, int chZ) {
|
||||
@@ -226,10 +235,10 @@ public class TCMazeHandler {
|
||||
MazeHandler.generateEldritch(GEN, GEN.rand, l.x, l.z);
|
||||
MazeHandler.labyrinth = old;
|
||||
}
|
||||
System.out.println("BuildTime: " + (System.currentTimeMillis() - startMs) + " (ms)");
|
||||
System.out.println("Blocks SET: " + GEN.blockCount);
|
||||
System.out.println("Maze BuildTime: " + (System.currentTimeMillis() - startMs) + " (ms)");
|
||||
/*System.out.println("Blocks SET: " + GEN.blockCount);
|
||||
System.out.println("Blocks OVERWRITTEN: " + GEN.blockOverwriteCount);
|
||||
System.out.println("BufferChunks CREATED: " + FakeWorldTCGeneration.ChunkBuffer.cnt);
|
||||
System.out.println("BufferChunks CREATED: " + FakeWorldTCGeneration.ChunkBuffer.cnt);*/
|
||||
|
||||
finishBuild();
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class TCMazeSession {
|
||||
TCMazeHandler.free(chunksAffected);
|
||||
if(teleport) {
|
||||
WorldUtil.tryTeleportBack(player, originDimId);
|
||||
player.setPosition(originLocation.xCoord, originLocation.yCoord, originLocation.zCoord);
|
||||
player.setPositionAndUpdate(originLocation.xCoord, originLocation.yCoord, originLocation.zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import thaumcraft.common.config.ConfigBlocks;
|
||||
import thaumcraft.common.entities.EntityPermanentItem;
|
||||
import thaumcraft.common.entities.monster.EntityEldritchGuardian;
|
||||
import thaumcraft.common.lib.utils.BlockUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -54,7 +55,18 @@ public class FakeWorldTCGeneration extends FakeWorld {
|
||||
|
||||
if(buf.blockData[key] != null) {
|
||||
blockOverwriteCount++;
|
||||
ChunkCoordinates cc = new ChunkCoordinates(x, y, z);
|
||||
if(gettedTE.containsKey(cc)) {
|
||||
gettedTE.remove(cc);
|
||||
}
|
||||
}
|
||||
|
||||
/*if(block == ConfigBlocks.blockEldritchNothing) {
|
||||
if(BlockUtils.isBlockExposed(this, x, y, z)) {
|
||||
meta = 1;
|
||||
}
|
||||
}*/
|
||||
|
||||
buf.blockData[key] = block;
|
||||
buf.metaBuffer[key] = (byte) meta;
|
||||
if(block.hasTileEntity(meta)) buf.tiles.add(new Integer[] {x, y, z, key});
|
||||
@@ -175,14 +187,9 @@ public class FakeWorldTCGeneration extends FakeWorld {
|
||||
public Block[] blockData = new Block[32768];
|
||||
public byte[] metaBuffer = new byte[32768];
|
||||
public List<Integer[]> tiles = new ArrayList<Integer[]>();
|
||||
public static int cnt = 0;
|
||||
|
||||
public ChunkBuffer(long key) {
|
||||
this.key = key;
|
||||
cnt++;
|
||||
if(cnt % 50 == 0) {
|
||||
System.out.println("ChunkBuffers created: " + cnt);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user