MCPcopy Create free account
hub / github.com/DGVPSH/SlackOpen / addEntity

Method addEntity

src/main/java/net/minecraft/world/chunk/Chunk.java:847–876  ·  view source on GitHub ↗

Adds an entity to the chunk. Args: entity

(Entity entityIn)

Source from the content-addressed store, hash-verified

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

Callers 3

readChunkFromNBTMethod · 0.95
spawnEntityInWorldMethod · 0.45

Calls 4

floor_doubleMethod · 0.95
warnMethod · 0.45
setDeadMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected