mirror of
https://github.com/GTNewHorizons/Gadomancy.git
synced 2026-11-28 15:36:17 +00:00
Fixed and Improved Gate of the Voidwalkers roguelike Thaumcraft Dungeon (#52)
Co-authored-by: Luca <[email protected]>
This commit is contained in:
1 parent
eaf28590f0
commit
43ede3edb0
11 files changed
+737
-805
No files matched your search
@@ -2,6 +2,7 @@ package makeo.gadomancy.common.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -12,6 +13,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import makeo.gadomancy.common.Gadomancy;
|
||||
import makeo.gadomancy.common.blocks.tiles.TileNodeManipulator;
|
||||
import makeo.gadomancy.common.blocks.tiles.TileNodeManipulator.MultiblockType;
|
||||
import makeo.gadomancy.common.registration.RegisteredItems;
|
||||
import thaumcraft.api.ThaumcraftApiHelper;
|
||||
import thaumcraft.common.blocks.BlockStoneDevice;
|
||||
@@ -26,6 +28,8 @@ import thaumcraft.common.lib.research.ResearchManager;
|
||||
*/
|
||||
public class BlockNodeManipulator extends BlockStoneDevice {
|
||||
|
||||
private static final int METADATA = 5;
|
||||
|
||||
public BlockNodeManipulator() {
|
||||
this.setBlockName("blockNodeManipulator");
|
||||
this.setCreativeTab(RegisteredItems.creativeTab);
|
||||
@@ -44,54 +48,70 @@ public class BlockNodeManipulator extends BlockStoneDevice {
|
||||
this.iconWandPedestalFocus[2] = ir.registerIcon(Gadomancy.MODID + ":manipulator_focus_bot");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// TC stuff...
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, int metadata) {
|
||||
if (metadata == 5) return new TileNodeManipulator();
|
||||
return null;
|
||||
return (metadata == METADATA) ? new TileNodeManipulator() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(World world, int x, int y, int z, int rs) {
|
||||
int ret = super.getComparatorInputOverride(world, x, y, z, rs);
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if (te instanceof TileNodeManipulator) return 0;
|
||||
return ret;
|
||||
return super.getComparatorInputOverride(world, x, y, z, rs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
|
||||
par3List.add(new ItemStack(par1, 1, 5));
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
|
||||
list.add(new ItemStack(item, 1, METADATA));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float par7,
|
||||
float par8, float par9) {
|
||||
TileNodeManipulator tile = (TileNodeManipulator) world.getTileEntity(x, y, z);
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float subX,
|
||||
float subY, float subZ) {
|
||||
if (world.isRemote) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if (!(te instanceof TileNodeManipulator nodeManipulatorTE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (nodeManipulatorTE.isInMultiblock()) {
|
||||
return super.onBlockActivated(world, x, y, z, player, side, subX, subY, subZ);
|
||||
}
|
||||
|
||||
if (nodeManipulatorTE.detectMultiblockType() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemStack heldItem = player.getHeldItem();
|
||||
if (tile.isInMultiblock()) {
|
||||
super.onBlockActivated(world, x, y, z, player, side, par7, par8, par9);
|
||||
} else if (!world.isRemote && heldItem != null && heldItem.getItem() instanceof ItemWandCasting) {
|
||||
tile.checkMultiblock();
|
||||
if (tile.isMultiblockStructurePresent()) {
|
||||
String research = tile.getMultiblockType().getResearchNeeded();
|
||||
if (!ResearchManager.isResearchComplete(player.getCommandSenderName(), research)) return false;
|
||||
if (ThaumcraftApiHelper.consumeVisFromWandCrafting(
|
||||
player.getCurrentEquippedItem(),
|
||||
player,
|
||||
tile.getMultiblockType().getMultiblockCosts(),
|
||||
true)) {
|
||||
tile.formMultiblock();
|
||||
return true;
|
||||
}
|
||||
if (heldItem == null || !(heldItem.getItem() instanceof ItemWandCasting)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MultiblockType type = nodeManipulatorTE.getMultiblockType();
|
||||
if (!ResearchManager.isResearchComplete(player.getCommandSenderName(), type.getResearchNeeded())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ThaumcraftApiHelper
|
||||
.consumeVisFromWandCrafting(player.getCurrentEquippedItem(), player, type.getMultiblockCosts(), true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nodeManipulatorTE.formMultiblock();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
|
||||
if (!world.isRemote) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if (te instanceof TileNodeManipulator nodeManipulatorTE) {
|
||||
if (nodeManipulatorTE.isInMultiblock()) nodeManipulatorTE.breakMultiblock();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
super.breakBlock(world, x, y, z, block, meta);
|
||||
}
|
||||
}
|
||||
+33
-18
@@ -19,19 +19,22 @@ import thaumcraft.common.tiles.TileEldritchPortal;
|
||||
/**
|
||||
* This class is part of the Gadomancy Mod Gadomancy is Open Source and distributed under the GNU LESSER GENERAL PUBLIC
|
||||
* LICENSE for more read the LICENSE file
|
||||
*
|
||||
* <p/>
|
||||
* Created by makeo @ 06.11.2015 23:32
|
||||
*/
|
||||
public class TileAdditionalEldritchPortal extends TileEldritchPortal {
|
||||
|
||||
private static Map<EntityPlayer, ExtendedChunkCoordinates> trackedPortalActivity = new HashMap<EntityPlayer, ExtendedChunkCoordinates>();
|
||||
private static final Map<EntityPlayer, ExtendedChunkCoordinates> trackedPortalActivity = new HashMap<>();
|
||||
private EntityPlayer toTeleport;
|
||||
private int count;
|
||||
|
||||
private final Map<EntityPlayerMP, Integer> inPortalFor = new HashMap<>();
|
||||
private static final int REQUIRED_TELEPORT_TICKS = 20;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
this.count += 1;
|
||||
if ((this.worldObj.isRemote) && ((this.count % 250 == 0) || (this.count == 0))) {
|
||||
if ((this.worldObj.isRemote) && ((this.count % 250 == 0) || (this.count == 1))) {
|
||||
this.worldObj.playSound(
|
||||
this.xCoord + 0.5D,
|
||||
this.yCoord + 0.5D,
|
||||
@@ -41,22 +44,28 @@ public class TileAdditionalEldritchPortal extends TileEldritchPortal {
|
||||
1.0F,
|
||||
false);
|
||||
}
|
||||
|
||||
// necessary for proper rendering of the portals visual fx
|
||||
if ((this.worldObj.isRemote) && (this.opencount < 30)) {
|
||||
this.opencount += 1;
|
||||
}
|
||||
|
||||
if ((!this.worldObj.isRemote) && (this.count % 5 == 0) && this.toTeleport == null) {
|
||||
List<EntityPlayerMP> players = this.worldObj.getEntitiesWithinAABB(
|
||||
EntityPlayerMP.class,
|
||||
AxisAlignedBB.getBoundingBox(
|
||||
this.xCoord,
|
||||
this.yCoord,
|
||||
this.zCoord,
|
||||
this.xCoord + 1,
|
||||
this.yCoord + 1,
|
||||
this.zCoord + 1).expand(0.5D, 1.0D, 0.5D));
|
||||
if (players != null && !players.isEmpty()) {
|
||||
EntityPlayerMP toTeleport = players.get(0);
|
||||
AxisAlignedBB portal = AxisAlignedBB.getBoundingBox(
|
||||
this.xCoord,
|
||||
this.yCoord,
|
||||
this.zCoord,
|
||||
this.xCoord + 1,
|
||||
this.yCoord + 1,
|
||||
this.zCoord + 1).expand(0.5D, 1.0D, 0.5D);
|
||||
List<EntityPlayerMP> playersInPortal = this.worldObj.getEntitiesWithinAABB(EntityPlayerMP.class, portal);
|
||||
|
||||
// Remove portal progress for any player who has left the portal this tick.
|
||||
this.inPortalFor.keySet()
|
||||
.removeIf(tracked -> playersInPortal == null || !playersInPortal.contains(tracked));
|
||||
|
||||
if (playersInPortal != null && !playersInPortal.isEmpty()) {
|
||||
EntityPlayerMP toTeleport = playersInPortal.get(0);
|
||||
|
||||
if (toTeleport.timeUntilPortal > 0) return;
|
||||
|
||||
@@ -66,12 +75,19 @@ public class TileAdditionalEldritchPortal extends TileEldritchPortal {
|
||||
return;
|
||||
}
|
||||
|
||||
int timeInPortal = this.inPortalFor.getOrDefault(toTeleport, 0);
|
||||
timeInPortal += 5;
|
||||
this.inPortalFor.put(toTeleport, timeInPortal);
|
||||
|
||||
if (timeInPortal < REQUIRED_TELEPORT_TICKS) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.toTeleport = toTeleport;
|
||||
toTeleport.timeUntilPortal = 200;
|
||||
|
||||
if (toTeleport.dimension != ModConfig.dimOuterId) {
|
||||
// Teleporting there.
|
||||
|
||||
if (TCMazeHandler.createSessionWaitForTeleport(toTeleport)) {
|
||||
TileAdditionalEldritchPortal.startTracking(
|
||||
toTeleport,
|
||||
@@ -81,7 +97,6 @@ public class TileAdditionalEldritchPortal extends TileEldritchPortal {
|
||||
}
|
||||
} else {
|
||||
// Teleporting back.
|
||||
|
||||
TCMazeHandler.closeSession(toTeleport, true);
|
||||
}
|
||||
}
|
||||
@@ -110,8 +125,8 @@ public class TileAdditionalEldritchPortal extends TileEldritchPortal {
|
||||
|
||||
public static class ExtendedChunkCoordinates {
|
||||
|
||||
private ChunkCoordinates coordinates;
|
||||
private int dimId;
|
||||
private final ChunkCoordinates coordinates;
|
||||
private final int dimId;
|
||||
|
||||
public ExtendedChunkCoordinates(ChunkCoordinates coordinates, int dimId) {
|
||||
this.coordinates = coordinates;
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -3,9 +3,11 @@ package makeo.gadomancy.common.blocks.tiles;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
|
||||
import makeo.gadomancy.common.utils.world.TCMazeHandler;
|
||||
import makeo.gadomancy.common.utils.world.TCMazeSession;
|
||||
import thaumcraft.common.lib.world.dim.Cell;
|
||||
import thaumcraft.common.lib.world.dim.CellLoc;
|
||||
import thaumcraft.common.lib.world.dim.MazeHandler;
|
||||
import thaumcraft.common.tiles.TileEldritchLock;
|
||||
@@ -20,35 +22,56 @@ public class TileOverrideEldritchLock extends TileEldritchLock {
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (!this.worldObj.isRemote) {
|
||||
if (super.count != -1) {
|
||||
if (super.count + 1 > 100) {
|
||||
ConcurrentHashMap<CellLoc, Short> old = MazeHandler.labyrinth;
|
||||
MazeHandler.labyrinth = TCMazeHandler.labyrinthCopy;
|
||||
|
||||
int nextEntityId = Entity.nextEntityID;
|
||||
|
||||
super.updateEntity();
|
||||
|
||||
int count = Entity.nextEntityID - nextEntityId;
|
||||
Entity[] bosses = new Entity[count];
|
||||
for (int i = 0; i < count; i++) {
|
||||
bosses[i] = this.worldObj.getEntityByID(nextEntityId + i);
|
||||
}
|
||||
|
||||
MazeHandler.labyrinth = old;
|
||||
for (TCMazeSession session : TCMazeHandler.getSessions().values()) {
|
||||
if (session.chunksAffected != null && session.chunksAffected
|
||||
.containsKey(new CellLoc(this.xCoord >> 4, this.zCoord >> 4))) {
|
||||
TCMazeHandler.putBosses(session, bosses);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (this.worldObj.isRemote || super.count == -1 || super.count + 1 <= 100) {
|
||||
super.updateEntity();
|
||||
return;
|
||||
}
|
||||
|
||||
ConcurrentHashMap<CellLoc, Short> old = MazeHandler.labyrinth;
|
||||
MazeHandler.labyrinth = TCMazeHandler.labyrinthCopy;
|
||||
|
||||
int nextEntityId = Entity.nextEntityID;
|
||||
super.updateEntity();
|
||||
|
||||
int count = Entity.nextEntityID - nextEntityId;
|
||||
Entity[] bosses = new Entity[count];
|
||||
for (int i = 0; i < count; i++) {
|
||||
bosses[i] = this.worldObj.getEntityByID(nextEntityId + i);
|
||||
}
|
||||
|
||||
MazeHandler.labyrinth = old;
|
||||
|
||||
CellLoc lockChunk = new CellLoc(this.xCoord >> 4, this.zCoord >> 4);
|
||||
for (TCMazeSession session : TCMazeHandler.getSessions().values()) {
|
||||
if (session.chunksAffected == null || !session.chunksAffected.containsKey(lockChunk)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
TCMazeHandler.putBosses(session, bosses);
|
||||
|
||||
int cx = this.xCoord >> 4;
|
||||
int cz = this.zCoord >> 4;
|
||||
int centerx = cx;
|
||||
int centerz = cz;
|
||||
|
||||
for (int a = -2; a <= 2; ++a) {
|
||||
for (int b = -2; b <= 2; ++b) {
|
||||
CellLoc here = new CellLoc(cx + a, cz + b);
|
||||
if (!session.chunksAffected.containsKey(here)) {
|
||||
continue;
|
||||
}
|
||||
Cell c = new Cell(session.chunksAffected.get(here));
|
||||
if (c.feature == 2) {
|
||||
centerx = cx + a;
|
||||
centerz = cz + b;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
centerx = centerx * 16 + 16;
|
||||
centerz = centerz * 16 + 16;
|
||||
session.bossSpawnCoordinates = new ChunkCoordinates(centerx, TCMazeHandler.TELEPORT_LAYER_Y - 2, centerz);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,6 @@ import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import makeo.gadomancy.common.Gadomancy;
|
||||
import makeo.gadomancy.common.blocks.tiles.TileAIShutdown;
|
||||
import makeo.gadomancy.common.blocks.tiles.TileBlockProtector;
|
||||
import makeo.gadomancy.common.blocks.tiles.TileNodeManipulator;
|
||||
import makeo.gadomancy.common.blocks.tiles.TileStickyJar;
|
||||
import makeo.gadomancy.common.data.SyncDataHolder;
|
||||
import makeo.gadomancy.common.data.config.ModConfig;
|
||||
@@ -222,12 +221,6 @@ public class EventHandlerWorld {
|
||||
@SubscribeEvent
|
||||
public void onBreak(BlockEvent.BreakEvent event) {
|
||||
if (!event.world.isRemote) {
|
||||
if (event.block == RegisteredBlocks.blockNodeManipulator) {
|
||||
TileEntity te = event.world.getTileEntity(event.x, event.y, event.z);
|
||||
if (te instanceof TileNodeManipulator) {
|
||||
if (((TileNodeManipulator) te).isInMultiblock()) ((TileNodeManipulator) te).breakMultiblock();
|
||||
}
|
||||
}
|
||||
if (event.block == RegisteredBlocks.blockStoneMachine && event.blockMetadata == 5) {
|
||||
TileAIShutdown.removeTrackedEntities(event.world, event.x, event.y, event.z);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package makeo.gadomancy.common.network.packets;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
@@ -81,21 +82,27 @@ public class PacketTCNodeBolt implements IMessage, IMessageHandler<PacketTCNodeB
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IMessage onMessage(PacketTCNodeBolt p, MessageContext ctx) {
|
||||
WorldClient world = Minecraft.getMinecraft().theWorld;
|
||||
FXLightningBolt bolt = new FXLightningBolt(
|
||||
Minecraft.getMinecraft().theWorld,
|
||||
world,
|
||||
p.x,
|
||||
p.y,
|
||||
p.z,
|
||||
p.targetX,
|
||||
p.targetY,
|
||||
p.targetZ,
|
||||
Minecraft.getMinecraft().theWorld.rand.nextLong(),
|
||||
world.rand.nextLong(),
|
||||
10,
|
||||
4.0F,
|
||||
5);
|
||||
bolt.defaultFractal();
|
||||
bolt.setType(p.type);
|
||||
bolt.finalizeBolt();
|
||||
if (world.rand.nextBoolean()) {
|
||||
float pitch = 0.9F + world.rand.nextFloat() * 0.2F;
|
||||
float volume = 0.1F + world.rand.nextFloat() * 0.1F;
|
||||
world.playSound(p.x, p.y, p.z, "thaumcraft:zap", volume, pitch, false);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,9 @@ public class RegisteredMultiblocks {
|
||||
|
||||
public static final MultiblockHelper.MultiblockPattern incompleteNodeManipulatorMultiblock = new MultiblockHelper.MultiblockPattern(
|
||||
RegisteredBlocks.blockNodeManipulator,
|
||||
5).addBlock(0, 2, 0, RegisteredBlocks.blockNode, 0).addBlock(0, 1, 0, RegisteredBlocks.blockStoneMachine, 0)
|
||||
5)
|
||||
// .addBlock(0, 2, 0, RegisteredBlocks.blockNode, 0)
|
||||
.addBlock(0, 1, 0, RegisteredBlocks.blockStoneMachine, 0)
|
||||
.addBlock(1, 0, 1, ConfigBlocks.blockCosmeticSolid, 15)
|
||||
.addBlock(-1, 0, 1, ConfigBlocks.blockCosmeticSolid, 15)
|
||||
.addBlock(-1, 0, -1, ConfigBlocks.blockCosmeticSolid, 15)
|
||||
@@ -25,7 +27,9 @@ public class RegisteredMultiblocks {
|
||||
|
||||
public static final MultiblockHelper.MultiblockPattern completeNodeManipulatorMultiblock = new MultiblockHelper.MultiblockPattern(
|
||||
RegisteredBlocks.blockNodeManipulator,
|
||||
5).addBlock(0, 2, 0, RegisteredBlocks.blockNode, 0).addBlock(0, 1, 0, RegisteredBlocks.blockStoneMachine, 0)
|
||||
5)
|
||||
// .addBlock(0, 2, 0, RegisteredBlocks.blockNode, 0)
|
||||
.addBlock(0, 1, 0, RegisteredBlocks.blockStoneMachine, 0)
|
||||
.addBlock(1, 0, 1, RegisteredBlocks.blockStoneMachine, 15)
|
||||
.addBlock(-1, 0, 1, RegisteredBlocks.blockStoneMachine, 15)
|
||||
.addBlock(-1, 0, -1, RegisteredBlocks.blockStoneMachine, 15)
|
||||
@@ -37,11 +41,9 @@ public class RegisteredMultiblocks {
|
||||
|
||||
public static final MultiblockHelper.MultiblockPattern incompleteEldritchPortalCreator = new MultiblockHelper.MultiblockPattern(
|
||||
RegisteredBlocks.blockNodeManipulator,
|
||||
5).addBlock(0, 2, 0, RegisteredBlocks.blockNode, 0).addBlock(0, 1, 0, RegisteredBlocks.blockStoneMachine, 3)
|
||||
// .addBlock(3, 0, 0, RegisteredBlocks.blockStoneMachine, 1).addBlock(0, 0, 3,
|
||||
// RegisteredBlocks.blockStoneMachine, 1)
|
||||
// .addBlock(-3, 0, 0, RegisteredBlocks.blockStoneMachine, 1).addBlock(0, 0, -3,
|
||||
// RegisteredBlocks.blockStoneMachine, 1)
|
||||
5)
|
||||
// .addBlock(0, 2, 0, RegisteredBlocks.blockNode, 0)
|
||||
.addBlock(0, 1, 0, RegisteredBlocks.blockStoneMachine, 3)
|
||||
.addBlock(1, 0, 1, ConfigBlocks.blockCosmeticSolid, 15)
|
||||
.addBlock(-1, 0, 1, ConfigBlocks.blockCosmeticSolid, 15)
|
||||
.addBlock(-1, 0, -1, ConfigBlocks.blockCosmeticSolid, 15)
|
||||
@@ -53,11 +55,9 @@ public class RegisteredMultiblocks {
|
||||
|
||||
public static final MultiblockHelper.MultiblockPattern completeEldritchPortalCreator = new MultiblockHelper.MultiblockPattern(
|
||||
RegisteredBlocks.blockNodeManipulator,
|
||||
5).addBlock(0, 2, 0, RegisteredBlocks.blockNode, 0).addBlock(0, 1, 0, RegisteredBlocks.blockStoneMachine, 3)
|
||||
// .addBlock(3, 0, 0, RegisteredBlocks.blockStoneMachine, 1).addBlock(0, 0, 3,
|
||||
// RegisteredBlocks.blockStoneMachine, 1)
|
||||
// .addBlock(-3, 0, 0, RegisteredBlocks.blockStoneMachine, 1).addBlock(0, 0, -3,
|
||||
// RegisteredBlocks.blockStoneMachine, 1)
|
||||
5)
|
||||
// .addBlock(0, 2, 0, RegisteredBlocks.blockNode, 0)
|
||||
.addBlock(0, 1, 0, RegisteredBlocks.blockStoneMachine, 3)
|
||||
.addBlock(1, 0, 1, RegisteredBlocks.blockStoneMachine, 15)
|
||||
.addBlock(-1, 0, 1, RegisteredBlocks.blockStoneMachine, 15)
|
||||
.addBlock(-1, 0, -1, RegisteredBlocks.blockStoneMachine, 15)
|
||||
|
||||
@@ -354,7 +354,7 @@ public class RegisteredRecipes {
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
new ItemStack(RegisteredBlocks.blockNode, 1, 5),
|
||||
new ItemStack(RegisteredBlocks.blockNode, 1, 0),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
@@ -381,71 +381,15 @@ public class RegisteredRecipes {
|
||||
// x y z
|
||||
RegisteredRecipes.multiblockEldritchPortalCreator = Arrays.asList(
|
||||
RegisteredRecipes.costsEldritchPortalCreatorMultiblock,
|
||||
7,
|
||||
3,
|
||||
7,
|
||||
3,
|
||||
3,
|
||||
Arrays.asList(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
new ItemStack(RegisteredBlocks.blockNode, 1, 5),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
new ItemStack(RegisteredBlocks.blockNode, 1, 0),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
@@ -454,84 +398,20 @@ public class RegisteredRecipes {
|
||||
null,
|
||||
new ItemStack(ConfigBlocks.blockCosmeticSolid, 1, 11),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
new ItemStack(RegisteredBlocks.blockStoneMachine, 1, 3),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
new ItemStack(ConfigBlocks.blockCosmeticSolid, 1, 11),
|
||||
null,
|
||||
new ItemStack(ConfigBlocks.blockCosmeticSolid, 1, 11),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
new ItemStack(RegisteredBlocks.blockStoneMachine, 1, 1),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
new ItemStack(ConfigBlocks.blockCosmeticSolid, 1, 15),
|
||||
null,
|
||||
new ItemStack(ConfigBlocks.blockCosmeticSolid, 1, 15),
|
||||
null,
|
||||
null,
|
||||
new ItemStack(RegisteredBlocks.blockStoneMachine, 1, 1),
|
||||
null,
|
||||
null,
|
||||
new ItemStack(RegisteredBlocks.blockNodeManipulator, 1, 5),
|
||||
null,
|
||||
null,
|
||||
new ItemStack(RegisteredBlocks.blockStoneMachine, 1, 1),
|
||||
null,
|
||||
null,
|
||||
new ItemStack(ConfigBlocks.blockCosmeticSolid, 1, 15),
|
||||
null,
|
||||
new ItemStack(ConfigBlocks.blockCosmeticSolid, 1, 15),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
new ItemStack(RegisteredBlocks.blockStoneMachine, 1, 1),
|
||||
null,
|
||||
null,
|
||||
null));
|
||||
new ItemStack(ConfigBlocks.blockCosmeticSolid, 1, 15)));
|
||||
|
||||
RegisteredRecipes.multiblockAuraPylon = Arrays.asList(
|
||||
RegisteredRecipes.costsAuraPylonMultiblock,
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package makeo.gadomancy.common.utils.world;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
@@ -11,6 +13,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
@@ -44,17 +47,27 @@ public class TCMazeHandler {
|
||||
// If a chunk is not listed in there, it's considered empty.
|
||||
// level saving itself is disabled. Players without active session will get teleported out.
|
||||
|
||||
// Our map to work with.
|
||||
public static ConcurrentHashMap<CellLoc, Short> labyrinthCopy = new ConcurrentHashMap<CellLoc, Short>();
|
||||
public static final int TELEPORT_LAYER_Y = 55;
|
||||
private static int tickCounter;
|
||||
// Adjust these to make the dungeon shorter or longer
|
||||
// For reference: A 8x8 dungeon takes approximately 1.5 minutes to complete on average.
|
||||
// Testing was done with Boots of the Traveler and Speed II
|
||||
// The scaling is quadratic; double the size, quadruple the time.
|
||||
// Width and Height are randomized separately, making a normal distribution for the size.
|
||||
// Vanilla Thaumcraft sizes: 11-23 and 15-31
|
||||
// Original Gadomancy size: 17-21
|
||||
public static final int MIN_LABYRINTH_SIZE = 12;
|
||||
public static final int MAX_LABYRINTH_SIZE = 16;
|
||||
|
||||
public static final int LABYRINTH_BUFFER_SIZE = MAX_LABYRINTH_SIZE * 2 + 1;
|
||||
|
||||
// Our map to work with.
|
||||
public static final int TELEPORT_LAYER_Y = 55;
|
||||
public static ConcurrentHashMap<CellLoc, Short> labyrinthCopy = new ConcurrentHashMap<>();
|
||||
private static int tickCounter;
|
||||
public static final FakeWorldTCGeneration GEN = new FakeWorldTCGeneration();
|
||||
|
||||
private static List<TCMazeSession> flaggedSessions = new ArrayList<TCMazeSession>();
|
||||
|
||||
private static Map<EntityPlayer, TCMazeSession> runningSessions = new HashMap<EntityPlayer, TCMazeSession>();
|
||||
private static Map<TCMazeSession, Entity[]> watchedBosses = new HashMap<TCMazeSession, Entity[]>();
|
||||
private static final List<TCMazeSession> flaggedSessions = new ArrayList<>();
|
||||
private static Map<EntityPlayer, TCMazeSession> runningSessions = new HashMap<>();
|
||||
private static final Map<TCMazeSession, Entity[]> watchedBosses = new HashMap<>();
|
||||
|
||||
public static void closeAllSessionsAndCleanup() {
|
||||
for (EntityPlayer pl : TCMazeHandler.runningSessions.keySet()) {
|
||||
@@ -66,14 +79,14 @@ public class TCMazeHandler {
|
||||
}
|
||||
|
||||
public static void tick() {
|
||||
WorldServer w = DimensionManager.getWorld(ModConfig.dimOuterId);
|
||||
if (w != null) {
|
||||
if (!w.levelSaving) w.levelSaving = true;
|
||||
WorldServer world = DimensionManager.getWorld(ModConfig.dimOuterId);
|
||||
if (world != null) {
|
||||
if (!world.levelSaving) world.levelSaving = true;
|
||||
|
||||
WorldServer out = MinecraftServer.getServer().worldServerForDimension(0);
|
||||
List playerObjects = w.playerEntities;
|
||||
for (int i = 0; i < playerObjects.size(); i++) {
|
||||
EntityPlayer player = (EntityPlayer) playerObjects.get(i);
|
||||
// Copy to avoid CME when teleporting modifies the player list.
|
||||
List<EntityPlayer> playerObjects = new ArrayList<>(world.playerEntities);
|
||||
for (EntityPlayer player : playerObjects) {
|
||||
if (!TCMazeHandler.hasOpenSession(player)) {
|
||||
WorldUtil.tryTeleportBack((EntityPlayerMP) player, 0);
|
||||
ChunkCoordinates cc = out.getSpawnPoint();
|
||||
@@ -97,18 +110,73 @@ public class TCMazeHandler {
|
||||
}
|
||||
|
||||
public static void handleBossFinish(TCMazeSession session) {
|
||||
CellLoc spawnChunk = session.portalCell;
|
||||
WorldServer world = MinecraftServer.getServer().worldServerForDimension(ModConfig.dimOuterId);
|
||||
int lX = (spawnChunk.x << 4) + 8;
|
||||
int lZ = (spawnChunk.z << 4) + 8;
|
||||
world.setBlock(lX, 52, lZ, ConfigBlocks.blockEldritch, 3, 3);
|
||||
world.setBlock(lX, 53, lZ, RegisteredBlocks.blockAdditionalEldrichPortal);
|
||||
GenCommon.genObelisk(world, lX, 54, lZ);
|
||||
TCMazeHandler.spawnPortal(world, session.spawnPortalCoordinates, true);
|
||||
if (session.bossSpawnCoordinates != null) {
|
||||
spawnPortal(world, session.bossSpawnCoordinates, false);
|
||||
}
|
||||
session.player.addChatMessage(
|
||||
new ChatComponentText(
|
||||
EnumChatFormatting.ITALIC + ""
|
||||
+ EnumChatFormatting.GRAY
|
||||
+ StatCollector.translateToLocal("gadomancy.eldritch.portalSpawned")));
|
||||
+ StatCollector.translateToLocal("gadomancy.eldritch.maze.portalSpawned")));
|
||||
TCMazeHandler.checkHighScores(session);
|
||||
}
|
||||
|
||||
private static void spawnPortal(WorldServer world, ChunkCoordinates coords, boolean obelisk) {
|
||||
world.setBlock(coords.posX, coords.posY, coords.posZ, RegisteredBlocks.blockAdditionalEldrichPortal);
|
||||
if (obelisk) {
|
||||
world.setBlock(coords.posX, coords.posY - 1, coords.posZ, ConfigBlocks.blockEldritch, 3, 3);
|
||||
GenCommon.genObelisk(world, coords.posX, coords.posY + 1, coords.posZ);
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkHighScores(TCMazeSession session) {
|
||||
Duration mazeTime = Duration.between(session.sessionStartTime, Instant.now());
|
||||
int thisTime = (int) mazeTime.getSeconds();
|
||||
|
||||
NBTTagCompound playerData = session.player.getEntityData();
|
||||
|
||||
if (!playerData.hasKey("Gadomancy:MazeTime")) {
|
||||
playerData.setInteger("Gadomancy:MazeTime", thisTime);
|
||||
session.player.addChatMessage(
|
||||
new ChatComponentText(
|
||||
EnumChatFormatting.GRAY + ""
|
||||
+ EnumChatFormatting.ITALIC
|
||||
+ StatCollector.translateToLocalFormatted(
|
||||
"gadomancy.eldritch.maze.first",
|
||||
formatTime(thisTime))));
|
||||
return;
|
||||
}
|
||||
|
||||
int previousTime = playerData.getInteger("Gadomancy:MazeTime");
|
||||
|
||||
if (thisTime < previousTime) {
|
||||
playerData.setInteger("Gadomancy:MazeTime", thisTime);
|
||||
session.player.addChatMessage(
|
||||
new ChatComponentText(
|
||||
EnumChatFormatting.GOLD + ""
|
||||
+ EnumChatFormatting.ITALIC
|
||||
+ StatCollector.translateToLocalFormatted(
|
||||
"gadomancy.eldritch.maze.newBest",
|
||||
formatTime(thisTime),
|
||||
formatTime(previousTime))));
|
||||
} else {
|
||||
session.player.addChatMessage(
|
||||
new ChatComponentText(
|
||||
EnumChatFormatting.GRAY + ""
|
||||
+ EnumChatFormatting.ITALIC
|
||||
+ StatCollector.translateToLocalFormatted(
|
||||
"gadomancy.eldritch.maze.default",
|
||||
formatTime(thisTime),
|
||||
formatTime(previousTime))));
|
||||
}
|
||||
}
|
||||
|
||||
private static String formatTime(int totalSeconds) {
|
||||
int minutes = totalSeconds / 60;
|
||||
int seconds = totalSeconds % 60;
|
||||
return String.format("%02d:%02d", minutes, seconds);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -136,15 +204,15 @@ public class TCMazeHandler {
|
||||
|
||||
private static Map<CellLoc, Short> calculateCellLocs(WorldServer world) {
|
||||
ConcurrentHashMap<CellLoc, Short> oldDat = MazeHandler.labyrinth;
|
||||
ConcurrentHashMap<CellLoc, Short> bufferOld = new ConcurrentHashMap<CellLoc, Short>(
|
||||
TCMazeHandler.labyrinthCopy);
|
||||
ConcurrentHashMap<CellLoc, Short> bufferOld = new ConcurrentHashMap<>(TCMazeHandler.labyrinthCopy);
|
||||
MazeHandler.labyrinth = TCMazeHandler.labyrinthCopy;
|
||||
int chX = TCMazeHandler.getHighestPossibleRandWH(); // To ensure we're always +x and +z
|
||||
int chZ = TCMazeHandler.getHighestPossibleRandWH();
|
||||
int w = TCMazeHandler.randWH(world.rand);
|
||||
int h = TCMazeHandler.randWH(world.rand);
|
||||
Random rand = world.rand;
|
||||
int chX = LABYRINTH_BUFFER_SIZE; // To ensure we're always +x and +z
|
||||
int chZ = LABYRINTH_BUFFER_SIZE;
|
||||
int w = MIN_LABYRINTH_SIZE + rand.nextInt(MAX_LABYRINTH_SIZE - MIN_LABYRINTH_SIZE + 1);
|
||||
int h = MIN_LABYRINTH_SIZE + rand.nextInt(MAX_LABYRINTH_SIZE - MIN_LABYRINTH_SIZE + 1);
|
||||
while (MazeHandler.mazesInRange(chX, chZ, w, h)) {
|
||||
chX++; // We grow the mazes in +x direction!
|
||||
chX += LABYRINTH_BUFFER_SIZE; // We grow the mazes in +x direction!
|
||||
}
|
||||
MazeThread mt = new MazeThread(chX, chZ, w, h, world.rand.nextLong());
|
||||
mt.run();
|
||||
@@ -157,7 +225,7 @@ public class TCMazeHandler {
|
||||
private static Map<CellLoc, Short> calculateDifferences(ConcurrentHashMap<CellLoc, Short> bufferOld) {
|
||||
ConcurrentHashMap<CellLoc, Short> newDat = MazeHandler.labyrinth; // Only the new data has data, the old one
|
||||
// doesn't have.
|
||||
Map<CellLoc, Short> newlyEvaluatedMaze = new HashMap<CellLoc, Short>();
|
||||
Map<CellLoc, Short> newlyEvaluatedMaze = new HashMap<>();
|
||||
for (CellLoc loc : newDat.keySet()) {
|
||||
if (!bufferOld.containsKey(loc)) {
|
||||
newlyEvaluatedMaze.put(loc, newDat.get(loc));
|
||||
@@ -170,20 +238,8 @@ public class TCMazeHandler {
|
||||
return ModConfig.maxMazeCount == -1 || TCMazeHandler.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() {
|
||||
TCMazeHandler.runningSessions = new HashMap<EntityPlayer, TCMazeSession>();
|
||||
TCMazeHandler.runningSessions = new HashMap<>();
|
||||
}
|
||||
|
||||
public static boolean hasOpenSession(EntityPlayer player) {
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package makeo.gadomancy.common.utils.world;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.ChunkCoordIntPair;
|
||||
@@ -22,40 +24,47 @@ import thaumcraft.common.lib.world.dim.CellLoc;
|
||||
/**
|
||||
* This class is part of the Gadomancy Mod Gadomancy is Open Source and distributed under the GNU LESSER GENERAL PUBLIC
|
||||
* LICENSE for more read the LICENSE file
|
||||
*
|
||||
* <p/>
|
||||
* Created by HellFirePvP @ 05.11.2015 14:12
|
||||
*/
|
||||
public class TCMazeSession {
|
||||
|
||||
public final EntityPlayerMP player;
|
||||
public final Map<CellLoc, Short> chunksAffected;
|
||||
public final CellLoc portalCell;
|
||||
|
||||
public final int originDimId;
|
||||
public final Vec3 originLocation;
|
||||
public final Instant sessionStartTime;
|
||||
public final ChunkCoordinates spawnPortalCoordinates;
|
||||
public ChunkCoordinates bossSpawnCoordinates;
|
||||
|
||||
TCMazeSession(EntityPlayer owner, Map<CellLoc, Short> locations, int dim, Vec3 origin) {
|
||||
this.player = (EntityPlayerMP) owner;
|
||||
this.chunksAffected = locations;
|
||||
this.originDimId = dim;
|
||||
this.originLocation = origin;
|
||||
this.portalCell = this.findPortal();
|
||||
this.sessionStartTime = Instant.now();
|
||||
this.spawnPortalCoordinates = this.findPortal();
|
||||
this.bossSpawnCoordinates = null;
|
||||
}
|
||||
|
||||
TCMazeSession() {
|
||||
this.player = null;
|
||||
this.chunksAffected = null;
|
||||
this.portalCell = null;
|
||||
this.originDimId = 0;
|
||||
this.originLocation = null;
|
||||
this.sessionStartTime = null;
|
||||
this.spawnPortalCoordinates = null;
|
||||
this.bossSpawnCoordinates = null;
|
||||
}
|
||||
|
||||
private CellLoc findPortal() {
|
||||
for (CellLoc loc : this.chunksAffected.keySet()) {
|
||||
Short s = this.chunksAffected.get(loc);
|
||||
Cell c = new Cell(s);
|
||||
if (c.feature == 1) {
|
||||
return loc;
|
||||
private ChunkCoordinates findPortal() {
|
||||
for (CellLoc chunk : this.chunksAffected.keySet()) {
|
||||
Short s = this.chunksAffected.get(chunk);
|
||||
Cell cell = new Cell(s);
|
||||
if (cell.feature == 1) {
|
||||
int x = (chunk.x * 16) + 8;
|
||||
int z = (chunk.z * 16) + 8;
|
||||
return new ChunkCoordinates(x, TCMazeHandler.TELEPORT_LAYER_Y - 2, z);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -84,7 +93,7 @@ public class TCMazeSession {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.portalCell == null) {
|
||||
if (this.spawnPortalCoordinates == null) {
|
||||
LogManager.getLogger().error(
|
||||
"Thaumcraft didn't generate a portal! Stopping instance! PLEASE REPORT THIS ERROR!",
|
||||
new IllegalStateException());
|
||||
@@ -95,9 +104,10 @@ public class TCMazeSession {
|
||||
+ "Thaumcraft didn't generate a portal in the Eldritch dimension. Sorry, we can't teleport you.."));
|
||||
} else {
|
||||
WorldUtil.teleportToFakeOuter(this.player);
|
||||
int x = this.portalCell.x * 16 + 8;
|
||||
int z = this.portalCell.z * 16 + 8;
|
||||
this.player.setPositionAndUpdate(x + 0.5, TCMazeHandler.TELEPORT_LAYER_Y, z + 0.5);
|
||||
this.player.setPositionAndUpdate(
|
||||
this.spawnPortalCoordinates.posX + 0.5,
|
||||
TCMazeHandler.TELEPORT_LAYER_Y,
|
||||
this.spawnPortalCoordinates.posZ + 0.5);
|
||||
Thaumcraft.proxy.getResearchManager().completeResearch(this.player, "ENTEROUTER"); // badumm tss
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user