Search in sources :

Example 31 with DimletKey

use of mcjty.rftools.items.dimlets.DimletKey in project RFTools by McJty.

the class EffectDimletType method constructDimension.

@Override
public void constructDimension(List<Pair<DimletKey, List<DimletKey>>> dimlets, Random random, DimensionInformation dimensionInformation) {
    Set<EffectType> effectTypes = dimensionInformation.getEffectTypes();
    dimlets = DimensionInformation.extractType(DimletType.DIMLET_EFFECT, dimlets);
    if (dimlets.isEmpty()) {
        while (random.nextFloat() < DimletConfiguration.randomEffectChance) {
            DimletKey key = DimletRandomizer.getRandomEffect(random, false);
            EffectType effectType = DimletObjectMapping.idToEffectType.get(key);
            if (!effectTypes.contains(effectType)) {
                dimensionInformation.updateCostFactor(key);
                effectTypes.add(effectType);
            }
        }
    } else {
        for (Pair<DimletKey, List<DimletKey>> dimletWithModifier : dimlets) {
            DimletKey key = dimletWithModifier.getLeft();
            EffectType effectType = DimletObjectMapping.idToEffectType.get(key);
            if (effectType != EffectType.EFFECT_NONE) {
                effectTypes.add(effectType);
            }
        }
    }
}
Also used : List(java.util.List) EffectType(mcjty.rftools.dimension.world.types.EffectType) DimletKey(mcjty.rftools.items.dimlets.DimletKey)

Example 32 with DimletKey

use of mcjty.rftools.items.dimlets.DimletKey in project RFTools 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_MOBS, dimlets);
    if (dimlets.isEmpty()) {
        while (random.nextFloat() < DimletConfiguration.randomExtraMobsChance) {
            DimletKey key = DimletRandomizer.getRandomMob(random, false);
            dimensionInformation.updateCostFactor(key);
            extraMobs.add(DimletObjectMapping.idtoMob.get(key));
        }
    } else {
        DimletKey key = dimlets.get(0).getLeft();
        MobDescriptor mobDescriptor = DimletObjectMapping.idtoMob.get(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.idtoMob.get(modifierKey);
                if (descriptor != null && descriptor.getEntityClass() != null) {
                    extraMobs.add(descriptor);
                }
            }
        }
    }
}
Also used : List(java.util.List) DimletKey(mcjty.rftools.items.dimlets.DimletKey) MobDescriptor(mcjty.rftools.dimension.description.MobDescriptor)

Example 33 with DimletKey

use of mcjty.rftools.items.dimlets.DimletKey in project RFTools by McJty.

the class TerrainDimletType method constructDimension.

@Override
public void constructDimension(List<Pair<DimletKey, List<DimletKey>>> dimlets, Random random, DimensionInformation dimensionInformation) {
    dimlets = DimensionInformation.extractType(DimletType.DIMLET_TERRAIN, dimlets);
    List<DimletKey> modifiers;
    TerrainType terrainType = TerrainType.TERRAIN_VOID;
    if (dimlets.isEmpty()) {
        // Pick a random terrain type with a seed that is generated from all the
        // dimlets so we always get the same random value for these dimlets.
        List<DimletKey> idList = new ArrayList<DimletKey>(DimletObjectMapping.idToTerrainType.keySet());
        DimletKey key = idList.get(random.nextInt(idList.size()));
        dimensionInformation.updateCostFactor(key);
        terrainType = DimletObjectMapping.idToTerrainType.get(key);
        modifiers = Collections.emptyList();
    } else {
        int index = random.nextInt(dimlets.size());
        DimletKey key = dimlets.get(index).getLeft();
        terrainType = DimletObjectMapping.idToTerrainType.get(key);
        modifiers = dimlets.get(index).getRight();
    }
    List<BlockMeta> blocks = new ArrayList<BlockMeta>();
    List<Block> fluids = new ArrayList<Block>();
    DimensionInformation.getMaterialAndFluidModifiers(modifiers, blocks, fluids);
    dimensionInformation.setTerrainType(terrainType);
    BlockMeta baseBlockForTerrain;
    if (dimensionInformation.isPatreonBitSet(Patreons.PATREON_LAYEREDMETA)) {
        baseBlockForTerrain = new BlockMeta(Blocks.wool, 127);
    } else {
        if (!blocks.isEmpty()) {
            baseBlockForTerrain = blocks.get(random.nextInt(blocks.size()));
            if (baseBlockForTerrain == null) {
                // This is the default in case None was specified.
                baseBlockForTerrain = BlockMeta.STONE;
            }
        } else {
            // If the terrain type is void we always pick stone as a random material.
            if (terrainType == TerrainType.TERRAIN_VOID) {
                baseBlockForTerrain = BlockMeta.STONE;
            } else if (random.nextFloat() < DimletConfiguration.randomBaseBlockChance) {
                DimletKey key = DimletRandomizer.getRandomMaterialBlock(random, false);
                dimensionInformation.updateCostFactor(key);
                baseBlockForTerrain = DimletObjectMapping.idToBlock.get(key);
            } else {
                baseBlockForTerrain = BlockMeta.STONE;
            }
        }
    }
    dimensionInformation.setBaseBlockForTerrain(baseBlockForTerrain);
    Block fluidForTerrain;
    if (!fluids.isEmpty()) {
        fluidForTerrain = fluids.get(random.nextInt(fluids.size()));
        if (fluidForTerrain == null) {
            // This is the default.
            fluidForTerrain = Blocks.water;
        }
    } else {
        // If the terrain type is void we always pick water as the random liquid.
        if (terrainType == TerrainType.TERRAIN_VOID) {
            fluidForTerrain = Blocks.water;
        } else if (random.nextFloat() < DimletConfiguration.randomOceanLiquidChance) {
            DimletKey key = DimletRandomizer.getRandomFluidBlock(random, false);
            dimensionInformation.updateCostFactor(key);
            fluidForTerrain = DimletObjectMapping.idToFluid.get(key);
        } else {
            fluidForTerrain = Blocks.water;
        }
    }
    dimensionInformation.setFluidForTerrain(fluidForTerrain);
}
Also used : ArrayList(java.util.ArrayList) Block(net.minecraft.block.Block) DimletKey(mcjty.rftools.items.dimlets.DimletKey) TerrainType(mcjty.rftools.dimension.world.types.TerrainType) BlockMeta(mcjty.lib.varia.BlockMeta)

Example 34 with DimletKey

use of mcjty.rftools.items.dimlets.DimletKey in project RFTools by McJty.

the class TimeAbsorberTileEntity method findBestTimeDimlet.

public static DimletKey findBestTimeDimlet(float a) {
    float bestDiff = 10000.0f;
    DimletKey bestDimlet = null;
    for (Map.Entry<DimletKey, Float> entry : DimletObjectMapping.idToCelestialAngle.entrySet()) {
        Float celangle = entry.getValue();
        if (celangle != null) {
            float diff = Math.abs(a - celangle);
            if (diff < bestDiff) {
                bestDiff = diff;
                bestDimlet = entry.getKey();
            }
            diff = Math.abs((a - 1.0f) - celangle);
            if (diff < bestDiff) {
                bestDiff = diff;
                bestDimlet = entry.getKey();
            }
            diff = Math.abs((a + 1.0f) - celangle);
            if (diff < bestDiff) {
                bestDiff = diff;
                bestDimlet = entry.getKey();
            }
        }
    }
    return bestDimlet;
}
Also used : DimletKey(mcjty.rftools.items.dimlets.DimletKey) Map(java.util.Map)

Example 35 with DimletKey

use of mcjty.rftools.items.dimlets.DimletKey in project RFTools by McJty.

the class RfToolsDimensionManager method checkDimletConfig.

/**
 * Check if the client dimlet id's match with the server.
 * This is executed on the server to the clients.
 */
public void checkDimletConfig(EntityPlayer player) {
    if (!player.getEntityWorld().isRemote) {
        // Send over dimlet configuration to the client so that the client can check that the id's match.
        Logging.log("Send validation data to the client");
        DimletMapping mapping = DimletMapping.getDimletMapping(player.getEntityWorld());
        Map<Integer, DimletKey> dimlets = new HashMap<Integer, DimletKey>();
        for (Integer id : mapping.getIds()) {
            dimlets.put(id, mapping.getKey(id));
        }
        RFToolsMessages.INSTANCE.sendTo(new PacketCheckDimletConfig(dimlets), (EntityPlayerMP) player);
    }
}
Also used : DimletMapping(mcjty.rftools.items.dimlets.DimletMapping) DimletKey(mcjty.rftools.items.dimlets.DimletKey) PacketCheckDimletConfig(mcjty.rftools.dimension.network.PacketCheckDimletConfig)

Aggregations

DimletKey (mcjty.rftools.items.dimlets.DimletKey)37 ItemStack (net.minecraft.item.ItemStack)9 List (java.util.List)7 ArrayList (java.util.ArrayList)6 DimletEntry (mcjty.rftools.items.dimlets.DimletEntry)5 Block (net.minecraft.block.Block)4 BlockMeta (mcjty.lib.varia.BlockMeta)3 TerrainType (mcjty.rftools.dimension.world.types.TerrainType)3 Slot (net.minecraft.inventory.Slot)3 SideOnly (cpw.mods.fml.relauncher.SideOnly)2 Map (java.util.Map)2 MobDescriptor (mcjty.rftools.dimension.description.MobDescriptor)2 ControllerType (mcjty.rftools.dimension.world.types.ControllerType)2 FeatureType (mcjty.rftools.dimension.world.types.FeatureType)2 DimletType (mcjty.rftools.items.dimlets.DimletType)2 MerchantRecipe (net.minecraft.village.MerchantRecipe)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Counter (mcjty.lib.varia.Counter)1