use of net.minecraft.server.world.ServerWorld in project FabricWaystones by LordDeatHunter.
the class WaystoneStorage method loadOrSaveWaystones.
public void loadOrSaveWaystones(boolean save) {
if (server == null) {
return;
}
ServerWorld world = server.getWorld(ServerWorld.OVERWORLD);
if (save) {
state.markDirty();
sendToAllPlayers();
} else {
try {
NbtCompound compoundTag = world.getPersistentStateManager().readNbt(ID, SharedConstants.getGameVersion().getWorldVersion());
state.writeNbt(compoundTag.getCompound("data"));
} catch (IOException ignored) {
}
}
world.getPersistentStateManager().save();
}
use of net.minecraft.server.world.ServerWorld in project CustomHUD by Minenash.
the class ComplexData method update.
@SuppressWarnings("ConstantConditions")
public static void update(Profile profile) {
if (profile.enabled.serverWorld) {
IntegratedServer integratedServer = client.getServer();
serverWorld = integratedServer != null ? integratedServer.getWorld(client.world.getRegistryKey()) : null;
}
if (profile.enabled.clientChunk) {
ChunkPos newPos = new ChunkPos(client.getCameraEntity().getBlockPos());
if (!Objects.equals(ComplexData.pos, newPos)) {
pos = newPos;
chunkFuture = null;
clientChunk = null;
}
if (clientChunk == null)
clientChunk = client.world.getChunk(pos.x, pos.z);
}
if (profile.enabled.serverChunk) {
if (chunkFuture == null) {
if (serverWorld != null)
chunkFuture = serverWorld.getChunkManager().getChunkFutureSyncOnMainThread(pos.x, pos.z, ChunkStatus.FULL, false).thenApply((either) -> either.map((chunk) -> (WorldChunk) chunk, (unloaded) -> null));
if (chunkFuture == null)
chunkFuture = CompletableFuture.completedFuture(clientChunk);
}
serverChunk = chunkFuture.getNow(null);
}
if (profile.enabled.targetBlock) {
HitResult hit = client.cameraEntity.raycast(profile.targetDistance, 0.0F, false);
targetBlockPos = hit.getType() == HitResult.Type.BLOCK ? ((BlockHitResult) hit).getBlockPos() : null;
}
if (profile.enabled.world)
world = DataFixUtils.orElse(Optional.ofNullable(client.getServer()).flatMap((integratedServer) -> Optional.ofNullable(integratedServer.getWorld(client.world.getRegistryKey()))), client.world);
if (profile.enabled.localDifficulty)
localDifficulty = new LocalDifficulty(world.getDifficulty(), world.getTimeOfDay(), serverChunk == null ? 0 : serverChunk.getInhabitedTime(), world.getMoonSize());
if (profile.enabled.sound)
sounds = client.getSoundManager().getDebugString().substring(8).replace(" + ", "/").split("/");
if (profile.enabled.clientChunkCache)
clientChunkCache = client.worldRenderer.getChunksDebugString().substring(20).split(", ");
if (profile.enabled.time) {
timeOfDay = (int) ((client.world.getTimeOfDay() + 6000) % 24000);
}
if (profile.enabled.velocity) {
if (velocityWaitCounter > 0) {
velocityWaitCounter--;
return;
}
velocityWaitCounter = 4;
ClientPlayerEntity p = client.player;
final double changeXZ = Math.sqrt(Math.pow(Math.abs(p.getX() - x1), 2) + Math.pow(Math.abs(p.getZ() - z1), 2));
final double changeY = Math.abs(p.getY() - y1);
final double changeXYZ = Math.sqrt(changeXZ * changeXZ + changeY * changeY);
x1 = p.getX();
y1 = p.getY();
z1 = p.getZ();
velocityXZ = ((int) (changeXZ * 40)) / 10.0;
velocityY = ((int) (changeY * 40)) / 10.0;
velocityXYZ = ((int) (changeXYZ * 40)) / 10.0;
}
}
use of net.minecraft.server.world.ServerWorld in project bewitchment by MoriyaShiine.
the class MakeEntitiesWetRitualFunction method start.
@Override
public void start(ServerWorld world, BlockPos glyphPos, BlockPos effectivePos, Inventory inventory, boolean catFamiliar) {
int radius = catFamiliar ? 9 : 3;
world.getEntitiesByClass(Entity.class, new Box(effectivePos).expand(radius), Entity::isAlive).forEach(entity -> BWComponents.ADDITIONAL_WATER_DATA_COMPONENT.get(entity).setWetTimer(6000 * (catFamiliar ? 3 : 1)));
BWUtil.getBlockPoses(effectivePos, radius, currentPos -> world.getBlockState(currentPos).getBlock() instanceof AbstractFireBlock).forEach(foundPos -> world.setBlockState(foundPos, Blocks.AIR.getDefaultState()));
super.start(world, glyphPos, effectivePos, inventory, catFamiliar);
}
use of net.minecraft.server.world.ServerWorld in project WK by witches-kitchen.
the class PhasingStatusEffect method applyUpdateEffect.
@Override
public void applyUpdateEffect(LivingEntity entity, int amplifier) {
World world = entity.getEntityWorld();
if (!world.isClient) {
double d = entity.getX();
double e = entity.getY();
double f = entity.getZ();
for (int i = 0; i < 16; ++i) {
double g = entity.getX() + (entity.getRandom().nextDouble() - 0.5D) * 16.0D;
double h = MathHelper.clamp(entity.getY() + (double) (entity.getRandom().nextInt(16) - 8), world.getBottomY(), world.getBottomY() + ((ServerWorld) world).getLogicalHeight() - 1);
double j = entity.getZ() + (entity.getRandom().nextDouble() - 0.5D) * 16.0D;
if (entity.hasVehicle()) {
entity.stopRiding();
}
if (entity.teleport(g, h, j, true)) {
SoundEvent soundEvent = entity instanceof FoxEntity ? SoundEvents.ENTITY_FOX_TELEPORT : SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT;
world.playSound(null, d, e, f, soundEvent, SoundCategory.PLAYERS, 1.0F, 1.0F);
entity.playSound(soundEvent, 1.0F, 1.0F);
break;
}
}
}
}
use of net.minecraft.server.world.ServerWorld in project beebuddy by queenofthebees.
the class BeeEntityMixin method doAceReproduction.
@Override
protected void doAceReproduction(PlayerEntity player, CallbackInfo cbi) {
if (beebuddy$getNectarType().equals("ace")) {
if (this.world instanceof ServerWorld) {
BeeEntity us = (BeeEntity) (Object) this;
us.breed((ServerWorld) this.world, us);
us.setBaby(true);
}
}
}
Aggregations