Search in sources :

Example 1 with ItemConfigurationCard

use of mekanism.common.item.ItemConfigurationCard in project Mekanism by mekanism.

the class ClientRegistration method init.

@SubscribeEvent
public static void init(FMLClientSetupEvent event) {
    MinecraftForge.EVENT_BUS.register(new ClientTickHandler());
    MinecraftForge.EVENT_BUS.register(new RenderTickHandler());
    MinecraftForge.EVENT_BUS.addListener(EventPriority.LOWEST, SoundHandler::onTilePlaySound);
    if (ModList.get().isLoaded(MekanismHooks.JEI_MOD_ID)) {
        // Note: We check this directly instead of using our value stored in Mekanism hooks
        // as that is initialized in CommonSetup and I believe that may be fired in parallel
        // to ClientSetup, in which case there would be a chance this gets ran before it is
        // properly initialized and will have the wrong value
        MinecraftForge.EVENT_BUS.addListener(EventPriority.LOWEST, RenderTickHandler::guiOpening);
    }
    MekanismKeyHandler.registerKeybindings();
    HolidayManager.init();
    // Register entity rendering handlers
    ClientRegistrationUtil.registerEntityRenderingHandler(MekanismEntityTypes.ROBIT, RenderRobit::new);
    ClientRegistrationUtil.registerEntityRenderingHandler(MekanismEntityTypes.FLAME, RenderFlame::new);
    // Register TileEntityRenderers
    ClientRegistrationUtil.bindTileEntityRenderer(RenderThermoelectricBoiler::new, MekanismTileEntityTypes.BOILER_CASING, MekanismTileEntityTypes.BOILER_VALVE);
    ClientRegistrationUtil.bindTileEntityRenderer(MekanismTileEntityTypes.CHEMICAL_DISSOLUTION_CHAMBER, RenderChemicalDissolutionChamber::new);
    ClientRegistrationUtil.bindTileEntityRenderer(RenderDynamicTank::new, MekanismTileEntityTypes.DYNAMIC_TANK, MekanismTileEntityTypes.DYNAMIC_VALVE);
    ClientRegistrationUtil.bindTileEntityRenderer(MekanismTileEntityTypes.DIGITAL_MINER, RenderDigitalMiner::new);
    ClientRegistrationUtil.bindTileEntityRenderer(MekanismTileEntityTypes.PERSONAL_CHEST, RenderPersonalChest::new);
    ClientRegistrationUtil.bindTileEntityRenderer(MekanismTileEntityTypes.NUTRITIONAL_LIQUIFIER, RenderNutritionalLiquifier::new);
    ClientRegistrationUtil.bindTileEntityRenderer(MekanismTileEntityTypes.PIGMENT_MIXER, RenderPigmentMixer::new);
    ClientRegistrationUtil.bindTileEntityRenderer(MekanismTileEntityTypes.QUANTUM_ENTANGLOPORTER, RenderQuantumEntangloporter::new);
    ClientRegistrationUtil.bindTileEntityRenderer(MekanismTileEntityTypes.SEISMIC_VIBRATOR, RenderSeismicVibrator::new);
    ClientRegistrationUtil.bindTileEntityRenderer(MekanismTileEntityTypes.SOLAR_NEUTRON_ACTIVATOR, RenderSolarNeutronActivator::new);
    ClientRegistrationUtil.bindTileEntityRenderer(MekanismTileEntityTypes.TELEPORTER, RenderTeleporter::new);
    ClientRegistrationUtil.bindTileEntityRenderer(MekanismTileEntityTypes.THERMAL_EVAPORATION_CONTROLLER, RenderThermalEvaporationPlant::new);
    ClientRegistrationUtil.bindTileEntityRenderer(MekanismTileEntityTypes.INDUSTRIAL_ALARM, RenderIndustrialAlarm::new);
    ClientRegistrationUtil.bindTileEntityRenderer(RenderSPS::new, MekanismTileEntityTypes.SPS_CASING, MekanismTileEntityTypes.SPS_PORT);
    ClientRegistrationUtil.bindTileEntityRenderer(RenderBin::new, MekanismTileEntityTypes.BASIC_BIN, MekanismTileEntityTypes.ADVANCED_BIN, MekanismTileEntityTypes.ELITE_BIN, MekanismTileEntityTypes.ULTIMATE_BIN, MekanismTileEntityTypes.CREATIVE_BIN);
    ClientRegistrationUtil.bindTileEntityRenderer(RenderEnergyCube::new, MekanismTileEntityTypes.BASIC_ENERGY_CUBE, MekanismTileEntityTypes.ADVANCED_ENERGY_CUBE, MekanismTileEntityTypes.ELITE_ENERGY_CUBE, MekanismTileEntityTypes.ULTIMATE_ENERGY_CUBE, MekanismTileEntityTypes.CREATIVE_ENERGY_CUBE);
    ClientRegistrationUtil.bindTileEntityRenderer(RenderFluidTank::new, MekanismTileEntityTypes.BASIC_FLUID_TANK, MekanismTileEntityTypes.ADVANCED_FLUID_TANK, MekanismTileEntityTypes.ELITE_FLUID_TANK, MekanismTileEntityTypes.ULTIMATE_FLUID_TANK, MekanismTileEntityTypes.CREATIVE_FLUID_TANK);
    // Transmitters
    ClientRegistrationUtil.bindTileEntityRenderer(RenderLogisticalTransporter::new, MekanismTileEntityTypes.RESTRICTIVE_TRANSPORTER, MekanismTileEntityTypes.DIVERSION_TRANSPORTER, MekanismTileEntityTypes.BASIC_LOGISTICAL_TRANSPORTER, MekanismTileEntityTypes.ADVANCED_LOGISTICAL_TRANSPORTER, MekanismTileEntityTypes.ELITE_LOGISTICAL_TRANSPORTER, MekanismTileEntityTypes.ULTIMATE_LOGISTICAL_TRANSPORTER);
    ClientRegistrationUtil.bindTileEntityRenderer(RenderMechanicalPipe::new, MekanismTileEntityTypes.BASIC_MECHANICAL_PIPE, MekanismTileEntityTypes.ADVANCED_MECHANICAL_PIPE, MekanismTileEntityTypes.ELITE_MECHANICAL_PIPE, MekanismTileEntityTypes.ULTIMATE_MECHANICAL_PIPE);
    ClientRegistrationUtil.bindTileEntityRenderer(RenderPressurizedTube::new, MekanismTileEntityTypes.BASIC_PRESSURIZED_TUBE, MekanismTileEntityTypes.ADVANCED_PRESSURIZED_TUBE, MekanismTileEntityTypes.ELITE_PRESSURIZED_TUBE, MekanismTileEntityTypes.ULTIMATE_PRESSURIZED_TUBE);
    ClientRegistrationUtil.bindTileEntityRenderer(RenderUniversalCable::new, MekanismTileEntityTypes.BASIC_UNIVERSAL_CABLE, MekanismTileEntityTypes.ADVANCED_UNIVERSAL_CABLE, MekanismTileEntityTypes.ELITE_UNIVERSAL_CABLE, MekanismTileEntityTypes.ULTIMATE_UNIVERSAL_CABLE);
    ClientRegistrationUtil.bindTileEntityRenderer(RenderThermodynamicConductor::new, MekanismTileEntityTypes.BASIC_THERMODYNAMIC_CONDUCTOR, MekanismTileEntityTypes.ADVANCED_THERMODYNAMIC_CONDUCTOR, MekanismTileEntityTypes.ELITE_THERMODYNAMIC_CONDUCTOR, MekanismTileEntityTypes.ULTIMATE_THERMODYNAMIC_CONDUCTOR);
    // Block render layers
    // Cutout
    ClientRegistrationUtil.setRenderLayer(RenderType.cutout(), MekanismBlocks.STRUCTURAL_GLASS, MekanismBlocks.LASER_AMPLIFIER, MekanismBlocks.LASER_TRACTOR_BEAM, MekanismBlocks.CHARGEPAD, MekanismBlocks.ELECTROLYTIC_SEPARATOR, // Fluid Tanks
    MekanismBlocks.BASIC_FLUID_TANK, MekanismBlocks.ADVANCED_FLUID_TANK, MekanismBlocks.ELITE_FLUID_TANK, MekanismBlocks.ULTIMATE_FLUID_TANK, MekanismBlocks.CREATIVE_FLUID_TANK, // Restrictive Transporter
    MekanismBlocks.RESTRICTIVE_TRANSPORTER, // Mechanical Pipes
    MekanismBlocks.BASIC_MECHANICAL_PIPE, MekanismBlocks.ADVANCED_MECHANICAL_PIPE, MekanismBlocks.ELITE_MECHANICAL_PIPE, MekanismBlocks.ULTIMATE_MECHANICAL_PIPE, // Pressurized Tubes
    MekanismBlocks.BASIC_PRESSURIZED_TUBE, MekanismBlocks.ADVANCED_PRESSURIZED_TUBE, MekanismBlocks.ELITE_PRESSURIZED_TUBE, MekanismBlocks.ULTIMATE_PRESSURIZED_TUBE, // Universal Cables
    MekanismBlocks.BASIC_UNIVERSAL_CABLE, MekanismBlocks.ADVANCED_UNIVERSAL_CABLE, MekanismBlocks.ELITE_UNIVERSAL_CABLE, MekanismBlocks.ULTIMATE_UNIVERSAL_CABLE, // Thermodynamic Conductors
    MekanismBlocks.BASIC_THERMODYNAMIC_CONDUCTOR, MekanismBlocks.ADVANCED_THERMODYNAMIC_CONDUCTOR, MekanismBlocks.ELITE_THERMODYNAMIC_CONDUCTOR, MekanismBlocks.ULTIMATE_THERMODYNAMIC_CONDUCTOR);
    // TODO: Does the diversion transporter actually need to be in multiple render types
    // Also can we move the overlay from the TER to being part of the baked model
    // Logistical Transporter
    ClientRegistrationUtil.setRenderLayer(renderType -> renderType == RenderType.cutout() || renderType == RenderType.translucent(), MekanismBlocks.DIVERSION_TRANSPORTER, MekanismBlocks.BASIC_LOGISTICAL_TRANSPORTER, MekanismBlocks.ADVANCED_LOGISTICAL_TRANSPORTER, MekanismBlocks.ELITE_LOGISTICAL_TRANSPORTER, MekanismBlocks.ULTIMATE_LOGISTICAL_TRANSPORTER);
    // Fluids (translucent)
    for (FluidRegistryObject<?, ?, ?, ?> fluidRO : MekanismFluids.FLUIDS.getAllFluids()) {
        ClientRegistrationUtil.setRenderLayer(RenderType.translucent(), fluidRO);
    }
    // Multi-Layer blocks (requiring both sold & translucent render layers)
    ClientRegistrationUtil.setRenderLayer(renderType -> renderType == RenderType.solid() || renderType == RenderType.translucent(), MekanismBlocks.ISOTOPIC_CENTRIFUGE, MekanismBlocks.ANTIPROTONIC_NUCLEOSYNTHESIZER, MekanismBlocks.CHEMICAL_CRYSTALLIZER, MekanismBlocks.NUTRITIONAL_LIQUIFIER);
    event.enqueueWork(() -> {
        ClientRegistrationUtil.setPropertyOverride(MekanismBlocks.CARDBOARD_BOX, Mekanism.rl("storage"), (stack, world, entity) -> ((ItemBlockCardboardBox) stack.getItem()).getBlockData(stack) == null ? 0 : 1);
        ClientRegistrationUtil.setPropertyOverride(MekanismItems.CRAFTING_FORMULA, Mekanism.rl("invalid"), (stack, world, entity) -> {
            ItemCraftingFormula formula = (ItemCraftingFormula) stack.getItem();
            return formula.getInventory(stack) != null && formula.isInvalid(stack) ? 1 : 0;
        });
        ClientRegistrationUtil.setPropertyOverride(MekanismItems.CRAFTING_FORMULA, Mekanism.rl("encoded"), (stack, world, entity) -> {
            ItemCraftingFormula formula = (ItemCraftingFormula) stack.getItem();
            return formula.getInventory(stack) != null && !formula.isInvalid(stack) ? 1 : 0;
        });
        ClientRegistrationUtil.setPropertyOverride(MekanismItems.CONFIGURATION_CARD, Mekanism.rl("encoded"), (stack, world, entity) -> ((ItemConfigurationCard) stack.getItem()).hasData(stack) ? 1 : 0);
        ClientRegistrationUtil.setPropertyOverride(MekanismItems.ELECTRIC_BOW, Mekanism.rl("pull"), (stack, world, entity) -> entity != null && entity.getUseItem() == stack ? (stack.getUseDuration() - entity.getUseItemRemainingTicks()) / 20.0F : 0);
        ClientRegistrationUtil.setPropertyOverride(MekanismItems.ELECTRIC_BOW, Mekanism.rl("pulling"), (stack, world, entity) -> entity != null && entity.isUsingItem() && entity.getUseItem() == stack ? 1.0F : 0.0F);
        ClientRegistrationUtil.setPropertyOverride(MekanismItems.GEIGER_COUNTER, Mekanism.rl("radiation"), (stack, world, entity) -> {
            if (entity instanceof PlayerEntity) {
                return RadiationManager.INSTANCE.getClientScale().ordinal();
            }
            return 0;
        });
        // Note: Our implementation allows for a null entity so don't worry about it and pass it
        ClientRegistrationUtil.setPropertyOverride(MekanismItems.HDPE_REINFORCED_ELYTRA, Mekanism.rl("broken"), (stack, world, entity) -> MekanismItems.HDPE_REINFORCED_ELYTRA.get().canElytraFly(stack, entity) ? 0.0F : 1.0F);
    });
    addCustomModel(MekanismBlocks.QIO_DRIVE_ARRAY, (orig, evt) -> new DriveArrayBakedModel(orig));
    addCustomModel(MekanismBlocks.QIO_REDSTONE_ADAPTER, (orig, evt) -> new QIORedstoneAdapterBakedModel(orig));
    addCustomModel(MekanismBlocks.DIGITAL_MINER, (orig, evt) -> new DigitalMinerBakedModel(orig));
    addLitModel(MekanismItems.PORTABLE_QIO_DASHBOARD, MekanismItems.MEKA_TOOL);
}
Also used : RenderLogisticalTransporter(mekanism.client.render.transmitter.RenderLogisticalTransporter) RenderNutritionalLiquifier(mekanism.client.render.tileentity.RenderNutritionalLiquifier) RenderSeismicVibrator(mekanism.client.render.tileentity.RenderSeismicVibrator) DriveArrayBakedModel(mekanism.client.model.baked.DriveArrayBakedModel) RenderDigitalMiner(mekanism.client.render.tileentity.RenderDigitalMiner) RenderMechanicalPipe(mekanism.client.render.transmitter.RenderMechanicalPipe) RenderThermoelectricBoiler(mekanism.client.render.tileentity.RenderThermoelectricBoiler) RenderQuantumEntangloporter(mekanism.client.render.tileentity.RenderQuantumEntangloporter) RenderPressurizedTube(mekanism.client.render.transmitter.RenderPressurizedTube) PlayerEntity(net.minecraft.entity.player.PlayerEntity) RenderSolarNeutronActivator(mekanism.client.render.tileentity.RenderSolarNeutronActivator) RenderThermalEvaporationPlant(mekanism.client.render.tileentity.RenderThermalEvaporationPlant) RenderFluidTank(mekanism.client.render.tileentity.RenderFluidTank) RenderChemicalDissolutionChamber(mekanism.client.render.tileentity.RenderChemicalDissolutionChamber) ItemCraftingFormula(mekanism.common.item.ItemCraftingFormula) RenderDynamicTank(mekanism.client.render.tileentity.RenderDynamicTank) RenderUniversalCable(mekanism.client.render.transmitter.RenderUniversalCable) RenderThermodynamicConductor(mekanism.client.render.transmitter.RenderThermodynamicConductor) RenderFlame(mekanism.client.render.entity.RenderFlame) DigitalMinerBakedModel(mekanism.client.model.baked.DigitalMinerBakedModel) ItemConfigurationCard(mekanism.common.item.ItemConfigurationCard) RenderIndustrialAlarm(mekanism.client.render.tileentity.RenderIndustrialAlarm) SoundHandler(mekanism.client.sound.SoundHandler) RenderPersonalChest(mekanism.client.render.tileentity.RenderPersonalChest) RenderBin(mekanism.client.render.tileentity.RenderBin) RenderPigmentMixer(mekanism.client.render.tileentity.RenderPigmentMixer) QIORedstoneAdapterBakedModel(mekanism.client.model.baked.QIORedstoneAdapterBakedModel) RenderRobit(mekanism.client.render.entity.RenderRobit) RenderTickHandler(mekanism.client.render.RenderTickHandler) RenderSPS(mekanism.client.render.tileentity.RenderSPS) RenderEnergyCube(mekanism.client.render.tileentity.RenderEnergyCube) RenderTeleporter(mekanism.client.render.tileentity.RenderTeleporter) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 2 with ItemConfigurationCard

use of mekanism.common.item.ItemConfigurationCard in project Mekanism by mekanism.

the class TileEntityMekanism method openGui.

public ActionResultType openGui(PlayerEntity player) {
    // Everything that calls this has isRemote being false but add the check just in case anyways
    if (hasGui() && !isRemote() && !player.isShiftKeyDown()) {
        if (hasSecurity() && !SecurityUtils.canAccess(player, this)) {
            SecurityUtils.displayNoAccess(player);
            return ActionResultType.FAIL;
        }
        // Pass on this activation if the player is rotating with a configurator
        ItemStack stack = player.getMainHandItem();
        if (isDirectional() && !stack.isEmpty() && stack.getItem() instanceof ItemConfigurator) {
            ItemConfigurator configurator = (ItemConfigurator) stack.getItem();
            if (configurator.getMode(stack) == ItemConfigurator.ConfiguratorMode.ROTATE) {
                return ActionResultType.PASS;
            }
        }
        // Pass on this activation if the player is using a configuration card (and this tile supports the capability)
        if (getCapability(Capabilities.CONFIG_CARD_CAPABILITY, null).isPresent()) {
            if (!stack.isEmpty() && stack.getItem() instanceof ItemConfigurationCard) {
                return ActionResultType.PASS;
            }
        }
        NetworkHooks.openGui((ServerPlayerEntity) player, Attribute.get(getBlockType(), AttributeGui.class).getProvider(this), worldPosition);
        return ActionResultType.SUCCESS;
    }
    return ActionResultType.PASS;
}
Also used : ItemConfigurationCard(mekanism.common.item.ItemConfigurationCard) ItemConfigurator(mekanism.common.item.ItemConfigurator) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ItemConfigurationCard (mekanism.common.item.ItemConfigurationCard)2 DigitalMinerBakedModel (mekanism.client.model.baked.DigitalMinerBakedModel)1 DriveArrayBakedModel (mekanism.client.model.baked.DriveArrayBakedModel)1 QIORedstoneAdapterBakedModel (mekanism.client.model.baked.QIORedstoneAdapterBakedModel)1 RenderTickHandler (mekanism.client.render.RenderTickHandler)1 RenderFlame (mekanism.client.render.entity.RenderFlame)1 RenderRobit (mekanism.client.render.entity.RenderRobit)1 RenderBin (mekanism.client.render.tileentity.RenderBin)1 RenderChemicalDissolutionChamber (mekanism.client.render.tileentity.RenderChemicalDissolutionChamber)1 RenderDigitalMiner (mekanism.client.render.tileentity.RenderDigitalMiner)1 RenderDynamicTank (mekanism.client.render.tileentity.RenderDynamicTank)1 RenderEnergyCube (mekanism.client.render.tileentity.RenderEnergyCube)1 RenderFluidTank (mekanism.client.render.tileentity.RenderFluidTank)1 RenderIndustrialAlarm (mekanism.client.render.tileentity.RenderIndustrialAlarm)1 RenderNutritionalLiquifier (mekanism.client.render.tileentity.RenderNutritionalLiquifier)1 RenderPersonalChest (mekanism.client.render.tileentity.RenderPersonalChest)1 RenderPigmentMixer (mekanism.client.render.tileentity.RenderPigmentMixer)1 RenderQuantumEntangloporter (mekanism.client.render.tileentity.RenderQuantumEntangloporter)1 RenderSPS (mekanism.client.render.tileentity.RenderSPS)1 RenderSeismicVibrator (mekanism.client.render.tileentity.RenderSeismicVibrator)1