Adds an entity to the chunk. Args: entity
(Entity entityIn)
| 845 | * Adds an entity to the chunk. Args: entity |
| 846 | */ |
| 847 | public void addEntity(Entity entityIn) |
| 848 | { |
| 849 | this.hasEntities = true; |
| 850 | int i = MathHelper.floor_double(entityIn.posX / 16.0D); |
| 851 | int j = MathHelper.floor_double(entityIn.posZ / 16.0D); |
| 852 | |
| 853 | if (i != this.xPosition || j != this.zPosition) |
| 854 | { |
| 855 | logger.warn("Wrong location! (" + i + ", " + j + ") should be (" + this.xPosition + ", " + this.zPosition + "), " + entityIn, new Object[] {entityIn}); |
| 856 | entityIn.setDead(); |
| 857 | } |
| 858 | |
| 859 | int k = MathHelper.floor_double(entityIn.posY / 16.0D); |
| 860 | |
| 861 | if (k < 0) |
| 862 | { |
| 863 | k = 0; |
| 864 | } |
| 865 | |
| 866 | if (k >= this.entityLists.length) |
| 867 | { |
| 868 | k = this.entityLists.length - 1; |
| 869 | } |
| 870 | |
| 871 | entityIn.addedToChunk = true; |
| 872 | entityIn.chunkCoordX = this.xPosition; |
| 873 | entityIn.chunkCoordY = k; |
| 874 | entityIn.chunkCoordZ = this.zPosition; |
| 875 | this.entityLists[k].add(entityIn); |
| 876 | } |
| 877 | |
| 878 | /** |
| 879 | * removes entity using its y chunk coordinate as its index |
no test coverage detected