use of net.minecraft.server.v1_16_R2.World in project WildChests by BG-Software-LLC.
the class NMSInventory_v1_12_R1 method updateTileEntity.
@Override
public void updateTileEntity(Chest chest) {
Location loc = chest.getLocation();
World world = ((CraftWorld) loc.getWorld()).getHandle();
BlockPosition blockPosition = new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
TileEntity tileEntity = world.getTileEntity(blockPosition);
TileEntityWildChest tileEntityWildChest;
if (tileEntity instanceof TileEntityWildChest) {
tileEntityWildChest = (TileEntityWildChest) tileEntity;
((WChest) chest).setTileEntityContainer(tileEntityWildChest);
} else {
tileEntityWildChest = new TileEntityWildChest(chest, world, blockPosition);
}
world.setTileEntity(blockPosition, tileEntityWildChest);
}
use of net.minecraft.server.v1_16_R2.World in project InteractionVisualizer by LOOHP.
the class V1_16_2 method getBoundingBoxes.
public List<BoundingBox> getBoundingBoxes(BlockPosition pos) {
net.minecraft.server.v1_16_R2.BlockPosition blockpos = new net.minecraft.server.v1_16_R2.BlockPosition(pos.getX(), pos.getY(), pos.getZ());
WorldServer world = ((CraftWorld) pos.getWorld()).getHandle();
VoxelShape shape = world.getType(blockpos).getShape(world, blockpos);
return shape.d().stream().map(each -> new BoundingBox(each.minX + pos.getX(), each.minY + pos.getY(), each.minZ + pos.getZ(), each.maxX + pos.getX(), each.maxY + pos.getY(), each.maxZ + pos.getZ())).collect(Collectors.toList());
}
use of net.minecraft.server.v1_16_R2.World in project RoseStacker by Rosewood-Development.
the class StackedSpawnerTileImpl method updateTile.
private void updateTile() {
World level = this.a();
if (level != null) {
level.b(this.blockPos, this.blockEntity);
IBlockData var1 = this.a().getType(this.b());
this.a().notify(this.blockPos, var1, var1, 3);
}
}
use of net.minecraft.server.v1_16_R2.World in project RoseStacker by Rosewood-Development.
the class StackedSpawnerTileImpl method c.
@Override
public void c() {
World level = this.a();
if (level == null)
return;
// Only tick the spawner if a player is nearby
this.playersTimeSinceLastCheck = (this.playersTimeSinceLastCheck + 1) % Setting.SPAWNER_PLAYER_CHECK_FREQUENCY.getInt();
if (this.playersTimeSinceLastCheck == 0)
this.playersNearby = this.isNearPlayer(level, this.blockPos);
if (!this.playersNearby)
return;
SpawnerStackSettings stackSettings = this.stackedSpawner.getStackSettings();
// Handle redstone deactivation if enabled
if (Setting.SPAWNER_DEACTIVATE_WHEN_POWERED.getBoolean()) {
if (this.redstoneTimeSinceLastCheck == 0) {
boolean hasSignal = level.isBlockIndirectlyPowered(this.blockPos);
if (this.redstoneDeactivated && !hasSignal) {
this.redstoneDeactivated = false;
this.requiredPlayerRange = stackSettings.getPlayerActivationRange();
this.updateTile();
} else if (!this.redstoneDeactivated && hasSignal) {
this.redstoneDeactivated = true;
this.requiredPlayerRange = 0;
this.updateTile();
}
if (this.redstoneDeactivated)
return;
}
this.redstoneTimeSinceLastCheck = (this.redstoneTimeSinceLastCheck + 1) % Setting.SPAWNER_POWERED_CHECK_FREQUENCY.getInt();
}
// Count down spawn timer unless we are ready to spawn
if (this.spawnDelay > 0) {
this.spawnDelay--;
return;
}
// Reset spawn delay
this.spawnDelay = level.getRandom().nextInt(this.maxSpawnDelay - this.minSpawnDelay + 1) + this.minSpawnDelay;
this.updateTile();
// Execute spawning method
if (this.spawnData != null) {
MinecraftKey resourceLocation = MinecraftKey.a(this.spawnData.getEntity().getString("id"));
if (resourceLocation != null) {
NamespacedKey namespacedKey = CraftNamespacedKey.fromMinecraft(resourceLocation);
EntityType entityType = this.fromKey(namespacedKey);
if (entityType != null)
new MobSpawningMethod(entityType).spawn(this.stackedSpawner);
}
}
// Randomize spawn potentials
if (!this.mobs.isEmpty())
this.setSpawnData(WeightedRandom.a(this.a().random, this.mobs));
}
use of net.minecraft.server.v1_16_R2.World in project RoseStacker by Rosewood-Development.
the class StackedSpawnerTileImpl method c.
@Override
public void c() {
World level = this.a();
if (level == null)
return;
// Only tick the spawner if a player is nearby
this.playersTimeSinceLastCheck = (this.playersTimeSinceLastCheck + 1) % Setting.SPAWNER_PLAYER_CHECK_FREQUENCY.getInt();
if (this.playersTimeSinceLastCheck == 0)
this.playersNearby = this.isNearPlayer(level, this.blockPos);
if (!this.playersNearby)
return;
SpawnerStackSettings stackSettings = this.stackedSpawner.getStackSettings();
// Handle redstone deactivation if enabled
if (Setting.SPAWNER_DEACTIVATE_WHEN_POWERED.getBoolean()) {
if (this.redstoneTimeSinceLastCheck == 0) {
boolean hasSignal = level.isBlockIndirectlyPowered(this.blockPos);
if (this.redstoneDeactivated && !hasSignal) {
this.redstoneDeactivated = false;
this.requiredPlayerRange = stackSettings.getPlayerActivationRange();
this.updateTile();
} else if (!this.redstoneDeactivated && hasSignal) {
this.redstoneDeactivated = true;
this.requiredPlayerRange = 0;
this.updateTile();
}
if (this.redstoneDeactivated)
return;
}
this.redstoneTimeSinceLastCheck = (this.redstoneTimeSinceLastCheck + 1) % Setting.SPAWNER_POWERED_CHECK_FREQUENCY.getInt();
}
// Count down spawn timer unless we are ready to spawn
if (this.spawnDelay > 0) {
this.spawnDelay--;
return;
}
// Reset spawn delay
this.spawnDelay = level.getRandom().nextInt(this.maxSpawnDelay - this.minSpawnDelay + 1) + this.minSpawnDelay;
this.updateTile();
// Execute spawning method
if (this.spawnData != null) {
MinecraftKey resourceLocation = MinecraftKey.a(this.spawnData.getEntity().getString("id"));
if (resourceLocation != null) {
NamespacedKey namespacedKey = CraftNamespacedKey.fromMinecraft(resourceLocation);
EntityType entityType = this.fromKey(namespacedKey);
if (entityType != null)
new MobSpawningMethod(entityType).spawn(this.stackedSpawner);
}
}
// Randomize spawn potentials
if (!this.mobs.isEmpty())
this.setSpawnData(WeightedRandom.a(this.a().random, this.mobs));
}
Aggregations