mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-13 16:54:22 +00:00
Added a boolean flag for disabling Entity onUpdate (#3731)
The flag is false by default, and if true the Entity will not update. It is saved and loaded from NBT, and is called updateBlocked. Modders are responsible for managing this flag for entities they with to 'freeze' or 'unfreeze'.
This commit is contained in:
1 parent
f7f46be8ff
commit
fd0dabd60c
3 files changed
+147
-53
No files matched your search
@@ -0,0 +1,49 @@
|
||||
package net.minecraftforge.test;
|
||||
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
||||
|
||||
@Mod(modid = "entityupdateblockedtest", name = "Entity Update Blocked Test", version = "1.0.0")
|
||||
public class EntityUpdateBlockedTest
|
||||
{
|
||||
@Mod.EventHandler
|
||||
public void init(FMLServerStartingEvent event)
|
||||
{
|
||||
event.registerServerCommand(new BlockEntityUpdateCommand());
|
||||
}
|
||||
|
||||
private class BlockEntityUpdateCommand extends CommandBase
|
||||
{
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "blockEntityUpdate";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsage(ICommandSender sender)
|
||||
{
|
||||
return "blockEntityUpdate <value>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
|
||||
{
|
||||
if (args.length != 1)
|
||||
return;
|
||||
boolean value = Boolean.parseBoolean(args[0]);
|
||||
for (Entity ent : sender.getEntityWorld().loadedEntityList)
|
||||
{
|
||||
if (!(ent instanceof EntityPlayer))
|
||||
ent.updateBlocked = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user