Search in sources :

Example 1 with ServerChunkProvider

use of net.minecraft.world.server.ServerChunkProvider in project dynmap by webbukkit.

the class ForgeMapChunkCache method setChunks.

public void setChunks(ForgeWorld dw, List<DynmapChunk> chunks) {
    this.dw = dw;
    this.w = dw.getWorld();
    if (dw.isLoaded()) {
        /* Check if world's provider is ServerChunkProvider */
        AbstractChunkProvider cp = this.w.getChunkProvider();
        if (cp instanceof ServerChunkProvider) {
            cps = (ServerChunkProvider) cp;
        } else {
            Log.severe("Error: world " + dw.getName() + " has unsupported chunk provider");
        }
    } else {
        chunks = new ArrayList<DynmapChunk>();
    }
    nsect = dw.worldheight >> 4;
    this.chunks = chunks;
    /* Compute range */
    if (chunks.size() == 0) {
        this.x_min = 0;
        this.x_max = 0;
        this.z_min = 0;
        this.z_max = 0;
        x_dim = 1;
    } else {
        x_min = x_max = chunks.get(0).x;
        z_min = z_max = chunks.get(0).z;
        for (DynmapChunk c : chunks) {
            if (c.x > x_max) {
                x_max = c.x;
            }
            if (c.x < x_min) {
                x_min = c.x;
            }
            if (c.z > z_max) {
                z_max = c.z;
            }
            if (c.z < z_min) {
                z_min = c.z;
            }
        }
        x_dim = x_max - x_min + 1;
    }
    snapcnt = x_dim * (z_max - z_min + 1);
    snaparray = new ChunkSnapshot[snapcnt];
    snaptile = new DynIntHashMap[snapcnt];
    isSectionNotEmpty = new boolean[snapcnt][];
}
Also used : DynmapChunk(org.dynmap.DynmapChunk) AbstractChunkProvider(net.minecraft.world.chunk.AbstractChunkProvider) ServerChunkProvider(net.minecraft.world.server.ServerChunkProvider)

Example 2 with ServerChunkProvider

use of net.minecraft.world.server.ServerChunkProvider in project dynmap by webbukkit.

the class ForgeMapChunkCache method setChunks.

public void setChunks(ForgeWorld dw, List<DynmapChunk> chunks) {
    this.dw = dw;
    this.w = dw.getWorld();
    if (dw.isLoaded()) {
        /* Check if world's provider is ServerChunkProvider */
        AbstractChunkProvider cp = this.w.getChunkProvider();
        if (cp instanceof ServerChunkProvider) {
            cps = (ServerChunkProvider) cp;
        } else {
            Log.severe("Error: world " + dw.getName() + " has unsupported chunk provider");
        }
    } else {
        chunks = new ArrayList<DynmapChunk>();
    }
    nsect = dw.worldheight >> 4;
    this.chunks = chunks;
    /* Compute range */
    if (chunks.size() == 0) {
        this.x_min = 0;
        this.x_max = 0;
        this.z_min = 0;
        this.z_max = 0;
        x_dim = 1;
    } else {
        x_min = x_max = chunks.get(0).x;
        z_min = z_max = chunks.get(0).z;
        for (DynmapChunk c : chunks) {
            if (c.x > x_max) {
                x_max = c.x;
            }
            if (c.x < x_min) {
                x_min = c.x;
            }
            if (c.z > z_max) {
                z_max = c.z;
            }
            if (c.z < z_min) {
                z_min = c.z;
            }
        }
        x_dim = x_max - x_min + 1;
    }
    snapcnt = x_dim * (z_max - z_min + 1);
    snaparray = new ChunkSnapshot[snapcnt];
    snaptile = new DynIntHashMap[snapcnt];
    isSectionNotEmpty = new boolean[snapcnt][];
}
Also used : DynmapChunk(org.dynmap.DynmapChunk) AbstractChunkProvider(net.minecraft.world.chunk.AbstractChunkProvider) ServerChunkProvider(net.minecraft.world.server.ServerChunkProvider)

Example 3 with ServerChunkProvider

use of net.minecraft.world.server.ServerChunkProvider in project endergetic by team-abnormals.

the class ServerWorldMixin method updateEntityRiddenBalloons.

@SuppressWarnings("deprecation")
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;rideTick()V", shift = At.Shift.AFTER), method = "tickPassenger")
private void updateEntityRiddenBalloons(Entity ridingEntity, Entity passenger, CallbackInfo info) {
    BalloonHolder balloonHolder = (BalloonHolder) passenger;
    ServerChunkProvider chunkProvider = ((ServerWorld) (Object) this).getChunkSource();
    for (BolloomBalloonEntity balloon : balloonHolder.getBalloons()) {
        if (!balloon.removed && balloon.getAttachedEntity() == passenger) {
            if (chunkProvider.isEntityTickingChunk(balloon)) {
                balloon.setPosAndOldPos(balloon.getX(), balloon.getY(), balloon.getZ());
                balloon.yRotO = balloon.yRot;
                balloon.xRotO = balloon.xRot;
                if (balloon.inChunk) {
                    balloon.tickCount++;
                    balloon.updateAttachedPosition();
                }
                ((ServerWorld) (Object) this).updateChunkPos(balloon);
            }
        } else {
            balloon.detachFromEntity();
        }
    }
}
Also used : ServerWorld(net.minecraft.world.server.ServerWorld) BalloonHolder(com.minecraftabnormals.endergetic.core.interfaces.BalloonHolder) ServerChunkProvider(net.minecraft.world.server.ServerChunkProvider) BolloomBalloonEntity(com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomBalloonEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 4 with ServerChunkProvider

use of net.minecraft.world.server.ServerChunkProvider in project FastAsyncWorldEdit by IntellectualSites.

the class ForgeWorld method regenerate.

@Override
public boolean regenerate(Region region, EditSession editSession) {
    // Don't even try to regen if it's going to fail.
    AbstractChunkProvider provider = getWorld().getChunkProvider();
    if (!(provider instanceof ServerChunkProvider)) {
        return false;
    }
    File saveFolder = Files.createTempDir();
    // register this just in case something goes wrong
    // normally it should be deleted at the end of this method
    saveFolder.deleteOnExit();
    try {
        ServerWorld originalWorld = (ServerWorld) getWorld();
        MinecraftServer server = originalWorld.getServer();
        SaveHandler saveHandler = new SaveHandler(saveFolder, originalWorld.getSaveHandler().getWorldDirectory().getName(), server, server.getDataFixer());
        try (World freshWorld = new ServerWorld(server, server.getBackgroundExecutor(), saveHandler, originalWorld.getWorldInfo(), originalWorld.dimension.getType(), originalWorld.getProfiler(), new NoOpChunkStatusListener())) {
            // Pre-gen all the chunks
            // We need to also pull one more chunk in every direction
            CuboidRegion expandedPreGen = new CuboidRegion(region.getMinimumPoint().subtract(16, 0, 16), region.getMaximumPoint().add(16, 0, 16));
            for (BlockVector2 chunk : expandedPreGen.getChunks()) {
                freshWorld.getChunk(chunk.getBlockX(), chunk.getBlockZ());
            }
            ForgeWorld from = new ForgeWorld(freshWorld);
            for (BlockVector3 vec : region) {
                editSession.setBlock(vec, from.getFullBlock(vec));
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    } catch (MaxChangedBlocksException e) {
        throw new RuntimeException(e);
    } finally {
        saveFolder.delete();
    }
    return true;
}
Also used : AbstractChunkProvider(net.minecraft.world.chunk.AbstractChunkProvider) CuboidRegion(com.sk89q.worldedit.regions.CuboidRegion) IOException(java.io.IOException) World(net.minecraft.world.World) ServerWorld(net.minecraft.world.server.ServerWorld) AbstractWorld(com.sk89q.worldedit.world.AbstractWorld) BlockVector3(com.sk89q.worldedit.math.BlockVector3) BlockVector2(com.sk89q.worldedit.math.BlockVector2) MinecraftServer(net.minecraft.server.MinecraftServer) MaxChangedBlocksException(com.sk89q.worldedit.MaxChangedBlocksException) ServerWorld(net.minecraft.world.server.ServerWorld) SaveHandler(net.minecraft.world.storage.SaveHandler) File(java.io.File) ServerChunkProvider(net.minecraft.world.server.ServerChunkProvider)

Example 5 with ServerChunkProvider

use of net.minecraft.world.server.ServerChunkProvider in project ChaosAwakens by ChaosAwakens.

the class CommonSetupEvent method addDimensionalSpacing.

// public static void registerReachModifiers(final PlayerEvent event) {
// double reachDistance = 0.0D;
// ImmutableMultimap.Builder<Attribute, AttributeModifier> builder = ImmutableMultimap.builder();
// builder.put(ForgeMod.REACH_DISTANCE.get(), new AttributeModifier(ExtendedHitWeaponItem.REACH_MODIFIER, "Weapon modifier", reachDistance, AttributeModifier.Operation.ADDITION));
// ItemStack bigBertha = new ItemStack(CAItems.BIG_BERTHA.get());
// ItemStack attitudeAdjuster = new ItemStack(CAItems.ATTITUDE_ADJUSTER.get());
// ItemStack prismaticReaper = new ItemStack(CAItems.PRISMATIC_REAPER.get());
// PlayerEntity player =  event.getPlayer();
// 
// if(player.getItemInHand(Hand.MAIN_HAND).equals(bigBertha)) {
// reachDistance = 25.0D;
// }
// 
// if(player.getItemInHand(Hand.MAIN_HAND).equals(attitudeAdjuster)) {
// reachDistance = 15.0D;
// }
// 
// if(player.getItemInHand(Hand.MAIN_HAND).equals(prismaticReaper)) {
// reachDistance = 13.0D;
// }
// }
public static void addDimensionalSpacing(final WorldEvent.Load event) {
    if (!(event.getWorld() instanceof ServerWorld))
        return;
    ServerWorld serverWorld = (ServerWorld) event.getWorld();
    ServerChunkProvider chunkProvider = serverWorld.getChunkSource();
    try {
        if (codecMethod == null)
            codecMethod = ObfuscationReflectionHelper.findMethod(ChunkGenerator.class, "codec");
        // TODO Fix this
        ResourceLocation chunkGeneratorKey = Registry.CHUNK_GENERATOR.getKey((Codec<? extends ChunkGenerator>) codecMethod.invoke(chunkProvider.generator));
        if (chunkGeneratorKey != null && chunkGeneratorKey.getNamespace().equals("terraforged"))
            return;
    } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
        ChaosAwakens.warn("WORLDGEN", e);
        e.printStackTrace();
    } catch (UnableToFindMethodException e) {
        if (CAConfig.COMMON.terraforgedCheckMsg.get())
            ChaosAwakens.info("WORLDGEN", "Unable to check if " + serverWorld.dimension().location() + " is using Terraforged's ChunkGenerator due to Terraforged not being present or not accessible," + " if you aren't using Terraforged please ignore this message");
    }
    if (serverWorld.getChunkSource().getGenerator() instanceof FlatChunkGenerator && serverWorld.dimension().equals(World.OVERWORLD))
        return;
    Map<Structure<?>, StructureSeparationSettings> tempMap = new HashMap<>(chunkProvider.generator.getSettings().structureConfig());
    tempMap.putIfAbsent(CAStructures.ACACIA_ENT_TREE.get(), DimensionStructuresSettings.DEFAULTS.get(CAStructures.ACACIA_ENT_TREE.get()));
    tempMap.putIfAbsent(CAStructures.BIRCH_ENT_TREE.get(), DimensionStructuresSettings.DEFAULTS.get(CAStructures.BIRCH_ENT_TREE.get()));
    tempMap.putIfAbsent(CAStructures.CRIMSON_ENT_TREE.get(), DimensionStructuresSettings.DEFAULTS.get(CAStructures.CRIMSON_ENT_TREE.get()));
    tempMap.putIfAbsent(CAStructures.DARK_OAK_ENT_TREE.get(), DimensionStructuresSettings.DEFAULTS.get(CAStructures.DARK_OAK_ENT_TREE.get()));
    tempMap.putIfAbsent(CAStructures.JUNGLE_ENT_TREE.get(), DimensionStructuresSettings.DEFAULTS.get(CAStructures.JUNGLE_ENT_TREE.get()));
    tempMap.putIfAbsent(CAStructures.OAK_ENT_TREE.get(), DimensionStructuresSettings.DEFAULTS.get(CAStructures.OAK_ENT_TREE.get()));
    tempMap.putIfAbsent(CAStructures.SPRUCE_ENT_TREE.get(), DimensionStructuresSettings.DEFAULTS.get(CAStructures.SPRUCE_ENT_TREE.get()));
    tempMap.putIfAbsent(CAStructures.WARPED_ENT_TREE.get(), DimensionStructuresSettings.DEFAULTS.get(CAStructures.WARPED_ENT_TREE.get()));
    tempMap.putIfAbsent(CAStructures.WASP_DUNGEON.get(), DimensionStructuresSettings.DEFAULTS.get(CAStructures.WASP_DUNGEON.get()));
    chunkProvider.generator.getSettings().structureConfig = tempMap;
}
Also used : UnableToFindMethodException(net.minecraftforge.fml.common.ObfuscationReflectionHelper.UnableToFindMethodException) HashMap(java.util.HashMap) FlatChunkGenerator(net.minecraft.world.gen.FlatChunkGenerator) InvocationTargetException(java.lang.reflect.InvocationTargetException) ServerWorld(net.minecraft.world.server.ServerWorld) ResourceLocation(net.minecraft.util.ResourceLocation) StructureSeparationSettings(net.minecraft.world.gen.settings.StructureSeparationSettings) Structure(net.minecraft.world.gen.feature.structure.Structure) ServerChunkProvider(net.minecraft.world.server.ServerChunkProvider)

Aggregations

ServerChunkProvider (net.minecraft.world.server.ServerChunkProvider)14 ServerWorld (net.minecraft.world.server.ServerWorld)11 ChunkPos (net.minecraft.util.math.ChunkPos)4 AbstractChunkProvider (net.minecraft.world.chunk.AbstractChunkProvider)4 Entity (net.minecraft.entity.Entity)3 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)3 World (net.minecraft.world.World)3 BolloomBalloonEntity (com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomBalloonEntity)2 BalloonHolder (com.minecraftabnormals.endergetic.core.interfaces.BalloonHolder)2 WorldBridge (io.izzel.arclight.common.bridge.world.WorldBridge)2 LongIterator (it.unimi.dsi.fastutil.longs.LongIterator)2 PlayerEntity (net.minecraft.entity.player.PlayerEntity)2 BlockPos (net.minecraft.util.math.BlockPos)2 StringTextComponent (net.minecraft.util.text.StringTextComponent)2 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)2 ForcedChunksSaveData (net.minecraft.world.ForcedChunksSaveData)2 DimensionType (net.minecraft.world.dimension.DimensionType)2 DynmapChunk (org.dynmap.DynmapChunk)2 Inject (org.spongepowered.asm.mixin.injection.Inject)2 MaxChangedBlocksException (com.sk89q.worldedit.MaxChangedBlocksException)1