Jump to content

GetEntitiesWithinAABBExludingEntity is not returning entities within boundingbox


Jershy

Recommended Posts

    I am trying to get the entities within the target entity of the same type to compare variables to affect gameplay

I know for a fact there are other entities within it bounding box yet not printing the message n the ide console.

this is my code

 package src.IVWeather.entity;

import java.util.List;

import src.IVWeather.biome.BiomeTemperature;
import src.IVWeather.block.BlockFlyingBlock;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.effect.EntityWeatherEffect;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeDecorator;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk;
import src.IVWeather.*;

public class EntityWeatherAirmass extends WeatherEntity{

public Vaccume vaccum;
public float temperature;
public float maxGramsOfWaterHoldable;
public float currentGramsOfWaterInAir;
BiomeTemperature BiomeTemp;
public float evaporationrate;
public float dewpoint;
int time;
double droplesize;
boolean rainProcess;
double yboundingBoxERatePerTick;
public boolean eventFlag;
List precipitationCunkList;
public BiomeTemperature bt;
protected double GreaterTemp;
protected TempCategory tc;

public EntityWeatherAirmass(World thisworld) {
	super(thisworld);
}

public TempCategory getTempCategory() {
	return tc;
}

public EntityWeatherAirmass(World arg0, float par1, double x, double z, double ddY, float setx, float setz) {
	super(arg0);
	this.setSize(setx, setz);
	this.temperature = par1;
	this.currentGramsOfWaterInAir =  evaporationrate;
	this.maxGramsOfWaterHoldable = .1580888888888888f * (temperature * 50);
	this.humidity = (this.currentGramsOfWaterInAir * 100) / this.maxGramsOfWaterHoldable;
   int time = 0;
   droplesize = 0;
   					
   				this.posX = x;
   				this.posZ = z;
   				this.posY = ddY;
   				
   				this.CyclePeriod = IVWeather.startCycle;
}

public float gethumidity() {
return humidity;
}

public boolean canBeCollidedWith() {
return true;

}

boolean flerg;
private List collidingBoundingWeather;
public float AverageHighLow;
public float CycleExtremeityMaxT;
public int CyclePeriod;
private boolean Active;
private boolean Declining;
public boolean cycloneFlag;

public void onUpdate() {

System.out.println("UPDATING AIRMASS;");

AxisAlignedBB boundingBox = this.boundingBox;
BiomeGenBase Biom = worldObj.getBiomeGenForCoords((int)Math.floor(this.posX), (int)Math.floor(this.posZ));
if (IVWeather.Seasonalchanges)
    {
	System.out.println("SesonalChanges Accepted");

      this.AverageHighLow = (Biom.temperature + 0.4F);
      
      if (this.AverageHighLow > 2.0F) {
        this.AverageHighLow = 2.0F;
        System.out.println("Too high Average High-Low Temp, Reseting to 2.0");
      }
      
      this.CycleExtremeityMaxT = (Biom.temperature + 0.6F);
      
      if (this.CycleExtremeityMaxT > 2.1F) {
        this.CycleExtremeityMaxT = 2.1F;
        System.out.println("Maximum Temps too High, Reseting to 2.1");
      }
        float par1;
        
        if (IVWeather.Fluc)
        {
        	System.out.println("Fluc Accepted");
          par1 = (this.CycleExtremeityMaxT - Biom.temperature) / IVWeather.WeatherPatternMaxD;
        }
        else
        {
          par1 = this.AverageHighLow;
          if (this.CyclePeriod == 1) {
            par1 = this.AverageHighLow;
          } else {
            par1 = -this.AverageHighLow;
          }
        }
        if ((this.CyclePeriod == 1) && (this.Active == true)) {
          Biom.temperature += par1;
          System.out.println("Cycle Active; Warm Cycle");
        }
        if ((this.CyclePeriod == 2) && (!this.Declining) && (this.Active == true)) {
          Biom.temperature += par1;
          System.out.println("Cycle Active; Cold Cycle");
        }
        if ((Biom.temperature == this.CycleExtremeityMaxT) || (Biom.temperature == -this.CycleExtremeityMaxT))
        {
          this.Declining = true;
          
          System.out.println("Now Declining");
        }
        else
        {
          this.Declining = false;
        }
        
        if ((this.Declining == true) && (this.Active == true)) {
          this.CycleExtremeityMaxT -= par1;
        }
      }else{
    	  System.out.println("SeasonalChanges Declined");
      }

double prevPosY = this.posY;
double cbiomeTemp = Biom.temperature;
List BlockList = this.collidingBoundingWeather;
List iiiiiii = this.collidingBoundingWeather;

if(BlockList != null) {

	BlockList.clear();

}
if(iiiiiii != null) {
	iiiiiii.clear();

}
double d0 = .25;
			  List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(d0, d0, d0));
if(list !=null) {
	System.out.println("list is not null");
}
  for (int j2 = 0; j2 < list.size(); j2++)
  {
    Entity entity = ((Entity)list.get(j2));
    
    if(entity instanceof EntityWeatherAirmass){
    	System.out.println("Adding entity to list");
    	iiiiiii.add(entity);
    }
double prevY = this.posY;
double prevMY= this.boundingBox.maxY;

	if(iiiiiii != null) {
		System.out.println("List located Other Airmasses");

for(int u =0; u < iiiiiii.size(); u++) {

	EntityWeatherAirmass e = (EntityWeatherAirmass) iiiiiii.get(u);

	this.GreaterTemp = this.temperature - e.temperature;

	if(!cycloneFlag) {

	 if(e.temperature < this.temperature){

		tc = TempCategory.WARM;
		System.out.println("now WARM");
	 }else if(e.temperature > this.temperature){

		tc = TempCategory.COLD;
		System.out.println("now COLD");
	 }else if(this.temperature > e.temperature && this.humidity < e.humidity) {

		tc = TempCategory.HOT;
		System.out.println("now HOT");
	 }
	}



	boolean eAirMassTSupport = false;
	boolean thisAirMassTSupport = false;

	double distance = 0;
	 double distance2 = 0;
	 distance = Math.abs(this.temperature - cbiomeTemp);
	 distance2 = Math.abs(e.temperature - cbiomeTemp);

	 if(distance > distance2) {
		 thisAirMassTSupport = true;
		 System.out.println("recievving t-support");
	 }

	 if(tc == TempCategory.WARM) {
		if(thisAirMassTSupport){
			this.boundingBox.expand(0, this.temperature - cbiomeTemp + 4, 0);
				System.out.println("Expanding");
		}
		else
		{
		 this.motionY = ((this.temperature - e.temperature) / 4);
	}
	}

	if(tc == TempCategory.COLD) {
		if(this.getCollidingBlockWithWE(this, this.boundingBox).size() < 150 && this.boundingBox.minX <= 55) {
		this.motionY = ((this.temperature - e.temperature) / 4);
		}
	}
	if(tc == TempCategory.HOT)  {
		this.motionY = ((this.temperature - e.temperature) / 3);
		if(e.humidity - this.humidity > this.humidity + (this.humidity / 6)) {
			flerg = true;
		}
	}

	if(flerg == true) {
		this.humidity = this.humidity + (float) .001;
	}
	if(list.size() == 0) {
		if(this.temperature > cbiomeTemp) {
			tc = TempCategory.WARM;
		}else{
			tc = TempCategory.COLD;
		}
		this.boundingBox.expand(15, 0, 15);
		if(this.boundingBox.maxY < 3000) {
			this.boundingBox.expand(0, 15, 0);
			if(tc == TempCategory.WARM && this.boundingBox.maxY > (Biom.temperature - (this.boundingBox.maxY / 700))) {

			}
		}
	}
		this.evaporationrate = (float) (Biom.temperature);

	this.currentGramsOfWaterInAir = maxGramsOfWaterHoldable / evaporationrate; 
	this.maxGramsOfWaterHoldable = .1580888888888888f * (temperature * 50);
	this.humidity = (this.currentGramsOfWaterInAir * 100) / this.maxGramsOfWaterHoldable;
   dewpoint = bt.getDewPoint(humidity, this.temperature);
   
   yboundingBoxERatePerTick = prevMY - prevY;
   
   if(this.temperature <= dewpoint) {
	   this.rainProcess = true;
	   if(droplesize <= 0) {
	   droplesize = .0000000001;
	  }
	 droplesize =  droplesize  * time;
   
	  int gravity = 18000;
  
   if(droplesize > (gravity + (this.yboundingBoxERatePerTick ) * 2.) {
	   double maxx = this.boundingBox.maxX;
	   double minx = this.boundingBox.minX;
	   double maxz = this.boundingBox.maxZ;
	   double minz = this.boundingBox.minZ;
	   
	   for(int o = (int) minx; o < maxx; o++) {
		   for(int p = (int) minz; p < maxz; p++) {
		  
			  Chunk C = worldObj.getChunkFromBlockCoords(o, p);

			  this.precipitationCunkList.clear();
			  
			  this.precipitationCunkList.add(C);
			  if(this.precipitationCunkList != null) {
				  System.out.println("Precipitation");
			  }else{
				  System.out.println("No Rain List");
			  }
		   }
	   }
	   
   }
   }
   
   double velocity = (this.motionX + this.motionY + this.motionZ )/3;
   		
   if(this.humidity < e.humidity) {
	   this.humidity = this.humidity + ((e.humidity - this.humidity)/50);
   }else if(this.humidity < bt.getBiomeTemp(Biom)) {
	   this.humidity = this.humidity + ((e.humidity - bt.getBiomeTemp(Biom))/50);
   }
   

	  }
}else{
			System.err.println("No Airmasses found");


				this.motionY = Biom.temperature - this.temperature;

		}
  	}
  }



protected void entityInit() {



}

public List collidingAirmasses(EntityWeatherAirmass ewa) {
List list = this.collidingBoundingWeather;
list.clear();
  int i = MathHelper.floor_double(ewa.posX + this.boundingBox.minX);
  int j = MathHelper.floor_double(ewa.posX + this.boundingBox.maxX + 1.0D);
  int k = MathHelper.floor_double(ewa.posY + this.boundingBox.minY);
  int l = MathHelper.floor_double(ewa.posY + this.boundingBox.maxY + 1.0D);
  int i1 = MathHelper.floor_double(ewa.posZ + this.boundingBox.minZ);
  int j1 = MathHelper.floor_double(ewa.posX + this.boundingBox.maxZ + 1.0D);
  double d0 = 0.25D;
  System.out.println(i);
  System.out.println(j);
  System.out.println(k);
  System.out.println(l);
  System.out.println(i1);
  System.out.println(j1);
  for(int q = i; q < j; q++) {
	  for(int w = k; k < l; k++) {
		  for(int f = i1; f < j1; f++) {

			  Block block = worldObj.getBlock(q, w, f);
			  
			  List list2 = worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(d0, d0, d0));
  
  for (int j2 = 0; j2 < list2.size(); j2++)
  {
    Entity entity = ((Entity)list2.get(j2));
    
    if(entity instanceof EntityWeatherAirmass){
    
    	list.add(entity);
    }
  }
}
   }
  }
  return list;
}

@Override
protected void readEntityFromNBT(NBTTagCompound arg0) {

}

@Override
protected void writeEntityToNBT(NBTTagCompound arg0) {
// TODO Auto-generated method stub

}

public enum TempCategory {

WARM, COLD, HOT, COOL;

}

}

 

thank you for reading.

Link to comment
Share on other sites

Though I can't tell immediately with the code you provided, but it could be that the chunk you are checking isn't loaded. worldObj.getEntitiesWithinAABB checks whether or not the chunk is loaded before it determines which entities are within the specified area. Double check that the chunk is loaded by using 'worlObj.chunkExists(chunkCoordX, chunkCoordY)'.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • where opportunities abound and promises of financial prosperity beckon from every corner of the internet, the line between opportunity and deception becomes increasingly blurred. As a 38-year-old single mom, I embarked on a journey into the world of cryptocurrency investing, hoping to secure a brighter future for myself and my family. Little did I know, this journey would lead me down a treacherous path fraught with deception and heartbreak. My foray into cryptocurrency investing began with the promise of lucrative returns from a platform claiming to operate within Europe and South Asia. Blinded by optimism and the allure of financial gain, I entrusted my hard-earned savings to this fraudulent company, believing wholeheartedly in its legitimacy. However, my hopes were dashed when I began encountering difficulties with withdrawals and found myself entangled in a web of exorbitant fees and dubious practices. In a desperate bid to salvage what remained of my investment, I turned to a recovery company recommended to me by the very platform that had deceived me. Yet, even in my darkest hour, the deceit persisted, as I soon discovered that the company tasked with recovering my funds was complicit in the deception. Faced with the crushing realization that I had been betrayed once again, I felt a sense of hopelessness engulf me. It was in this moment of despair that I stumbled upon Lee Ultimate Hacker – a shining beacon of hope amidst the darkness of deception. Through a stroke of luck, I came across a blog post singing the praises of this remarkable team, and I knew I had found my savior. With nothing left to lose and everything to gain, I reached out to them, hoping against hope for a chance at redemption. From the outset, Lee Ultimate Hacker proved to be a guiding light in my journey toward financial recovery. Their professionalism, expertise, and unwavering commitment to client satisfaction set them apart from the myriad of recovery services in the digital sphere. With empathy and understanding, they listened to my story and embarked on a mission to reclaim what was rightfully mine. Through their diligent efforts and meticulous attention to detail, Lee Ultimate Hacker succeeded where others had failed, restoring a sense of hope and security in the wake of betrayal. Their dedication to justice and unwavering determination to deliver results ensured that I emerged from the ordeal stronger and more resilient than ever before. Throughout the recovery process, their team remained accessible, transparent, and supportive, offering guidance and reassurance every step of the way. To anyone grappling with devastating financial fraud, I offer a lifeline of hope – trust in Lee Ultimate Hacker to guide you through the storm with expertise and compassion. In a world rife with deception and uncertainty, they stand as a beacon of reliability and trustworthiness, ready to lead you toward financial restitution and a brighter future. If you find yourself in a similar predicament, do not hesitate to reach out to Lee Ultimate Hacker.AT LEEULTIMATEHACKER@ AOL. COM   Support @ leeultimatehacker . com.  telegram:LEEULTIMATE   wh@tsapp +1  (715) 314  -  9248  https://leeultimatehacker.com
    • Sorry, this is the report https://paste.ee/p/OeDj1
    • Please share a link to your crash report on https://paste.ee, as explained in the FAQ
    • This is the crash report [User dumped their crash report directly in their thread, triggering the anti-spam]  
    • Add the crash-report or latest.log (logs-folder) with sites like https://paste.ee/ and paste the link to it here  
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.