-Added new spawnClone function with an extra boolean parameter to check for spawn protection or not.
This commit is contained in:
c0508383 committed 2022-07-05 22:55:38 -07:00
1 parent 5fd3cc37ef
commit 43e41a0e95
3 files changed
+18 -1

No files matched your search

@@ -102,7 +102,7 @@ public class PacketHandlerServer{
if(type.needsNpc && npc == null){
}
else if(type.hasPermission() && !CustomNpcsPermissions.Instance.hasPermission(player, type.permission)){
else if(type.hasPermission() && !CustomNpcsPermissions.hasPermission(player, type.permission)){
//player doesnt have permission to do this
}
else if(item == null && (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave || type == EnumPacketServer.ScriptNPCGet || type == EnumPacketServer.ScriptNPCSave || type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave))
@@ -2,6 +2,7 @@ package noppes.npcs.scripted;
import java.util.*;
import com.mojang.authlib.GameProfile;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.effect.EntityLightningBolt;
@@ -18,9 +19,12 @@ import net.minecraft.tileentity.TileEntitySign;
import net.minecraft.util.Vec3;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.FakePlayer;
import noppes.npcs.CustomNpcs;
import noppes.npcs.CustomNpcsPermissions;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.blocks.tiles.TileBigSign;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.ServerCloneController;
import noppes.npcs.scripted.interfaces.IBlock;
@@ -585,9 +589,20 @@ public class ScriptWorld implements IWorld {
* @return Returns the entity which was spawned
*/
public IEntity spawnClone(int x, int y, int z, int tab, String name){
return spawnClone(x,y,z,tab,name,true);
}
public IEntity spawnClone(int x, int y, int z, int tab, String name, boolean ignoreProtection){
NBTTagCompound compound = ServerCloneController.Instance.getCloneData(null, name, tab);
if(compound == null)
return null;
if (!ignoreProtection) {
FakePlayer fakePlayer = new FakePlayer(world, new GameProfile(null, "NpcAPI"));
if (!CustomNpcsPermissions.hasPermission(fakePlayer, EnumPacketServer.SpawnMob.permission))
return null;
}
Entity entity = NoppesUtilServer.spawnClone(compound, x, y, z, world);
if(entity == null)
return null;
@@ -350,6 +350,8 @@ public interface IWorld {
*/
IEntity spawnClone(int x, int y, int z, int tab, String name);
IEntity spawnClone(int x, int y, int z, int tab, String name, boolean ignoreProtection);
ScriptScoreboard getScoreboard();
/**