本文整理汇总了Java中thaumcraft.api.WorldCoordinates类的典型用法代码示例。如果您正苦于以下问题:Java WorldCoordinates类的具体用法?Java WorldCoordinates怎么用?Java WorldCoordinates使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WorldCoordinates类属于thaumcraft.api包,在下文中一共展示了WorldCoordinates类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeThisNode
import thaumcraft.api.WorldCoordinates; //导入依赖的package包/类
public void removeThisNode() {
for (WeakReference<TileVisNode> n : getChildren()) {
if ( (n != null) && (n.get() != null)) {
n.get().removeThisNode();
}
}
children = new ArrayList<WeakReference<TileVisNode>>();
if (VisNetHandler.isNodeValid(this.getParent())) {
this.getParent().get().nodeRefresh = true;
}
this.setParent(null);
this.parentChanged();
if (this.isSource()) {
HashMap<WorldCoordinates, WeakReference<TileVisNode>> sourcelist = VisNetHandler.sources.get(worldObj.provider.dimensionId);
if (sourcelist == null) {
sourcelist = new HashMap<WorldCoordinates, WeakReference<TileVisNode>>();
}
sourcelist.remove(getLocation());
VisNetHandler.sources.put(worldObj.provider.dimensionId, sourcelist);
}
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
示例2: findClosestNodes
import thaumcraft.api.WorldCoordinates; //导入依赖的package包/类
public static ArrayList<Object[]> findClosestNodes(TileVisNode target, TileVisNode parent, ArrayList<Object[]> in) {
if ( (cache.size() > 512) || cache.contains(new WorldCoordinates(parent))) {
return in;
}
cache.add(new WorldCoordinates(parent));
for (WeakReference<TileVisNode> childWR : parent.getChildren()) {
TileVisNode child = childWR.get();
if ( (child != null) && !child.equals(target) && !child.equals(parent)) {
float r2 = inRange(child.getWorldObj(), child.getLocation(), target.getLocation(), target.getRange());
if (r2 > 0) {
in.add(new Object[] {
child,
r2
});
}
in = findClosestNodes(target, child, in);
}
}
return in;
}
示例3: removeThisNode
import thaumcraft.api.WorldCoordinates; //导入依赖的package包/类
public void removeThisNode() {
for (WeakReference<TileVisNode> n:getChildren()) {
if (n!=null && n.get()!=null) {
n.get().removeThisNode();
}
}
children = new ArrayList<WeakReference<TileVisNode>>();
if (VisNetHandler.isNodeValid(this.getParent())) {
this.getParent().get().nodeRefresh=true;
}
this.setParent(null);
this.parentChanged();
if (this.isSource()) {
HashMap<WorldCoordinates, WeakReference<TileVisNode>> sourcelist = VisNetHandler.sources.get(worldObj.provider.dimensionId);
if (sourcelist==null) {
sourcelist = new HashMap<WorldCoordinates, WeakReference<TileVisNode>>();
}
sourcelist.remove(getLocation());
VisNetHandler.sources.put( worldObj.provider.dimensionId, sourcelist );
}
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
示例4: findClosestNodes
import thaumcraft.api.WorldCoordinates; //导入依赖的package包/类
public static ArrayList<Object[]> findClosestNodes(TileVisNode target,
TileVisNode parent, ArrayList<Object[]> in) {
if (cache.size() > 512 || cache.contains(new WorldCoordinates(parent))) return in;
cache.add(new WorldCoordinates(parent));
for (WeakReference<TileVisNode> childWR : parent.getChildren()) {
TileVisNode child = childWR.get();
if (child != null && !child.equals(target) && !child.equals(parent)) {
float r2 = inRange(child.getWorldObj(), child.getLocation(),
target.getLocation(), target.getRange());
if (r2 > 0) {
in.add(new Object[] { child, r2 });
}
in = findClosestNodes(target, child, in);
}
}
return in;
}
示例5: findClosestNodes
import thaumcraft.api.WorldCoordinates; //导入依赖的package包/类
public static ArrayList<Object[]> findClosestNodes(TileVisNode target, TileVisNode parent, ArrayList<Object[]> in)
{
if(cache.size() > 512 || cache.contains(new WorldCoordinates(parent))) return in;
cache.add(new WorldCoordinates(parent));
for(WeakReference<TileVisNode> childWR : parent.getChildren())
{
TileVisNode child = childWR.get();
if(child != null && !child.equals(target) && !child.equals(parent))
{
float r2 = inRange(child.getWorldObj(), child.getLocation(), target.getLocation(), target.getRange());
if(r2 > 0)
{
in.add(new Object[]{child, r2});
}
in = findClosestNodes(target, child, in);
}
}
return in;
}
示例6: doDrain
import thaumcraft.api.WorldCoordinates; //导入依赖的package包/类
private boolean doDrain(Aspect a, List<WorldCoordinates> coordinates) {
for (WorldCoordinates coordinate : coordinates) {
TileEntity sourceTile = worldObj.getTileEntity(coordinate.x, coordinate.y, coordinate.z);
if ((sourceTile == null) || (!(sourceTile instanceof IAspectSource))) {
continue;
}
if(sourceTile instanceof TileEssentiaCompressor) continue;
IAspectSource as = (IAspectSource)sourceTile;
AspectList contains = as.getAspects();
if(contains == null || contains.visSize() > al.visSize()) continue;
if(!canAccept(a)) continue;
if (as.takeFromContainer(a, 1)) {
PacketHandler.INSTANCE.sendToAllAround(new PacketFXEssentiaSource(xCoord, yCoord + 1, zCoord,
(byte)(xCoord - coordinate.x), (byte)(yCoord - coordinate.y + 1), (byte)(zCoord - coordinate.z),
a.getColor()), new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord + 1, zCoord, 32.0D));
return true;
}
}
return false;
}
示例7: searchAndGetSources
import thaumcraft.api.WorldCoordinates; //导入依赖的package包/类
private List<WorldCoordinates> searchAndGetSources() {
WorldCoordinates thisCoordinates = new WorldCoordinates(this);
Map<WorldCoordinates, List<WorldCoordinates>> teSources = new HashMap<WorldCoordinates, List<WorldCoordinates>>();
getSourcesField(teSources);
if(!teSources.containsKey(thisCoordinates)) {
searchSources();
getSourcesField(teSources);
if(teSources.containsKey(thisCoordinates)) {
return searchAndGetSources();
}
return new ArrayList<WorldCoordinates>();
}
List<WorldCoordinates> result = teSources.get(thisCoordinates);
((Map<WorldCoordinates, List<WorldCoordinates>>) injEssentiaHandler.getField("sources")).remove(thisCoordinates);
return result;
}
示例8: removeThisNode
import thaumcraft.api.WorldCoordinates; //导入依赖的package包/类
public void removeThisNode() {
for (WeakReference<TileVisNode> n : getChildren()) {
if (n != null && n.get() != null) {
n.get().removeThisNode();
}
}
children = new ArrayList<WeakReference<TileVisNode>>();
if (VisNetHandler.isNodeValid(this.getParent())) {
this.getParent().get().nodeRefresh = true;
}
this.setParent(null);
this.parentChanged();
if (this.isSource()) {
HashMap<WorldCoordinates, WeakReference<TileVisNode>> sourcelist = VisNetHandler.sources.get(worldObj.provider.dimensionId);
if (sourcelist == null) {
sourcelist = new HashMap<WorldCoordinates, WeakReference<TileVisNode>>();
}
sourcelist.remove(getLocation());
VisNetHandler.sources.put(worldObj.provider.dimensionId, sourcelist);
}
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
示例9: findClosestNodes
import thaumcraft.api.WorldCoordinates; //导入依赖的package包/类
public static ArrayList<Object[]> findClosestNodes(TileVisNode target,
TileVisNode parent, ArrayList<Object[]> in) {
if (cache.size() > 512 || cache.contains(new WorldCoordinates(parent))) {
return in;
}
cache.add(new WorldCoordinates(parent));
for (WeakReference<TileVisNode> childWR : parent.getChildren()) {
TileVisNode child = childWR.get();
if (child != null && !child.equals(target) && !child.equals(parent)) {
float r2 = inRange(child.getWorldObj(), child.getLocation(),
target.getLocation(), target.getRange());
if (r2 > 0) {
in.add(new Object[]{child, r2});
}
in = findClosestNodes(target, child, in);
}
}
return in;
}
示例10: drainVis
import thaumcraft.api.WorldCoordinates; //导入依赖的package包/类
/**
* This method drains vis from a relay or source near the passed in location. The amount
* received can be less than the amount requested so take that into account.
*
* @param world
* @param x
* the x position of the draining block or entity
* @param y
* the y position of the draining block or entity
* @param z
* the z position of the draining block or entity
* @param aspect
* what aspect to drain
* @param amount
* how much to drain
* @return how much was actually drained
*/
public static int drainVis(World world, int x, int y, int z, Aspect aspect, int amount) {
int drainedAmount = 0;
WorldCoordinates drainer = new WorldCoordinates(x, y, z, world.provider.dimensionId);
if (!nearbyNodes.containsKey(drainer)) {
calculateNearbyNodes(world, x, y, z);
}
ArrayList<WeakReference<TileVisNode>> nodes = nearbyNodes.get(drainer);
if ( (nodes != null) && (nodes.size() > 0)) {
for (WeakReference<TileVisNode> noderef : nodes) {
TileVisNode node = noderef.get();
if (node == null) {
continue;
}
int a = node.consumeVis(aspect, amount);
drainedAmount += a;
amount -= a;
if (a > 0) {
int color = Aspect.getPrimalAspects().indexOf(aspect);
generateVisEffect(world.provider.dimensionId, x, y, z, node.xCoord, node.yCoord, node.zCoord, color);
}
if (amount <= 0) {
break;
}
}
}
return drainedAmount;
}
示例11: addSource
import thaumcraft.api.WorldCoordinates; //导入依赖的package包/类
public static void addSource(World world, TileVisNode vs) {
HashMap<WorldCoordinates, WeakReference<TileVisNode>> sourcelist = sources.get(world.provider.dimensionId);
if (sourcelist == null) {
sourcelist = new HashMap<WorldCoordinates, WeakReference<TileVisNode>>();
}
sourcelist.put(vs.getLocation(), new WeakReference(vs));
sources.put(world.provider.dimensionId, sourcelist);
nearbyNodes.clear();
}
示例12: calculateNearbyNodes
import thaumcraft.api.WorldCoordinates; //导入依赖的package包/类
private static void calculateNearbyNodes(World world, int x, int y, int z) {
HashMap<WorldCoordinates, WeakReference<TileVisNode>> sourcelist = sources.get(world.provider.dimensionId);
if (sourcelist == null) {
sourcelist = new HashMap<WorldCoordinates, WeakReference<TileVisNode>>();
return;
}
ArrayList<WeakReference<TileVisNode>> cn = new ArrayList<WeakReference<TileVisNode>>();
WorldCoordinates drainer = new WorldCoordinates(x, y, z, world.provider.dimensionId);
ArrayList<Object[]> nearby = new ArrayList<Object[]>();
for (WeakReference<TileVisNode> root : sourcelist.values()) {
if (!isNodeValid(root)) {
continue;
}
TileVisNode source = root.get();
TileVisNode closest = null;
float range = Float.MAX_VALUE;
float r = inRange(world, drainer, source.getLocation(), source.getRange());
if (r > 0) {
range = r;
closest = source;
}
ArrayList<WeakReference<TileVisNode>> children = new ArrayList<WeakReference<TileVisNode>>();
children = getAllChildren(source, children);
for (WeakReference<TileVisNode> child : children) {
TileVisNode n = child.get();
if ( (n != null) && !n.equals(root)) {
float r2 = inRange(n.getWorldObj(), n.getLocation(), drainer, n.getRange());
if ( (r2 > 0) && (r2 < range)) {
range = r2;
closest = n;
}
}
}
if (closest != null) {
cn.add(new WeakReference(closest));
}
}
nearbyNodes.put(drainer, cn);
}
示例13: drainVis
import thaumcraft.api.WorldCoordinates; //导入依赖的package包/类
/**
* This method drains vis from a relay or source near the passed in
* location. The amount received can be less than the amount requested so
* take that into account.
*
* @param world
* @param x the x position of the draining block or entity
* @param y the y position of the draining block or entity
* @param z the z position of the draining block or entity
* @param aspect what aspect to drain
* @param amount how much to drain
* @return how much was actually drained
*/
public static int drainVis(World world, int x, int y, int z, Aspect aspect, int amount) {
int drainedAmount = 0;
WorldCoordinates drainer = new WorldCoordinates(x, y, z,
world.provider.dimensionId);
if (!nearbyNodes.containsKey(drainer)) {
calculateNearbyNodes(world, x, y, z);
}
ArrayList<WeakReference<TileVisNode>> nodes = nearbyNodes.get(drainer);
if (nodes!=null && nodes.size()>0)
for (WeakReference<TileVisNode> noderef : nodes) {
TileVisNode node = noderef.get();
if (node == null) continue;
int a = node.consumeVis(aspect, amount);
drainedAmount += a;
amount -= a;
if (a>0) {
int color = Aspect.getPrimalAspects().indexOf(aspect);
generateVisEffect(world.provider.dimensionId, x, y, z, node.xCoord, node.yCoord, node.zCoord, color);
}
if (amount <= 0) {
break;
}
}
return drainedAmount;
}
示例14: addSource
import thaumcraft.api.WorldCoordinates; //导入依赖的package包/类
public static void addSource(World world, TileVisNode vs) {
HashMap<WorldCoordinates, WeakReference<TileVisNode>> sourcelist = sources
.get(world.provider.dimensionId);
if (sourcelist == null) {
sourcelist = new HashMap<WorldCoordinates, WeakReference<TileVisNode>>();
}
sourcelist.put(vs.getLocation(), new WeakReference(vs));
sources.put(world.provider.dimensionId, sourcelist);
nearbyNodes.clear();
}
示例15: removeThisNode
import thaumcraft.api.WorldCoordinates; //导入依赖的package包/类
public void removeThisNode()
{
for(WeakReference<TileVisNode> n : getChildren())
{
if(n != null && n.get() != null)
{
n.get().removeThisNode();
}
}
children = new ArrayList<WeakReference<TileVisNode>>();
if(VisNetHandler.isNodeValid(this.getParent()))
{
this.getParent().get().nodeRefresh = true;
}
this.setParent(null);
this.parentChanged();
if(this.isSource())
{
HashMap<WorldCoordinates, WeakReference<TileVisNode>> sourcelist = VisNetHandler.sources.get(worldObj.provider.dimensionId);
if(sourcelist == null)
{
sourcelist = new HashMap<WorldCoordinates, WeakReference<TileVisNode>>();
}
sourcelist.remove(getLocation());
VisNetHandler.sources.put(worldObj.provider.dimensionId, sourcelist);
}
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}