diff --git a/src/main/java/jco2641/thaumcomp/devices/DriverDioptra.java b/src/main/java/jco2641/thaumcomp/devices/DriverDioptra.java index 837d3b4..3f0d5fd 100644 --- a/src/main/java/jco2641/thaumcomp/devices/DriverDioptra.java +++ b/src/main/java/jco2641/thaumcomp/devices/DriverDioptra.java @@ -12,6 +12,8 @@ import net.minecraft.world.World; import jco2641.thaumcomp.util.ManagedTileEntityEnvironment; +import java.util.ArrayList; + /* Derived from work Copyright (c) 2013-2015 Florian "Sangar" Nücke published under MIT license */ @@ -32,16 +34,52 @@ public EnvironmentAspectContainer(final TileDioptra dioptra) { super(dioptra, "thaumic_dioptra"); } - @Callback(doc = "function():number -- Get the vis in the current chunk") + @Callback(doc = "function():float -- Get the vis in the current chunk") public Object[] getVis(final Context context, final Arguments args) { final float vis = AuraHelper.getVis(tileEntity.getWorld(), tileEntity.getPos()); return new Object[]{vis}; } - @Callback(doc = "function():number -- Get the flux in the current chunk") + @Callback(doc = "function():float -- Get the flux in the current chunk") public Object[] getFlux(final Context context, final Arguments args) { final float flux = AuraHelper.getFlux(tileEntity.getWorld(), tileEntity.getPos()); return new Object[]{flux}; } + + @Callback(doc = "function(int N:number of chunks):list(float) -- Get the Vis in the surrounding N(<7) chunk radius") + public Object[] getVisMap(final Context context, final Arguments args) { + ArrayList visValues = new ArrayList<>(); + int radius; + if ( args.checkInteger(0) > 5 ) { + radius = 6; + } else { + radius = args.checkInteger(0); + } + int offs = (16 * radius); + for (int zoffs = -offs; zoffs <= offs; zoffs += 16) { + for ( int xoffs = -offs; xoffs <= offs; xoffs += 16 ) { + visValues.add((float) AuraHelper.getVis(tileEntity.getWorld(), tileEntity.getPos().add(xoffs, 0, zoffs))); + } + } + return new Object[]{visValues}; + } + + @Callback(doc = "function(int N: number of chunks):list(float) -- Get the Flux in the surrounding N(<7) chunk radius") + public Object[] getFluxMap(final Context context, final Arguments args) { + ArrayList fluxValues = new ArrayList<>(); + int radius; + if (args.checkInteger(0) > 5) { + radius = 6; + } else { + radius = args.checkInteger(0); + } + int offs = (16 * radius); + for (int zoffs = -offs; zoffs <= offs; zoffs += 16) { + for (int xoffs = -offs; xoffs <= offs; xoffs += 16) { + fluxValues.add((float) AuraHelper.getFlux(tileEntity.getWorld(), tileEntity.getPos().add(xoffs, 0, zoffs))); + } + } + return new Object[]{fluxValues}; + } } }