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);
}
}
}
}
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);
}
}
}
}
}
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);
}
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;
}
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);
}
}
Aggregations