thaumcraft.api.aspects.IAspectContainer Java Examples

The following examples show how to use thaumcraft.api.aspects.IAspectContainer. 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: AdapterAspectContainer.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.TABLE, description = "Get the map of aspects stored in the block (summed, if there are multiple entries)")
public Map<String, Integer> getAspectsSum(IAspectContainer container) {
	AspectList aspectList = container.getAspects();
	if (aspectList == null) return null;
	Map<String, Integer> result = Maps.newHashMap();
	for (Aspect aspect : aspectList.getAspects()) {
		if (aspect == null) continue;
		String name = aspect.getName();
		int amount = Objects.firstNonNull(result.get(name), 0);
		result.put(name, amount + aspectList.getAmount(aspect));
	}
	return result;
}
 
Example #3
Source File: AdapterAspectContainer.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.NUMBER, description = "Get amount of specific aspect stored in this block")
public int getAspectCount(IAspectContainer container,
		@Arg(name = "aspect", description = "Aspect to be checked") String aspectName) {

	Aspect aspect = Aspect.getAspect(aspectName.toLowerCase(Locale.ENGLISH));
	Preconditions.checkNotNull(aspect, "Invalid aspect name");
	AspectList list = container.getAspects();
	if (list == null) return 0;
	return list.getAmount(aspect);
}
 
Example #4
Source File: AdapterJar.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.TABLE, description = "Get the Aspects stored in the block")
public List<Map<String, Object>> getAspects(IAspectContainer container) {
	List<Map<String, Object>> result = ConverterAspectList.aspectsToMap(container.getAspects());
	if (result.isEmpty()) {
		Aspect filter = ASPECT_FILTER.get(container);
		if (filter != null) ConverterAspectList.appendAspectEntry(result, filter, 0);
	}

	return result;
}
 
Example #5
Source File: DroneInteractEssentiaImport.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean doInteract(ChunkPosition pos, IDrone drone, IBlockInteractHandler interactHandler, boolean simulate){
    TileEntity te = drone.getWorld().getTileEntity(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
    if(te instanceof IAspectContainer) {
        IAspectContainer container = (IAspectContainer)te;

    }
    return false;
}
 
Example #6
Source File: AdapterAspectContainer.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@Override
public Class<?> getTargetClass() {
	return IAspectContainer.class;
}
 
Example #7
Source File: AdapterAspectContainer.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.TABLE, description = "Get the Aspects stored in the block")
public AspectList getAspects(IAspectContainer container) {
	return container.getAspects();
}
 
Example #8
Source File: BlockTrackEntryThaumcraft.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean shouldTrackWithThisEntry(IBlockAccess world, int x, int y, int z, Block block, TileEntity te){
    return te instanceof IAspectContainer;
}