mirror of
https://github.com/GTNewHorizons/Gadomancy.git
synced 2026-11-26 14:53:21 +00:00
- NodeManipulator: Can manipulate nodes now + still some fx missing
This commit is contained in:
1 parent
0457e83936
commit
b24e75e14f
10 files changed
+527
-49
No files matched your search
@@ -3,6 +3,9 @@ package makeo.gadomancy.common.node;
|
||||
import makeo.gadomancy.common.blocks.tiles.TileExtendedNode;
|
||||
import makeo.gadomancy.common.registration.RegisteredManipulations;
|
||||
import net.minecraft.util.WeightedRandom;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.common.lib.research.ResearchManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -13,7 +16,7 @@ import java.util.Random;
|
||||
* Gadomancy is Open Source and distributed under the
|
||||
* GNU LESSER GENERAL PUBLIC LICENSE
|
||||
* for more read the LICENSE file
|
||||
* <p/>
|
||||
*
|
||||
* Created by HellFirePvP @ 28.10.2015 11:43
|
||||
*/
|
||||
public class NodeManipulatorResultHandler {
|
||||
@@ -22,6 +25,10 @@ public class NodeManipulatorResultHandler {
|
||||
|
||||
private NodeManipulatorResultHandler() {}
|
||||
|
||||
public static NodeManipulatorResult getRandomResult(TileExtendedNode affectedNode) {
|
||||
return getRandomResult(affectedNode.getWorldObj().rand, affectedNode);
|
||||
}
|
||||
|
||||
public static NodeManipulatorResult getRandomResult(Random random, TileExtendedNode affectedNode) {
|
||||
List<NodeManipulatorResult> localResults = new ArrayList<NodeManipulatorResult>();
|
||||
for(NodeManipulatorResult result : possibleResults) {
|
||||
@@ -31,8 +38,43 @@ public class NodeManipulatorResultHandler {
|
||||
return (NodeManipulatorResult) WeightedRandom.getRandomItem(random, localResults);
|
||||
}
|
||||
|
||||
public static void combine(AspectList containingList, Aspect a, Aspect b) {
|
||||
if(!canCombine(a, b)) return;
|
||||
Aspect combination = NodeManipulatorResultHandler.getCombination(a, b);
|
||||
int lowerAmount;
|
||||
if(containingList.getAmount(a) < containingList.getAmount(b)) {
|
||||
lowerAmount = containingList.getAmount(a);
|
||||
} else {
|
||||
lowerAmount = containingList.getAmount(b);
|
||||
}
|
||||
containingList.remove(a, lowerAmount);
|
||||
containingList.remove(b, lowerAmount);
|
||||
containingList.add(combination, lowerAmount);
|
||||
}
|
||||
|
||||
public static boolean canCombine(Aspect a, Aspect b) {
|
||||
return getCombination(a, b) != null;
|
||||
}
|
||||
|
||||
public static Aspect getCombination(Aspect a, Aspect b) {
|
||||
for(Aspect aspect : Aspect.getCompoundAspects()) {
|
||||
Aspect[] components = aspect.getComponents();
|
||||
if((components[0] == a && components[1] == b) ||
|
||||
components[0] == b && components[1] == a) {
|
||||
return aspect;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static {
|
||||
//Aspect combination pair
|
||||
possibleResults.add(RegisteredManipulations.resultBreakCompounds);
|
||||
possibleResults.add(RegisteredManipulations.resultCombineAspects);
|
||||
|
||||
//Modifier pair
|
||||
possibleResults.add(RegisteredManipulations.resultIncreaseModifier);
|
||||
possibleResults.add(RegisteredManipulations.resultDecreaseModifier);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user