thaumcraft.api.nodes.INode Java Examples

The following examples show how to use thaumcraft.api.nodes.INode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BlockTrackEntryThaumcraft.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void addInformation(World world, int x, int y, int z, TileEntity te, List<String> infoList){
    if(te instanceof IAspectContainer) {
        IAspectContainer container = (IAspectContainer)te;
        AspectList aspects = container.getAspects();
        if(aspects != null && aspects.size() > 0) {
            infoList.add("blockTracker.info.thaumcraft");
            for(Map.Entry<Aspect, Integer> entry : aspects.aspects.entrySet()) {
                infoList.add("-" + entry.getValue() + "x " + entry.getKey().getName());
            }
        } else {
            infoList.add(I18n.format("blockTracker.info.thaumcraft") + " -");
        }
        if(container instanceof INode) {
            INode node = (INode)container;
            infoList.add(I18n.format("blockTracker.info.thaumcraft.nodetype") + " " + I18n.format("nodetype." + node.getNodeType() + ".name"));
            if(node.getNodeModifier() != null) infoList.add(I18n.format("blockTracker.info.thaumcraft.nodeModifier") + " " + I18n.format("nodemod." + node.getNodeModifier() + ".name"));
        }
    }
}
 
Example #2
Source File: TileNodeManipulator.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void schedulePortalCreation() {
    workTick = 0;
    isWorking = false;
    workAspectList = new AspectList();

    TileEntity te = worldObj.getTileEntity(xCoord, yCoord + 2, zCoord);
    if(te == null || !(te instanceof INode)) return;

    consumeEldritchEyes();

    worldObj.removeTileEntity(xCoord, yCoord + 2, zCoord);
    worldObj.setBlockToAir(xCoord, yCoord + 2, zCoord);
    worldObj.setBlock(xCoord, yCoord + 2, zCoord, RegisteredBlocks.blockAdditionalEldrichPortal);

    worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
    worldObj.markBlockForUpdate(xCoord, yCoord + 2, zCoord);
    markDirty();
}
 
Example #3
Source File: TileNodeManipulator.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void scheduleManipulation() {
    float overSized = calcOversize(NODE_MANIPULATION_POSSIBLE_WORK_START);

    workTick = 0;
    isWorking = false;
    workAspectList = new AspectList();

    TileEntity te = worldObj.getTileEntity(xCoord, yCoord + 2, zCoord);
    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) {
        percChanceForBetter = (int) ((overSized / ((float) areaRange)) * 100);
    }
    NodeManipulatorResult result;
    do {
        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();
    ((TileEntity) node).markDirty();
}
 
Example #4
Source File: RegisteredManipulations.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean affect(World world, INode node) {
    AspectList baseList = node.getAspectsBase();
    AspectList list = node.getAspects();
    for(Aspect a : baseList.getAspects()) {
        if(!a.isPrimal()) {
            Aspect[] subComponents = a.getComponents();
            int initialValue = baseList.getAmount(a);
            list.remove(a);
            baseList.remove(a);
            baseList.add(subComponents[0], initialValue);
            list.add(subComponents[0], initialValue);
            baseList.add(subComponents[1], initialValue);
            list.add(subComponents[1], initialValue);
            return true;
        }
    }
    return false;
}
 
Example #5
Source File: NodeManipulatorResultHandler.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
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(world, affectedNode)) {
            ResultType type = result.getResultType();
            if(type == ResultType.NEGATIVE) {
                if(random.nextInt(100) < resultPositiveChance) continue;
            }

            localResults.add(result);
        }
    }
    if(localResults.isEmpty()) return null;
    return (NodeManipulatorResult) WeightedRandom.getRandomItem(random, localResults);
}
 
Example #6
Source File: RegisteredManipulations.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean affect(World world, INode node) {
    if(node.getNodeModifier() == null) {
        node.setNodeModifier(NodeModifier.BRIGHT);
        return true;
    }
    switch (node.getNodeModifier()) {
        case BRIGHT:
            return false;
        case PALE:
            node.setNodeModifier(null);
            break;
        case FADING:
            node.setNodeModifier(NodeModifier.PALE);
            break;
    }
    return true;
}
 
Example #7
Source File: RegisteredManipulations.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean affect(World world, INode node) {
    if(node.getNodeModifier() == null) {
        node.setNodeModifier(NodeModifier.PALE);
        return true;
    }
    switch (node.getNodeModifier()) {
        case BRIGHT:
            node.setNodeModifier(null);
            break;
        case PALE:
            node.setNodeModifier(NodeModifier.FADING);
            break;
        case FADING:
            return false;
    }
    return true;
}
 
Example #8
Source File: RegisteredManipulations.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean affect(World world, INode node) {
    NodeType newType = node.getNodeType();
    int random = world.rand.nextInt(40);
    if(random > 38) {
        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) {
        newType = NodeType.UNSTABLE; //3 of 40
    } else if(random > 29) {
        newType = NodeType.DARK; //5 of 40
    } else if(random > 24) {
        newType = NodeType.PURE; //5 of 40
    } else if(random > 14) {
        newType = NodeType.NORMAL; //10 of 40
    }
    //15 of 40 chance nothing happens
    boolean changed = !newType.equals(node.getNodeType());
    if(changed) node.setNodeType(newType);
    return changed;
}
 
Example #9
Source File: RegisteredManipulations.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
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) {
        node.setExtendedNodeType(ExtendedNodeType.GROWING);
        ResearchHelper.distributeResearch(Gadomancy.MODID.toUpperCase() + ".GROWING", node.getWorldObj(), node.xCoord, node.yCoord, node.zCoord, 12);
    }
    return isGrowingAlready;
}
 
Example #10
Source File: ItemNodeRenderer.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static void renderItemNode(INode node) {
    if (node.getAspects().size() > 0) {
        EntityLivingBase viewer = Minecraft.getMinecraft().renderViewEntity;
        float alpha = 0.5F;
        if (node.getNodeModifier() != null) {
            switch (node.getNodeModifier()) {
                case BRIGHT:
                    alpha *= 1.5F;
                    break;
                case PALE:
                    alpha *= 0.66F;
                    break;
                case FADING:
                    alpha *= (MathHelper.sin(viewer.ticksExisted / 3.0F) * 0.25F + 0.33F);
            }
        }
        GL11.glPushMatrix();
        GL11.glAlphaFunc(516, 0.003921569F);
        GL11.glDepthMask(false);
        GL11.glDisable(2884);
        long nt = System.nanoTime();
        long time = nt / 5000000L;
        float bscale = 0.25F;

        GL11.glPushMatrix();
        float rad = 6.283186F;
        GL11.glColor4f(1.0F, 1.0F, 1.0F, alpha);

        UtilsFX.bindTexture(TileNodeRenderer.nodetex);
        int frames = 32;
        int i = (int) ((nt / 40000000L + 1L) % frames);

        int count = 0;
        float scale = 0.0F;
        float average = 0.0F;
        for (Aspect aspect : node.getAspects().getAspects()) {
            if (aspect.getBlend() == 771) {
                alpha = (float) (alpha * 1.5D);
            }
            average += node.getAspects().getAmount(aspect);
            GL11.glPushMatrix();
            GL11.glEnable(3042);
            GL11.glBlendFunc(770, aspect.getBlend());
            scale = MathHelper.sin(viewer.ticksExisted / (14.0F - count)) * bscale + bscale * 2.0F;
            scale = 0.2F + scale * (node.getAspects().getAmount(aspect) / 50.0F);
            UtilsFX.renderAnimatedQuadStrip(scale, alpha / node.getAspects().size(), frames, 0, i, 0.0F, aspect.getColor());
            GL11.glDisable(3042);
            GL11.glPopMatrix();
            count++;
            if (aspect.getBlend() == 771) {
                alpha = (float) (alpha / 1.5D);
            }
        }
        average /= node.getAspects().size();
        GL11.glPushMatrix();
        GL11.glEnable(3042);
        i = (int) ((nt / 40000000L + 1L) % frames);
        scale = 0.1F + average / 150.0F;
        int strip = 1;
        switch (node.getNodeType()) {
            case NORMAL:
                GL11.glBlendFunc(770, 1);
                break;
            case UNSTABLE:
                GL11.glBlendFunc(770, 1);
                strip = 6;
                break;
            case DARK:
                GL11.glBlendFunc(770, 771);
                strip = 2;
                break;
            case TAINTED:
                GL11.glBlendFunc(770, 771);
                strip = 5;
                break;
            case PURE:
                GL11.glBlendFunc(770, 1);
                strip = 4;
                break;
            case HUNGRY:
                scale *= 0.75F;
                GL11.glBlendFunc(770, 1);
                strip = 3;
        }
        GL11.glColor4f(1.0F, 0.0F, 1.0F, alpha);
        UtilsFX.renderAnimatedQuadStrip(scale, alpha, frames, strip, i, 0.0F, 16777215);

        GL11.glDisable(3042);
        GL11.glPopMatrix();

        GL11.glPopMatrix();

        GL11.glEnable(2884);
        GL11.glDepthMask(true);
        GL11.glAlphaFunc(516, 0.1F);
        GL11.glPopMatrix();
    }
}
 
Example #11
Source File: RegisteredManipulations.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public boolean canAffect(World world, INode node) {
    return node.getNodeModifier() != NodeModifier.FADING;
}
 
Example #12
Source File: NodeManipulatorResultHandler.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static NodeManipulatorResult getRandomResult(World world, INode affectedNode, int percChance) {
    return getRandomResult(world, world.rand, affectedNode, percChance);
}
 
Example #13
Source File: RegisteredManipulations.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public boolean canAffect(World world, INode node) {
    return node.getNodeModifier() != NodeModifier.BRIGHT;
}
 
Example #14
Source File: NodeManipulatorResult.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
public boolean canAffect(World world, INode node) {
    return true;
}
 
Example #15
Source File: AdapterNode.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@Override
public Class<?> getTargetClass() {
	return INode.class;
}
 
Example #16
Source File: AdapterNode.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.STRING, description = "Get the type of the node")
public String getNodeType(INode node) {
	NodeType nodeType = node.getNodeType();
	return (nodeType != null? nodeType.name() : NONE);
}
 
Example #17
Source File: AdapterNode.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.STRING, description = "Get the modifier of the node")
public String getNodeModifier(INode node) {
	NodeModifier nodeModifier = node.getNodeModifier();
	return (nodeModifier != null? nodeModifier.name() : NONE);
}
 
Example #18
Source File: WandHandler.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
private static void handleJarForming(World world, int x, int y, int z, int xx, int yy, int zz, boolean degrade) {
    TileEntity tile = world.getTileEntity(x + xx, y - yy + 2, z + zz);
    INode node = (INode) tile;
    AspectList na = node.getAspects().copy();
    int nt = node.getNodeType().ordinal();
    int nm = -1;
    int exNt = -1;
    NBTTagCompound behaviorSnapshot = null;
    if (node.getNodeModifier() != null) {
        nm = node.getNodeModifier().ordinal();
    }
    if(tile instanceof TileExtendedNode && ((TileExtendedNode) tile).getExtendedNodeType() != null) {
        exNt = ((TileExtendedNode) tile).getExtendedNodeType().ordinal();
        behaviorSnapshot = ((TileExtendedNode) tile).getBehaviorSnapshot();
    }
    if(degrade) {
        if (world.rand.nextFloat() < 0.75F) {
            if (node.getNodeModifier() == null) {
                nm = NodeModifier.PALE.ordinal();
            } else if (node.getNodeModifier() == NodeModifier.BRIGHT) {
                nm = -1;
            } else if (node.getNodeModifier() == NodeModifier.PALE) {
                nm = NodeModifier.FADING.ordinal();
            }
        }
    }
    String nid = node.getId();
    node.setAspects(new AspectList());
    world.removeTileEntity(x + xx, y - yy + 2, z + zz);
    if(exNt != -1) {
        world.setBlock(x + xx, y - yy + 2, z + zz, RegisteredBlocks.blockExtendedNodeJar, 0, 3);
        tile = world.getTileEntity(x + xx, y - yy + 2, z + zz);
        TileExtendedNodeJar exJar = (TileExtendedNodeJar) tile;
        exJar.setAspects(na);
        if (nm >= 0) {
            exJar.setNodeModifier(NodeModifier.values()[nm]);
        }
        exJar.setNodeType(NodeType.values()[nt]);
        exJar.setExtendedNodeType(ExtendedNodeType.values()[exNt]);
        if(behaviorSnapshot != null) {
            exJar.setBehaviorSnapshot(behaviorSnapshot);
        }
        exJar.setId(nid);
        world.addBlockEvent(x + xx, y - yy + 2, z + zz, RegisteredBlocks.blockExtendedNodeJar, 9, 0);
    } else {
        world.setBlock(x + xx, y - yy + 2, z + zz, ConfigBlocks.blockJar, 2, 3);
        tile = world.getTileEntity(x + xx, y - yy + 2, z + zz);
        TileJarNode jar = (TileJarNode) tile;
        jar.setAspects(na);
        if (nm >= 0) {
            jar.setNodeModifier(NodeModifier.values()[nm]);
        }
        jar.setNodeType(NodeType.values()[nt]);
        jar.setId(nid);
        world.addBlockEvent(x + xx, y - yy + 2, z + zz, ConfigBlocks.blockJar, 9, 0);
    }
}
 
Example #19
Source File: NodeManipulatorResult.java    From Gadomancy with GNU Lesser General Public License v3.0 votes vote down vote up
public abstract boolean affect(World world, INode node);