Search in sources :

Example 1 with ChunkProviderLands

use of com.mraof.minestuck.world.lands.gen.ChunkProviderLands in project Minestuck by mraof.

the class MessageType method createMessage.

private static ITextComponent createMessage(EntityConsort consort, EntityPlayer player, String unlocalizedMessage, String[] args, boolean consortPrefix) {
    String s = EntityList.getEntityString(consort);
    if (s == null) {
        s = "generic";
    }
    Object[] obj = new Object[args.length];
    SburbConnection c = SburbHandler.getConnectionForDimension(consort.homeDimension);
    Title title = c == null ? null : MinestuckPlayerData.getData(c.getClientIdentifier()).title;
    for (int i = 0; i < args.length; i++) {
        if (args[i].equals("playerNameLand")) {
            if (c != null)
                obj[i] = c.getClientIdentifier().getUsername();
            else
                obj[i] = "Player name";
        } else if (args[i].equals("playerName")) {
            obj[i] = player.getName();
        } else if (args[i].equals("landName")) {
            World world = consort.getServer().getWorld(consort.homeDimension);
            if (world != null && consort.world.provider instanceof WorldProviderLands) {
                ChunkProviderLands chunkProvider = (ChunkProviderLands) world.provider.createChunkGenerator();
                ITextComponent aspect1 = new TextComponentTranslation("land." + chunkProvider.aspect1.getNames()[chunkProvider.nameIndex1]);
                ITextComponent aspect2 = new TextComponentTranslation("land." + chunkProvider.aspect2.getNames()[chunkProvider.nameIndex2]);
                if (chunkProvider.nameOrder)
                    obj[i] = new TextComponentTranslation("land.format", aspect1, aspect2);
                else
                    obj[i] = new TextComponentTranslation("land.format", aspect2, aspect1);
            } else
                obj[i] = "Land name";
        } else if (args[i].equals("playerTitleLand")) {
            if (title != null)
                obj[i] = title.asTextComponent();
            else
                obj[i] = "Player title";
        } else if (args[i].equals("playerClassLand")) {
            if (title != null)
                obj[i] = title.getHeroClass().asTextComponent();
            else
                obj[i] = "Player class";
        } else if (args[i].equals("playerAspectLand")) {
            if (title != null)
                obj[i] = title.getHeroAspect().asTextComponent();
            else
                obj[i] = "Player aspect";
        } else if (args[i].equals("consortSound")) {
            obj[i] = new TextComponentTranslation("consort.sound." + s);
        } else if (args[i].equals("consortType")) {
            obj[i] = new TextComponentTranslation("entity." + s + ".name");
        } else if (args[i].equals("consortTypes")) {
            obj[i] = new TextComponentTranslation("entity." + s + ".plural.name");
        } else if (args[i].equals("playerTitle")) {
            PlayerIdentifier identifier = IdentifierHandler.encode(player);
            if (MinestuckPlayerData.getTitle(identifier) != null)
                obj[i] = MinestuckPlayerData.getTitle(identifier).asTextComponent();
            else
                obj[i] = player.getName();
        } else if (args[i].equals("denizen")) {
            if (title != null)
                obj[i] = new TextComponentTranslation("denizen." + MinestuckPlayerData.getData(c.getClientIdentifier()).title.getHeroAspect().toString() + ".name");
            else
                obj[i] = "Denizen";
        } else if (args[i].startsWith("nbtItem:")) {
            NBTTagCompound nbt = consort.getMessageTagForPlayer(player);
            ItemStack stack = new ItemStack(nbt.getCompoundTag(args[i].substring(8)));
            if (!stack.isEmpty())
                obj[i] = new TextComponentTranslation(stack.getUnlocalizedName() + ".name");
            else
                obj[i] = "Item";
        }
    }
    TextComponentTranslation message = new TextComponentTranslation("consort." + unlocalizedMessage, obj);
    if (consortPrefix) {
        message.getStyle().setColor(consort.getConsortType().getColor());
        TextComponentTranslation entity = new TextComponentTranslation("entity." + s + ".name");
        return new TextComponentTranslation("chat.type.text", entity, message);
    } else
        return message;
}
Also used : ChunkProviderLands(com.mraof.minestuck.world.lands.gen.ChunkProviderLands) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Title(com.mraof.minestuck.util.Title) World(net.minecraft.world.World) PlayerIdentifier(com.mraof.minestuck.util.IdentifierHandler.PlayerIdentifier) WorldProviderLands(com.mraof.minestuck.world.WorldProviderLands) ItemStack(net.minecraft.item.ItemStack) SburbConnection(com.mraof.minestuck.network.skaianet.SburbConnection)

Example 2 with ChunkProviderLands

use of com.mraof.minestuck.world.lands.gen.ChunkProviderLands in project Minestuck by mraof.

the class TitleLandAspect method createChunkProvider.

public ChunkProviderLands createChunkProvider(WorldProviderLands land) {
    ChunkProviderLands chunkProvider = new ChunkProviderLands(land.getWorld(), land, land.getWorld().isRemote);
    prepareChunkProvider(chunkProvider);
    if (!land.getWorld().isRemote)
        prepareChunkProviderServer(chunkProvider);
    chunkProvider.createBiomeGen();
    return chunkProvider;
}
Also used : ChunkProviderLands(com.mraof.minestuck.world.lands.gen.ChunkProviderLands)

Example 3 with ChunkProviderLands

use of com.mraof.minestuck.world.lands.gen.ChunkProviderLands in project Minestuck by mraof.

the class SessionHandler method createDataTag.

/**
 * Creates data to be used for the data checker
 */
public static NBTTagCompound createDataTag(MinecraftServer server) {
    NBTTagCompound nbt = new NBTTagCompound();
    NBTTagList sessionList = new NBTTagList();
    nbt.setTag("sessions", sessionList);
    int nameIndex = 1;
    for (int i = 0; i < sessions.size(); i++) {
        Session session = sessions.get(i);
        NBTTagList connectionList = new NBTTagList();
        Set<PlayerIdentifier> playerSet = new HashSet<PlayerIdentifier>();
        for (SburbConnection c : session.connections) {
            if (c.isMain)
                playerSet.add(c.getClientIdentifier());
            NBTTagCompound connectionTag = new NBTTagCompound();
            connectionTag.setString("client", c.getClientIdentifier().getUsername());
            connectionTag.setString("clientId", c.getClientIdentifier().getString());
            if (!c.getServerIdentifier().equals(IdentifierHandler.nullIdentifier))
                connectionTag.setString("server", c.getServerIdentifier().getUsername());
            connectionTag.setBoolean("isMain", c.isMain);
            connectionTag.setBoolean("isActive", c.isActive);
            if (c.isMain) {
                connectionTag.setInteger("clientDim", c.enteredGame ? c.clientHomeLand : 0);
                if (c.enteredGame && DimensionManager.isDimensionRegistered(c.clientHomeLand)) {
                    LandAspectRegistry.AspectCombination aspects = MinestuckDimensionHandler.getAspects(c.clientHomeLand);
                    IChunkGenerator chunkGen = server.getWorld(c.clientHomeLand).provider.createChunkGenerator();
                    if (chunkGen instanceof ChunkProviderLands) {
                        ChunkProviderLands landChunkGen = (ChunkProviderLands) chunkGen;
                        if (landChunkGen.nameOrder) {
                            connectionTag.setString("aspect1", aspects.aspectTerrain.getNames()[landChunkGen.nameIndex1]);
                            connectionTag.setString("aspect2", aspects.aspectTitle.getNames()[landChunkGen.nameIndex2]);
                        } else {
                            connectionTag.setString("aspect1", aspects.aspectTitle.getNames()[landChunkGen.nameIndex2]);
                            connectionTag.setString("aspect2", aspects.aspectTerrain.getNames()[landChunkGen.nameIndex1]);
                        }
                    }
                    Title title = MinestuckPlayerData.getTitle(c.getClientIdentifier());
                    connectionTag.setByte("class", title == null ? -1 : (byte) title.getHeroClass().ordinal());
                    connectionTag.setByte("aspect", title == null ? -1 : (byte) title.getHeroAspect().ordinal());
                } else if (session.predefinedPlayers.containsKey(c.getClientIdentifier())) {
                    PredefineData data = session.predefinedPlayers.get(c.getClientIdentifier());
                    if (data.title != null) {
                        connectionTag.setByte("class", (byte) data.title.getHeroClass().ordinal());
                        connectionTag.setByte("aspect", (byte) data.title.getHeroAspect().ordinal());
                    }
                    if (data.landTerrain != null)
                        connectionTag.setString("aspectTerrain", data.landTerrain.getPrimaryName());
                    if (data.landTitle != null)
                        connectionTag.setString("aspectTitle", data.landTitle.getPrimaryName());
                }
            }
            connectionList.appendTag(connectionTag);
        }
        for (Map.Entry<PlayerIdentifier, PredefineData> entry : session.predefinedPlayers.entrySet()) {
            if (playerSet.contains(entry.getKey()))
                continue;
            NBTTagCompound connectionTag = new NBTTagCompound();
            connectionTag.setString("client", entry.getKey().getUsername());
            connectionTag.setString("clientId", entry.getKey().getString());
            connectionTag.setBoolean("isMain", true);
            connectionTag.setBoolean("isActive", false);
            connectionTag.setInteger("clientDim", 0);
            PredefineData data = entry.getValue();
            if (data.title != null) {
                connectionTag.setByte("class", (byte) data.title.getHeroClass().ordinal());
                connectionTag.setByte("aspect", (byte) data.title.getHeroAspect().ordinal());
            }
            if (data.landTerrain != null)
                connectionTag.setString("aspectTerrain", data.landTerrain.getPrimaryName());
            if (data.landTitle != null)
                connectionTag.setString("aspectTitle", data.landTitle.getPrimaryName());
            connectionList.appendTag(connectionTag);
        }
        NBTTagCompound sessionTag = new NBTTagCompound();
        if (session.name != null)
            sessionTag.setString("name", session.name);
        sessionTag.setTag("connections", connectionList);
        sessionList.appendTag(sessionTag);
    }
    return nbt;
}
Also used : ChunkProviderLands(com.mraof.minestuck.world.lands.gen.ChunkProviderLands) IChunkGenerator(net.minecraft.world.gen.IChunkGenerator) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Title(com.mraof.minestuck.util.Title) PlayerIdentifier(com.mraof.minestuck.util.IdentifierHandler.PlayerIdentifier) LandAspectRegistry(com.mraof.minestuck.world.lands.LandAspectRegistry) NBTTagList(net.minecraft.nbt.NBTTagList)

Example 4 with ChunkProviderLands

use of com.mraof.minestuck.world.lands.gen.ChunkProviderLands in project Minestuck by mraof.

the class OreHandler method addOreSpawn.

public void addOreSpawn(IBlockState block, World world, Random random, int blockXPos, int blockZPos, int maxX, int maxZ, int maxVeinSize, int chancesToSpawn, int minY, int maxY) {
    // int maxPossY = minY + (maxY - 1);
    int diffBtwnMinMaxY = maxY - minY;
    IBlockState groundType = Blocks.STONE.getDefaultState();
    if (world.provider instanceof WorldProviderLands)
        groundType = ((ChunkProviderLands) world.provider.createChunkGenerator()).getGroundBlock();
    if (block.getBlock() == MinestuckBlocks.oreCruxite)
        block = BlockCruxiteOre.getBlockState(groundType);
    if (block.getBlock() == MinestuckBlocks.oreUranium)
        block = MinestuckBlocks.oreUranium.getBlockState(groundType);
    for (int x = 0; x < chancesToSpawn; x++) {
        int posX = blockXPos + random.nextInt(maxX);
        int posY = minY + random.nextInt(diffBtwnMinMaxY);
        int posZ = blockZPos + random.nextInt(maxZ);
        (new WorldGenMinable(block, maxVeinSize, new BlockStatePredicate(groundType))).generate(world, random, new BlockPos(posX, posY, posZ));
    }
}
Also used : ChunkProviderLands(com.mraof.minestuck.world.lands.gen.ChunkProviderLands) IBlockState(net.minecraft.block.state.IBlockState) WorldProviderLands(com.mraof.minestuck.world.WorldProviderLands) BlockPos(net.minecraft.util.math.BlockPos) WorldGenMinable(net.minecraft.world.gen.feature.WorldGenMinable)

Example 5 with ChunkProviderLands

use of com.mraof.minestuck.world.lands.gen.ChunkProviderLands in project Minestuck by mraof.

the class MinestuckPlayerTracker method sendLandEntryMessage.

public static void sendLandEntryMessage(EntityPlayer player) {
    if (MinestuckDimensionHandler.isLandDimension(player.dimension)) {
        LandAspectRegistry.AspectCombination aspects = MinestuckDimensionHandler.getAspects(player.dimension);
        ChunkProviderLands chunkProvider = (ChunkProviderLands) player.world.provider.createChunkGenerator();
        ITextComponent aspect1 = new TextComponentTranslation("land." + aspects.aspectTerrain.getNames()[chunkProvider.nameIndex1]);
        ITextComponent aspect2 = new TextComponentTranslation("land." + aspects.aspectTitle.getNames()[chunkProvider.nameIndex2]);
        ITextComponent toSend;
        if (chunkProvider.nameOrder)
            toSend = new TextComponentTranslation("land.message.entry", aspect1, aspect2);
        else
            toSend = new TextComponentTranslation("land.message.entry", aspect2, aspect1);
        player.sendMessage(toSend);
    }
}
Also used : ChunkProviderLands(com.mraof.minestuck.world.lands.gen.ChunkProviderLands) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ITextComponent(net.minecraft.util.text.ITextComponent) LandAspectRegistry(com.mraof.minestuck.world.lands.LandAspectRegistry)

Aggregations

ChunkProviderLands (com.mraof.minestuck.world.lands.gen.ChunkProviderLands)6 LandAspectRegistry (com.mraof.minestuck.world.lands.LandAspectRegistry)3 PlayerIdentifier (com.mraof.minestuck.util.IdentifierHandler.PlayerIdentifier)2 Title (com.mraof.minestuck.util.Title)2 WorldProviderLands (com.mraof.minestuck.world.WorldProviderLands)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 ITextComponent (net.minecraft.util.text.ITextComponent)2 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)2 SburbConnection (com.mraof.minestuck.network.skaianet.SburbConnection)1 IBlockState (net.minecraft.block.state.IBlockState)1 PlayerNotFoundException (net.minecraft.command.PlayerNotFoundException)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 ItemStack (net.minecraft.item.ItemStack)1 NBTTagList (net.minecraft.nbt.NBTTagList)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1 IChunkGenerator (net.minecraft.world.gen.IChunkGenerator)1 WorldGenMinable (net.minecraft.world.gen.feature.WorldGenMinable)1