|
@@ -225,27 +225,28 @@ public class EntityCommands {
|
|
|
((ItemEntity) in[0].get(sc)).setPickupDelay(in[1].getInt(sc));
|
|
|
});
|
|
|
sm.registerFunction("entity.spawn", (sc, in) -> {
|
|
|
- ResourceLocation rl = new ResourceLocation(in[0].getString(sc));
|
|
|
+ ResourceLocation type = new ResourceLocation(in[0].getString(sc));
|
|
|
Location l = (Location) in[1].get(sc);
|
|
|
+ if(!World.isInvalidPosition(l.getBlockPos())) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ CompoundNBT nbt = in.length >= 3 ? JsonToNBT.getTagFromJson(in[2].getString(sc)) : new CompoundNBT();
|
|
|
+ nbt.putString("id", type.toString());
|
|
|
ServerWorld sw = (ServerWorld) l.getWorld();
|
|
|
-
|
|
|
- CompoundNBT compoundnbt = in.length >= 3 ? JsonToNBT.getTagFromJson(in[2].getString(sc)) : new CompoundNBT();
|
|
|
- compoundnbt.putString("id", rl.toString());
|
|
|
- if(EntityType.getKey(EntityType.LIGHTNING_BOLT).equals(rl)) {
|
|
|
- LightningBoltEntity ent = EntityType.LIGHTNING_BOLT.create(sw);
|
|
|
- ent.moveForced(l.getPos());
|
|
|
- sw.addEntity(ent);
|
|
|
+ Entity ent = EntityType.loadEntityAndExecute(nbt, sw, (e) -> {
|
|
|
+ e.setLocationAndAngles(l.getX(), l.getY(), l.getZ(), e.rotationYaw, e.rotationPitch);
|
|
|
+ return e;
|
|
|
+ });
|
|
|
+ if(ent == null) {
|
|
|
return ent;
|
|
|
}
|
|
|
-
|
|
|
- Entity entity = EntityType.loadEntityAndExecute(compoundnbt, sw, (ent) -> {
|
|
|
- ent.setLocationAndAngles(l.getX(), l.getY(), l.getZ(), ent.rotationYaw, ent.rotationPitch);
|
|
|
- return sw.summonEntity(ent) ? ent : null;
|
|
|
- });
|
|
|
- if(entity != null && entity instanceof MobEntity) {
|
|
|
- ((MobEntity) entity).onInitialSpawn(sw, sw.getDifficultyForLocation(entity.getPosition()), SpawnReason.COMMAND, null, null);
|
|
|
+ if(ent instanceof MobEntity) {
|
|
|
+ ((MobEntity) ent).onInitialSpawn(sw, sw.getDifficultyForLocation(ent.getPosition()), SpawnReason.COMMAND, null, null);
|
|
|
}
|
|
|
- return entity;
|
|
|
+ if(!sw.func_242106_g(ent)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return ent;
|
|
|
});
|
|
|
sm.registerFunction("entity.near", (sc, in) -> {
|
|
|
Object o = in[0].get(sc);
|