Search in sources :

Example 1 with VanillaBlocksFactory

use of fr.neatmonster.nocheatplus.compat.blocks.init.vanilla.VanillaBlocksFactory in project NoCheatPlus by NoCheatPlus.

the class BlockProperties method init.

/**
 * Initialize blocks and tools properties. This can be called at any time
 * during runtime.
 *
 * @param mcAccess
 *            If mcAccess implements BlockPropertiesSetup,
 *            mcAccess.setupBlockProperties will be called directly after
 *            basic initialization but before the configuration is applied.
 * @param worldConfigProvider
 *            the world config provider
 */
public static void init(final IHandle<MCAccess> mcAccess, final WorldConfigProvider<?> worldConfigProvider) {
    wrapBlockCache = new WrapBlockCache();
    rtRay = new PassableRayTracing();
    rtAxis = new PassableAxisTracing();
    pLoc = new PlayerLocation(mcAccess, null);
    // getClass().getName() or some abstract.
    final Set<String> blocksFeatures = new LinkedHashSet<String>();
    try {
        initTools(mcAccess, worldConfigProvider);
        initBlocks(mcAccess, worldConfigProvider);
        blocksFeatures.add("BlocksMC1_4");
        // Extra hand picked setups.
        try {
            blocksFeatures.addAll(new VanillaBlocksFactory().setupVanillaBlocks(worldConfigProvider));
        } catch (Throwable t) {
            StaticLog.logSevere("Could not initialize vanilla blocks: " + t.getClass().getSimpleName() + " - " + t.getMessage());
            StaticLog.logSevere(t);
        }
        // Allow mcAccess to setup block properties.
        if (mcAccess instanceof BlockPropertiesSetup) {
            try {
                ((BlockPropertiesSetup) mcAccess).setupBlockProperties(worldConfigProvider);
                blocksFeatures.add(mcAccess.getClass().getSimpleName());
            } catch (Throwable t) {
                StaticLog.logSevere("McAccess.setupBlockProperties (" + mcAccess.getClass().getSimpleName() + ") could not execute properly: " + t.getClass().getSimpleName() + " - " + t.getMessage());
                StaticLog.logSevere(t);
            }
        }
    // TODO: Add registry for further BlockPropertiesSetup instances.
    } catch (Throwable t) {
        StaticLog.logSevere(t);
    }
    // Override feature tags for blocks.
    NCPAPIProvider.getNoCheatPlusAPI().setFeatureTags("blocks", blocksFeatures);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) VanillaBlocksFactory(fr.neatmonster.nocheatplus.compat.blocks.init.vanilla.VanillaBlocksFactory) PassableAxisTracing(fr.neatmonster.nocheatplus.utilities.collision.PassableAxisTracing) PassableRayTracing(fr.neatmonster.nocheatplus.utilities.collision.PassableRayTracing) PlayerLocation(fr.neatmonster.nocheatplus.utilities.location.PlayerLocation) BlockPropertiesSetup(fr.neatmonster.nocheatplus.compat.blocks.BlockPropertiesSetup)

Aggregations

BlockPropertiesSetup (fr.neatmonster.nocheatplus.compat.blocks.BlockPropertiesSetup)1 VanillaBlocksFactory (fr.neatmonster.nocheatplus.compat.blocks.init.vanilla.VanillaBlocksFactory)1 PassableAxisTracing (fr.neatmonster.nocheatplus.utilities.collision.PassableAxisTracing)1 PassableRayTracing (fr.neatmonster.nocheatplus.utilities.collision.PassableRayTracing)1 PlayerLocation (fr.neatmonster.nocheatplus.utilities.location.PlayerLocation)1 LinkedHashSet (java.util.LinkedHashSet)1