Posted April 3, 201510 yr I want my custom wagon entity to add an instance of EntityAnimal and add it to a field like an array or list for my custom entity and have the passive entity move while the wagon is moving. When getEntitiesWithinAABB is called, it's not returning any entities in the list, I am fairly new to entity processing. I am using similar code found in the method interactFirst of the EntityLeashKnot class. Here is the source code: /** * First layer of player interaction */ public boolean interactFirst(EntityPlayer playerEntity) { double minMaxAABB = 7.0D; // Get list of all entities leashed by player List leashedList = this.worldObj.getEntitiesWithinAABB( EntityAnimal.class, AxisAlignedBB.getBoundingBox((double) this.posX - minMaxAABB, (double) this.posY - minMaxAABB, (double) this.posZ - minMaxAABB, (double) this.posX - minMaxAABB, (double) this.posY + minMaxAABB, (double) this.posZ + minMaxAABB)); // if there are up to 2 entities leashed anchor them to the wagon if (leashedList != null && leashedList.size() <= 2) { System.out.println("Returned list of leashed entities on interaction with wagon entity"); Iterator iterator = leashedList.iterator(); while (iterator.hasNext()) { EntityAnimal entity = (EntityAnimal) iterator.next(); if (entity.getLeashed() && entity.getLeashedToEntity() == playerEntity) { // break leash from player entity.clearLeashed(true, true); // add entity to wagon this.entityHorses.add(entity); // DEBUG: to know the correct entities are referenced System.out.println(this.entityHorses.isEmpty()); } } } return true; }
April 4, 201510 yr You made a typo in your bounding box: AxisAlignedBB.getBoundingBox((double) this.posX - minMaxAABB, (double) this.posY - minMaxAABB, (double) this.posZ - minMaxAABB, (double) this.posX - minMaxAABB, (double) this.posY + minMaxAABB, (double) this.posZ + minMaxAABB)); The second posX should be +minMaxAABB not -minMaxAABB. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
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.