Search in sources :

Example 41 with DimletKey

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

the class GuiEssencePainter method extractModifiersForType.

private List<DimletKey> extractModifiersForType(List<DimletKey> modifiers, DimletType type) {
    List<DimletKey> modifiersForType = new ArrayList<DimletKey>();
    int i = 0;
    while (i < modifiers.size()) {
        DimletKey modifier = modifiers.get(i);
        if (type.dimletType.isModifiedBy(modifier.getType())) {
            modifiersForType.add(modifier);
            modifiers.remove(i);
        } else {
            i++;
        }
    }
    return modifiersForType;
}
Also used : ArrayList(java.util.ArrayList) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey)

Example 42 with DimletKey

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

the class DimletWorkbenchTileEntity method readRestorableFromNBT.

@Override
public void readRestorableFromNBT(NBTTagCompound tagCompound) {
    super.readRestorableFromNBT(tagCompound);
    readBufferFromNBT(tagCompound, inventoryHelper);
    extracting = tagCompound.getInteger("extracting");
    extractMode = tagCompound.getBoolean("extractMode");
    idToExtract = null;
    if (tagCompound.hasKey("extKtype")) {
        DimletType type = DimletType.getTypeByOpcode(tagCompound.getString("extKtype"));
        idToExtract = new DimletKey(type, tagCompound.getString("extDkey"));
    } else {
        idToExtract = null;
    }
}
Also used : IDimletType(mcjty.rftoolsdim.dimensions.dimlets.types.IDimletType) DimletType(mcjty.rftoolsdim.dimensions.dimlets.types.DimletType) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey)

Example 43 with DimletKey

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

the class GuiDimletWorkbench method suggestParts.

private void suggestParts() {
    int selected = itemList.getSelected();
    if (selected == -1) {
        return;
    }
    Widget widget = itemList.getChild(selected);
    Object userObject = widget.getUserObject();
    if (userObject instanceof DimletKey) {
        DimletKey key = (DimletKey) userObject;
        sendServerCommand(RFToolsDimMessages.INSTANCE, DimletWorkbenchTileEntity.CMD_SUGGESTPARTS, new Argument("type", key.getType().dimletType.getName()), new Argument("id", key.getId()));
    }
}
Also used : Argument(mcjty.lib.network.Argument) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey)

Example 44 with DimletKey

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

the class FeatureDimletType method findFeatureDimlet.

private static DimletKey findFeatureDimlet(NBTTagCompound essenceCompound) {
    String feature = essenceCompound.getString("feature");
    DimletKey key = new DimletKey(DimletType.DIMLET_FEATURE, feature);
    Settings settings = KnownDimletConfiguration.getSettings(key);
    if (settings == null || !settings.isDimlet()) {
        return null;
    }
    return key;
}
Also used : DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey) Settings(mcjty.rftoolsdim.config.Settings)

Example 45 with DimletKey

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

the class FeatureDimletType method getRandomFluidArray.

private Block[] getRandomFluidArray(Random random, DimensionInformation dimensionInformation, Set<FeatureType> featureTypes, Map<FeatureType, List<DimletKey>> modifiersForFeature, FeatureType t, boolean allowEmpty) {
    Block[] fluidsForLakes;
    if (featureTypes.contains(t)) {
        List<IBlockState> blocks = new ArrayList<>();
        List<Block> fluids = new ArrayList<>();
        DimensionInformation.getMaterialAndFluidModifiers(modifiersForFeature.get(t), blocks, fluids);
        // If no fluids are specified we will usually have default fluid generation (water+lava). Otherwise some random selection.
        if (fluids.isEmpty()) {
            while (random.nextFloat() < WorldgenConfiguration.randomLakeFluidChance) {
                DimletKey key = DimletRandomizer.getRandomFluidBlock(random);
                if (key != null) {
                    dimensionInformation.updateCostFactor(key);
                    fluids.add(DimletObjectMapping.getFluid(key));
                }
            }
        } else if (fluids.size() == 1 && fluids.get(0) == null) {
            fluids.clear();
        }
        fluidsForLakes = fluids.toArray(new Block[fluids.size()]);
        for (int i = 0; i < fluidsForLakes.length; i++) {
            if (fluidsForLakes[i] == null) {
                fluidsForLakes[i] = Blocks.WATER;
            }
        }
    } else {
        fluidsForLakes = new Block[0];
    }
    if (allowEmpty || fluidsForLakes.length > 0) {
        return fluidsForLakes;
    }
    return new Block[] { Blocks.WATER };
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey)

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