Fixed executeCommand() function for scripting API.

This commit is contained in:
luisc committed 2021-10-19 16:59:09 -05:00
1 parent b15f5221fd
commit 8b710ed520
3 files changed
+7 -4

No files matched your search

@@ -359,7 +359,7 @@ public class ScriptWorld implements IWorld {
* Expert use only
* @return Returns minecraft world object
*/
public World getMCWorld(){
return world;
public WorldServer getMCWorld(){
return this.world;
}
}
@@ -2,6 +2,7 @@ package noppes.npcs.scripted.interfaces;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import noppes.npcs.scripted.*;
import noppes.npcs.scripted.entity.ScriptEntity;
import noppes.npcs.scripted.entity.ScriptPlayer;
@@ -208,5 +209,5 @@ public interface IWorld {
* Expert use only
* @return Returns minecraft world object
*/
public World getMCWorld();
public WorldServer getMCWorld();
}
@@ -7,7 +7,9 @@ package noppes.npcs.scripted.wrapper;
import java.io.File;
import java.util.Map;
import java.util.UUID;
import com.mojang.authlib.GameProfile;
import cpw.mods.fml.common.eventhandler.EventBus;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
@@ -173,7 +175,7 @@ public class WrapperNpcAPI extends NpcAPI {
}
public String executeCommand(IWorld world, String command) {
FakePlayer player = EntityNPCInterface.CommandPlayer;
FakePlayer player = new FakePlayer(world.getMCWorld(), new GameProfile(new UUID(0L,0L), "CommandPlayer"));
player.setWorld(world.getMCWorld());
player.setPosition(0.0D, 0.0D, 0.0D);
return NoppesUtilServer.runCommand(world.getMCWorld(), BlockPos.ORIGIN, "API", command, (EntityPlayer)null, player);