mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-27 04:25:19 +01:00
Implement missing Methods in NMS v1_19_R3 after merge (+ code cleanup)
Related commit 6d8c3beeb3
This commit is contained in:
parent
6d8c3beeb3
commit
ecf472c6c7
@ -17,6 +17,6 @@ public class AnvilInventoryCustom extends CraftInventoryAnvil {
|
||||
|
||||
@Override
|
||||
public InventoryHolder getHolder() {
|
||||
return holder;
|
||||
return this.holder;
|
||||
}
|
||||
}
|
||||
|
@ -25,78 +25,78 @@ public class NBTCompoundImpl implements NBTCompound {
|
||||
|
||||
@Override
|
||||
public NBTCompound set(String tag, String s) {
|
||||
compound.putString(tag, s);
|
||||
this.compound.putString(tag, s);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTCompound set(String tag, boolean b) {
|
||||
compound.putBoolean(tag, b);
|
||||
this.compound.putBoolean(tag, b);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTCompound set(String tag, int i) {
|
||||
compound.putInt(tag, i);
|
||||
this.compound.putInt(tag, i);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTCompound set(String tag, double i) {
|
||||
compound.putDouble(tag, i);
|
||||
this.compound.putDouble(tag, i);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTCompound set(String tag, long l) {
|
||||
compound.putLong(tag, l);
|
||||
this.compound.putLong(tag, l);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTCompound set(String tag, short s) {
|
||||
compound.putShort(tag, s);
|
||||
this.compound.putShort(tag, s);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTCompound set(String tag, byte b) {
|
||||
compound.putByte(tag, b);
|
||||
this.compound.putByte(tag, b);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTCompound set(String tag, int[] i) {
|
||||
compound.putIntArray(tag, i);
|
||||
this.compound.putIntArray(tag, i);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTCompound set(String tag, byte[] b) {
|
||||
compound.putByteArray(tag, b);
|
||||
this.compound.putByteArray(tag, b);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTCompound set(String tag, UUID u) {
|
||||
compound.putUUID(tag, u);
|
||||
this.compound.putUUID(tag, u);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTCompound remove(String tag) {
|
||||
compound.remove(tag);
|
||||
this.compound.remove(tag);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String tag) {
|
||||
return compound.contains(tag);
|
||||
return this.compound.contains(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTObject getNBTObject(String tag) {
|
||||
return new NBTObjectImpl(compound, tag);
|
||||
return new NBTObjectImpl(this.compound, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -151,18 +151,18 @@ public class NBTCompoundImpl implements NBTCompound {
|
||||
}
|
||||
|
||||
CompoundTag newCompound = new CompoundTag();
|
||||
compound.put(tag, newCompound);
|
||||
this.compound.put(tag, newCompound);
|
||||
return new NBTCompoundImpl(newCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getKeys() {
|
||||
return compound.getAllKeys();
|
||||
return this.compound.getAllKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getKeys(String tag) {
|
||||
return compound.getCompound(tag).getAllKeys();
|
||||
return this.compound.getCompound(tag).getAllKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -190,7 +190,7 @@ public class NBTCompoundImpl implements NBTCompound {
|
||||
public void deSerialize(byte[] serialized) {
|
||||
try (ByteArrayInputStream inputStream = new ByteArrayInputStream(serialized);
|
||||
ObjectInputStream dataInput = new ObjectInputStream(inputStream)) {
|
||||
compound = NbtIo.readCompressed(dataInput);
|
||||
this.compound = NbtIo.readCompressed(dataInput);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
@ -203,6 +203,6 @@ public class NBTCompoundImpl implements NBTCompound {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return compound.toString();
|
||||
return this.compound.toString();
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package com.songoda.core.nms.v1_19_R3.nbt;
|
||||
|
||||
import com.songoda.core.nms.nbt.NBTEntity;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
@ -33,7 +32,7 @@ public class NBTEntityImpl extends NBTCompoundImpl implements NBTEntity {
|
||||
|
||||
Entity spawned = optionalEntity.get().spawn(
|
||||
((CraftWorld) location.getWorld()).getHandle(),
|
||||
compound,
|
||||
this.compound,
|
||||
null,
|
||||
new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()),
|
||||
MobSpawnType.COMMAND,
|
||||
@ -42,10 +41,10 @@ public class NBTEntityImpl extends NBTCompoundImpl implements NBTEntity {
|
||||
);
|
||||
|
||||
if (spawned != null) {
|
||||
spawned.load(compound);
|
||||
spawned.load(this.compound);
|
||||
org.bukkit.entity.Entity entity = spawned.getBukkitEntity();
|
||||
entity.teleport(location);
|
||||
nmsEntity = spawned;
|
||||
this.nmsEntity = spawned;
|
||||
|
||||
return entity;
|
||||
}
|
||||
@ -56,12 +55,12 @@ public class NBTEntityImpl extends NBTCompoundImpl implements NBTEntity {
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity reSpawn(Location location) {
|
||||
nmsEntity.discard();
|
||||
this.nmsEntity.discard();
|
||||
return spawn(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addExtras() {
|
||||
compound.putString("entity_type", BuiltInRegistries.ENTITY_TYPE.getKey(nmsEntity.getType()).toString());
|
||||
this.compound.putString("entity_type", BuiltInRegistries.ENTITY_TYPE.getKey(this.nmsEntity.getType()).toString());
|
||||
}
|
||||
}
|
||||
|
@ -15,10 +15,10 @@ public class NBTItemImpl extends NBTCompoundImpl implements NBTItem {
|
||||
}
|
||||
|
||||
public org.bukkit.inventory.ItemStack finish() {
|
||||
if (nmsItem == null) {
|
||||
return CraftItemStack.asBukkitCopy(ItemStack.of(compound));
|
||||
if (this.nmsItem == null) {
|
||||
return CraftItemStack.asBukkitCopy(ItemStack.of(this.compound));
|
||||
}
|
||||
|
||||
return CraftItemStack.asBukkitCopy(nmsItem);
|
||||
return CraftItemStack.asBukkitCopy(this.nmsItem);
|
||||
}
|
||||
}
|
||||
|
@ -17,56 +17,56 @@ public class NBTObjectImpl implements NBTObject {
|
||||
|
||||
@Override
|
||||
public String asString() {
|
||||
return compound.getString(tag);
|
||||
return this.compound.getString(this.tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean asBoolean() {
|
||||
return compound.getBoolean(tag);
|
||||
return this.compound.getBoolean(this.tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int asInt() {
|
||||
return compound.getInt(tag);
|
||||
return this.compound.getInt(this.tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double asDouble() {
|
||||
return compound.getDouble(tag);
|
||||
return this.compound.getDouble(this.tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long asLong() {
|
||||
return compound.getLong(tag);
|
||||
return this.compound.getLong(this.tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public short asShort() {
|
||||
return compound.getShort(tag);
|
||||
return this.compound.getShort(this.tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte asByte() {
|
||||
return compound.getByte(tag);
|
||||
return this.compound.getByte(this.tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] asIntArray() {
|
||||
return compound.getIntArray(tag);
|
||||
return this.compound.getIntArray(this.tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] asByteArray() {
|
||||
return compound.getByteArray(tag);
|
||||
return this.compound.getByteArray(this.tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTCompound asCompound() {
|
||||
return new NBTCompoundImpl(compound.getCompound(tag));
|
||||
return new NBTCompoundImpl(this.compound.getCompound(this.tag));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getKeys() {
|
||||
return compound.getAllKeys();
|
||||
return this.compound.getAllKeys();
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public class SItemStackImpl implements SItemStack {
|
||||
vec3d1 = vec3d1.yRot(-entityPlayer.getYRot() * 0.017453292F);
|
||||
vec3d1 = vec3d1.add(entityPlayer.getX(), entityPlayer.getEyeY(), entityPlayer.getZ());
|
||||
|
||||
entityPlayer.level.addParticle(new ItemParticleOption(ParticleTypes.ITEM, CraftItemStack.asNMSCopy(item)), vec3d1.x, vec3d1.y, vec3d1.z, vec3d.x, vec3d.y + 0.05D, vec3d.z);
|
||||
entityPlayer.level.addParticle(new ItemParticleOption(ParticleTypes.ITEM, CraftItemStack.asNMSCopy(this.item)), vec3d1.x, vec3d1.y, vec3d1.z, vec3d.x, vec3d.y + 0.05D, vec3d.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,13 +46,13 @@ public class SSpawnerImpl implements SSpawner {
|
||||
|
||||
short spawnRange = 4;
|
||||
for (int i = 0; i < 50; i++) {
|
||||
assert spawnerLocation.getWorld() != null;
|
||||
ServerLevel world = ((CraftWorld) spawnerLocation.getWorld()).getHandle();
|
||||
assert this.spawnerLocation.getWorld() != null;
|
||||
ServerLevel world = ((CraftWorld) this.spawnerLocation.getWorld()).getHandle();
|
||||
|
||||
RandomSource random = world.getRandom();
|
||||
double x = spawnerLocation.getX() + (random.nextDouble() - random.nextDouble()) * (double) spawnRange + 0.5D;
|
||||
double y = spawnerLocation.getY() + random.nextInt(3) - 1;
|
||||
double z = spawnerLocation.getZ() + (random.nextDouble() - random.nextDouble()) * (double) spawnRange + 0.5D;
|
||||
double x = this.spawnerLocation.getX() + (random.nextDouble() - random.nextDouble()) * (double) spawnRange + 0.5D;
|
||||
double y = this.spawnerLocation.getY() + random.nextInt(3) - 1;
|
||||
double z = this.spawnerLocation.getZ() + (random.nextDouble() - random.nextDouble()) * (double) spawnRange + 0.5D;
|
||||
|
||||
Optional<Entity> optionalEntity = net.minecraft.world.entity.EntityType.create(compound, world);
|
||||
if (optionalEntity.isEmpty()) continue;
|
||||
@ -67,7 +67,7 @@ public class SSpawnerImpl implements SSpawner {
|
||||
continue;
|
||||
}
|
||||
|
||||
Location spot = new Location(spawnerLocation.getWorld(), x, y, z);
|
||||
Location spot = new Location(this.spawnerLocation.getWorld(), x, y, z);
|
||||
|
||||
if (!canSpawn(world, entityInsentient, spot, canSpawnOn)) {
|
||||
continue;
|
||||
@ -122,7 +122,7 @@ public class SSpawnerImpl implements SSpawner {
|
||||
for (CompatibleMaterial material : canSpawnOn) {
|
||||
if (material == null) continue;
|
||||
|
||||
if (spawnedOn.equals(material) || material.isAir()) {
|
||||
if (spawnedOn == material || material.isAir()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,16 @@
|
||||
package com.songoda.core.nms.v1_19_R3.world;
|
||||
|
||||
import com.songoda.core.nms.world.SWorld;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.entity.LevelEntityGetter;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_19_R3.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_19_R3.block.data.CraftBlockData;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -22,7 +27,7 @@ public class SWorldImpl implements SWorld {
|
||||
public List<LivingEntity> getLivingEntities() {
|
||||
List<LivingEntity> result = new ArrayList<>();
|
||||
|
||||
ServerLevel worldServer = ((CraftWorld) world).getHandle();
|
||||
ServerLevel worldServer = ((CraftWorld) this.world).getHandle();
|
||||
LevelEntityGetter<Entity> entities = worldServer.getEntities();
|
||||
|
||||
entities.getAll().forEach((mcEnt) -> {
|
||||
@ -35,4 +40,13 @@ public class SWorldImpl implements SWorld {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockFast(int x, int y, int z, Material material) {
|
||||
ServerLevel serverLevel = ((CraftWorld) this.world).getHandle();
|
||||
LevelChunk levelChunk = serverLevel.getChunk(x >> 4, z >> 4);
|
||||
BlockState blockState = ((CraftBlockData) material.createBlockData()).getState();
|
||||
|
||||
levelChunk.setBlockState(new BlockPos(x & 0xF, y, z & 0xF), blockState, true);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.world.level.BaseSpawner;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.chunk.LevelChunkSection;
|
||||
@ -20,14 +21,14 @@ import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.craftbukkit.v1_19_R3.CraftChunk;
|
||||
import org.bukkit.craftbukkit.v1_19_R3.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_19_R3.util.CraftMagicNumbers;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class WorldCoreImpl implements WorldCore {
|
||||
@Override
|
||||
public SSpawner getSpawner(CreatureSpawner spawner) {
|
||||
return new SSpawnerImpl(spawner.getLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSpawner getSpawner(Location location) {
|
||||
return new SSpawnerImpl(location);
|
||||
@ -57,37 +58,48 @@ public class WorldCoreImpl implements WorldCore {
|
||||
public void randomTickChunk(org.bukkit.Chunk bukkitChunk, int tickAmount) {
|
||||
LevelChunk chunk = ((CraftChunk) bukkitChunk).getHandle();
|
||||
ServerLevel world = chunk.q;
|
||||
ProfilerFiller gameProfilerFiller = world.getProfiler();
|
||||
ProfilerFiller gameprofilerfiller = world.getProfiler();
|
||||
|
||||
ChunkPos chunkCoordIntPair = chunk.getPos();
|
||||
int j = chunkCoordIntPair.getMinBlockX();
|
||||
int k = chunkCoordIntPair.getMinBlockZ();
|
||||
|
||||
gameProfilerFiller.popPush("tickBlocks");
|
||||
gameprofilerfiller.push("tickBlocks");
|
||||
if (tickAmount > 0) {
|
||||
LevelChunkSection[] aChunkSection = chunk.getSections();
|
||||
|
||||
for (LevelChunkSection chunkSection : aChunkSection) {
|
||||
if (chunkSection.isRandomlyTicking()) {
|
||||
int j1 = chunkSection.bottomBlockY();
|
||||
int l1 = chunkSection.bottomBlockY();
|
||||
|
||||
for (int k1 = 0; k1 < tickAmount; ++k1) {
|
||||
BlockPos blockposition2 = world.getBlockRandomPos(j, j1, k, 15);
|
||||
gameProfilerFiller.push("randomTick");
|
||||
BlockState iBlockData1 = chunkSection.getBlockState(blockposition2.getX() - j, blockposition2.getY() - j1, blockposition2.getZ() - k);
|
||||
if (iBlockData1.isRandomlyTicking()) {
|
||||
iBlockData1.randomTick(world, blockposition2, world.random);
|
||||
for (int l = 0; l < tickAmount; ++l) {
|
||||
BlockPos blockposition2 = world.getBlockRandomPos(j, l1, k, 15);
|
||||
gameprofilerfiller.push("randomTick");
|
||||
BlockState iBlockData3 = chunkSection.getBlockState(blockposition2.getX() - j, blockposition2.getY() - l1, blockposition2.getZ() - k);
|
||||
if (iBlockData3.isRandomlyTicking()) {
|
||||
iBlockData3.randomTick(world, blockposition2, world.random);
|
||||
}
|
||||
|
||||
FluidState fluid = iBlockData1.getFluidState();
|
||||
FluidState fluid = iBlockData3.getFluidState();
|
||||
if (fluid.isRandomlyTicking()) {
|
||||
fluid.randomTick(world, blockposition2, world.random);
|
||||
}
|
||||
|
||||
gameProfilerFiller.pop();
|
||||
gameprofilerfiller.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
gameprofilerfiller.pop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAdjacentComparators(@NotNull Location loc) {
|
||||
Objects.requireNonNull(loc.getWorld());
|
||||
|
||||
ServerLevel serverLevel = ((CraftWorld) loc.getWorld()).getHandle();
|
||||
BlockPos blockPos = new BlockPos(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
Block nmsBlock = CraftMagicNumbers.getBlock(loc.getBlock().getType());
|
||||
|
||||
serverLevel.updateNeighbourForOutputSignal(blockPos, nmsBlock);
|
||||
}
|
||||
}
|
||||
|
@ -70,85 +70,85 @@ public class BBaseSpawnerImpl implements BBaseSpawner {
|
||||
*/
|
||||
@Override
|
||||
public void tick() throws InvocationTargetException, IllegalAccessException {
|
||||
ServerLevel worldserver = getWorld();
|
||||
ServerLevel worldServer = getWorld();
|
||||
BlockPos blockposition = getBlockPosition();
|
||||
|
||||
if (this.spawner.spawnDelay == -1) {
|
||||
this.delay(worldserver, blockposition);
|
||||
this.delay(worldServer, blockposition);
|
||||
}
|
||||
|
||||
if (this.spawner.spawnDelay > 0) {
|
||||
--this.spawner.spawnDelay;
|
||||
} else {
|
||||
boolean flag = false;
|
||||
RandomSource randomsource = worldserver.getRandom();
|
||||
SpawnData mobspawnerdata = (SpawnData) this.getOrCreateNextSpawnDataMethod.invoke(this.spawner, worldserver, randomsource, blockposition);
|
||||
RandomSource randomsource = worldServer.getRandom();
|
||||
SpawnData mobSpawnerData = (SpawnData) this.getOrCreateNextSpawnDataMethod.invoke(this.spawner, worldServer, randomsource, blockposition);
|
||||
int i = 0;
|
||||
|
||||
while (true) {
|
||||
if (i >= this.spawner.spawnCount) {
|
||||
if (flag) {
|
||||
this.delay(worldserver, blockposition);
|
||||
this.delay(worldServer, blockposition);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
CompoundTag nbttagcompound = mobspawnerdata.getEntityToSpawn();
|
||||
Optional<EntityType<?>> optional = EntityType.by(nbttagcompound);
|
||||
CompoundTag nbtTagCompound = mobSpawnerData.getEntityToSpawn();
|
||||
Optional<EntityType<?>> optional = EntityType.by(nbtTagCompound);
|
||||
if (optional.isEmpty()) {
|
||||
this.delay(worldserver, blockposition);
|
||||
this.delay(worldServer, blockposition);
|
||||
return;
|
||||
}
|
||||
|
||||
ListTag nbttaglist = nbttagcompound.getList("Pos", 6);
|
||||
int j = nbttaglist.size();
|
||||
double d0 = j >= 1 ? nbttaglist.getDouble(0) : (double) blockposition.getX() + (randomsource.nextDouble() - randomsource.nextDouble()) * (double) this.spawner.spawnRange + 0.5;
|
||||
double d1 = j >= 2 ? nbttaglist.getDouble(1) : (double) (blockposition.getY() + randomsource.nextInt(3) - 1);
|
||||
double d2 = j >= 3 ? nbttaglist.getDouble(2) : (double) blockposition.getZ() + (randomsource.nextDouble() - randomsource.nextDouble()) * (double) this.spawner.spawnRange + 0.5;
|
||||
if (worldserver.noCollision(optional.get().getAABB(d0, d1, d2))) {
|
||||
ListTag nbtTagList = nbtTagCompound.getList("Pos", 6);
|
||||
int j = nbtTagList.size();
|
||||
double d0 = j >= 1 ? nbtTagList.getDouble(0) : (double) blockposition.getX() + (randomsource.nextDouble() - randomsource.nextDouble()) * (double) this.spawner.spawnRange + 0.5;
|
||||
double d1 = j >= 2 ? nbtTagList.getDouble(1) : (double) (blockposition.getY() + randomsource.nextInt(3) - 1);
|
||||
double d2 = j >= 3 ? nbtTagList.getDouble(2) : (double) blockposition.getZ() + (randomsource.nextDouble() - randomsource.nextDouble()) * (double) this.spawner.spawnRange + 0.5;
|
||||
if (worldServer.noCollision(optional.get().getAABB(d0, d1, d2))) {
|
||||
label128:
|
||||
{
|
||||
BlockPos blockposition1 = BlockPos.containing(d0, d1, d2);
|
||||
if (mobspawnerdata.getCustomSpawnRules().isPresent()) {
|
||||
if (!optional.get().getCategory().isFriendly() && worldserver.getDifficulty() == Difficulty.PEACEFUL) {
|
||||
if (mobSpawnerData.getCustomSpawnRules().isPresent()) {
|
||||
if (!optional.get().getCategory().isFriendly() && worldServer.getDifficulty() == Difficulty.PEACEFUL) {
|
||||
break label128;
|
||||
}
|
||||
|
||||
SpawnData.CustomSpawnRules mobspawnerdata_a = mobspawnerdata.getCustomSpawnRules().get();
|
||||
if (!mobspawnerdata_a.blockLightLimit().isValueInRange(worldserver.getBrightness(LightLayer.BLOCK, blockposition1)) || !mobspawnerdata_a.skyLightLimit().isValueInRange(worldserver.getBrightness(LightLayer.SKY, blockposition1))) {
|
||||
SpawnData.CustomSpawnRules mobSpawnerData_a = mobSpawnerData.getCustomSpawnRules().get();
|
||||
if (!mobSpawnerData_a.blockLightLimit().isValueInRange(worldServer.getBrightness(LightLayer.BLOCK, blockposition1)) || !mobSpawnerData_a.skyLightLimit().isValueInRange(worldServer.getBrightness(LightLayer.SKY, blockposition1))) {
|
||||
break label128;
|
||||
}
|
||||
} else if (!SpawnPlacements.checkSpawnRules((EntityType<?>) optional.get(), worldserver, MobSpawnType.SPAWNER, blockposition1, worldserver.getRandom())) {
|
||||
} else if (!SpawnPlacements.checkSpawnRules((EntityType<?>) optional.get(), worldServer, MobSpawnType.SPAWNER, blockposition1, worldServer.getRandom())) {
|
||||
break label128;
|
||||
}
|
||||
|
||||
Entity entity = EntityType.loadEntityRecursive(nbttagcompound, worldserver, (entity1) -> {
|
||||
Entity entity = EntityType.loadEntityRecursive(nbtTagCompound, worldServer, (entity1) -> {
|
||||
entity1.moveTo(d0, d1, d2, entity1.getYRot(), entity1.getXRot());
|
||||
return entity1;
|
||||
});
|
||||
if (entity == null) {
|
||||
this.delay(worldserver, blockposition);
|
||||
this.delay(worldServer, blockposition);
|
||||
return;
|
||||
}
|
||||
|
||||
int k = worldserver.getEntitiesOfClass(entity.getClass(), (new AABB(blockposition.getX(), blockposition.getY(), blockposition.getZ(), blockposition.getX() + 1, blockposition.getY() + 1, blockposition.getZ() + 1)).inflate(this.spawner.spawnRange)).size();
|
||||
int k = worldServer.getEntitiesOfClass(entity.getClass(), (new AABB(blockposition.getX(), blockposition.getY(), blockposition.getZ(), blockposition.getX() + 1, blockposition.getY() + 1, blockposition.getZ() + 1)).inflate(this.spawner.spawnRange)).size();
|
||||
if (k >= this.spawner.maxNearbyEntities) {
|
||||
this.delay(worldserver, blockposition);
|
||||
this.delay(worldServer, blockposition);
|
||||
return;
|
||||
}
|
||||
|
||||
entity.moveTo(entity.getX(), entity.getY(), entity.getZ(), randomsource.nextFloat() * 360.0F, 0.0F);
|
||||
if (entity instanceof Mob entityinsentient) {
|
||||
if (mobspawnerdata.getCustomSpawnRules().isEmpty() && !entityinsentient.checkSpawnRules(worldserver, MobSpawnType.SPAWNER) || !entityinsentient.checkSpawnObstruction(worldserver)) {
|
||||
if (entity instanceof Mob entityInsentient) {
|
||||
if (mobSpawnerData.getCustomSpawnRules().isEmpty() && !entityInsentient.checkSpawnRules(worldServer, MobSpawnType.SPAWNER) || !entityInsentient.checkSpawnObstruction(worldServer)) {
|
||||
break label128;
|
||||
}
|
||||
|
||||
if (mobspawnerdata.getEntityToSpawn().size() == 1 && mobspawnerdata.getEntityToSpawn().contains("id", 8)) {
|
||||
((Mob) entity).finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entity.blockPosition()), MobSpawnType.SPAWNER, null, null);
|
||||
if (mobSpawnerData.getEntityToSpawn().size() == 1 && mobSpawnerData.getEntityToSpawn().contains("id", 8)) {
|
||||
((Mob) entity).finalizeSpawn(worldServer, worldServer.getCurrentDifficultyAt(entity.blockPosition()), MobSpawnType.SPAWNER, null, null);
|
||||
}
|
||||
|
||||
if (entityinsentient.level.spigotConfig.nerfSpawnerMobs) {
|
||||
entityinsentient.aware = false;
|
||||
if (entityInsentient.level.spigotConfig.nerfSpawnerMobs) {
|
||||
entityInsentient.aware = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -162,13 +162,13 @@ public class BBaseSpawnerImpl implements BBaseSpawner {
|
||||
passenger.discard();
|
||||
}
|
||||
} else {
|
||||
if (!worldserver.tryAddFreshEntityWithPassengers(entity, CreatureSpawnEvent.SpawnReason.SPAWNER)) {
|
||||
this.delay(worldserver, blockposition);
|
||||
if (!worldServer.tryAddFreshEntityWithPassengers(entity, CreatureSpawnEvent.SpawnReason.SPAWNER)) {
|
||||
this.delay(worldServer, blockposition);
|
||||
return;
|
||||
}
|
||||
|
||||
worldserver.levelEvent(2004, blockposition, 0);
|
||||
worldserver.gameEvent(entity, GameEvent.ENTITY_PLACE, blockposition1);
|
||||
worldServer.levelEvent(2004, blockposition, 0);
|
||||
worldServer.gameEvent(entity, GameEvent.ENTITY_PLACE, blockposition1);
|
||||
if (entity instanceof Mob) {
|
||||
((Mob) entity).spawnAnim();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user