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

    • Baba  Serege [[+27-73 590 8989]] has experience of 27 years in helping and guiding many people from all over the world. His psychic abilities may help you answer and resolve many unanswered questions. He specialize in helping women and men from all walks of life.. 1) – Bring back lost lover. even if lost for a long time. 2) – My lover is abusing alcohol, partying and cheating on me I urgently need help” 3) – Divorce or court issues. 4) – Is your love falling apart? 5) – Do you want your love to grow stronger? 6) – Is your partner losing interest in you? 7) – Do you want to catch your partner cheating on you? – We help to keep your partner faithful and loyal to you. 9) – We recover love and happiness when relationship breaks down. 10) – Making your partner loves you alone. 11) – We create loyalty and everlasting love between couples. 12) – Get a divorce settlement quickly from your ex-partner. 13) – We create everlasting love between couples. 14) – We help you look for the best suitable partner. 15) – We bring back lost lover even if lost for a long time. 16) – We strengthen bonds in all love relationship and marriages 17) – Are you an herbalist who wants to get more powers? 18) – Buy a house or car of your dream. 19) – Unfinished jobs by other doctors come to me. 20) – I help those seeking employment. 21) – Pensioners free treatment. 22) – Win business tenders and contracts. 23) – Do you need to recover your lost property? 24) – Promotion at work and better pay. 25) – Do you want to be protected from bad spirits and nightmares? 26) – Financial problems. 27) – Why you can’t keep money or lovers? 28) – Why you have a lot of enemies? 29) – Why you are fired regularly on jobs? 30) – Speed up money claim spell, delayed payments, pension and accident funds 31) – I help students pass their exams/interviews. 33) – Removal of bad luck and debts. 34) – Are struggling to sleep because of a spiritual wife or husband. 35- ) Recover stolen property
    • OLXTOTO adalah situs bandar togel online resmi terbesar dan terpercaya di Indonesia. Bergabunglah dengan OLXTOTO dan nikmati pengalaman bermain togel yang aman dan terjamin. Koleksi toto 4D dan togel toto terlengkap di OLXTOTO membuat para member memiliki pilihan taruhan yang lebih banyak. Sebagai situs togel terpercaya, OLXTOTO menjaga keamanan dan kenyamanan para membernya dengan sistem keamanan terbaik dan enkripsi data. Transaksi yang cepat, aman, dan terpercaya merupakan jaminan dari OLXTOTO. Nikmati layanan situs toto terbaik dari OLXTOTO dengan tampilan yang user-friendly dan mudah digunakan. Layanan pelanggan tersedia 24/7 untuk membantu para member. Bergabunglah dengan OLXTOTO sekarang untuk merasakan pengalaman bermain togel yang menyenangkan dan menguntungkan.
    • Baba  Serege [[+27-73 590 8989]] has experience of 27 years in helping and guiding many people from all over the world. His psychic abilities may help you answer and resolve many unanswered questions. He specialize in helping women and men from all walks of life.. 1) – Bring back lost lover. even if lost for a long time. 2) – My lover is abusing alcohol, partying and cheating on me I urgently need help” 3) – Divorce or court issues. 4) – Is your love falling apart? 5) – Do you want your love to grow stronger? 6) – Is your partner losing interest in you? 7) – Do you want to catch your partner cheating on you? – We help to keep your partner faithful and loyal to you. 9) – We recover love and happiness when relationship breaks down. 10) – Making your partner loves you alone. 11) – We create loyalty and everlasting love between couples. 12) – Get a divorce settlement quickly from your ex-partner. 13) – We create everlasting love between couples. 14) – We help you look for the best suitable partner. 15) – We bring back lost lover even if lost for a long time. 16) – We strengthen bonds in all love relationship and marriages 17) – Are you an herbalist who wants to get more powers? 18) – Buy a house or car of your dream. 19) – Unfinished jobs by other doctors come to me. 20) – I help those seeking employment. 21) – Pensioners free treatment. 22) – Win business tenders and contracts. 23) – Do you need to recover your lost property? 24) – Promotion at work and better pay. 25) – Do you want to be protected from bad spirits and nightmares? 26) – Financial problems. 27) – Why you can’t keep money or lovers? 28) – Why you have a lot of enemies? 29) – Why you are fired regularly on jobs? 30) – Speed up money claim spell, delayed payments, pension and accident funds 31) – I help students pass their exams/interviews. 33) – Removal of bad luck and debts. 34) – Are struggling to sleep because of a spiritual wife or husband. 35- ) Recover stolen property
  • Topics

×
×
  • Create New...

Important Information

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