feat: Реализация BlockSource.spawnEntity
This commit is contained in:
@@ -127,7 +127,7 @@ public class BlockSourceMethods {
|
|||||||
int updateType) {
|
int updateType) {
|
||||||
Block block = level.getBlock(x, y, z);
|
Block block = level.getBlock(x, y, z);
|
||||||
defDestroy(level, block);
|
defDestroy(level, block);
|
||||||
level.setBlock(x, y, z, Block.get(id, data).clone(), false, allowUpdate);
|
level.setBlock(x, y, z, Block.get(id, data), false, allowUpdate);
|
||||||
sendBlock(level, x, y, z, 0);
|
sendBlock(level, x, y, z, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,9 +236,12 @@ public class BlockSourceMethods {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static long spawnEntity(Level level, int type, float x, float y, float z) {
|
public static long spawnEntity(Level level, int type, float x, float y, float z) {
|
||||||
Entity entity = Entity.createEntity(type, new Position(x, y, z));
|
Entity entity = Entity.createEntity(type, new Position(x, y, z, level));
|
||||||
level.addEntity(entity);
|
if (entity != null) {
|
||||||
return entity.getId();
|
entity.spawnToAll();
|
||||||
|
return entity.getId();
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long spawnNamespacedEntity(Level level, float x, float y, float z, String str1, String str2,
|
public static long spawnNamespacedEntity(Level level, float x, float y, float z, String str1, String str2,
|
||||||
@@ -248,16 +251,22 @@ public class BlockSourceMethods {
|
|||||||
}
|
}
|
||||||
// TODO: Quite BETTER name to identifier conversion!
|
// TODO: Quite BETTER name to identifier conversion!
|
||||||
Entity entity = Entity.createEntity(str2.substring(0, 1).toUpperCase() + str2.substring(1).replace("_", ""),
|
Entity entity = Entity.createEntity(str2.substring(0, 1).toUpperCase() + str2.substring(1).replace("_", ""),
|
||||||
new Position(x, y, z));
|
new Position(x, y, z, level));
|
||||||
level.addEntity(entity);
|
if (entity != null) {
|
||||||
return entity.getId();
|
entity.spawnToAll();
|
||||||
|
return entity.getId();
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long spawnExpOrbs(Level level, float x, float y, float z, int amount) {
|
public static long spawnExpOrbs(Level level, float x, float y, float z, int amount) {
|
||||||
Vector3 source = new Vector3(x, y, z);
|
Vector3 source = new Vector3(x, y, z);
|
||||||
CompoundTag nbt = Entity.getDefaultNBT(source, new Vector3(0, 0, 0));
|
CompoundTag nbt = Entity.getDefaultNBT(source, new Vector3(0, 0, 0));
|
||||||
Entity entity = Entity.createEntity("XpOrb", level.getChunk(source.getChunkX(), source.getChunkZ()), nbt);
|
Entity entity = Entity.createEntity("XpOrb", new Position(x, y, z, level), nbt);
|
||||||
entity.spawnToAll();
|
if (entity != null) {
|
||||||
return entity.getId();
|
entity.spawnToAll();
|
||||||
|
return entity.getId();
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user