net.minecraft.world.WorldSettings Java Examples

The following examples show how to use net.minecraft.world.WorldSettings. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MixinNetHandlerPlayClient.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
@Inject(method = "handleJoinGame", at = @At("HEAD"), cancellable = true)
private void handleJoinGameWithAntiForge(S01PacketJoinGame packetIn, final CallbackInfo callbackInfo) {
    if(!AntiForge.enabled || !AntiForge.blockFML || Minecraft.getMinecraft().isIntegratedServerRunning())
        return;

    PacketThreadUtil.checkThreadAndEnqueue(packetIn, (NetHandlerPlayClient) (Object) this, gameController);
    this.gameController.playerController = new PlayerControllerMP(gameController, (NetHandlerPlayClient) (Object) this);
    this.clientWorldController = new WorldClient((NetHandlerPlayClient) (Object) this, new WorldSettings(0L, packetIn.getGameType(), false, packetIn.isHardcoreMode(), packetIn.getWorldType()), packetIn.getDimension(), packetIn.getDifficulty(), this.gameController.mcProfiler);
    this.gameController.gameSettings.difficulty = packetIn.getDifficulty();
    this.gameController.loadWorld(this.clientWorldController);
    this.gameController.thePlayer.dimension = packetIn.getDimension();
    this.gameController.displayGuiScreen(new GuiDownloadTerrain((NetHandlerPlayClient) (Object) this));
    this.gameController.thePlayer.setEntityId(packetIn.getEntityId());
    this.currentServerMaxPlayers = packetIn.getMaxPlayers();
    this.gameController.thePlayer.setReducedDebug(packetIn.isReducedDebugInfo());
    this.gameController.playerController.setGameType(packetIn.getGameType());
    this.gameController.gameSettings.sendSettingsToServer();
    this.netManager.sendPacket(new C17PacketCustomPayload("MC|Brand", (new PacketBuffer(Unpooled.buffer())).writeString(ClientBrandRetriever.getClientModName())));
    callbackInfo.cancel();
}
 
Example #2
Source File: MixinNetHandlerPlayClient.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
@Inject(method = "handleJoinGame", at = @At("HEAD"), cancellable = true)
private void handleJoinGameWithAntiForge(S01PacketJoinGame packetIn, final CallbackInfo callbackInfo) {
    if(!AntiForge.enabled || !AntiForge.blockFML || Minecraft.getMinecraft().isIntegratedServerRunning())
        return;

    PacketThreadUtil.checkThreadAndEnqueue(packetIn, (NetHandlerPlayClient) (Object) this, gameController);
    this.gameController.playerController = new PlayerControllerMP(gameController, (NetHandlerPlayClient) (Object) this);
    this.clientWorldController = new WorldClient((NetHandlerPlayClient) (Object) this, new WorldSettings(0L, packetIn.getGameType(), false, packetIn.isHardcoreMode(), packetIn.getWorldType()), packetIn.getDimension(), packetIn.getDifficulty(), this.gameController.mcProfiler);
    this.gameController.gameSettings.difficulty = packetIn.getDifficulty();
    this.gameController.loadWorld(this.clientWorldController);
    this.gameController.thePlayer.dimension = packetIn.getDimension();
    this.gameController.displayGuiScreen(new GuiDownloadTerrain((NetHandlerPlayClient) (Object) this));
    this.gameController.thePlayer.setEntityId(packetIn.getEntityId());
    this.currentServerMaxPlayers = packetIn.getMaxPlayers();
    this.gameController.thePlayer.setReducedDebug(packetIn.isReducedDebugInfo());
    this.gameController.playerController.setGameType(packetIn.getGameType());
    this.gameController.gameSettings.sendSettingsToServer();
    this.netManager.sendPacket(new C17PacketCustomPayload("MC|Brand", (new PacketBuffer(Unpooled.buffer())).writeString(ClientBrandRetriever.getClientModName())));
    callbackInfo.cancel();
}
 
Example #3
Source File: VanillaEnhancementsHud.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
@InvokeEvent
public void renderItemCount(RenderHUDEvent event) {
    if (Settings.ITEM_COUNTER) {
        if (mc.thePlayer.getCurrentEquippedItem() != null) {
            boolean holdingBow = mc.thePlayer.getCurrentEquippedItem().getItem() instanceof ItemBow;
            int count = getHeldItemCount(holdingBow);
            if (count > 1 || (holdingBow && count > 0)) {
                int offset = mc.playerController.getCurrentGameType() == WorldSettings.GameType.CREATIVE ? 10 : 0;
                mc.fontRendererObj.drawString(String.valueOf(count),
                    event.getResolution().getScaledWidth() - mc.fontRendererObj.getStringWidth(String.valueOf(count)) >> 1,
                    event.getResolution().getScaledHeight() - 46 - offset,
                    -1,
                    true);
            }
        }
    }
}
 
Example #4
Source File: GuiEntityRender.java    From WearableBackpacks with MIT License 5 votes vote down vote up
public DummyWorld(WorldSettings settings) {
	super(new DummySaveHandler(),
	      new WorldInfo(settings, "DummyWorld"),
	      new WorldProviderSurface(), null, true);
	provider.setWorld(this);
	player = new DummyPlayerSP(this);
}
 
Example #5
Source File: FakeWorldServer.java    From Framez with GNU General Public License v3.0 5 votes vote down vote up
private FakeWorldServer(World world) {

        super(MinecraftServer.getServer(), new NonSavingHandler(), world.getWorldInfo().getWorldName(), world.provider.dimensionId,
                new WorldSettings(world.getWorldInfo()), world.theProfiler);
        DimensionManager.setWorld(world.provider.dimensionId, (WorldServer) world);

        chunkProvider = world.getChunkProvider();
    }
 
Example #6
Source File: CraftServer.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setDefaultGameMode(GameMode mode) {
    Validate.notNull(mode, "Mode cannot be null");

    for (World world : getWorlds()) {
        ((CraftWorld) world).getHandle().worldInfo.setGameType(net.minecraft.world.WorldSettings.GameType.getByID(mode.getValue()));
    }
}
 
Example #7
Source File: BiomeGeneratorImplementation.java    From malmo with MIT License 5 votes vote down vote up
@Override
public boolean createWorld(MissionInit missionInit) {
	long seed = getWorldSeedFromString();
	WorldType.WORLD_TYPES[0].onGUICreateWorldPress();
	WorldSettings worldsettings = new WorldSettings(seed, GameType.SURVIVAL, true, false, WorldType.WORLD_TYPES[0]);
	worldsettings.enableCommands();
	// Create a filename for this map - we use the time stamp to make sure
	// it is different from other worlds, otherwise no new world
	// will be created, it will simply load the old one.
	return MapFileHelper.createAndLaunchWorld(worldsettings, this.bparams.isDestroyAfterUse());
}
 
Example #8
Source File: FlatWorldGeneratorImplementation.java    From malmo with MIT License 5 votes vote down vote up
@Override
public boolean createWorld(MissionInit missionInit)
{
    long seed = DefaultWorldGeneratorImplementation.getWorldSeedFromString(this.fwparams.getSeed());
    WorldSettings worldsettings = new WorldSettings(seed, GameType.SURVIVAL, false, false, WorldType.FLAT);
    // This call to setWorldName allows us to specify the layers of our world, and also the features that will be created.
    // This website provides a handy way to generate these strings: http://chunkbase.com/apps/superflat-generator
    worldsettings.setGeneratorOptions(this.fwparams.getGeneratorString());
    worldsettings.enableCommands(); // Enables cheat commands.
    // Create a filename for this map - we use the time stamp to make sure it is different from other worlds, otherwise no new world
    // will be created, it will simply load the old one.
    return MapFileHelper.createAndLaunchWorld(worldsettings, this.fwparams.isDestroyAfterUse());
}
 
Example #9
Source File: DefaultWorldGeneratorImplementation.java    From malmo with MIT License 5 votes vote down vote up
@Override
public boolean createWorld(MissionInit missionInit)
{
    long seed = getWorldSeedFromString(this.dwparams.getSeed());
    WorldType.WORLD_TYPES[0].onGUICreateWorldPress();
    WorldSettings worldsettings = new WorldSettings(seed, GameType.SURVIVAL, true, false, WorldType.WORLD_TYPES[0]);
    worldsettings.enableCommands();
    // Create a filename for this map - we use the time stamp to make sure it is different from other worlds, otherwise no new world
    // will be created, it will simply load the old one.
    return MapFileHelper.createAndLaunchWorld(worldsettings, this.dwparams.isDestroyAfterUse());
}
 
Example #10
Source File: MapFileHelper.java    From malmo with MIT License 5 votes vote down vote up
/**
 * Creates and launches a unique world according to the settings. 
 * @param worldsettings the world's settings
 * @param isTemporary if true, the world will be deleted whenever newer worlds are created
 * @return
 */
public static boolean createAndLaunchWorld(WorldSettings worldsettings, boolean isTemporary)
{
    String s = getNewSaveFileLocation(isTemporary);
    Minecraft.getMinecraft().launchIntegratedServer(s, s, worldsettings);
    cleanupTemporaryWorlds(s);
    return true;
}
 
Example #11
Source File: MaterialCache.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
private MaterialCache()
{
    WorldSettings settings = new WorldSettings(0L, GameType.CREATIVE, false, false, WorldType.FLAT);

    this.tempWorld = new WorldSchematic(null, settings, -1, EnumDifficulty.PEACEFUL, Minecraft.getMinecraft().profiler);
    this.checkPos = new BlockPos(8, 0, 8);

    WorldUtils.loadChunksClientWorld(this.tempWorld, this.checkPos, new Vec3i(1, 1, 1));
}
 
Example #12
Source File: WorldSchematic.java    From litematica with GNU Lesser General Public License v3.0 4 votes vote down vote up
public WorldSchematic(NetHandlerPlayClient netHandler, WorldSettings settings, int dimension,
        EnumDifficulty difficulty, Profiler profilerIn)
{
    super(netHandler, settings, dimension, difficulty, profilerIn);
}
 
Example #13
Source File: VisualCreative.java    From ehacks-pro with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onModuleDisabled() {
    Wrapper.INSTANCE.mc().playerController.setGameType(WorldSettings.GameType.SURVIVAL);
    WorldSettings.GameType.CREATIVE.configurePlayerCapabilities(Wrapper.INSTANCE.player().capabilities);
    Wrapper.INSTANCE.player().sendPlayerAbilities();
}
 
Example #14
Source File: VisualCreative.java    From ehacks-pro with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onModuleEnabled() {
    Wrapper.INSTANCE.mc().playerController.setGameType(WorldSettings.GameType.CREATIVE);
    WorldSettings.GameType.CREATIVE.configurePlayerCapabilities(Wrapper.INSTANCE.player().capabilities);
    Wrapper.INSTANCE.player().sendPlayerAbilities();
}
 
Example #15
Source File: ProxyWorld.java    From LookingGlass with GNU General Public License v3.0 4 votes vote down vote up
public ProxyWorld(int dimensionID) {
	super(Minecraft.getMinecraft().getNetHandler(), new WorldSettings(0L, GameType.SURVIVAL, true, false, WorldType.DEFAULT), dimensionID, Minecraft.getMinecraft().gameSettings.difficulty, Minecraft.getMinecraft().theWorld.theProfiler);
}
 
Example #16
Source File: CraftServer.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
@Override
public World createWorld(WorldCreator creator) {
    Validate.notNull(creator, "Creator may not be null");

    String name = creator.name();
    ChunkGenerator generator = creator.generator();
    File folder = new File(getWorldContainer(), name);
    World world = getWorld(name);
    net.minecraft.world.WorldType type = net.minecraft.world.WorldType.parseWorldType(creator.type().getName());
    boolean generateStructures = creator.generateStructures();

    if ((folder.exists()) && (!folder.isDirectory())) {
        throw new IllegalArgumentException("File exists with the name '" + name + "' and isn't a folder");
    }

    if (world != null) {
        return world;
    }

    boolean hardcore = false;
    WorldSettings worldSettings = new WorldSettings(creator.seed(), net.minecraft.world.WorldSettings.GameType.getByID(getDefaultGameMode().getValue()), generateStructures, hardcore, type);
    net.minecraft.world.WorldServer worldserver = DimensionManager.initDimension(creator, worldSettings);

    pluginManager.callEvent(new WorldInitEvent(worldserver.getWorld()));
    net.minecraftforge.cauldron.CauldronHooks.craftWorldLoading = true;
    System.out.print("Preparing start region for level " + (console.worlds.size() - 1) + " (Dimension: " + worldserver.provider.dimensionId + ", Seed: " + worldserver.getSeed() + ")"); // Cauldron - log dimension

    if (worldserver.getWorld().getKeepSpawnInMemory()) {
        short short1 = 196;
        long i = System.currentTimeMillis();
        for (int j = -short1; j <= short1; j += 16) {
            for (int k = -short1; k <= short1; k += 16) {
                long l = System.currentTimeMillis();

                if (l < i) {
                    i = l;
                }

                if (l > i + 1000L) {
                    int i1 = (short1 * 2 + 1) * (short1 * 2 + 1);
                    int j1 = (j + short1) * (short1 * 2 + 1) + k + 1;

                    System.out.println("Preparing spawn area for " + worldserver.getWorld().getName() + ", " + (j1 * 100 / i1) + "%");
                    i = l;
                }

                net.minecraft.util.ChunkCoordinates chunkcoordinates = worldserver.getSpawnPoint();
                worldserver.theChunkProviderServer.loadChunk(chunkcoordinates.posX + j >> 4, chunkcoordinates.posZ + k >> 4);
            }
        }
    }
    pluginManager.callEvent(new WorldLoadEvent(worldserver.getWorld()));
    net.minecraftforge.cauldron.CauldronHooks.craftWorldLoading = false;
    return worldserver.getWorld();
}
 
Example #17
Source File: FakeWorldClient.java    From Framez with GNU General Public License v3.0 4 votes vote down vote up
private FakeWorldClient() {

        super(new NetHandlerPlayClient(Minecraft.getMinecraft(), null, new NetworkManager(true)), new WorldSettings(0, GameType.NOT_SET,
                false, false, WorldType.DEFAULT), 0, EnumDifficulty.PEACEFUL, Minecraft.getMinecraft().theWorld.theProfiler);
    }
 
Example #18
Source File: WrapperWorldSettings.java    From ClientBase with MIT License 4 votes vote down vote up
public WorldSettings unwrap() {
    return this.real;
}
 
Example #19
Source File: GuiEntityRender.java    From WearableBackpacks with MIT License 4 votes vote down vote up
public DummyWorld()
{ this(new WorldSettings(0, GameType.SURVIVAL, false, false, WorldType.DEFAULT)); }
 
Example #20
Source File: WrapperWorldSettings.java    From ClientBase with MIT License 4 votes vote down vote up
public WrapperWorldSettings(WorldSettings var1) {
    this.real = var1;
}
 
Example #21
Source File: MixinMinecraft.java    From Hyperium with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Invoked once the player has joined a singleplayer world
 *
 * @param ci {@see org.spongepowered.asm.mixin.injection.callback.CallbackInfo}
 */
@Inject(method = "launchIntegratedServer", at = @At("HEAD"))
private void launchIntegratedServer(String folderName, String worldName, WorldSettings worldSettingsIn, CallbackInfo ci) {
    hyperiumMinecraft.launchIntegratedServer();
}
 
Example #22
Source File: FakeWorldServer.java    From Framez with GNU General Public License v3.0 2 votes vote down vote up
@Override
protected void initialize(WorldSettings p_72963_1_) {

}