- Added additionally support when additional nodetypes are disabled

This commit is contained in:
HellFirePvP committed 2015-12-19 12:46:07 +01:00
1 parent a3a7a1ef88
commit df8f4399b7
5 files changed
+70 -52

No files matched your search

@@ -22,6 +22,7 @@ import net.minecraft.world.World;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.aspects.IAspectContainer;
import thaumcraft.api.nodes.INode;
import thaumcraft.api.wands.IWandable;
import thaumcraft.common.config.ConfigItems;
import thaumcraft.common.items.wands.ItemWandCasting;
@@ -273,8 +274,8 @@ public class TileNodeManipulator extends TileWandPedestal implements IAspectCont
workAspectList = new AspectList();
TileEntity te = worldObj.getTileEntity(xCoord, yCoord + 2, zCoord);
if(te == null || !(te instanceof TileExtendedNode)) return;
TileExtendedNode node = (TileExtendedNode) te;
if(te == null || !(te instanceof INode)) return;
INode node = (INode) te;
int areaRange = NODE_MANIPULATION_WORK_ASPECT_CAP - NODE_MANIPULATION_POSSIBLE_WORK_START;
int percChanceForBetter = 0;
if(areaRange > 0) {
@@ -282,14 +283,14 @@ public class TileNodeManipulator extends TileWandPedestal implements IAspectCont
}
NodeManipulatorResult result;
do {
result = NodeManipulatorResultHandler.getRandomResult(node, percChanceForBetter);
} while (!result.affect(node));
result = NodeManipulatorResultHandler.getRandomResult(worldObj, node, percChanceForBetter);
} while (!result.affect(worldObj, node));
PacketStartAnimation packet = new PacketStartAnimation(PacketStartAnimation.ID_SPARKLE_SPREAD, xCoord, yCoord + 2, zCoord);
PacketHandler.INSTANCE.sendToAllAround(packet, getTargetPoint(32));
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
worldObj.markBlockForUpdate(xCoord, yCoord + 2, zCoord);
markDirty();
node.markDirty();
((TileEntity) node).markDirty();
}
private float calcOversize(int neededAspects) {
@@ -2,6 +2,8 @@ package makeo.gadomancy.common.node;
import makeo.gadomancy.common.blocks.tiles.TileExtendedNode;
import net.minecraft.util.WeightedRandom;
import net.minecraft.world.World;
import thaumcraft.api.nodes.INode;
/**
* This class is part of the Gadomancy Mod
@@ -24,10 +26,10 @@ public abstract class NodeManipulatorResult extends WeightedRandom.Item {
return resultType;
}
public boolean canAffect(TileExtendedNode node) {
public boolean canAffect(World world, INode node) {
return true;
}
public abstract boolean affect(TileExtendedNode node);
public abstract boolean affect(World world, INode node);
}
@@ -1,11 +1,12 @@
package makeo.gadomancy.common.node;
import makeo.gadomancy.common.blocks.tiles.TileExtendedNode;
import makeo.gadomancy.common.data.config.ModConfig;
import makeo.gadomancy.common.registration.RegisteredManipulations;
import net.minecraft.util.WeightedRandom;
import net.minecraft.world.World;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.nodes.INode;
import java.util.ArrayList;
import java.util.List;
@@ -25,15 +26,15 @@ public class NodeManipulatorResultHandler {
private NodeManipulatorResultHandler() {}
public static NodeManipulatorResult getRandomResult(TileExtendedNode affectedNode, int percChance) {
return getRandomResult(affectedNode.getWorldObj().rand, affectedNode, percChance);
public static NodeManipulatorResult getRandomResult(World world, INode affectedNode, int percChance) {
return getRandomResult(world, world.rand, affectedNode, percChance);
}
public static NodeManipulatorResult getRandomResult(Random random, TileExtendedNode affectedNode, int percChance) {
public static NodeManipulatorResult getRandomResult(World world, Random random, INode affectedNode, int percChance) {
int resultPositiveChance = Math.round(((float) percChance) / 5F);
List<NodeManipulatorResult> localResults = new ArrayList<NodeManipulatorResult>();
for(NodeManipulatorResult result : possibleResults) {
if(result.canAffect(affectedNode)) {
if(result.canAffect(world, affectedNode)) {
ResultType type = result.getResultType();
if(type == ResultType.NEGATIVE) {
if(random.nextInt(100) < resultPositiveChance) continue;
@@ -6,8 +6,10 @@ import makeo.gadomancy.common.node.ExtendedNodeType;
import makeo.gadomancy.common.node.NodeManipulatorResult;
import makeo.gadomancy.common.node.NodeManipulatorResultHandler;
import makeo.gadomancy.common.utils.ResearchHelper;
import net.minecraft.world.World;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.nodes.INode;
import thaumcraft.api.nodes.NodeModifier;
import thaumcraft.api.nodes.NodeType;
@@ -25,7 +27,7 @@ public class RegisteredManipulations {
public static NodeManipulatorResult resultBreakCompounds = new NodeManipulatorResult(4, NodeManipulatorResultHandler.ResultType.NEGATIVE) {
@Override
public boolean affect(TileExtendedNode node) {
public boolean affect(World world, INode node) {
AspectList baseList = node.getAspectsBase();
AspectList list = node.getAspects();
for(Aspect a : baseList.getAspects()) {
@@ -47,35 +49,35 @@ public class RegisteredManipulations {
public static NodeManipulatorResult resultCombineAspects = new NodeManipulatorResult(5, NodeManipulatorResultHandler.ResultType.POSITIVE) {
@Override
public boolean affect(TileExtendedNode node) {
public boolean affect(World world, INode node) {
AspectList base = node.getAspectsBase();
if(base.getAspects().length < 2)
return false;
if(base.getAspects().length == 2) {
if(!NodeManipulatorResultHandler.canCombine(base.getAspects()[0], base.getAspects()[1])) return false;
int addition = node.getWorldObj().rand.nextInt(4);
int addition = world.rand.nextInt(4);
NodeManipulatorResultHandler.combine(base, base.getAspects()[0], base.getAspects()[1], addition);
NodeManipulatorResultHandler.combine(node.getAspects(), base.getAspects()[0], base.getAspects()[1], addition);
return true;
}
if(base.getAspects().length > 2) {
int actuallyCombined = 0;
int combineCount = node.getWorldObj().rand.nextInt(1) + 1;
int combineCount = world.rand.nextInt(1) + 1;
doLabel:
do {
if(base.getAspects().length < 2) break;
int randIndexForA = node.getWorldObj().rand.nextInt(base.getAspects().length);
int randIndexForA = world.rand.nextInt(base.getAspects().length);
for (int i = 0; i < base.getAspects().length; i++) {
int indexA = (i + randIndexForA) % base.getAspects().length;
Aspect a = base.getAspects()[indexA];
int randIndexForB = node.getWorldObj().rand.nextInt(base.getAspects().length);
int randIndexForB = world.rand.nextInt(base.getAspects().length);
for (int j = 0; j < base.getAspects().length; j++) {
int indexB = (j + randIndexForB) % base.getAspects().length;
Aspect b = base.getAspects()[indexB];
if(NodeManipulatorResultHandler.canCombine(a, b)) {
int addition = node.getWorldObj().rand.nextInt(4);
int addition = world.rand.nextInt(4);
NodeManipulatorResultHandler.combine(base, a, b, addition);
NodeManipulatorResultHandler.combine(node.getAspects(), a, b, addition);
combineCount--;
@@ -98,12 +100,12 @@ public class RegisteredManipulations {
public static NodeManipulatorResult resultIncreaseModifier = new NodeManipulatorResult(4, NodeManipulatorResultHandler.ResultType.POSITIVE) {
@Override
public boolean canAffect(TileExtendedNode node) {
public boolean canAffect(World world, INode node) {
return node.getNodeModifier() != NodeModifier.BRIGHT;
}
@Override
public boolean affect(TileExtendedNode node) {
public boolean affect(World world, INode node) {
if(node.getNodeModifier() == null) {
node.setNodeModifier(NodeModifier.BRIGHT);
return true;
@@ -125,12 +127,12 @@ public class RegisteredManipulations {
public static NodeManipulatorResult resultDecreaseModifier = new NodeManipulatorResult(5, NodeManipulatorResultHandler.ResultType.NEGATIVE) {
@Override
public boolean canAffect(TileExtendedNode node) {
public boolean canAffect(World world, INode node) {
return node.getNodeModifier() != NodeModifier.FADING;
}
@Override
public boolean affect(TileExtendedNode node) {
public boolean affect(World world, INode node) {
if(node.getNodeModifier() == null) {
node.setNodeModifier(NodeModifier.PALE);
return true;
@@ -151,12 +153,12 @@ public class RegisteredManipulations {
public static NodeManipulatorResult resultGainPrimal = new NodeManipulatorResult(3, NodeManipulatorResultHandler.ResultType.POSITIVE) {
@Override
public boolean affect(TileExtendedNode node) {
public boolean affect(World world, INode node) {
List<Aspect> primals = Aspect.getPrimalAspects();
int visSize = node.getAspectsBase().visSize();
int size = node.getAspectsBase().size();
int modulo = primals.size();
int index = node.getWorldObj().rand.nextInt(primals.size());
int index = world.rand.nextInt(primals.size());
for (int i = 0; i < primals.size(); i++) {
int get = (index + i) % modulo;
Aspect rand = primals.get(get);
@@ -176,11 +178,18 @@ public class RegisteredManipulations {
public static NodeManipulatorResult resultSwitchType = new NodeManipulatorResult(2, NodeManipulatorResultHandler.ResultType.NEUTRAL) {
@Override
public boolean affect(TileExtendedNode node) {
public boolean affect(World world, INode node) {
NodeType newType = node.getNodeType();
int random = node.getWorldObj().rand.nextInt(40);
int random = world.rand.nextInt(40);
if(random > 38) {
if(!(node.getExtendedNodeType() != null && node.getExtendedNodeType().equals(ExtendedNodeType.GROWING))) newType = NodeType.HUNGRY; //1 of 40
if(node instanceof TileExtendedNode) {
TileExtendedNode tNode = (TileExtendedNode) node;
if(!(tNode.getExtendedNodeType() != null && tNode.getExtendedNodeType().equals(ExtendedNodeType.GROWING))) {
newType = NodeType.HUNGRY; //1 of 40
}
} else {
newType = NodeType.HUNGRY; //1 of 40
}
} else if(random > 37) {
newType = NodeType.TAINTED; //1 of 40
} else if(random > 34) {
@@ -201,7 +210,9 @@ public class RegisteredManipulations {
public static NodeManipulatorResult resultApplyGrowing = new NodeManipulatorResult(1, NodeManipulatorResultHandler.ResultType.POSITIVE) {
@Override
public boolean affect(TileExtendedNode node) {
public boolean affect(World world, INode inode) {
if(!(inode instanceof TileExtendedNode)) return false;
TileExtendedNode node = (TileExtendedNode) inode;
boolean isGrowingAlready = node.getExtendedNodeType() != null && node.getExtendedNodeType().equals(ExtendedNodeType.GROWING);
if(isGrowingAlready) if(node.getNodeType().equals(NodeType.HUNGRY)) isGrowingAlready = false;
if(!isGrowingAlready) {
@@ -149,33 +149,36 @@ public class RegisteredResearches {
.setConcealed()
.setPages(new ResearchPage("gadomancy.research_page.BLOCK_PROTECTOR.1"), new ResearchPage(RegisteredRecipes.recipeBlockProtector), new ResearchPage("gadomancy.research_page.BLOCK_PROTECTOR.3"), new ResearchPage("gadomancy.research_page.BLOCK_PROTECTOR.4")).registerResearchItem();
researchGrowingNodes = new ResearchItem(Gadomancy.MODID.toUpperCase() + ".GROWING", Gadomancy.MODID, new AspectList(), -8, -1, 5, new ResourceLocation("thaumcraft", "textures/misc/r_nodes.png"))
.setSpecial().setLost().setConcealed()
.setParents(Gadomancy.MODID.toUpperCase() + ".NODE_MANIPULATOR")
.setPages(new ResearchPage("gadomancy.research_page.GROWING.1"), new ResearchPage("gadomancy.research_page.GROWING.2")).registerResearchItem();
if(ModConfig.enableAdditionalNodeTypes) {
researchGrowingNodes = new ResearchItem(Gadomancy.MODID.toUpperCase() + ".GROWING", Gadomancy.MODID, new AspectList(), -8, -1, 5, new ResourceLocation("thaumcraft", "textures/misc/r_nodes.png"))
.setSpecial().setLost().setConcealed()
.setParents(Gadomancy.MODID.toUpperCase() + ".NODE_MANIPULATOR")
.setPages(new ResearchPage("gadomancy.research_page.GROWING.1"), new ResearchPage("gadomancy.research_page.GROWING.2")).registerResearchItem();
researchGrowingNodeAgression = new ResearchItem(Gadomancy.MODID.toUpperCase() + ".GROWING_AGGRESSION", Gadomancy.MODID, new AspectList(), -5, 0, 6, new ItemStack(ConfigBlocks.blockAiry, 1, 5))
.setLost()
.setParents(Gadomancy.MODID.toUpperCase() + ".GROWING")
.setPages(new ResearchPage("gadomancy.research_page.GROWING_AGGRESSION.1")).registerResearchItem();
researchGrowingNodeAgression = new ResearchItem(Gadomancy.MODID.toUpperCase() + ".GROWING_AGGRESSION", Gadomancy.MODID, new AspectList(), -5, 0, 6, new ItemStack(ConfigBlocks.blockAiry, 1, 5))
.setLost()
.setParents(Gadomancy.MODID.toUpperCase() + ".GROWING")
.setPages(new ResearchPage("gadomancy.research_page.GROWING_AGGRESSION.1")).registerResearchItem();
researchGrowingNodeGrowth = new ResearchItem(Gadomancy.MODID.toUpperCase() + ".GROWING_GROWTH", Gadomancy.MODID, new AspectList(), -7, 2, 6, new ResourceLocation("gadomancy", "textures/misc/r_node_star.png"))
.setLost()
.setParents(Gadomancy.MODID.toUpperCase() + ".GROWING")
.setPages(new ResearchPage("gadomancy.research_page.GROWING_GROWTH.1"), new ResearchPage("gadomancy.research_page.GROWING_GROWTH.2")).registerResearchItem();
researchGrowingNodeGrowth = new ResearchItem(Gadomancy.MODID.toUpperCase() + ".GROWING_GROWTH", Gadomancy.MODID, new AspectList(), -7, 2, 6, new ResourceLocation("gadomancy", "textures/misc/r_node_star.png"))
.setLost()
.setParents(Gadomancy.MODID.toUpperCase() + ".GROWING")
.setPages(new ResearchPage("gadomancy.research_page.GROWING_GROWTH.1"), new ResearchPage("gadomancy.research_page.GROWING_GROWTH.2")).registerResearchItem();
researchGrowingNodeAttackNodes = new ResearchItem(Gadomancy.MODID.toUpperCase() + ".GROWING_ATTACK", Gadomancy.MODID, new AspectList(), -6, 1, 6, new ResourceLocation("gadomancy", "textures/misc/r_node_dark.png"))
.setLost()
.setParents(Gadomancy.MODID.toUpperCase() + ".GROWING")
.setPages(new ResearchPage("gadomancy.research_page.GROWING_ATTACK.1")).registerResearchItem();
researchGrowingNodeAttackNodes = new ResearchItem(Gadomancy.MODID.toUpperCase() + ".GROWING_ATTACK", Gadomancy.MODID, new AspectList(), -6, 1, 6, new ResourceLocation("gadomancy", "textures/misc/r_node_dark.png"))
.setLost()
.setParents(Gadomancy.MODID.toUpperCase() + ".GROWING")
.setPages(new ResearchPage("gadomancy.research_page.GROWING_ATTACK.1")).registerResearchItem();
researchGrowingNodeGrowthClue = new ResearchItem(Gadomancy.MODID.toUpperCase() + ".GROWING_GROWTHCLUE", Gadomancy.MODID,
new AspectList().add(Aspect.AURA, 10).add(Aspect.MAGIC, 15).add(Aspect.ELDRITCH, 5).add(Aspect.VOID, 12).add(Aspect.ENERGY, 12).add(Aspect.ENTROPY, 8).add(Aspect.DEATH, 3)
.add(Aspect.GREED, 10).add(Aspect.HUNGER, 10).add(Aspect.MECHANISM, 12).add(Aspect.DARKNESS, 12),
-4, 3, 2, new ItemStack(ConfigBlocks.blockAiry, 1, 5))
.setSpecial().setRound().setConcealed()
.setParents(Gadomancy.MODID.toUpperCase() + ".GROWING_AGGRESSION", Gadomancy.MODID.toUpperCase() + ".GROWING_GROWTH", Gadomancy.MODID.toUpperCase() + ".GROWING_ATTACK")
.setPages(new ResearchPage("gadomancy.research_page.GROWING_GROWTHCLUE.1"), new ResearchPage("gadomancy.research_page.GROWING_GROWTHCLUE.2")).registerResearchItem();
researchGrowingNodeGrowthClue = new ResearchItem(Gadomancy.MODID.toUpperCase() + ".GROWING_GROWTHCLUE", Gadomancy.MODID,
new AspectList().add(Aspect.AURA, 10).add(Aspect.MAGIC, 15).add(Aspect.ELDRITCH, 5).add(Aspect.VOID, 12).add(Aspect.ENERGY, 12).add(Aspect.ENTROPY, 8).add(Aspect.DEATH, 3)
.add(Aspect.GREED, 10).add(Aspect.HUNGER, 10).add(Aspect.MECHANISM, 12).add(Aspect.DARKNESS, 12),
-4, 3, 2, new ItemStack(ConfigBlocks.blockAiry, 1, 5))
.setSpecial().setRound().setConcealed()
.setParents(Gadomancy.MODID.toUpperCase() + ".GROWING_AGGRESSION", Gadomancy.MODID.toUpperCase() + ".GROWING_GROWTH", Gadomancy.MODID.toUpperCase() + ".GROWING_ATTACK")
.setPages(new ResearchPage("gadomancy.research_page.GROWING_GROWTHCLUE.1"), new ResearchPage("gadomancy.research_page.GROWING_GROWTHCLUE.2")).registerResearchItem();
}
ResearchItem nitorResearch = PseudoResearchItem.create("NITOR", 2, -4).registerResearchItem();
ResearchItem runicResearch = PseudoResearchItem.create("RUNICARMOR", 4, -4).registerResearchItem();