diff --git a/src/main/java/makeo/gadomancy/common/blocks/BlockNodeManipulator.java b/src/main/java/makeo/gadomancy/common/blocks/BlockNodeManipulator.java
index 85edba1..bcf3383 100644
--- a/src/main/java/makeo/gadomancy/common/blocks/BlockNodeManipulator.java
+++ b/src/main/java/makeo/gadomancy/common/blocks/BlockNodeManipulator.java
@@ -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);
}
}
diff --git a/src/main/java/makeo/gadomancy/common/blocks/tiles/TileAdditionalEldritchPortal.java b/src/main/java/makeo/gadomancy/common/blocks/tiles/TileAdditionalEldritchPortal.java
index ad4dd0d..3965327 100644
--- a/src/main/java/makeo/gadomancy/common/blocks/tiles/TileAdditionalEldritchPortal.java
+++ b/src/main/java/makeo/gadomancy/common/blocks/tiles/TileAdditionalEldritchPortal.java
@@ -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
- *
+ *
* Created by makeo @ 06.11.2015 23:32
*/
public class TileAdditionalEldritchPortal extends TileEldritchPortal {
- private static Map trackedPortalActivity = new HashMap();
+ private static final Map trackedPortalActivity = new HashMap<>();
private EntityPlayer toTeleport;
private int count;
+ private final Map 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 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 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;
diff --git a/src/main/java/makeo/gadomancy/common/blocks/tiles/TileNodeManipulator.java b/src/main/java/makeo/gadomancy/common/blocks/tiles/TileNodeManipulator.java
index 37aac56..fb07a56 100644
--- a/src/main/java/makeo/gadomancy/common/blocks/tiles/TileNodeManipulator.java
+++ b/src/main/java/makeo/gadomancy/common/blocks/tiles/TileNodeManipulator.java
@@ -2,7 +2,6 @@ package makeo.gadomancy.common.blocks.tiles;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -41,197 +40,249 @@ import thaumcraft.common.tiles.TileWandPedestal;
/**
* 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
- *
+ *
* Created by HellFirePvP @ 26.10.2015 20:16
*/
public class TileNodeManipulator extends TileWandPedestal implements IWandable {
- private static final int NODE_MANIPULATION_POSSIBLE_WORK_START = 70;
- private static final int NODE_MANIPULATION_WORK_ASPECT_CAP = 120;
+ // WARNING: the ratio between manipulation cap and start affect the improvement of the node
+ private static final int NODE_MANIPULATION_WORK_START = 70;
+ private static final int NODE_MANIPULATION_ASPECT_CAP = 120;
+ private static final int NODE_MANIPULATION_TICKS = 300;
- private static final int ELDRITCH_PORTAL_CREATOR_WORK_START = 120;
- private static final int ELDRITCH_PORTAL_CREATOR_ASPECT_CAP = 150;
+ // There is no change for having more than the required aspects to form a portal
+ private static final int ELDRITCH_PORTAL_ASPECT_REQUIREMENT = 120;
+ private static final int ELDRITCH_PORTAL_TICKS = 400;
+
+ private static final int REQUIRED_ELDRITCH_PEDESTALS = 4;
+
+ private static final Vec3[] PILLAR_OFFSETS = { Vec3.createVectorHelper(0.7, -0.6, 0.7),
+ Vec3.createVectorHelper(-0.7, -0.6, 0.7), Vec3.createVectorHelper(-0.7, -0.6, -0.7),
+ Vec3.createVectorHelper(0.7, -0.6, -0.7), };
- // Already set when only multiblock would be present. aka is set, if 'isMultiblockPresent()' returns true.
private MultiblockType multiblockType;
- private boolean multiblockStructurePresent;
private boolean isMultiblock;
private AspectList workAspectList = new AspectList();
-
- private List bufferedCCPedestals = new ArrayList();
-
private boolean isWorking;
private int workTick;
+ private final List bufferedCCPedestals = new ArrayList<>();
+
+ // -------------------------------------------------------------------------
+ // Update loop
+ // -------------------------------------------------------------------------
+
@Override
public void updateEntity() {
-
if (this.worldObj.isRemote) return;
- if (this.isInMultiblock()) {
- this.checkMultiblockTick();
- }
- if (this.isInMultiblock()) {
- this.multiblockTick();
- }
+ if (!this.isInMultiblock()) return;
+
+ this.multiblockTick();
}
private void multiblockTick() {
- if (this.multiblockType == null) {
- if (MultiblockHelper.isMultiblockPresent(
- this.worldObj,
- this.xCoord,
- this.yCoord,
- this.zCoord,
- RegisteredMultiblocks.completeNodeManipulatorMultiblock)) {
- this.multiblockType = MultiblockType.NODE_MANIPULATOR;
- } else if (MultiblockHelper.isMultiblockPresent(
- this.worldObj,
- this.xCoord,
- this.yCoord,
- this.zCoord,
- RegisteredMultiblocks.completeEldritchPortalCreator) && this.checkEldritchEyes(false)) {
- this.multiblockType = MultiblockType.E_PORTAL_CREATOR;
- }
- }
- if (this.multiblockType == null) {
+ if (!this.isMultiblockPresent()) {
this.breakMultiblock();
+ this.isMultiblock = false;
+ this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
+ this.markDirty();
return;
}
+
switch (this.multiblockType) {
case NODE_MANIPULATOR:
if (!this.isWorking) {
- this.doAspectChecks(
- TileNodeManipulator.NODE_MANIPULATION_WORK_ASPECT_CAP,
- TileNodeManipulator.NODE_MANIPULATION_POSSIBLE_WORK_START);
- } else {
+ this.doAspectChecks(NODE_MANIPULATION_ASPECT_CAP, NODE_MANIPULATION_WORK_START);
+ } else if (this.workTick > 0 || this.hasNode()) {
this.manipulationTick();
}
break;
+
case E_PORTAL_CREATOR:
if (!this.isWorking) {
- this.doAspectChecks(
- TileNodeManipulator.ELDRITCH_PORTAL_CREATOR_ASPECT_CAP,
- TileNodeManipulator.ELDRITCH_PORTAL_CREATOR_WORK_START);
- } else {
- if (!this.checkEldritchEyes(true)) {
- if (this.workTick > 1) {
- this.workAspectList = new AspectList();
- this.workTick = 0;
- this.isWorking = false;
- this.markDirty();
- this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
- }
- return;
- }
- this.eldritchPortalCreationTick();
+ this.doAspectChecks(ELDRITCH_PORTAL_ASPECT_REQUIREMENT, ELDRITCH_PORTAL_ASPECT_REQUIREMENT);
+ } else if (this.workTick > 0 || (this.hasNode() && this.checkPedestalsAndEyes())) {
+ this.eldritchPortalCreatorTick();
}
break;
}
}
- private boolean checkEldritchEyes(boolean checkForEyes) {
- this.bufferedCCPedestals.clear();
+ private boolean isMultiblockPresent() {
+ if (multiblockType == null) return false;
- int validPedestalsFound = 0;
-
- labelIt: for (int xDiff = -8; xDiff <= 8; xDiff++) {
- labelZ: for (int zDiff = -8; zDiff <= 8; zDiff++) {
- for (int yDiff = -5; yDiff <= 10; yDiff++) {
- int itX = this.xCoord + xDiff;
- int itY = this.yCoord + yDiff;
- int itZ = this.zCoord + zDiff;
-
- Block block = this.worldObj.getBlock(itX, itY, itZ);
- int meta = this.worldObj.getBlockMetadata(itX, itY, itZ);
- TileEntity te = this.worldObj.getTileEntity(itX, itY, itZ);
- if (block != null && block.equals(RegisteredBlocks.blockStoneMachine)
- && meta == 1
- && te != null
- && te instanceof TilePedestal
- && (!checkForEyes || this.checkTile((TilePedestal) te))) {
- validPedestalsFound++;
- this.bufferedCCPedestals.add(new ChunkCoordinates(itX, itY, itZ));
- if (validPedestalsFound >= 4) {
- break labelIt;
- }
- continue labelZ;
- }
- }
- }
- }
- return validPedestalsFound >= 4;
- }
-
- private boolean checkTile(TilePedestal te) {
- ItemStack stack = te.getStackInSlot(0);
- return !(stack == null || stack.getItem() != ConfigItems.itemEldritchObject || stack.getItemDamage() != 0);
- }
-
- private void eldritchPortalCreationTick() {
- this.workTick++;
- if (this.workTick < 400) {
- if ((this.workTick & 15) == 0) {
- PacketStartAnimation packet = new PacketStartAnimation(
- PacketStartAnimation.ID_RUNES,
+ switch (this.multiblockType) {
+ case NODE_MANIPULATOR:
+ if (MultiblockHelper.isMultiblockPresent(
+ this.worldObj,
this.xCoord,
this.yCoord,
this.zCoord,
- (byte) 1);
- PacketHandler.INSTANCE.sendToAllAround(packet, this.getTargetPoint(32));
+ RegisteredMultiblocks.completeNodeManipulatorMultiblock)) {
+ return true;
+ }
+ break;
+ case E_PORTAL_CREATOR:
+ if (MultiblockHelper.isMultiblockPresent(
+ this.worldObj,
+ this.xCoord,
+ this.yCoord,
+ this.zCoord,
+ RegisteredMultiblocks.completeEldritchPortalCreator)) {
+ return true;
+ }
+ break;
+ }
+ return false;
+ }
+
+ // -------------------------------------------------------------------------
+ // Node Randomization
+ // -------------------------------------------------------------------------
+
+ private void manipulationTick() {
+ if (!this.hasNode()) {
+ // node was removed mid-operation; abort
+ this.resetWorkState();
+ return;
+ }
+
+ this.workTick++;
+ this.manipulationAnimationTick();
+ }
+
+ private void manipulationAnimationTick() {
+ if (this.workTick < NODE_MANIPULATION_TICKS) {
+ // Periodic rune animation
+ if (this.workTick % 16 == 0) {
+ this.sendRuneAnimation(this.xCoord, this.yCoord, this.zCoord, (byte) 0);
}
- if ((this.workTick & 7) == 0) {
- int index = (this.workTick >> 3) & 3;
- try {
- ChunkCoordinates cc = this.bufferedCCPedestals.get(index);
- PacketStartAnimation packet = new PacketStartAnimation(
- PacketStartAnimation.ID_RUNES,
- cc.posX,
- cc.posY,
- cc.posZ,
- (byte) 1);
- PacketHandler.INSTANCE.sendToAllAround(packet, this.getTargetPoint(32));
- } catch (Exception exc) {}
- }
- if (this.worldObj.rand.nextBoolean()) {
- Vec3 rel = this.getRelPillarLoc(this.worldObj.rand.nextInt(4));
- PacketTCNodeBolt bolt = new PacketTCNodeBolt(
+ // Random bolt FX toward one of the four pillars
+ if (this.worldObj.rand.nextInt(4) == 0) {
+ Vec3 rel = PILLAR_OFFSETS[this.worldObj.rand.nextInt(4)];
+ this.sendNodeBolt(
this.xCoord + 0.5F,
this.yCoord + 2.5F,
this.zCoord + 0.5F,
(float) (this.xCoord + 0.5F + rel.xCoord),
(float) (this.yCoord + 2.5F + rel.yCoord),
(float) (this.zCoord + 0.5F + rel.zCoord),
- 2,
- false);
- PacketHandler.INSTANCE.sendToAllAround(bolt, this.getTargetPoint(32));
- }
- if (this.worldObj.rand.nextInt(4) == 0) {
- Vec3 relPed = this.getRelPedestalLoc(this.worldObj.rand.nextInt(4));
- PacketTCNodeBolt bolt = new PacketTCNodeBolt(
- this.xCoord + 0.5F,
- this.yCoord + 2.5F,
- this.zCoord + 0.5F,
- (float) (this.xCoord + 0.5F - relPed.xCoord),
- (float) (this.yCoord + 1.5 + relPed.yCoord),
- (float) (this.zCoord + 0.5F - relPed.zCoord),
- 2,
- false);
- PacketHandler.INSTANCE.sendToAllAround(bolt, this.getTargetPoint(32));
+ 0);
}
} else {
- this.schedulePortalCreation();
+ this.finishManipulation();
}
}
- private void schedulePortalCreation() {
- this.workTick = 0;
- this.isWorking = false;
- this.workAspectList = new AspectList();
+ private void finishManipulation() {
+ float overSized = this.calcOversize();
+ this.resetWorkState();
TileEntity te = this.worldObj.getTileEntity(this.xCoord, this.yCoord + 2, this.zCoord);
- if (te == null || !(te instanceof INode)) return;
+ if (!(te instanceof INode node)) {
+ return;
+ }
+
+ int areaRange = NODE_MANIPULATION_ASPECT_CAP - NODE_MANIPULATION_WORK_START;
+ int improvementChance = (int) (overSized / (float) areaRange * 100);
+
+ NodeManipulatorResult result;
+ do {
+ result = NodeManipulatorResultHandler.getRandomResult(this.worldObj, node, improvementChance);
+ } while (!result.affect(this.worldObj, node));
+
+ PacketHandler.INSTANCE.sendToAllAround(
+ new PacketStartAnimation(
+ PacketStartAnimation.ID_SPARKLE_SPREAD,
+ this.xCoord,
+ this.yCoord + 2,
+ this.zCoord),
+ this.getTargetPoint(32));
+
+ this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
+ this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord + 2, this.zCoord);
+ this.markDirty();
+ ((TileEntity) node).markDirty();
+ }
+
+ /**
+ * Returns the average amount by which the collected aspects exceed the minimum work threshold, used to scale the
+ * probability of getting a better manipulation result.
+ */
+ private float calcOversize() {
+ int total = 0;
+ for (Aspect a : Aspect.getPrimalAspects()) {
+ total += this.workAspectList.getAmount(a) - TileNodeManipulator.NODE_MANIPULATION_WORK_START;
+ }
+ return total / 6F;
+ }
+
+ // -------------------------------------------------------------------------
+ // Node Redirection
+ // -------------------------------------------------------------------------
+
+ private void eldritchPortalCreatorTick() {
+ if (!this.checkPedestalsAndEyes() || !this.hasNode()) {
+ // Eyes or node were removed mid-operation; abort
+ this.resetWorkState();
+ return;
+ }
+
+ this.workTick++;
+ this.eldritchPortalAnimationTick();
+ }
+
+ private void eldritchPortalAnimationTick() {
+ if (this.workTick >= ELDRITCH_PORTAL_TICKS) {
+ this.finishEldritchPortal();
+ return;
+ }
+
+ // Rune animation at the manipulator every 16 ticks
+ if ((this.workTick & 15) == 0) {
+ this.sendRuneAnimation(this.xCoord, this.yCoord, this.zCoord, (byte) 1);
+ }
+ // Rune animation cycling through the four pedestals every 8 ticks
+ if ((this.workTick & 7) == 0) {
+ int index = (this.workTick >> 3) & 3;
+ if (index < this.bufferedCCPedestals.size()) {
+ ChunkCoordinates cc = this.bufferedCCPedestals.get(index);
+ this.sendRuneAnimation(cc.posX, cc.posY, cc.posZ, (byte) 1);
+ }
+ }
+ // Random bolt FX toward a pillar
+ if (this.worldObj.rand.nextBoolean()) {
+ Vec3 rel = PILLAR_OFFSETS[this.worldObj.rand.nextInt(4)];
+ this.sendNodeBolt(
+ this.xCoord + 0.5F,
+ this.yCoord + 2.5F,
+ this.zCoord + 0.5F,
+ (float) (this.xCoord + 0.5F + rel.xCoord),
+ (float) (this.yCoord + 2.5F + rel.yCoord),
+ (float) (this.zCoord + 0.5F + rel.zCoord),
+ 2);
+ }
+ // Random bolt FX toward a pedestal
+ if (this.worldObj.rand.nextInt(4) == 0) {
+ Vec3 relPed = this.getPedestalOffset(this.worldObj.rand.nextInt(4));
+ this.sendNodeBolt(
+ this.xCoord + 0.5F,
+ this.yCoord + 2.5F,
+ this.zCoord + 0.5F,
+ (float) (this.xCoord + 0.5F - relPed.xCoord),
+ (float) (this.yCoord + 1.5 + relPed.yCoord),
+ (float) (this.zCoord + 0.5F - relPed.zCoord),
+ 2);
+ }
+ }
+
+ private void finishEldritchPortal() {
+ this.resetWorkState();
+
+ TileEntity te = this.worldObj.getTileEntity(this.xCoord, this.yCoord + 2, this.zCoord);
+ if (!(te instanceof INode)) return;
this.consumeEldritchEyes();
@@ -245,117 +296,76 @@ public class TileNodeManipulator extends TileWandPedestal implements IWandable {
this.markDirty();
}
+ private boolean checkPedestalsAndEyes() {
+ if (this.bufferedCCPedestals.size() >= REQUIRED_ELDRITCH_PEDESTALS) {
+ for (ChunkCoordinates cc : this.bufferedCCPedestals) {
+ TileEntity te = this.worldObj.getTileEntity(cc.posX, cc.posY, cc.posZ);
+ if (!(te instanceof TilePedestal) || !pedestalHasEldritchEye((TilePedestal) te)) {
+ this.bufferedCCPedestals.clear();
+ return false;
+ }
+ }
+ return true;
+ }
+
+ this.bufferedCCPedestals.clear();
+
+ outer: for (int xDiff = -8; xDiff <= 8; xDiff++) {
+ for (int zDiff = -8; zDiff <= 8; zDiff++) {
+ for (int yDiff = -5; yDiff <= 10; yDiff++) {
+ int itX = this.xCoord + xDiff;
+ int itY = this.yCoord + yDiff;
+ int itZ = this.zCoord + zDiff;
+
+ Block block = this.worldObj.getBlock(itX, itY, itZ);
+ int meta = this.worldObj.getBlockMetadata(itX, itY, itZ);
+ TileEntity te = this.worldObj.getTileEntity(itX, itY, itZ);
+
+ boolean isPedestal = block != null && block.equals(RegisteredBlocks.blockStoneMachine)
+ && meta == 1
+ && te instanceof TilePedestal
+ && this.pedestalHasEldritchEye((TilePedestal) te);
+
+ if (isPedestal) {
+ this.bufferedCCPedestals.add(new ChunkCoordinates(itX, itY, itZ));
+ if (this.bufferedCCPedestals.size() >= REQUIRED_ELDRITCH_PEDESTALS) {
+ break outer;
+ }
+ break; // Only one valid pedestal per Y column
+ }
+ }
+ }
+ }
+
+ return this.bufferedCCPedestals.size() >= REQUIRED_ELDRITCH_PEDESTALS;
+ }
+
+ private boolean pedestalHasEldritchEye(TilePedestal pedestal) {
+ ItemStack stack = pedestal.getStackInSlot(0);
+ return stack != null && stack.getItem() == ConfigItems.itemEldritchObject && stack.getItemDamage() == 0;
+ }
+
private void consumeEldritchEyes() {
+ NetworkRegistry.TargetPoint target = this.getTargetPoint(32);
for (ChunkCoordinates cc : this.bufferedCCPedestals) {
- try {
- TilePedestal pedestal = (TilePedestal) this.worldObj.getTileEntity(cc.posX, cc.posY, cc.posZ);
- pedestal.setInventorySlotContents(0, null);
- PacketStartAnimation packet = new PacketStartAnimation(
- PacketStartAnimation.ID_SPARKLE_SPREAD,
- cc.posX,
- cc.posY,
- cc.posZ);
- PacketHandler.INSTANCE.sendToAllAround(packet, this.getTargetPoint(32));
- } catch (Exception exc) {}
+ TileEntity te = this.worldObj.getTileEntity(cc.posX, cc.posY, cc.posZ);
+ if (!(te instanceof TilePedestal)) continue;
+ ((TilePedestal) te).setInventorySlotContents(0, null);
+ PacketHandler.INSTANCE.sendToAllAround(
+ new PacketStartAnimation(PacketStartAnimation.ID_SPARKLE_SPREAD, cc.posX, cc.posY, cc.posZ),
+ target);
}
}
- private void manipulationTick() {
- this.workTick++;
- if (this.workTick < 300) {
- if (this.workTick % 16 == 0) {
- PacketStartAnimation packet = new PacketStartAnimation(
- PacketStartAnimation.ID_RUNES,
- this.xCoord,
- this.yCoord,
- this.zCoord);
- PacketHandler.INSTANCE.sendToAllAround(packet, this.getTargetPoint(32));
- }
- if (this.worldObj.rand.nextInt(4) == 0) {
- Vec3 rel = this.getRelPillarLoc(this.worldObj.rand.nextInt(4));
- PacketTCNodeBolt bolt = new PacketTCNodeBolt(
- this.xCoord + 0.5F,
- this.yCoord + 2.5F,
- this.zCoord + 0.5F,
- (float) (this.xCoord + 0.5F + rel.xCoord),
- (float) (this.yCoord + 2.5F + rel.yCoord),
- (float) (this.zCoord + 0.5F + rel.zCoord),
- 0,
- false);
- PacketHandler.INSTANCE.sendToAllAround(bolt, this.getTargetPoint(32));
- }
- } else {
- this.scheduleManipulation();
- }
- }
-
- private Vec3 getRelPedestalLoc(int pedestalId) {
- try {
- ChunkCoordinates cc = this.bufferedCCPedestals.get(pedestalId);
- return Vec3.createVectorHelper(this.xCoord - cc.posX, this.yCoord - cc.posY, this.zCoord - cc.posZ);
- } catch (Exception exc) {}
- return Vec3.createVectorHelper(0, 0, 0);
- }
-
- private Vec3 getRelPillarLoc(int pillarId) {
- switch (pillarId) {
- case 0:
- return Vec3.createVectorHelper(0.7, -0.6, 0.7);
- case 1:
- return Vec3.createVectorHelper(-0.7, -0.6, 0.7);
- case 2:
- return Vec3.createVectorHelper(-0.7, -0.6, -0.7);
- case 3:
- return Vec3.createVectorHelper(0.7, -0.6, -0.7);
- }
- return Vec3.createVectorHelper(0, 0, 0);
- }
-
- private void scheduleManipulation() {
- float overSized = this.calcOversize(TileNodeManipulator.NODE_MANIPULATION_POSSIBLE_WORK_START);
-
- this.workTick = 0;
- this.isWorking = false;
- this.workAspectList = new AspectList();
-
- TileEntity te = this.worldObj.getTileEntity(this.xCoord, this.yCoord + 2, this.zCoord);
- if (te == null || !(te instanceof INode)) return;
- INode node = (INode) te;
- int areaRange = TileNodeManipulator.NODE_MANIPULATION_WORK_ASPECT_CAP
- - TileNodeManipulator.NODE_MANIPULATION_POSSIBLE_WORK_START;
- int percChanceForBetter = 0;
- if (areaRange > 0) {
- percChanceForBetter = (int) ((overSized / ((float) areaRange)) * 100);
- }
- NodeManipulatorResult result;
- do {
- result = NodeManipulatorResultHandler.getRandomResult(this.worldObj, node, percChanceForBetter);
- } while (!result.affect(this.worldObj, node));
- PacketStartAnimation packet = new PacketStartAnimation(
- PacketStartAnimation.ID_SPARKLE_SPREAD,
- this.xCoord,
- this.yCoord + 2,
- this.zCoord);
- PacketHandler.INSTANCE.sendToAllAround(packet, this.getTargetPoint(32));
- this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
- this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord + 2, this.zCoord);
- this.markDirty();
- ((TileEntity) node).markDirty();
- }
-
- private float calcOversize(int neededAspects) {
- int overall = 0;
- for (Aspect a : Aspect.getPrimalAspects()) {
- overall += this.workAspectList.getAmount(a) - neededAspects;
- }
- return ((float) overall) / 6F;
- }
+ // -------------------------------------------------------------------------
+ // Wand Handling
+ // -------------------------------------------------------------------------
private void doAspectChecks(int aspectCap, int possibleWorkStart) {
if (this.canDrainFromWand(aspectCap)) {
- Aspect a = this.drainAspectFromWand(aspectCap);
- if (a != null) {
- this.playAspectDrainFromWand(a);
+ Aspect drained = this.drainAspectFromWand(aspectCap);
+ if (drained != null) {
+ this.playAspectDrainFX(drained);
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
this.markDirty();
}
@@ -364,27 +374,36 @@ public class TileNodeManipulator extends TileWandPedestal implements IWandable {
}
}
- private void checkIfEnoughVis(int start) {
- boolean enough = true;
+ private void checkIfEnoughVis(int requiredPerAspect) {
for (Aspect a : Aspect.getPrimalAspects()) {
- if (this.workAspectList.getAmount(a) < start) {
- enough = false;
- break;
- }
+ if (this.workAspectList.getAmount(a) < requiredPerAspect) return;
}
- if (enough) {
- this.isWorking = true;
+ this.isWorking = true;
+ }
+
+ private boolean canDrainFromWand(int cap) {
+ ItemStack stack = this.getStackInSlot(0);
+ if (!(stack != null && stack.getItem() instanceof ItemWandCasting)) return false;
+
+ AspectList aspects = ((ItemWandCasting) stack.getItem()).getAllVis(stack);
+ for (Aspect a : Aspect.getPrimalAspects()) {
+ if (aspects.getAmount(a) >= 100 && this.workAspectList.getAmount(a) < cap) return true;
}
+ return false;
}
private Aspect drainAspectFromWand(int cap) {
ItemStack stack = this.getStackInSlot(0);
- if (stack == null || !(stack.getItem() instanceof ItemWandCasting)) return null; // Should never happen..
- AspectList aspects = ((ItemWandCasting) stack.getItem()).getAllVis(stack);
- for (Aspect a : this.getRandomlyOrderedPrimalAspectList()) {
+ if (!(stack != null && stack.getItem() instanceof ItemWandCasting wand)) return null;
+
+ AspectList aspects = wand.getAllVis(stack);
+
+ List shuffled = new ArrayList<>(Aspect.getPrimalAspects());
+ Collections.shuffle(shuffled);
+
+ for (Aspect a : shuffled) {
if (aspects.getAmount(a) >= 100 && this.workAspectList.getAmount(a) < cap) {
- int amt = aspects.getAmount(a);
- ((ItemWandCasting) stack.getItem()).storeVis(stack, a, amt - 100);
+ wand.storeVis(stack, a, aspects.getAmount(a) - 100);
this.workAspectList.add(a, 1);
return a;
}
@@ -392,104 +411,14 @@ public class TileNodeManipulator extends TileWandPedestal implements IWandable {
return null;
}
- private List getRandomlyOrderedPrimalAspectList() {
- ArrayList primals = (ArrayList) Aspect.getPrimalAspects().clone();
- Collections.shuffle(primals);
- return primals;
- }
-
- private boolean canDrainFromWand(int cap) {
- ItemStack stack = this.getStackInSlot(0);
- if (stack == null || !(stack.getItem() instanceof ItemWandCasting)) return false;
- AspectList aspects = ((ItemWandCasting) stack.getItem()).getAllVis(stack);
- for (Aspect a : Aspect.getPrimalAspects()) {
- if (aspects.getAmount(a) < 100) continue;
- if (this.workAspectList.getAmount(a) < cap) return true;
- }
- return false;
- }
-
- private void checkMultiblockTick() {
- this.checkMultiblock();
- if (!this.isMultiblockStructurePresent()) {
- this.breakMultiblock();
- this.isMultiblock = false;
- this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
- this.markDirty();
- }
- }
-
- private void playAspectDrainFromWand(Aspect drained) {
- if (drained == null) return;
- NetworkRegistry.TargetPoint point = this.getTargetPoint(32);
- PacketTCWispyLine line = new PacketTCWispyLine(
- this.worldObj.provider.dimensionId,
- this.xCoord + 0.5,
- this.yCoord + 0.8,
- this.zCoord + 0.5,
- this.xCoord + 0.5,
- this.yCoord + 1.4 + (((double) this.worldObj.rand.nextInt(4)) / 10D),
- this.zCoord + 0.5,
- 40,
- drained.getColor());
- PacketHandler.INSTANCE.sendToAllAround(line, point);
- }
-
- private void dropWand() {
- if (this.getStackInSlot(0) != null)
- InventoryUtils.dropItems(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
- }
-
- public void breakMultiblock() {
- MultiblockHelper.MultiblockPattern compareableCompleteStructure, toRestore;
- if (this.multiblockType == null) {
- this.workAspectList = new AspectList();
- this.dropWand();
- this.workTick = 0;
- this.isWorking = false;
- return;
- }
- switch (this.multiblockType) {
- case NODE_MANIPULATOR:
- compareableCompleteStructure = RegisteredMultiblocks.completeNodeManipulatorMultiblock;
- toRestore = RegisteredMultiblocks.incompleteNodeManipulatorMultiblock;
- break;
- case E_PORTAL_CREATOR:
- compareableCompleteStructure = RegisteredMultiblocks.completeEldritchPortalCreator;
- toRestore = RegisteredMultiblocks.incompleteEldritchPortalCreator;
- break;
- default:
- return;
- }
- for (MultiblockHelper.IntVec3 v : compareableCompleteStructure.keySet()) {
- MultiblockHelper.BlockInfo info = compareableCompleteStructure.get(v);
- MultiblockHelper.BlockInfo restoreInfo = toRestore.get(v);
- if (info.block == RegisteredBlocks.blockNode
- || (info.block == RegisteredBlocks.blockStoneMachine && (info.meta == 0 || info.meta == 3))
- || info.block == Blocks.air
- || info.block == RegisteredBlocks.blockNodeManipulator)
- continue;
- int absX = v.x + this.xCoord;
- int absY = v.y + this.yCoord;
- int absZ = v.z + this.zCoord;
- if (this.worldObj.getBlock(absX, absY, absZ) == info.block
- && this.worldObj.getBlockMetadata(absX, absY, absZ) == info.meta) {
- this.worldObj.setBlock(absX, absY, absZ, Blocks.air, 0, 0);
- this.worldObj.setBlock(absX, absY, absZ, restoreInfo.block, restoreInfo.meta, 0);
- this.worldObj.markBlockForUpdate(absX, absY, absZ);
- }
- }
-
- this.workAspectList = new AspectList();
- this.multiblockType = null;
- this.dropWand();
- this.workTick = 0;
- this.isWorking = false;
- }
+ // -------------------------------------------------------------------------
+ // Breaking and Forming Multiblock
+ // -------------------------------------------------------------------------
public void formMultiblock() {
- MultiblockHelper.MultiblockPattern toBuild;
if (this.multiblockType == null) return;
+
+ MultiblockHelper.MultiblockPattern toBuild;
switch (this.multiblockType) {
case NODE_MANIPULATOR:
toBuild = RegisteredMultiblocks.completeNodeManipulatorMultiblock;
@@ -500,66 +429,181 @@ public class TileNodeManipulator extends TileWandPedestal implements IWandable {
default:
return;
}
- for (MultiblockHelper.IntVec3 v : toBuild.keySet()) {
- MultiblockHelper.BlockInfo info = toBuild.get(v);
- if (info.block == RegisteredBlocks.blockNode
- || (info.block == RegisteredBlocks.blockStoneMachine
- && (info.meta == 0 || info.meta == 1 || info.meta == 3))
- || info.block == Blocks.air
- || info.block == RegisteredBlocks.blockNodeManipulator)
- continue;
+
+ for (Map.Entry entry : toBuild.entrySet()) {
+ MultiblockHelper.IntVec3 v = entry.getKey();
+ MultiblockHelper.BlockInfo info = entry.getValue();
+
+ if (this.shouldSkip(info)) continue;
+
int absX = v.x + this.xCoord;
int absY = v.y + this.yCoord;
int absZ = v.z + this.zCoord;
+
this.worldObj.setBlock(absX, absY, absZ, Blocks.air, 0, 0);
this.worldObj.setBlock(absX, absY, absZ, info.block, info.meta, 0);
this.worldObj.markBlockForUpdate(absX, absY, absZ);
}
+
NetworkRegistry.TargetPoint target = this.getTargetPoint(32);
- TileManipulatorPillar pillar = (TileManipulatorPillar) this.worldObj
- .getTileEntity(this.xCoord + 1, this.yCoord, this.zCoord + 1); // wrong
- pillar.setOrientation((byte) 5);
- PacketStartAnimation animation = new PacketStartAnimation(
- PacketStartAnimation.ID_RUNES,
- pillar.xCoord,
- pillar.yCoord,
- pillar.zCoord);
- PacketHandler.INSTANCE.sendToAllAround(animation, target);
- TileManipulatorPillar pillar2 = (TileManipulatorPillar) this.worldObj
- .getTileEntity(this.xCoord - 1, this.yCoord, this.zCoord + 1);
- pillar2.setOrientation((byte) 3);
- animation = new PacketStartAnimation(
- PacketStartAnimation.ID_RUNES,
- pillar2.xCoord,
- pillar2.yCoord,
- pillar2.zCoord);
- PacketHandler.INSTANCE.sendToAllAround(animation, target);
- TileManipulatorPillar pillar3 = (TileManipulatorPillar) this.worldObj
- .getTileEntity(this.xCoord + 1, this.yCoord, this.zCoord - 1); // wrong
- pillar3.setOrientation((byte) 4);
- animation = new PacketStartAnimation(
- PacketStartAnimation.ID_RUNES,
- pillar3.xCoord,
- pillar3.yCoord,
- pillar3.zCoord);
- PacketHandler.INSTANCE.sendToAllAround(animation, target);
- animation = new PacketStartAnimation(
- PacketStartAnimation.ID_RUNES,
- this.xCoord - 1,
- this.yCoord,
- this.zCoord - 1);
- PacketHandler.INSTANCE.sendToAllAround(animation, target);
+
+ this.orientAndAnimatePillar(this.xCoord + 1, this.yCoord, this.zCoord + 1, (byte) 5, target);
+ this.orientAndAnimatePillar(this.xCoord + 1, this.yCoord, this.zCoord - 1, (byte) 4, target);
+ this.orientAndAnimatePillar(this.xCoord - 1, this.yCoord, this.zCoord + 1, (byte) 3, target);
+ PacketHandler.INSTANCE.sendToAllAround(
+ new PacketStartAnimation(PacketStartAnimation.ID_RUNES, this.xCoord - 1, this.yCoord, this.zCoord - 1),
+ target);
+
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
this.markDirty();
this.isMultiblock = true;
}
+ public void breakMultiblock() {
+ if (this.multiblockType == null) {
+ this.resetWorkState();
+ this.dropWand();
+ return;
+ }
+
+ MultiblockHelper.MultiblockPattern complete;
+ MultiblockHelper.MultiblockPattern incomplete;
+
+ switch (this.multiblockType) {
+ case NODE_MANIPULATOR:
+ complete = RegisteredMultiblocks.completeNodeManipulatorMultiblock;
+ incomplete = RegisteredMultiblocks.incompleteNodeManipulatorMultiblock;
+ break;
+ case E_PORTAL_CREATOR:
+ complete = RegisteredMultiblocks.completeEldritchPortalCreator;
+ incomplete = RegisteredMultiblocks.incompleteEldritchPortalCreator;
+ break;
+ default:
+ return;
+ }
+
+ for (Map.Entry entry : complete.entrySet()) {
+ MultiblockHelper.IntVec3 v = entry.getKey();
+ MultiblockHelper.BlockInfo info = entry.getValue();
+ MultiblockHelper.BlockInfo restoreInfo = incomplete.get(v);
+
+ if (this.shouldSkip(info)) continue;
+
+ int absX = v.x + this.xCoord;
+ int absY = v.y + this.yCoord;
+ int absZ = v.z + this.zCoord;
+
+ if (this.worldObj.getBlock(absX, absY, absZ) == info.block
+ && this.worldObj.getBlockMetadata(absX, absY, absZ) == info.meta) {
+ this.worldObj.setBlock(absX, absY, absZ, Blocks.air, 0, 0);
+ this.worldObj.setBlock(absX, absY, absZ, restoreInfo.block, restoreInfo.meta, 0);
+ this.worldObj.markBlockForUpdate(absX, absY, absZ);
+ }
+ }
+
+ this.multiblockType = null;
+ this.resetWorkState();
+ this.dropWand();
+ }
+
+ private boolean shouldSkip(MultiblockHelper.BlockInfo info) {
+ return info.block == RegisteredBlocks.blockNode || info.block == Blocks.air
+ || info.block == RegisteredBlocks.blockNodeManipulator
+ || (info.block == RegisteredBlocks.blockStoneMachine
+ && (info.meta == 0 || info.meta == 1 || info.meta == 3));
+ }
+
+ private void orientAndAnimatePillar(int x, int y, int z, byte orientation, NetworkRegistry.TargetPoint target) {
+ TileManipulatorPillar pillar = (TileManipulatorPillar) this.worldObj.getTileEntity(x, y, z);
+ pillar.setOrientation(orientation);
+ PacketHandler.INSTANCE.sendToAllAround(
+ new PacketStartAnimation(PacketStartAnimation.ID_RUNES, pillar.xCoord, pillar.yCoord, pillar.zCoord),
+ target);
+ }
+
+ // -------------------------------------------------------------------------
+ // Helpers / Other
+ // -------------------------------------------------------------------------
+
+ public MultiblockType detectMultiblockType() {
+ if (MultiblockHelper.isMultiblockPresent(
+ this.worldObj,
+ this.xCoord,
+ this.yCoord,
+ this.zCoord,
+ RegisteredMultiblocks.incompleteNodeManipulatorMultiblock)) {
+ this.multiblockType = MultiblockType.NODE_MANIPULATOR;
+ return MultiblockType.NODE_MANIPULATOR;
+ }
+ if (MultiblockHelper.isMultiblockPresent(
+ this.worldObj,
+ this.xCoord,
+ this.yCoord,
+ this.zCoord,
+ RegisteredMultiblocks.incompleteEldritchPortalCreator)) {
+ this.multiblockType = MultiblockType.E_PORTAL_CREATOR;
+ return MultiblockType.E_PORTAL_CREATOR;
+ }
+ this.multiblockType = null;
+ return null;
+ }
+
+ private boolean hasNode() {
+ return this.worldObj.getBlock(this.xCoord, this.yCoord + 2, this.zCoord) == RegisteredBlocks.blockNode;
+ }
+
+ private void resetWorkState() {
+ this.workAspectList = new AspectList();
+ this.workTick = 0;
+ this.isWorking = false;
+ this.markDirty();
+ this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
+ }
+
+ private void dropWand() {
+ if (this.getStackInSlot(0) != null) {
+ InventoryUtils.dropItems(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
+ }
+ }
+
+ private Vec3 getPedestalOffset(int index) {
+ if (index < this.bufferedCCPedestals.size()) {
+ ChunkCoordinates cc = this.bufferedCCPedestals.get(index);
+ return Vec3.createVectorHelper(this.xCoord - cc.posX, this.yCoord - cc.posY, this.zCoord - cc.posZ);
+ }
+ return Vec3.createVectorHelper(0, 0, 0);
+ }
+
+ private void sendRuneAnimation(int x, int y, int z, byte flags) {
+ PacketHandler.INSTANCE.sendToAllAround(
+ new PacketStartAnimation(PacketStartAnimation.ID_RUNES, x, y, z, flags),
+ this.getTargetPoint(32));
+ }
+
+ private void sendNodeBolt(float x1, float y1, float z1, float x2, float y2, float z2, int type) {
+ PacketHandler.INSTANCE
+ .sendToAllAround(new PacketTCNodeBolt(x1, y1, z1, x2, y2, z2, type, false), this.getTargetPoint(32));
+ }
+
+ private void playAspectDrainFX(Aspect drained) {
+ PacketHandler.INSTANCE.sendToAllAround(
+ new PacketTCWispyLine(
+ this.worldObj.provider.dimensionId,
+ this.xCoord + 0.5,
+ this.yCoord + 0.8,
+ this.zCoord + 0.5,
+ this.xCoord + 0.5,
+ this.yCoord + 1.4 + (this.worldObj.rand.nextInt(4) / 10D),
+ this.zCoord + 0.5,
+ 40,
+ drained.getColor()),
+ this.getTargetPoint(32));
+ }
+
@Override
public void readCustomNBT(NBTTagCompound compound) {
super.readCustomNBT(compound);
-
NBTTagCompound tag = compound.getCompoundTag("Gadomancy");
- this.multiblockStructurePresent = tag.getBoolean("mBlockPresent");
this.isMultiblock = tag.getBoolean("mBlockState");
this.isWorking = tag.getBoolean("manipulating");
this.workTick = tag.getInteger("workTick");
@@ -572,9 +616,7 @@ public class TileNodeManipulator extends TileWandPedestal implements IWandable {
@Override
public void writeCustomNBT(NBTTagCompound compound) {
super.writeCustomNBT(compound);
-
NBTTagCompound tag = new NBTTagCompound();
- tag.setBoolean("mBlockPresent", this.multiblockStructurePresent);
tag.setBoolean("mBlockState", this.isMultiblock);
tag.setBoolean("manipulating", this.isWorking);
tag.setInteger("workTick", this.workTick);
@@ -589,97 +631,13 @@ public class TileNodeManipulator extends TileWandPedestal implements IWandable {
return this.isMultiblock;
}
- public boolean isMultiblockStructurePresent() {
- return this.multiblockStructurePresent;
- }
-
public MultiblockType getMultiblockType() {
return this.multiblockType;
}
- public boolean checkMultiblock() {
- boolean prevState = this.isMultiblockStructurePresent();
- if (prevState) { // If there is already a multiblock formed...
- if (this.isInMultiblock()) { // If we were actually in multiblock before
- if (this.multiblockType == null) {
- if (MultiblockHelper.isMultiblockPresent(
- this.worldObj,
- this.xCoord,
- this.yCoord,
- this.zCoord,
- RegisteredMultiblocks.completeNodeManipulatorMultiblock)) {
- this.multiblockType = MultiblockType.NODE_MANIPULATOR;
- } else if (MultiblockHelper.isMultiblockPresent(
- this.worldObj,
- this.xCoord,
- this.yCoord,
- this.zCoord,
- RegisteredMultiblocks.completeEldritchPortalCreator) && this.checkEldritchEyes(false)) {
- this.multiblockType = MultiblockType.E_PORTAL_CREATOR;
- }
- }
- if (this.multiblockType == null) {
- this.breakMultiblock();
- return false;
- }
- switch (this.multiblockType) {
- case NODE_MANIPULATOR:
- this.setMultiblockStructurePresent(
- MultiblockHelper.isMultiblockPresent(
- this.worldObj,
- this.xCoord,
- this.yCoord,
- this.zCoord,
- RegisteredMultiblocks.completeNodeManipulatorMultiblock),
- MultiblockType.NODE_MANIPULATOR);
- break;
- case E_PORTAL_CREATOR:
- this.setMultiblockStructurePresent(
- MultiblockHelper.isMultiblockPresent(
- this.worldObj,
- this.xCoord,
- this.yCoord,
- this.zCoord,
- RegisteredMultiblocks.completeEldritchPortalCreator)
- && this.checkEldritchEyes(false),
- MultiblockType.E_PORTAL_CREATOR);
- break;
- }
- } else { // If we weren't in multiblock eventhough it would be possible.
- this.checkForNonExistingMultiblock();
- }
- } else { // If there was no multiblock formed before..
- this.checkForNonExistingMultiblock();
- }
- return this.isMultiblockStructurePresent();
- }
-
- private void setMultiblockStructurePresent(boolean present, MultiblockType type) {
- if (present) {
- this.multiblockType = type;
- }
- this.multiblockStructurePresent = present;
- }
-
- private void checkForNonExistingMultiblock() {
- Map patternMap = new HashMap();
- patternMap.put(RegisteredMultiblocks.incompleteEldritchPortalCreator, MultiblockType.E_PORTAL_CREATOR);
- patternMap.put(RegisteredMultiblocks.incompleteNodeManipulatorMultiblock, MultiblockType.NODE_MANIPULATOR);
-
- for (MultiblockHelper.MultiblockPattern pattern : patternMap.keySet()) {
- if (MultiblockHelper.isMultiblockPresent(this.worldObj, this.xCoord, this.yCoord, this.zCoord, pattern)) {
- if (pattern == RegisteredMultiblocks.incompleteEldritchPortalCreator) {
- if (!this.checkEldritchEyes(false)) return;
- }
- this.setMultiblockStructurePresent(true, patternMap.get(pattern));
- return;
- }
- }
- }
-
@Override
- public boolean canInsertItem(int par1, ItemStack par2ItemStack, int par3) {
- return this.isInMultiblock() && super.canInsertItem(par1, par2ItemStack, par3);
+ public boolean canInsertItem(int slot, ItemStack stack, int side) {
+ return this.isInMultiblock() && super.canInsertItem(slot, stack, side);
}
public NetworkRegistry.TargetPoint getTargetPoint(double radius) {
@@ -696,44 +654,11 @@ public class TileNodeManipulator extends TileWandPedestal implements IWandable {
return this.workAspectList;
}
- @Override
- public void setAspects(AspectList aspectList) {}
-
@Override
public boolean doesContainerAccept(Aspect aspect) {
return false;
}
- @Override
- public int addToContainer(Aspect aspect, int i) {
- return 0;
- }
-
- @Override
- public boolean takeFromContainer(Aspect aspect, int i) {
- return false;
- }
-
- @Override
- public boolean takeFromContainer(AspectList aspectList) {
- return false;
- }
-
- @Override
- public boolean doesContainerContainAmount(Aspect aspect, int i) {
- return false;
- }
-
- @Override
- public boolean doesContainerContain(AspectList aspectList) {
- return false;
- }
-
- @Override
- public int containerContains(Aspect aspect) {
- return 0;
- }
-
@Override
public int onWandRightClick(World world, ItemStack stack, EntityPlayer player, int i, int i2, int i3, int i4,
int i5) {
@@ -758,8 +683,8 @@ public class TileNodeManipulator extends TileWandPedestal implements IWandable {
E_PORTAL_CREATOR(Gadomancy.MODID.toUpperCase() + ".E_PORTAL_CREATOR",
RegisteredRecipes.costsEldritchPortalCreatorMultiblock);
- private String research;
- private AspectList costs;
+ private final String research;
+ private final AspectList costs;
MultiblockType(String research, AspectList costs) {
this.research = research;
diff --git a/src/main/java/makeo/gadomancy/common/blocks/tiles/TileOverrideEldritchLock.java b/src/main/java/makeo/gadomancy/common/blocks/tiles/TileOverrideEldritchLock.java
index 36cffda..90110e9 100644
--- a/src/main/java/makeo/gadomancy/common/blocks/tiles/TileOverrideEldritchLock.java
+++ b/src/main/java/makeo/gadomancy/common/blocks/tiles/TileOverrideEldritchLock.java
@@ -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 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 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;
+ }
}
}
diff --git a/src/main/java/makeo/gadomancy/common/events/EventHandlerWorld.java b/src/main/java/makeo/gadomancy/common/events/EventHandlerWorld.java
index a6fa563..3a57cdb 100644
--- a/src/main/java/makeo/gadomancy/common/events/EventHandlerWorld.java
+++ b/src/main/java/makeo/gadomancy/common/events/EventHandlerWorld.java
@@ -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);
}
diff --git a/src/main/java/makeo/gadomancy/common/network/packets/PacketTCNodeBolt.java b/src/main/java/makeo/gadomancy/common/network/packets/PacketTCNodeBolt.java
index 85d0320..5915ed8 100644
--- a/src/main/java/makeo/gadomancy/common/network/packets/PacketTCNodeBolt.java
+++ b/src/main/java/makeo/gadomancy/common/network/packets/PacketTCNodeBolt.java
@@ -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 labyrinthCopy = new ConcurrentHashMap();
- 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 labyrinthCopy = new ConcurrentHashMap<>();
+ private static int tickCounter;
public static final FakeWorldTCGeneration GEN = new FakeWorldTCGeneration();
- private static List flaggedSessions = new ArrayList();
-
- private static Map runningSessions = new HashMap();
- private static Map watchedBosses = new HashMap();
+ private static final List flaggedSessions = new ArrayList<>();
+ private static Map runningSessions = new HashMap<>();
+ private static final Map 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 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 calculateCellLocs(WorldServer world) {
ConcurrentHashMap oldDat = MazeHandler.labyrinth;
- ConcurrentHashMap bufferOld = new ConcurrentHashMap(
- TCMazeHandler.labyrinthCopy);
+ ConcurrentHashMap 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 calculateDifferences(ConcurrentHashMap bufferOld) {
ConcurrentHashMap newDat = MazeHandler.labyrinth; // Only the new data has data, the old one
// doesn't have.
- Map newlyEvaluatedMaze = new HashMap();
+ Map 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();
+ TCMazeHandler.runningSessions = new HashMap<>();
}
public static boolean hasOpenSession(EntityPlayer player) {
diff --git a/src/main/java/makeo/gadomancy/common/utils/world/TCMazeSession.java b/src/main/java/makeo/gadomancy/common/utils/world/TCMazeSession.java
index 1dfe13c..868b4f7 100644
--- a/src/main/java/makeo/gadomancy/common/utils/world/TCMazeSession.java
+++ b/src/main/java/makeo/gadomancy/common/utils/world/TCMazeSession.java
@@ -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
- *
+ *
* Created by HellFirePvP @ 05.11.2015 14:12
*/
public class TCMazeSession {
public final EntityPlayerMP player;
public final Map 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 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
}
}
diff --git a/src/main/resources/assets/gadomancy/lang/en_US.lang b/src/main/resources/assets/gadomancy/lang/en_US.lang
index ad220dd..11f90e8 100644
--- a/src/main/resources/assets/gadomancy/lang/en_US.lang
+++ b/src/main/resources/assets/gadomancy/lang/en_US.lang
@@ -51,7 +51,7 @@ gadomancy.research_page.REMOTEJAR.2=If a network already exists, then the jar wi
tc.research_name.GADOMANCY.ETHEREAL_FAMILIAR=Ethereal Familiar
tc.research_text.GADOMANCY.ETHEREAL_FAMILIAR=An arcane follower
-gadomancy.research_page.ETHEREAL_FAMILIAR.1=Wisps have intrigued you for some time now. Many of these sentient bits of ethereal magic seem to be passive, but when attacked, they retaliate with surprising speed and efficiency. Not only that, but sometimes just approaching a wisp too quickly will provoke an attack.This behavior gave you an unexpected inspiration. By exploiting the unusually responsive nature of a wisp, it may be possible to bend its defensive instincts to act as a personal protector. Unfortunately, wild wisps have proven to be far too unpredictable to capture.
+gadomancy.research_page.ETHEREAL_FAMILIAR.1=Wisps have intrigued you for some time now. Many of these sentient bits of ethereal magic seem to be passive, but when attacked, they retaliate with surprising speed and efficiency. Not only that, but sometimes just approaching a wisp too quickly will provoke an attack.This behavior gave you an unexpected inspiration. By exploiting the unusually responsive nature of a wisp, it may be possible to bend its defensive instincts to act as a personal protector. Unfortunately, wild wisps have proven to be far too unpredictable to capture.
gadomancy.research_page.ETHEREAL_FAMILIAR.3=By infusing large amounts of magic and a few binding agents into a sample of ethereal essence, an artificial wisp can be created. This Ethereal "Familiar" will anchor to its wearer's aura and act similarly to a turret when it is held in the amulet slot, shooting sparks any hostile entities that attack its wearer. It is considerably weaker and slower than its wild counterparts, however you feel that there are definitely methods of strengthening it.
gadomancy.research_page.ETHEREAL_FAMILIAR.4=Its attacks don't consume any vis until an elemental upgrade is applied. It should be noted that the familiar is also not strong enough to survive any power range or speed modifications until it has an elemental upgrade to bolster its strength.
@@ -95,8 +95,8 @@ gadomancy.research_page.KNOWLEDGE_BOOK.4=You have found that placing any form of
tc.research_name.GADOMANCY.ESSENTIA_COMPRESSOR=Essentia Condenser
tc.research_text.GADOMANCY.ESSENTIA_COMPRESSOR=NON-noisy Essentia Storage
-gadomancy.research_page.ESSENTIA_COMPRESSOR.1= While experimenting with void materials, you discovered an odd reaction between void seeds and liquid essentia. When a void seed is left in close proximity with a warded jar for an extended period of time, the energy it releases has the odd tendency to make the essentia in the jar condense into a slightly more dense state, freeing up a small amount of space in the jar without actually destroying any essentia. After some further testing, you found that the seed alone was not powerful enough to make any major difference, but with enhancements to increase the potency of the energy released by the seed, a device that can compress essentia into a super dense state could be made.
-gadomancy.research_page.ESSENTIA_COMPRESSOR.2=By condensing large amounts of void materials, infusing the resulting mass into void seed to create a small cross dimensional rift, and freezing the resulting anomaly inside a crystal shell, it is possible to increase the potency the void energy the seed can release by several thousand times. Despite the fact that this new “Element of Darkness” seems to be incredibly stable, its effects are far too potent for a normal warded jar to handle. It also has the unfortunate side effect of sucking all of the light out of any space it is dropped in, blinding anything that holds it or stands near it when it is dropped on the ground.
+gadomancy.research_page.ESSENTIA_COMPRESSOR.1= While experimenting with void materials, you discovered an odd reaction between void seeds and liquid essentia. When a void seed is left in close proximity with a warded jar for an extended period of time, the energy it releases has the odd tendency to make the essentia in the jar condense into a slightly more dense state, freeing up a small amount of space in the jar without actually destroying any essentia. After some further testing, you found that the seed alone was not powerful enough to make any major difference, but with enhancements to increase the potency of the energy released by the seed, a device that can compress essentia into a super dense state could be made.
+gadomancy.research_page.ESSENTIA_COMPRESSOR.2=By condensing large amounts of void materials, infusing the resulting mass into void seed to create a small cross dimensional rift, and freezing the resulting anomaly inside a crystal shell, it is possible to increase the potency the void energy the seed can release by several thousand times. Despite the fact that this new “Element of Darkness” seems to be incredibly stable, its effects are far too potent for a normal warded jar to handle. It also has the unfortunate side effect of sucking all of the light out of any space it is dropped in, blinding anything that holds it or stands near it when it is dropped on the ground.
gadomancy.research_page.ESSENTIA_COMPRESSOR.4=By assembling a reinforced shell around the Element of Darkness and stabilizing essentia flow with an aqua aura core, a device that is capable of storing massive amounts of essentia can be created. In order to assemble the machine, place all three blocks on top of each other, and right click with a wand. The Essentia Condenser can store all types of essentia inside one construct, with a base capacity of 200 essentia that can be stored. The device does have some mechanical limitations though.
gadomancy.research_page.ESSENTIA_COMPRESSOR.6=Due to the incredible amount of energy in the core of the Essentia Condenser, it cannot safely interact with pipes, nor can essentia be directly placed into the device by hand. Golems have to be used to insert the first bit of essentia into the condenser for it to start accepting on its own. Once essentia is stored however, the Condenser will actively pull in essentia from every available jar, reservoir, and mirror within 5 blocks of the device, however it only seems to pull from containers that have less essentia inside them than the main condenser. Although direct physical interaction with the Essentia Condenser is limited to golems, infusion altars as well any device that can pull from an essentia mirror can supply themselves.
gadomancy.research_page.ESSENTIA_COMPRESSOR.8=The Essentia Condenser, like most things that contain large amounts of liquid essentia, does not deal with large amounts of physical stress very well. If any of the blocks in the structure are broken while any essentia is contained inside, the entire device will violently explode, leaving a large amount of flux and taint behind. Unlike its slightly more tame counterpart, the essentia reservoir, if the Essentia Condenser has any essentia within, it will release enough destabilized flux to immediately taint the land.
@@ -105,7 +105,7 @@ gadomancy.research_page.ESSENTIA_COMPRESSOR.9=If an element of darkness is place
tc.research_name.GADOMANCY.NODE_MANIPULATOR=Node Manipulator
tc.research_text.GADOMANCY.NODE_MANIPULATOR=Almost like roulette
gadomancy.research_page.NODE_MANIPULATOR.1=Aura nodes have intrigued you for the longest time. Where do they come from? Why are there so many varieties? After some time, you found yourself asking another question entirely; would it be possible to change how a node functions? After journeying far across the world and into the depths of the ancient eldritch mazes, you found a set of materials capable of changing the way aura behaves. After carefully developing these materials, and using them to augment the only device you found to be capable of channeling pure vis directly from a node, one of the most dangerous machines you could fathom finally fell within your grasp.
-gadomancy.research_page.NODE_MANIPULATOR.3=The Node Manipulator is a device that essentially works in a manner opposite to that of a wand recharge pedestal. By drawing vis from a wand or staff and channeling it back into the node, the node manipulator will force a node to destabilize slightly. The manipulator's main pedestal is not stable enough to alter nodes on its own. By adding a specially modified focus to hold the wand/staff in place for vis extraction and a set of pillars to channel the extracted vis into the node, the device is finally ready for use. Just place a wand/staff on the pedestal, and the node manipulator will start automatically.
+gadomancy.research_page.NODE_MANIPULATOR.3=The Node Manipulator is a device that essentially works in a manner opposite to that of a wand recharge pedestal. By drawing vis from a wand or staff and channeling it back into the node, the node manipulator will force a node to destabilize slightly. The manipulator's main pedestal is not stable enough to alter nodes on its own. By adding a specially modified focus to hold the wand/staff in place for vis extraction and a set of pillars to channel the extracted vis into the node, the device is finally ready for use. Form the manipulator under a node, place a wand or staff on the pedestal, and the device will start automatically.
gadomancy.research_page.NODE_MANIPULATOR.6=The Node Manipulator needs at least 70 of all six primal aspects to begin manipulating a node, but allowing more than 70 seems to yield greater results.
Despite all of your research into node behavior, you still haven't the slightest idea what the node manipulator will actually do to aura nodes. The only way to find out seems to be testing it out...
tc.research_name.GADOMANCY.E_PORTAL_CREATOR=Gate of the Voidwalkers
@@ -113,7 +113,7 @@ tc.research_text.GADOMANCY.E_PORTAL_CREATOR=Into the abyss...
gadomancy.research_page.E_PORTAL_CREATOR.1="He who fights with monsters should look to it that he himself does not become a monster. And when you gaze long into an abyss the abyss also gazes into you."
-Friedrich Nietzsche At first it was just a miracle, the discovery of the primordial pearl. Its light revealed many secrets of the world and of creation, but after a while, you began to feel that one pearl just wasn't enough. Its light was warm, but seemed fitful and weak, as though it was only a spark.
gadomancy.research_page.E_PORTAL_CREATOR.3=Dark, ancient whispers have begun to pervade your consciousness. More powerful and insistent that before, they speak of a road not meant to be walked, a way too dark to see, a path to the greatest of all powers, hidden beyond the edges of the void. You suspect you know exactly what the voices speak of, as you have a piece of that power in your possession. Now you have only to solve the problem of finding this invisible, intangible path.
gadomancy.research_page.E_PORTAL_CREATOR.4=Not surprisingly, the solution to the problem of entering the path came directly from the eldritch obelisks. These ancient devices each contain a node that, when enough vis is directed through, can be widened into a small stable portal. By altering the functions of a compound recharge focus to mimic the functions of the obelisk, the same type of vis redirection can be achieved.
This new focus is not unlike the normal randomization focus, as it also needs to be placed atop a node manipulator in order to function.
-gadomancy.research_page.E_PORTAL_CREATOR.6=In order to build the gate frame, a node manipulator must be constructed in the same manner as normal, but with four ancient pedestals around the outside and the redirection focus in place of the usual randomization focus. The Gate of the Voidwalkers needs 150 of each primal aspect vis to be assembled.
Once assembled, four eldritch eyes must be placed on the pedestals somewhere around the gate, and a staff/wand containing at least 120 vis must be placed in the manipulator.
Once the manipulator drains the necessary vis, the node atop the focus will be forced to open into a portal.
+gadomancy.research_page.E_PORTAL_CREATOR.6=In order to build the gate frame, a Node Manipulator must be constructed in the same manner as normal, but with the Redirection Focus in place of the usual Randomization Focus under a node. The Gate of the Voidwalkers needs 150 of each primal aspect vis to be assembled.
Once assembled, four Eldritch Eyes must be placed on Ancient Pedestals somewhere around the gate, and the Node Manipulator requires 120 of all six primal aspects from a wand or staff to begin it's work. When all conditions are met, the Eldritch Eyes will be consumed to force open the Node in to an Eldritch Portal.
gadomancy.research_page.E_PORTAL_CREATOR.8=At first glance it resembles any other eldritch portal, however when you look closer, you can see that it is far stronger and less stable than the others. You can see that the Gate will not survive more than one entity passing through, so return via the same portal will be impossible. As you step through the Gate of the Voidwalkers, you feel an odd sense of anticipation and foreboding, as though hundreds of ancient eyes are watching silently as you walk into the depths of the abyss...
tc.research_name.GADOMANCY.BLOCK_PROTECTOR=Enervation Field Emitter
@@ -138,12 +138,12 @@ gadomancy.research_page.GROWING_AGGRESSION.1=Suddenly, and completely out of now
tc.research_name.GADOMANCY.GROWING_GROWTH=Growing Behavior
tc.research_text.GADOMANCY.GROWING_GROWTH=A picky one.
-gadomancy.research_page.GROWING_GROWTH.1=The node has begun to display similarities to a hungry node, in that it has started to grow.
The big difference between this node and an average hungry node seems to be that this node only attracts things containing pure aspects, such as Wisps or Ethereal Essence. As far as your research goes, it seems that the more pure the aspect is, the more likely it will fuse with the node. Aspect Orbs and Wisps are absorbed most because they are the most pure.
+gadomancy.research_page.GROWING_GROWTH.1=The node has begun to display similarities to a hungry node, in that it has started to grow.
The big difference between this node and an average hungry node seems to be that this node only attracts things containing pure aspects, such as Wisps or Ethereal Essence. As far as your research goes, it seems that the more pure the aspect is, the more likely it will fuse with the node. Aspect Orbs and Wisps are absorbed most because they are the most pure.
gadomancy.research_page.GROWING_GROWTH.2=Materialized or solid vis in forms of essentia like Mana Beans, Ethereal Essence, or Crystallized Essentia may work too, but you feel you should take care with what you throw into this thing...
Still it is more fascinating than a hungry node by far. In contrast to its hungry brother, this node seems to keep the complexity of its gained compound aspects instead of breaking them down to primal aspects. It seems to have something against primal aspects...
tc.research_name.GADOMANCY.GROWING_ATTACK=Destroying Behavior
tc.research_text.GADOMANCY.GROWING_ATTACK=Stop bullying!
-gadomancy.research_page.GROWING_ATTACK.1=It seems the growing node does not only bully the other nodes, it completely destroys them! If the growing node can find another node within range it attacks it and breaks the other node into aspect orbs.
Further research shows that the node stabilizers cannot stop the growing node from destroying other nodes, but the growing node does not seem to attack bigger nodes than itself.
+gadomancy.research_page.GROWING_ATTACK.1=It seems the growing node does not only bully the other nodes, it completely destroys them! If the growing node can find another node within range it attacks it and breaks the other node into aspect orbs.
Further research shows that the node stabilizers cannot stop the growing node from destroying other nodes, but the growing node does not seem to attack bigger nodes than itself.
tc.research_name.GADOMANCY.GROWING_GROWTHCLUE=Secrets of growth
tc.research_text.GADOMANCY.GROWING_GROWTHCLUE=Growing explained
@@ -201,7 +201,11 @@ gadomancy.lore.disguise.none=Transparent
gadomancy.eldritch.portalPlacerCreative=Creative portal placer
gadomancy.eldritch.noflyCreative=(even in creative)
gadomancy.eldritch.nobreakPortalNothing=This portal cannot be broken
-gadomancy.eldritch.portalSpawned=You sense the opening of a portal in the distance.
+
+gadomancy.eldritch.maze.portalSpawned=You sense portals open across the Labyrinth.
+gadomancy.eldritch.maze.first=You completed the Eldritch Labyrinth in %s.
+gadomancy.eldritch.maze.newBest=New fastest Eldritch Labyrinth completion: %s. Previous best time: %s.
+gadomancy.eldritch.maze.default=You completed the Eldritch Labyrinth in %s. Best time: %s.
tile.BlockStickyJar.name=Sticky Jar
tile.BlockArcaneDropper.name=Arcane Dropper
@@ -212,8 +216,7 @@ tile.BlockNode.name=Aura Node
tile.BlockExtendedNodeJar.name=Node in a Jar
tile.BlockNodeManipulator.name=Node Manipulator
tile.BlockNodeManipulator.5.name=Node Manipulator
-tile.BlockStoneMachine.name=Randomization Focus
-tile.BlockStoneMachine.0.name=Machine
+tile.BlockStoneMachine.0.name=Randomization Focus
tile.BlockStoneMachine.1.name=Ancient Pedestal
tile.BlockStoneMachine.2.name=Arcane Enervation Emitter
tile.BlockStoneMachine.3.name=Redirection Focus