Skip to content

Commit

Permalink
Add area query to dioptra. #6
Browse files Browse the repository at this point in the history
  • Loading branch information
jco2641 committed Apr 12, 2020
1 parent 8a9d04f commit d7254f0
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions src/main/java/jco2641/thaumcomp/devices/DriverDioptra.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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<Float> 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<Float> 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};
}
}
}

0 comments on commit d7254f0

Please sign in to comment.