Search in sources :

Example 16 with DimletKey

use of mcjty.rftoolsdim.dimensions.dimlets.DimletKey in project RFToolsDimensions by McJty.

the class KnownDimlet method addInformation.

// @todo
//    @Override
//    public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
//        if (world.isRemote) {
//            return stack;
//        }
//
//        DimletKey key = KnownDimletConfiguration.getDimletKey(stack, world);
//        DimletEntry entry = KnownDimletConfiguration.getEntry(key);
//        if (entry != null) {
//            if (isSeedDimlet(entry)) {
//                NBTTagCompound tagCompound = stack.getTagCompound();
//                if (tagCompound == null) {
//                    tagCompound = new NBTTagCompound();
//                }
//
//                boolean locked = tagCompound.getBoolean("locked");
//                if (locked) {
//                    Logging.message(player, TextFormatting.YELLOW + "This seed dimlet is locked. You cannot modify it!");
//                    return stack;
//                }
//
//                long forcedSeed = tagCompound.getLong("forcedSeed");
//                if (player.isSneaking()) {
//                    if (forcedSeed == 0) {
//                        Logging.message(player, TextFormatting.YELLOW + "This dimlet has no seed. You cannot lock it!");
//                        return stack;
//                    }
//                    tagCompound.setBoolean("locked", true);
//                    Logging.message(player, "Dimlet locked!");
//                } else {
//                    long seed = world.getSeed();
//                    tagCompound.setLong("forcedSeed", seed);
//                    Logging.message(player, "Seed set to: " + seed);
//                }
//
//                stack.setTagCompound(tagCompound);
//            }
//        }
//
//        return stack;
//    }
@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack itemStack, EntityPlayer player, List<String> list, boolean showExtended) {
    super.addInformation(itemStack, player, list, showExtended);
    DimletKey key = KnownDimletConfiguration.getDimletKey(itemStack);
    Settings settings = KnownDimletConfiguration.getSettings(key);
    if (showExtended) {
        list.add(TextFormatting.GOLD + "Key: " + key.getId());
    }
    if (settings == null) {
        list.add(TextFormatting.WHITE + "Dimlet " + key.getType().dimletType.getName() + "." + key.getId());
        list.add(TextFormatting.RED + "This dimlet is blacklisted!");
        return;
    }
    list.add(TextFormatting.BLUE + "Rarity: " + settings.getRarity() + (KnownDimletConfiguration.isCraftable(key) ? " (craftable)" : ""));
    list.add(TextFormatting.YELLOW + "Create cost: " + settings.getCreateCost() + " RF/tick");
    int maintainCost = settings.getMaintainCost();
    if (maintainCost < 0) {
        list.add(TextFormatting.YELLOW + "Maintain cost: " + maintainCost + "% RF/tick");
    } else {
        list.add(TextFormatting.YELLOW + "Maintain cost: " + maintainCost + " RF/tick");
    }
    list.add(TextFormatting.YELLOW + "Tick cost: " + settings.getTickCost() + " ticks");
    if (KnownDimletConfiguration.isSeedDimlet(key)) {
        NBTTagCompound tagCompound = itemStack.getTagCompound();
        if (tagCompound != null && tagCompound.getLong("forcedSeed") != 0) {
            long forcedSeed = tagCompound.getLong("forcedSeed");
            boolean locked = tagCompound.getBoolean("locked");
            list.add(TextFormatting.BLUE + "Forced seed: " + forcedSeed + (locked ? " [LOCKED]" : ""));
        } else {
            list.add(TextFormatting.BLUE + "Right click to copy seed from dimension.");
            list.add(TextFormatting.BLUE + "Shift-Right click to lock copied seed.");
        }
    }
    if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
        for (String info : key.getType().dimletType.getInformation()) {
            list.add(TextFormatting.WHITE + info);
        }
    // @todo
    //            List<String> extra = KnownDimletConfiguration.idToExtraInformation.get(entry.getKey());
    //            if (extra != null) {
    //                for (String info : extra) {
    //                    list.add(TextFormatting.YELLOW + info);
    //                }
    //            }
    } else {
        list.add(TextFormatting.WHITE + RFToolsDim.SHIFT_MESSAGE);
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey) Settings(mcjty.rftoolsdim.config.Settings) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 17 with DimletKey

use of mcjty.rftoolsdim.dimensions.dimlets.DimletKey in project RFToolsDimensions by McJty.

the class GenericWorldGenerator method generateDungeon.

private void generateDungeon(World world, Random random, int midx, int starty, int midz) {
    boolean doSmallAntenna = random.nextInt(4) == 0;
    boolean doExtraFeature = random.nextInt(4) == 0;
    Block cornerBlock;
    switch(random.nextInt(3)) {
        case 0:
            cornerBlock = ModBlocks.dimensionalCrossBlock;
            break;
        case 1:
            cornerBlock = ModBlocks.dimensionalPattern1Block;
            break;
        case 2:
            cornerBlock = ModBlocks.dimensionalPattern2Block;
            break;
        default:
            cornerBlock = ModBlocks.dimensionalCross2Block;
    }
    Block buildingBlock = Blocks.STAINED_HARDENED_CLAY;
    int color = random.nextInt(5);
    if (color == 0) {
        color = 3;
    } else if (color == 1) {
        color = 9;
    } else if (color == 2) {
        color = 11;
    } else {
        color = 0;
        buildingBlock = ModBlocks.dimensionalBlankBlock;
    }
    // Spawn the building
    for (int x = midx - 3; x <= midx + 3; x++) {
        for (int z = midz - 3; z <= midz + 3; z++) {
            boolean corner = (x == midx - 3 || x == midx + 3) && (z == midz - 3 || z == midz + 3);
            boolean xside = x == midx - 3 || x == midx + 3;
            boolean zside = z == midz - 3 || z == midz + 3;
            boolean antenna = (x == midx - 2 && z == midz - 2);
            boolean smallAntenna = doSmallAntenna && (x == midx + 2 && z == midz + 2);
            world.setBlockState(new BlockPos(x, starty, z), Blocks.DOUBLE_STONE_SLAB.getDefaultState(), 2);
            if (corner) {
                world.setBlockState(new BlockPos(x, starty + 1, z), cornerBlock.getStateFromMeta(1), 2);
                world.setBlockState(new BlockPos(x, starty + 2, z), cornerBlock.getStateFromMeta(1), 2);
                world.setBlockState(new BlockPos(x, starty + 3, z), cornerBlock.getStateFromMeta(1), 2);
            } else if (xside) {
                world.setBlockState(new BlockPos(x, starty + 1, z), buildingBlock.getStateFromMeta(color), 2);
                if (z >= midz - 1 && z <= midz + 1) {
                    world.setBlockState(new BlockPos(x, starty + 2, z), Blocks.GLASS_PANE.getStateFromMeta(0), 2);
                } else {
                    world.setBlockState(new BlockPos(x, starty + 2, z), buildingBlock.getStateFromMeta(color), 2);
                }
                world.setBlockState(new BlockPos(x, starty + 3, z), buildingBlock.getStateFromMeta(color), 2);
            } else if (zside) {
                world.setBlockState(new BlockPos(x, starty + 1, z), buildingBlock.getStateFromMeta(color), 2);
                world.setBlockState(new BlockPos(x, starty + 2, z), buildingBlock.getStateFromMeta(color), 2);
                world.setBlockState(new BlockPos(x, starty + 3, z), buildingBlock.getStateFromMeta(color), 2);
            } else {
                world.setBlockToAir(new BlockPos(x, starty + 1, z));
                world.setBlockToAir(new BlockPos(x, starty + 2, z));
                world.setBlockToAir(new BlockPos(x, starty + 3, z));
            }
            if (antenna) {
                world.setBlockState(new BlockPos(x, starty + 4, z), Blocks.DOUBLE_STONE_SLAB.getDefaultState(), 2);
                world.setBlockState(new BlockPos(x, starty + 5, z), Blocks.IRON_BARS.getDefaultState(), 2);
                world.setBlockState(new BlockPos(x, starty + 6, z), Blocks.IRON_BARS.getDefaultState(), 2);
                world.setBlockState(new BlockPos(x, starty + 7, z), Blocks.IRON_BARS.getDefaultState(), 2);
                world.setBlockState(new BlockPos(x, starty + 8, z), Blocks.GLOWSTONE.getDefaultState(), 3);
            } else if (smallAntenna) {
                world.setBlockState(new BlockPos(x, starty + 4, z), Blocks.DOUBLE_STONE_SLAB.getDefaultState(), 2);
                world.setBlockState(new BlockPos(x, starty + 5, z), Blocks.IRON_BARS.getDefaultState(), 2);
                world.setBlockToAir(new BlockPos(x, starty + 6, z));
                world.setBlockToAir(new BlockPos(x, starty + 7, z));
                world.setBlockToAir(new BlockPos(x, starty + 8, z));
            } else {
                world.setBlockState(new BlockPos(x, starty + 4, z), Blocks.STONE_SLAB.getDefaultState(), 2);
                world.setBlockToAir(new BlockPos(x, starty + 5, z));
                world.setBlockToAir(new BlockPos(x, starty + 6, z));
                world.setBlockToAir(new BlockPos(x, starty + 7, z));
                world.setBlockToAir(new BlockPos(x, starty + 8, z));
            }
            // Spawn stone under the building for as long as it is air.
            WorldGenerationTools.fillEmptyWithStone(world, x, starty - 1, z);
        }
    }
    if (doExtraFeature) {
        if (!WorldGenerationTools.isSolid(world, midx + 4, starty, midz - 3)) {
            world.setBlockState(new BlockPos(midx + 4, starty, midz - 3), Blocks.IRON_BARS.getDefaultState(), 2);
        }
        world.setBlockState(new BlockPos(midx + 4, starty + 1, midz - 3), Blocks.IRON_BARS.getDefaultState(), 2);
        world.setBlockState(new BlockPos(midx + 4, starty + 2, midz - 3), Blocks.IRON_BARS.getDefaultState(), 2);
        if (!WorldGenerationTools.isSolid(world, midx + 5, starty, midz - 3)) {
            world.setBlockState(new BlockPos(midx + 5, starty, midz - 3), buildingBlock.getStateFromMeta(color), 2);
        }
        world.setBlockState(new BlockPos(midx + 5, starty + 1, midz - 3), buildingBlock.getStateFromMeta(color), 2);
        world.setBlockState(new BlockPos(midx + 5, starty + 2, midz - 3), buildingBlock.getStateFromMeta(color), 2);
        WorldGenerationTools.fillEmptyWithStone(world, midx + 4, starty - 1, midz - 3);
        WorldGenerationTools.fillEmptyWithStone(world, midx + 5, starty - 1, midz - 3);
    }
    // Clear the space before the door.
    for (int x = midx - 3; x <= midx + 3; x++) {
        for (int y = starty + 1; y <= starty + 3; y++) {
            world.setBlockToAir(new BlockPos(x, y, midz - 4));
        }
    }
    // Small platform before the door
    world.setBlockState(new BlockPos(midx - 1, starty, midz - 4), Blocks.DOUBLE_STONE_SLAB.getDefaultState(), 2);
    world.setBlockState(new BlockPos(midx, starty, midz - 4), Blocks.DOUBLE_STONE_SLAB.getDefaultState(), 2);
    world.setBlockState(new BlockPos(midx + 1, starty, midz - 4), Blocks.DOUBLE_STONE_SLAB.getDefaultState(), 2);
    world.setBlockState(new BlockPos(midx, starty + 1, midz - 3), Blocks.IRON_DOOR.getStateFromMeta(1), 2);
    world.setBlockState(new BlockPos(midx, starty + 2, midz - 3), Blocks.IRON_DOOR.getStateFromMeta(8), 2);
    world.setBlockState(new BlockPos(midx - 1, starty + 2, midz - 4), Blocks.STONE_BUTTON.getStateFromMeta(4), 2);
    world.setBlockState(new BlockPos(midx + 1, starty + 2, midz - 2), Blocks.STONE_BUTTON.getStateFromMeta(3), 2);
    world.setBlockState(new BlockPos(midx, starty + 3, midz + 3), Blocks.REDSTONE_LAMP.getDefaultState(), 2);
    world.setBlockState(new BlockPos(midx, starty + 3, midz + 2), Blocks.LEVER.getStateFromMeta(4), 2);
    world.setBlockState(new BlockPos(midx + 2, starty + 1, midz - 2), Blocks.CHEST.getDefaultState(), 2);
    RarityRandomSelector.Distribution<Integer> bestDistribution = DimletRandomizer.getRandomDimlets().createDistribution(0.2f);
    TileEntityChest chest = (TileEntityChest) world.getTileEntity(new BlockPos(midx + 2, starty + 1, midz - 2));
    for (int i = 0; i < random.nextInt(4) + 3; i++) {
        ItemStack stack = DimletRandomizer.getRandomPart(random);
        chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), stack);
    }
    if (WorldgenConfiguration.enableDimletsInRFToolsDungeons > 0) {
        for (int i = 0; i < random.nextInt(WorldgenConfiguration.enableDimletsInRFToolsDungeons); i++) {
            DimletKey key = DimletRandomizer.getRandomDimlets().select(bestDistribution, random);
            if (key != null) {
                ItemStack stack = KnownDimletConfiguration.getDimletStack(key);
                chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), stack);
            }
        }
    }
    // Always generate a few cosmetic dimlets
    for (int i = 0; i < WorldgenConfiguration.uncraftableDimletsInRFToolsDungeons; i++) {
        RarityRandomSelector<Integer, DimletKey> dimlets = DimletRandomizer.getRandomUncraftableDimlets();
        DimletKey key = dimlets.select(bestDistribution, random);
        if (key != null) {
            ItemStack stack = KnownDimletConfiguration.getDimletStack(key);
            chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), stack);
        }
    }
    for (int i = 0; i < random.nextInt(2); i++) {
        chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), new ItemStack(ModItems.dimletParcelItem));
    }
    EntityItemFrame frame1 = spawnItemFrame(world, midx - 1, starty + 2, midz + 2);
    EntityItemFrame frame2 = spawnItemFrame(world, midx, starty + 2, midz + 2);
    EntityItemFrame frame3 = spawnItemFrame(world, midx + 1, starty + 2, midz + 2);
    if (WorldgenConfiguration.enableDimletsInRFToolsFrames) {
        DimletKey rd1 = DimletRandomizer.getRandomDimlets().select(bestDistribution, random);
        if (rd1 != null) {
            frame1.setDisplayedItem(KnownDimletConfiguration.getDimletStack(rd1));
        }
        DimletKey rd2 = DimletRandomizer.getRandomDimlets().select(bestDistribution, random);
        if (rd2 != null) {
            frame2.setDisplayedItem(KnownDimletConfiguration.getDimletStack(rd2));
        }
        DimletKey rd3 = DimletRandomizer.getRandomDimlets().select(bestDistribution, random);
        if (rd3 != null) {
            frame3.setDisplayedItem(KnownDimletConfiguration.getDimletStack(rd3));
        }
    } else {
        frame1.setDisplayedItem(DimletRandomizer.getRandomPart(random));
        frame2.setDisplayedItem(DimletRandomizer.getRandomPart(random));
        frame3.setDisplayedItem(DimletRandomizer.getRandomPart(random));
    }
}
Also used : RarityRandomSelector(mcjty.rftoolsdim.varia.RarityRandomSelector) TileEntityChest(net.minecraft.tileentity.TileEntityChest) EntityItemFrame(net.minecraft.entity.item.EntityItemFrame) GenericBlock(mcjty.lib.container.GenericBlock) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey)

Example 18 with DimletKey

use of mcjty.rftoolsdim.dimensions.dimlets.DimletKey in project RFToolsDimensions by McJty.

the class MobDimletType method constructDimension.

@Override
public void constructDimension(List<Pair<DimletKey, List<DimletKey>>> dimlets, Random random, DimensionInformation dimensionInformation) {
    List<MobDescriptor> extraMobs = dimensionInformation.getExtraMobs();
    dimlets = DimensionInformation.extractType(DimletType.DIMLET_MOB, dimlets);
    if (dimlets.isEmpty()) {
        while (random.nextFloat() < WorldgenConfiguration.randomExtraMobsChance) {
            DimletKey key = DimletRandomizer.getRandomMob(random);
            if (key != null) {
                dimensionInformation.updateCostFactor(key);
                MobDescriptor mob = DimletObjectMapping.getMob(key);
                extraMobs.add(mob);
            }
        }
    } else {
        DimletKey key = dimlets.get(0).getLeft();
        MobDescriptor mobDescriptor = DimletObjectMapping.getMob(key);
        if (dimlets.size() == 1 && (mobDescriptor == null || mobDescriptor.getEntityClass() == null)) {
        // Just default.
        } else {
            for (Pair<DimletKey, List<DimletKey>> dimletWithModifiers : dimlets) {
                DimletKey modifierKey = dimletWithModifiers.getLeft();
                MobDescriptor descriptor = DimletObjectMapping.getMob(modifierKey);
                if (descriptor != null && descriptor.getEntityClass() != null) {
                    extraMobs.add(descriptor);
                }
            }
        }
    }
}
Also used : List(java.util.List) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey) MobDescriptor(mcjty.rftoolsdim.dimensions.description.MobDescriptor)

Example 19 with DimletKey

use of mcjty.rftoolsdim.dimensions.dimlets.DimletKey in project RFToolsDimensions by McJty.

the class TimeDimletType method constructDimension.

@Override
public void constructDimension(List<Pair<DimletKey, List<DimletKey>>> dimlets, Random random, DimensionInformation dimensionInformation) {
    Float celestialAngle = null;
    Float timeSpeed = null;
    dimlets = DimensionInformation.extractType(DimletType.DIMLET_TIME, dimlets);
    if (dimlets.isEmpty()) {
        if (random.nextFloat() < WorldgenConfiguration.randomSpecialTimeChance) {
            // Default
            celestialAngle = null;
            timeSpeed = null;
        } else {
            List<DimletKey> keys = new ArrayList<>(DimletObjectMapping.getTimeDimlets());
            DimletKey key = keys.get(random.nextInt(keys.size()));
            celestialAngle = DimletObjectMapping.getCelestialAngle(key);
            timeSpeed = DimletObjectMapping.getTimeSpeed(key);
        }
    } else {
        DimletKey key = dimlets.get(random.nextInt(dimlets.size())).getKey();
        celestialAngle = DimletObjectMapping.getCelestialAngle(key);
        timeSpeed = DimletObjectMapping.getTimeSpeed(key);
    }
    dimensionInformation.setCelestialAngle(celestialAngle);
    dimensionInformation.setTimeSpeed(timeSpeed);
}
Also used : ArrayList(java.util.ArrayList) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey)

Example 20 with DimletKey

use of mcjty.rftoolsdim.dimensions.dimlets.DimletKey in project RFToolsDimensions by McJty.

the class GenericWorldGenerator method randomLoot.

private ItemStack randomLoot(Random rand) {
    switch(rand.nextInt(10)) {
        case 0:
            return DimletRandomizer.getRandomPart(rand);
        case 1:
            return DimletRandomizer.getRandomPart(rand);
        case 2:
            RarityRandomSelector.Distribution<Integer> bestDistribution = DimletRandomizer.getRandomDimlets().createDistribution(0.2f);
            DimletKey key = DimletRandomizer.getRandomDimlets().select(bestDistribution, rand);
            if (key != null) {
                return KnownDimletConfiguration.getDimletStack(key);
            } else {
                return ItemStackTools.getEmptyStack();
            }
        case 3:
            return new ItemStack(ModItems.dimletParcelItem, 1 + rand.nextInt(3));
        default:
            return new ItemStack(ForgeRegistries.ITEMS.getValue(new ResourceLocation("rftools", "dimensional_shard")), rand.nextInt(20) + 10);
    }
}
Also used : RarityRandomSelector(mcjty.rftoolsdim.varia.RarityRandomSelector) ResourceLocation(net.minecraft.util.ResourceLocation) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey) ItemStack(net.minecraft.item.ItemStack)

Aggregations

DimletKey (mcjty.rftoolsdim.dimensions.dimlets.DimletKey)61 ArrayList (java.util.ArrayList)19 List (java.util.List)15 Settings (mcjty.rftoolsdim.config.Settings)14 ItemStack (net.minecraft.item.ItemStack)14 DimletType (mcjty.rftoolsdim.dimensions.dimlets.types.DimletType)13 Block (net.minecraft.block.Block)10 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)7 IBlockState (net.minecraft.block.state.IBlockState)6 TerrainType (mcjty.rftoolsdim.dimensions.types.TerrainType)5 DimensionDescriptor (mcjty.rftoolsdim.dimensions.description.DimensionDescriptor)3 IDimletType (mcjty.rftoolsdim.dimensions.dimlets.types.IDimletType)3 ControllerType (mcjty.rftoolsdim.dimensions.types.ControllerType)3 FeatureType (mcjty.rftoolsdim.dimensions.types.FeatureType)3 ResourceLocation (net.minecraft.util.ResourceLocation)3 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 Pair (org.apache.commons.lang3.tuple.Pair)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Argument (mcjty.lib.network.Argument)2