Add IChunkLoadHandler.canEntityUpdate() function to allow entities to update while in custom loaded chunks.
This commit is contained in:
parent
21afe2a2aa
commit
1a024e5656
4 changed files with 38 additions and 0 deletions
|
@ -182,6 +182,18 @@ public class ForgeHooks
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean canUpdateEntity(Entity entity)
|
||||||
|
{
|
||||||
|
for(IChunkLoadHandler loader : chunkLoadHandlers)
|
||||||
|
{
|
||||||
|
if(loader.canUpdateEntity(entity))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
static LinkedList<IChunkLoadHandler> chunkLoadHandlers = new LinkedList<IChunkLoadHandler>();
|
static LinkedList<IChunkLoadHandler> chunkLoadHandlers = new LinkedList<IChunkLoadHandler>();
|
||||||
|
|
||||||
public static boolean onEntityInteract(EntityPlayer player, Entity entity, boolean isAttack)
|
public static boolean onEntityInteract(EntityPlayer player, Entity entity, boolean isAttack)
|
||||||
|
|
|
@ -3,6 +3,7 @@ package net.minecraft.src.forge;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import net.minecraft.src.Chunk;
|
import net.minecraft.src.Chunk;
|
||||||
import net.minecraft.src.ChunkCoordIntPair;
|
import net.minecraft.src.ChunkCoordIntPair;
|
||||||
|
import net.minecraft.src.Entity;
|
||||||
import net.minecraft.src.World;
|
import net.minecraft.src.World;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,4 +25,11 @@ public interface IChunkLoadHandler
|
||||||
* @param chunk The chunk to be unloaded
|
* @param chunk The chunk to be unloaded
|
||||||
*/
|
*/
|
||||||
public boolean canUnloadChunk(Chunk chunk);
|
public boolean canUnloadChunk(Chunk chunk);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called from World.updateEntityWithOptionalForce.
|
||||||
|
* Return true to allow this entity to update.
|
||||||
|
* @param entity The entity to update
|
||||||
|
*/
|
||||||
|
public boolean canUpdateEntity(Entity entity);
|
||||||
}
|
}
|
|
@ -80,6 +80,15 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2148,7 +2151,7 @@
|
||||||
|
int var4 = MathHelper.floor_double(par1Entity.posZ);
|
||||||
|
byte var5 = 32;
|
||||||
|
|
||||||
|
- if (!par2 || this.checkChunksExist(var3 - var5, 0, var4 - var5, var3 + var5, 0, var4 + var5))
|
||||||
|
+ if (!par2 || this.checkChunksExist(var3 - var5, 0, var4 - var5, var3 + var5, 0, var4 + var5) || ForgeHooks.canUpdateEntity(par1Entity))
|
||||||
|
{
|
||||||
|
par1Entity.lastTickPosX = par1Entity.posX;
|
||||||
|
par1Entity.lastTickPosY = par1Entity.posY;
|
||||||
@@ -2325,7 +2328,14 @@
|
@@ -2325,7 +2328,14 @@
|
||||||
if (var11 == Block.fire.blockID || var11 == Block.lavaMoving.blockID || var11 == Block.lavaStill.blockID)
|
if (var11 == Block.fire.blockID || var11 == Block.lavaMoving.blockID || var11 == Block.lavaStill.blockID)
|
||||||
{
|
{
|
||||||
|
|
|
@ -76,6 +76,15 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1680,7 +1685,7 @@
|
||||||
|
int var4 = MathHelper.floor_double(par1Entity.posZ);
|
||||||
|
byte var5 = 32;
|
||||||
|
|
||||||
|
- if (!par2 || this.checkChunksExist(var3 - var5, 0, var4 - var5, var3 + var5, 0, var4 + var5))
|
||||||
|
+ if (!par2 || this.checkChunksExist(var3 - var5, 0, var4 - var5, var3 + var5, 0, var4 + var5) || ForgeHooks.canUpdateEntity(par1Entity))
|
||||||
|
{
|
||||||
|
par1Entity.lastTickPosX = par1Entity.posX;
|
||||||
|
par1Entity.lastTickPosY = par1Entity.posY;
|
||||||
@@ -1903,6 +1908,13 @@
|
@@ -1903,6 +1908,13 @@
|
||||||
if (var11 == Block.fire.blockID || var11 == Block.lavaMoving.blockID || var11 == Block.lavaStill.blockID)
|
if (var11 == Block.fire.blockID || var11 == Block.lavaMoving.blockID || var11 == Block.lavaStill.blockID)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue