Search in sources :

Example 16 with Settings

use of mcjty.rftoolsdim.config.Settings in project RFToolsDimensions by McJty.

the class KnownDimletConfiguration method initMaterialDimlet.

private static void initMaterialDimlet(Block block) {
    if (block instanceof BlockLiquid || block == Blocks.LIT_REDSTONE_ORE) {
        return;
    }
    Set<Filter.Feature> features = getBlockFeatures(block);
    ResourceLocation nameForObject = Block.REGISTRY.getNameForObject(block);
    String mod = nameForObject.getResourceDomain();
    for (IBlockState state : block.getBlockState().getValidStates()) {
        int meta = state.getBlock().getMetaFromState(state);
        ItemStack stack = new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state));
        if (stack.getItem() != null) {
            // Protection
            List<IProperty<?>> propertyNames = new ArrayList<>(state.getPropertyKeys());
            propertyNames.sort(Comparator.comparing(IProperty::getName));
            ImmutableMap<IProperty<?>, Comparable<?>> properties = state.getProperties();
            Map<String, String> props = new HashMap<>();
            for (Map.Entry<IProperty<?>, Comparable<?>> entry : properties.entrySet()) {
                props.put(entry.getKey().getName(), entry.getValue().toString());
            }
            DimletKey key = new DimletKey(DimletType.DIMLET_MATERIAL, block.getRegistryName() + "@" + meta);
            Settings settings = DimletRules.getSettings(key, mod, features, props);
            if (!settings.isBlacklisted()) {
                knownDimlets.put(key, settings);
            }
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockLiquid(net.minecraft.block.BlockLiquid) IProperty(net.minecraft.block.properties.IProperty) ResourceLocation(net.minecraft.util.ResourceLocation) ItemStack(net.minecraft.item.ItemStack) ImmutableMap(com.google.common.collect.ImmutableMap) Settings(mcjty.rftoolsdim.config.Settings)

Example 17 with Settings

use of mcjty.rftoolsdim.config.Settings in project RFToolsDimensions by McJty.

the class KnownDimletConfiguration method dumpMob.

private static void dumpMob(String id) {
    EntityEntry entry = ForgeRegistries.ENTITIES.getValue(new ResourceLocation(id));
    Class<? extends Entity> entityClass = entry == null ? null : entry.getEntityClass();
    if (entry != null) {
        DimletKey key = new DimletKey(DimletType.DIMLET_MOB, id);
        String mod = entry.getRegistryName().getResourceDomain();
        Settings settings = DimletRules.getSettings(key, mod);
        String resourceName = EntityTools.findEntityIdByClass(entityClass);
        String readableName = EntityTools.findEntityLocNameByClass(entityClass);
        Logging.log(resourceName + " (" + resourceName + ", " + readableName + "): " + settings.toString());
    }
}
Also used : EntityEntry(net.minecraftforge.fml.common.registry.EntityEntry) ResourceLocation(net.minecraft.util.ResourceLocation) Settings(mcjty.rftoolsdim.config.Settings)

Example 18 with Settings

use of mcjty.rftoolsdim.config.Settings in project RFToolsDimensions by McJty.

the class DimletCraftingTools method matchDimletRecipe.

public static boolean matchDimletRecipe(DimletKey key, ItemStack stackController, ItemStack stackMemory, ItemStack stackEnergy) {
    Settings settings = KnownDimletConfiguration.getSettings(key);
    if (settings == null) {
        return false;
    }
    int rarity = settings.getRarity();
    if (stackController.getItemDamage() != rarity) {
        return false;
    }
    int level = calculateItemLevelFromRarity(rarity);
    if (stackMemory.getItemDamage() != level) {
        return false;
    }
    if (stackEnergy.getItemDamage() != level) {
        return false;
    }
    return true;
}
Also used : Settings(mcjty.rftoolsdim.config.Settings)

Example 19 with Settings

use of mcjty.rftoolsdim.config.Settings in project RFToolsDimensions by McJty.

the class PacketSyncRules method toBytes.

@Override
public void toBytes(ByteBuf buf) {
    buf.writeInt(rules.size());
    for (Pair<Filter, Settings> rule : rules) {
        Filter filter = rule.getLeft();
        Settings settings = rule.getRight();
        filter.toBytes(buf);
        settings.toBytes(buf);
    }
    Logging.log("Rules packet size: " + buf.writerIndex() + " of " + buf.array().length);
}
Also used : Filter(mcjty.rftoolsdim.config.Filter) Settings(mcjty.rftoolsdim.config.Settings)

Example 20 with Settings

use of mcjty.rftoolsdim.config.Settings in project RFToolsDimensions by McJty.

the class DimensionEnscriberTileEntity method convertToDimensionDescriptor.

/**
     * Convert the dimlets in the inventory to a dimension descriptor.
     */
private DimensionDescriptor convertToDimensionDescriptor() {
    List<DimletKey> descriptors = new ArrayList<>();
    long forcedSeed = 0;
    for (int i = 0; i < DimensionEnscriberContainer.SIZE_DIMLETS; i++) {
        ItemStack stack = inventoryHelper.getStackInSlot(i + DimensionEnscriberContainer.SLOT_DIMLETS);
        if (ItemStackTools.isValid(stack)) {
            DimletKey key = KnownDimletConfiguration.getDimletKey(stack);
            Settings settings = KnownDimletConfiguration.getSettings(key);
            if (settings != null) {
                // Make sure the dimlet is not blacklisted.
                descriptors.add(key);
                NBTTagCompound tagCompound = stack.getTagCompound();
                if (tagCompound != null && tagCompound.getLong("forcedSeed") != 0) {
                    forcedSeed = tagCompound.getLong("forcedSeed");
                }
            }
        }
        inventoryHelper.setStackInSlot(i + DimensionEnscriberContainer.SLOT_DIMLETS, ItemStackTools.getEmptyStack());
    }
    return new DimensionDescriptor(descriptors, forcedSeed);
}
Also used : DimensionDescriptor(mcjty.rftoolsdim.dimensions.description.DimensionDescriptor) ArrayList(java.util.ArrayList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey) ItemStack(net.minecraft.item.ItemStack) Settings(mcjty.rftoolsdim.config.Settings)

Aggregations

Settings (mcjty.rftoolsdim.config.Settings)33 DimletKey (mcjty.rftoolsdim.dimensions.dimlets.DimletKey)16 ItemStack (net.minecraft.item.ItemStack)9 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)6 ArrayList (java.util.ArrayList)5 Block (net.minecraft.block.Block)5 ResourceLocation (net.minecraft.util.ResourceLocation)5 Filter (mcjty.rftoolsdim.config.Filter)3 DimensionDescriptor (mcjty.rftoolsdim.dimensions.description.DimensionDescriptor)3 IBlockState (net.minecraft.block.state.IBlockState)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 DimletType (mcjty.rftoolsdim.dimensions.dimlets.types.DimletType)2 BlockLiquid (net.minecraft.block.BlockLiquid)2 IProperty (net.minecraft.block.properties.IProperty)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 SortedMap (java.util.SortedMap)1 IFilterBuilder (mcjty.rftoolsdim.api.dimlet.IFilterBuilder)1 ISettingsBuilder (mcjty.rftoolsdim.api.dimlet.ISettingsBuilder)1