-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
PatchChunk.java
56 lines (46 loc) · 1.85 KB
/
PatchChunk.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package me.nallar.tickthreading.minecraft.patched;
import cpw.mods.fml.common.FMLLog;
import net.minecraft.entity.Entity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.event.world.ChunkEvent;
public abstract class PatchChunk extends Chunk {
public PatchChunk(World par1World, int par2, int par3) {
super(par1World, par2, par3);
}
@Override
public void onChunkLoad() {
this.isChunkLoaded = true;
this.worldObj.addTileEntity(this.chunkTileEntityMap.values());
for (int var1 = 0; var1 < this.entityLists.length; ++var1) {
this.worldObj.addLoadedEntities(this.entityLists[var1]);
}
MinecraftForge.EVENT_BUS.post(new ChunkEvent.Load(this));
}
@Override
public void addEntity(Entity par1Entity) {
int var2 = MathHelper.floor_double(par1Entity.posX / 16.0D);
int var3 = MathHelper.floor_double(par1Entity.posZ / 16.0D);
if (var2 != this.xPosition || var3 != this.zPosition) {
FMLLog.warning("Entity %s added to the wrong chunk - expected x%d z%d, got x%d z%d", par1Entity.toString(), this.xPosition, this.zPosition, var2, var3);
return;
}
this.hasEntities = true;
int var4 = MathHelper.floor_double(par1Entity.posY / 16.0D);
if (var4 < 0) {
var4 = 0;
}
if (var4 >= this.entityLists.length) {
var4 = this.entityLists.length - 1;
}
MinecraftForge.EVENT_BUS.post(new EntityEvent.EnteringChunk(par1Entity, this.xPosition, this.zPosition, par1Entity.chunkCoordX, par1Entity.chunkCoordZ));
par1Entity.addedToChunk = true;
par1Entity.chunkCoordX = this.xPosition;
par1Entity.chunkCoordY = var4;
par1Entity.chunkCoordZ = this.zPosition;
this.entityLists[var4].add(par1Entity);
}
}